1285809Sscottl/******************************************************************************* 2285809Sscottl*Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved. 3285809Sscottl* 4285809Sscottl*Redistribution and use in source and binary forms, with or without modification, are permitted provided 5285809Sscottl*that the following conditions are met: 6285809Sscottl*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 7285809Sscottl*following disclaimer. 8285809Sscottl*2. Redistributions in binary form must reproduce the above copyright notice, 9285809Sscottl*this list of conditions and the following disclaimer in the documentation and/or other materials provided 10285809Sscottl*with the distribution. 11285809Sscottl* 12285809Sscottl*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED 13285809Sscottl*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14285809Sscottl*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 15285809Sscottl*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 16285809Sscottl*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 17285809Sscottl*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 18285809Sscottl*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 19285809Sscottl*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 20285809Sscottl 21285809Sscottl********************************************************************************/ 22285809Sscottl/*****************************************************************************/ 23285809Sscottl/** \file 24285809Sscottl * 25285809Sscottl * The file implementing SCSI/ATA Translation (SAT) for LL Layer callback 26285809Sscottl * 27285809Sscottl */ 28285809Sscottl/*****************************************************************************/ 29285809Sscottl#include <sys/cdefs.h> 30285809Sscottl__FBSDID("$FreeBSD$"); 31285809Sscottl#include <dev/pms/config.h> 32285809Sscottl 33285809Sscottl#include <dev/pms/freebsd/driver/common/osenv.h> 34285809Sscottl#include <dev/pms/freebsd/driver/common/ostypes.h> 35285809Sscottl#include <dev/pms/freebsd/driver/common/osdebug.h> 36285809Sscottl 37285809Sscottl#ifdef SATA_ENABLE 38285809Sscottl 39285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/sa.h> 40285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/saapi.h> 41285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/saosapi.h> 42285809Sscottl 43285809Sscottl#include <dev/pms/RefTisa/tisa/api/titypes.h> 44285809Sscottl#include <dev/pms/RefTisa/tisa/api/ostiapi.h> 45285809Sscottl#include <dev/pms/RefTisa/tisa/api/tiapi.h> 46285809Sscottl#include <dev/pms/RefTisa/tisa/api/tiglobal.h> 47285809Sscottl 48285809Sscottl#ifdef FDS_SM 49285809Sscottl#include <dev/pms/RefTisa/sat/api/sm.h> 50285809Sscottl#include <dev/pms/RefTisa/sat/api/smapi.h> 51285809Sscottl#include <dev/pms/RefTisa/sat/api/tdsmapi.h> 52285809Sscottl#endif 53285809Sscottl 54285809Sscottl#ifdef FDS_DM 55285809Sscottl#include <dev/pms/RefTisa/discovery/api/dm.h> 56285809Sscottl#include <dev/pms/RefTisa/discovery/api/dmapi.h> 57285809Sscottl#include <dev/pms/RefTisa/discovery/api/tddmapi.h> 58285809Sscottl#endif 59285809Sscottl 60285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h> 61285809Sscottl#include <dev/pms/freebsd/driver/common/osstring.h> 62285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h> 63285809Sscottl 64285809Sscottl#ifdef INITIATOR_DRIVER 65285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h> 66285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h> 67285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h> 68285809Sscottl#endif 69285809Sscottl 70285809Sscottl#ifdef TARGET_DRIVER 71285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h> 72285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h> 73285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h> 74285809Sscottl#endif 75285809Sscottl 76285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h> 77285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h> 78285809Sscottl 79285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sata/host/sat.h> 80285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sata/host/satproto.h> 81285809Sscottl 82285809Sscottl/***************************************************************************** 83285809Sscottl*! \brief ossaSATACompleted 84285809Sscottl* 85285809Sscottl* This routine is called to complete a SATA request previously issued to the 86285809Sscottl* LL Layer in saSATAStart() 87285809Sscottl* 88285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 89285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 90285809Sscottl* \param agIOStatus: Status of completed I/O. 91285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 92285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 93285809Sscottl* length. 94285809Sscottl* \param agParam: Additional info based on status. 95285809Sscottl* 96285809Sscottl* \return: none 97285809Sscottl* 98285809Sscottl*****************************************************************************/ 99285809SscottlGLOBAL void 100285809SscottlossaSATACompleted( 101285809Sscottl agsaRoot_t *agRoot, 102285809Sscottl agsaIORequest_t *agIORequest, 103285809Sscottl bit32 agIOStatus, 104285809Sscottl void *agFirstDword, 105285809Sscottl bit32 agIOInfoLen, 106285809Sscottl void *agParam 107285809Sscottl ) 108285809Sscottl 109285809Sscottl{ 110285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 111285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 112285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 113285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared); 114285809Sscottl tdIORequestBody_t *tdIORequestBody; 115285809Sscottl satIOContext_t *satIOContext; 116285809Sscottl satDeviceData_t *pSatDevData; 117285809Sscottl tdsaDeviceData_t *tdsaDeviceData = agNULL; 118285809Sscottl tdsaPortContext_t *onePortContext; 119285809Sscottl tiDeviceHandle_t *tiDeviceHandle = agNULL; 120285809Sscottl agsaDevHandle_t *agDevHandle = agNULL; 121285809Sscottl bit32 status; 122285809Sscottl tdsaDeviceData_t *oneDeviceData = agNULL; 123285809Sscottl 124285809Sscottl TDSA_OUT_ENTER(tiRoot); 125285809Sscottl 126285809Sscottl TI_DBG6(("ossaSATACompleted: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 127285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 128285809Sscottl 129285809Sscottl if (agIORequest == agNULL) 130285809Sscottl { 131285809Sscottl TI_DBG1(("ossaSATACompleted: agIORequest is NULL!!!!\n")); 132285809Sscottl return; 133285809Sscottl } 134285809Sscottl 135285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 136285809Sscottl 137285809Sscottl if (tdIORequestBody == agNULL) 138285809Sscottl { 139285809Sscottl TI_DBG1(("ossaSATACompleted: tdIORequestBody is NULL!!!!\n")); 140285809Sscottl return; 141285809Sscottl } 142285809Sscottl /* for debugging */ 143285809Sscottl if (tdIORequestBody->ioCompleted == agTRUE) 144285809Sscottl { 145285809Sscottl tiDeviceHandle = tdIORequestBody->tiDevHandle; 146285809Sscottl if (tiDeviceHandle == agNULL) 147285809Sscottl { 148285809Sscottl TI_DBG1(("ossaSATACompleted: tiDeviceHandle is NULL!!!!\n")); 149285809Sscottl return; 150285809Sscottl } 151285809Sscottl tdsaDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 152285809Sscottl TI_DBG1(("ossaSATACompleted: Error!!!!!! double completion\n")); 153285809Sscottl if (tdsaDeviceData == agNULL) 154285809Sscottl { 155285809Sscottl TI_DBG1(("ossaSATACompleted: tdsaDeviceData is NULL!!!!\n")); 156285809Sscottl return; 157285809Sscottl } 158285809Sscottl TI_DBG1(("ossaSATACompleted: did %d \n", tdsaDeviceData->id)); 159285809Sscottl return; 160285809Sscottl } 161285809Sscottl 162285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 163285809Sscottl satIOContext = &(tdIORequestBody->transport.SATA.satIOContext); 164285809Sscottl 165285809Sscottl if (satIOContext == agNULL) 166285809Sscottl { 167285809Sscottl TI_DBG1(("ossaSATACompleted: satIOContext is NULL!!!!\n")); 168285809Sscottl return; 169285809Sscottl } 170285809Sscottl 171285809Sscottl pSatDevData = satIOContext->pSatDevData; 172285809Sscottl 173285809Sscottl if (tdIORequestBody->tiDevHandle != agNULL) 174285809Sscottl { 175285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tdIORequestBody->tiDevHandle->tdData; 176285809Sscottl } 177285809Sscottl 178285809Sscottl if (pSatDevData == agNULL && oneDeviceData != agNULL) 179285809Sscottl { 180285809Sscottl TI_DBG1(("ossaSATACompleted: pSatDevData is NULL, loc 1, wrong\n")); 181285809Sscottl pSatDevData = &(oneDeviceData->satDevData); 182285809Sscottl } 183285809Sscottl 184285809Sscottl if (pSatDevData == agNULL) 185285809Sscottl { 186285809Sscottl TI_DBG1(("ossaSATACompleted: pSatDevData is NULL loc 2, wrong\n")); 187285809Sscottl if (satIOContext->satOrgIOContext == agNULL) 188285809Sscottl { 189285809Sscottl TI_DBG1(("ossaSATACompleted: external command\n")); 190285809Sscottl } 191285809Sscottl else 192285809Sscottl { 193285809Sscottl TI_DBG1(("ossaSATACompleted: internal command\n")); 194285809Sscottl } 195285809Sscottl goto ext; 196285809Sscottl } 197285809Sscottl 198285809Sscottl tdsaDeviceData = (tdsaDeviceData_t *)pSatDevData->satSaDeviceData; 199285809Sscottl if (oneDeviceData != tdsaDeviceData) 200285809Sscottl { 201285809Sscottl if (satIOContext->satOrgIOContext == agNULL) 202285809Sscottl { 203285809Sscottl TI_DBG1(("ossaSATACompleted: diff device handle; external command\n")); 204285809Sscottl } 205285809Sscottl else 206285809Sscottl { 207285809Sscottl TI_DBG1(("ossaSATACompleted: diff device handle; internal command\n")); 208285809Sscottl } 209285809Sscottl } 210285809Sscottl 211285809Sscottl if (tdsaDeviceData == agNULL) 212285809Sscottl { 213285809Sscottl TI_DBG1(("ossaSATACompleted: tdsaDeviceData is NULL!!!!\n")); 214285809Sscottl return; 215285809Sscottl } 216285809Sscottl 217285809Sscottl onePortContext = tdsaDeviceData->tdPortContext; 218285809Sscottl 219285809Sscottl /* retries in OSSA_IO_XFER_OPEN_RETRY_TIMEOUT */ 220285809Sscottl if (agIOStatus == OSSA_IO_XFER_OPEN_RETRY_TIMEOUT) 221285809Sscottl { 222285809Sscottl if (tdsaDeviceData->valid == agTRUE && tdsaDeviceData->registered == agTRUE && 223285809Sscottl tdsaDeviceData->tdPortContext != agNULL ) 224285809Sscottl { 225285809Sscottl if (tdIORequestBody->reTries <= OPEN_RETRY_RETRIES) /* 10 */ 226285809Sscottl { 227285809Sscottl agDevHandle = tdsaDeviceData->agDevHandle; 228285809Sscottl status = saSATAStart( agRoot, 229285809Sscottl agIORequest, 230285809Sscottl tdsaRotateQnumber(tiRoot, tdsaDeviceData), 231285809Sscottl agDevHandle, 232285809Sscottl satIOContext->reqType, 233285809Sscottl &(tdIORequestBody->transport.SATA.agSATARequestBody), 234285809Sscottl satIOContext->sataTag, 235285809Sscottl ossaSATACompleted); 236285809Sscottl 237285809Sscottl if (status == AGSA_RC_SUCCESS) 238285809Sscottl { 239285809Sscottl TI_DBG1(("ossaSATACompleted: retried\n")); 240285809Sscottl tdIORequestBody->ioStarted = agTRUE; 241285809Sscottl tdIORequestBody->ioCompleted = agFALSE; 242285809Sscottl tdIORequestBody->reTries++; 243285809Sscottl goto ext; 244285809Sscottl } 245285809Sscottl else 246285809Sscottl { 247285809Sscottl TI_DBG1(("ossaSATACompleted: retry failed\n")); 248285809Sscottl tdIORequestBody->ioStarted = agFALSE; 249285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 250285809Sscottl tdIORequestBody->reTries = 0; 251285809Sscottl } 252285809Sscottl } 253285809Sscottl else 254285809Sscottl { 255285809Sscottl /* retries is over, do nothing */ 256285809Sscottl TI_DBG1(("ossaSATACompleted: retry is over and fail\n")); 257285809Sscottl tdIORequestBody->reTries = 0; 258285809Sscottl } 259285809Sscottl } 260285809Sscottl else 261285809Sscottl { 262285809Sscottl TI_DBG1(("ossaSATACompleted: incorrect device state or no portcontext\n")); 263285809Sscottl tdIORequestBody->reTries = 0; 264285809Sscottl } 265285809Sscottl } /* if OSSA_IO_XFER_OPEN_RETRY_TIMEOUT*/ 266285809Sscottl 267285809Sscottl /* release tag value for SATA */ 268285809Sscottl if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) || 269285809Sscottl (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) ) 270285809Sscottl { 271285809Sscottl satTagRelease(tiRoot, pSatDevData, satIOContext->sataTag); 272285809Sscottl } 273285809Sscottl 274285809Sscottl /* send SMP_PHY_CONTROL_HARD_RESET */ 275285809Sscottl if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY && tdsaAllShared->FCA) 276285809Sscottl { 277285809Sscottl if (pSatDevData->NumOfFCA <= 0) /* does SMP HARD RESET only upto one time */ 278285809Sscottl { 279285809Sscottl TI_DBG1(("ossaSATACompleted: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; sending HARD_RESET\n")); 280285809Sscottl pSatDevData->NumOfFCA++; 281285809Sscottl tdsaPhyControlSend(tiRoot, 282285809Sscottl tdsaDeviceData, 283285809Sscottl SMP_PHY_CONTROL_HARD_RESET, 284285809Sscottl agNULL, 285285809Sscottl tdsaRotateQnumber(tiRoot, tdsaDeviceData) 286285809Sscottl ); 287285809Sscottl } 288285809Sscottl else 289285809Sscottl { 290285809Sscottl /* given up after one time of SMP HARD RESET; */ 291285809Sscottl TI_DBG1(("ossaSATACompleted: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; NO!!! sending HARD_RESET\n")); 292285809Sscottl if (tdsaDeviceData->registered == agTRUE && tdsaAllShared->ResetInDiscovery == 0) 293285809Sscottl { 294285809Sscottl /* 295285809Sscottl 1. remove this device 296285809Sscottl 2. device removal event 297285809Sscottl */ 298285809Sscottl tdsaAbortAll(tiRoot, agRoot, tdsaDeviceData); 299285809Sscottl tdsaDeviceData->valid = agFALSE; 300285809Sscottl tdsaDeviceData->valid2 = agFALSE; 301285809Sscottl tdsaDeviceData->registered = agFALSE; 302285809Sscottl// pSatDevData->NumOfFCA = 0; 303285809Sscottl ostiInitiatorEvent( 304285809Sscottl tiRoot, 305285809Sscottl onePortContext->tiPortalContext, 306285809Sscottl agNULL, 307285809Sscottl tiIntrEventTypeDeviceChange, 308285809Sscottl tiDeviceRemoval, 309285809Sscottl agNULL 310285809Sscottl ); 311285809Sscottl } 312285809Sscottl } 313285809Sscottl } 314285809Sscottl 315285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 316285809Sscottl { 317285809Sscottl /* 318285809Sscottl free abort IO request itself - agParam; done in ossaSATAEvent() 319285809Sscottl */ 320285809Sscottl } 321285809Sscottl /* just for debugging */ 322285809Sscottl if (agIOStatus == OSSA_IO_DS_NON_OPERATIONAL) 323285809Sscottl { 324285809Sscottl TI_DBG1(("ossaSATACompleted: agIOStatus is OSSA_IO_DS_NON_OPERATIONAL\n")); 325285809Sscottl } 326285809Sscottl if (agIOStatus == OSSA_IO_DS_IN_RECOVERY) 327285809Sscottl { 328285809Sscottl TI_DBG1(("ossaSATACompleted: agIOStatus is OSSA_IO_DS_IN_RECOVERY\n")); 329285809Sscottl } 330285809Sscottl 331285809Sscottl satIOContext->satCompleteCB( agRoot, 332285809Sscottl agIORequest, 333285809Sscottl agIOStatus, 334285809Sscottl agFirstDword, 335285809Sscottl agIOInfoLen, 336285809Sscottl agParam, 337285809Sscottl satIOContext); 338285809Sscottlext: 339285809Sscottl TDSA_OUT_LEAVE(tiRoot); 340285809Sscottl} 341285809Sscottl 342285809Sscottl/***************************************************************************** 343285809Sscottl*! \brief satPacketCB 344285809Sscottl* 345285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 346285809Sscottl* This CB routine deals with normal Packet command I/O SATA request. 347285809Sscottl* 348285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 349285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 350285809Sscottl* \param agIOStatus: Status of completed I/O. 351285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 352285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 353285809Sscottl* length. 354285809Sscottl* \param agParam: Additional info based on status. 355285809Sscottl* \param ioContext: Pointer to satIOContext_t. 356285809Sscottl* 357285809Sscottl* \return: none 358285809Sscottl* 359285809Sscottl*****************************************************************************/ 360285809Sscottl 361285809Sscottlvoid satPacketCB( 362285809Sscottl agsaRoot_t *agRoot, 363285809Sscottl agsaIORequest_t *agIORequest, 364285809Sscottl bit32 agIOStatus, 365285809Sscottl agsaFisHeader_t *agFirstDword, 366285809Sscottl bit32 agIOInfoLen, 367285809Sscottl void *agParam, 368285809Sscottl void *ioContext 369285809Sscottl ) 370285809Sscottl{ 371285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 372285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 373285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 374285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 375285809Sscottl tdIORequestBody_t *tdIORequestBody; 376285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 377285809Sscottl satIOContext_t *satIOContext; 378285809Sscottl satIOContext_t *satOrgIOContext; 379285809Sscottl satIOContext_t *satNewIOContext; 380285809Sscottl satInternalIo_t *satIntIo; 381285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 382285809Sscottl satDeviceData_t *satDevData; 383285809Sscottl scsiRspSense_t *pSense; 384285809Sscottl tiIORequest_t *tiOrgIORequest; 385285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 386285809Sscottl bit32 interruptContext = osData->IntContext; 387285809Sscottl bit8 bSenseKey = 0; 388285809Sscottl bit16 bSenseCodeInfo = 0; 389285809Sscottl bit32 status = 0; 390285809Sscottl 391285809Sscottl TI_DBG4(("satPacketCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 392285809Sscottl 393285809Sscottl /* internally generate tiIOContext */ 394285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 395285809Sscottl satIOContext = (satIOContext_t *) ioContext; 396285809Sscottl satIntIo = satIOContext->satIntIoContext; 397285809Sscottl satDevData = satIOContext->pSatDevData; 398285809Sscottl 399285809Sscottl /*ttttttthe one */ 400285809Sscottl if (satIntIo == agNULL) 401285809Sscottl { 402285809Sscottl TI_DBG4(("satPacketCB: External satInternalIo_t satIntIoContext\n")); 403285809Sscottl satOrgIOContext = satIOContext; 404285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 405285809Sscottl pSense = satOrgIOContext->pSense; 406285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 407285809Sscottl } 408285809Sscottl else 409285809Sscottl { 410285809Sscottl TI_DBG4(("satPacketCB: Internal satInternalIo_t satIntIoContext\n")); 411285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 412285809Sscottl if (satOrgIOContext == agNULL) 413285809Sscottl { 414285809Sscottl TI_DBG4(("satPacketCB: satOrgIOContext is NULL, wrong\n")); 415285809Sscottl return; 416285809Sscottl } 417285809Sscottl else 418285809Sscottl { 419285809Sscottl TI_DBG4(("satPacketCB: satOrgIOContext is NOT NULL\n")); 420285809Sscottl } 421285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 422285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 423285809Sscottl pSense = satOrgIOContext->pSense; 424285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 425285809Sscottl } 426285809Sscottl 427285809Sscottl /* Parse CDB */ 428285809Sscottl switch(scsiCmnd->cdb[0]) 429285809Sscottl { 430285809Sscottl case SCSIOPC_TEST_UNIT_READY: 431285809Sscottl //satTestUnitReadyCB(agRoot, agIORequest, agIOStatus, agFirstDword, agIOInfoLen, agParam, ioContext); 432285809Sscottl //break; 433285809Sscottl case SCSIOPC_GET_EVENT_STATUS_NOTIFICATION: 434285809Sscottl //break; 435285809Sscottl case SCSIOPC_READ_CAPACITY_10: 436285809Sscottl case SCSIOPC_READ_CAPACITY_16: 437285809Sscottl //satPacketReadCapacityCB(agRoot, agIORequest, agIOStatus, agFirstDword, agIOInfoLen, agParam, ioContext); 438285809Sscottl //break; 439285809Sscottl default: 440285809Sscottl break; 441285809Sscottl } 442285809Sscottl 443285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 444285809Sscottl 445285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 446285809Sscottl tdIORequestBody->ioStarted = agFALSE; 447285809Sscottl 448285809Sscottl /* interal structure free */ 449285809Sscottl satFreeIntIoResource( tiRoot, satDevData, satIntIo); 450285809Sscottl 451285809Sscottl if( agIOStatus == OSSA_IO_SUCCESS && agFirstDword == agNULL) 452285809Sscottl { 453285809Sscottl TI_DBG1(("satPacketCB: agIOStatus == OSSA_IO_SUCCESS, agFirstDword == agNULL \n")); 454285809Sscottl ostiInitiatorIOCompleted( tiRoot, 455285809Sscottl tdIORequestBody->tiIORequest, 456285809Sscottl tiIOSuccess, 457285809Sscottl SCSI_STAT_GOOD, 458285809Sscottl agNULL, 459285809Sscottl interruptContext); 460285809Sscottl } 461285809Sscottl else if (agIOStatus == OSSA_IO_SUCCESS && agFirstDword != agNULL) 462285809Sscottl { 463285809Sscottl TI_DBG1(("satPacketCB: wrong. agIOStatus == OSSA_IO_SUCCESS && agFirstDword != agNULL \n")); 464285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 465285809Sscottl tiOrgIORequest, 466285809Sscottl satDevData, 467285809Sscottl 32, 468285809Sscottl satNewIntIo); 469285809Sscottl if (satNewIntIo == agNULL) 470285809Sscottl { 471285809Sscottl /* memory allocation failure */ 472285809Sscottl /* just translate the ATAPI error register to sense information */ 473285809Sscottl satTranslateATAPIErrorsToSCSIErrors( 474285809Sscottl scsiCmnd->cdb[0], 475285809Sscottl agFirstDword->D2H.status, 476285809Sscottl agFirstDword->D2H.error, 477285809Sscottl &bSenseKey, 478285809Sscottl &bSenseCodeInfo 479285809Sscottl ); 480285809Sscottl satSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 481285809Sscottl ostiInitiatorIOCompleted( tiRoot, 482285809Sscottl tdIORequestBody->tiIORequest, 483285809Sscottl tiIOSuccess, 484285809Sscottl SCSI_STAT_CHECK_CONDITION, 485285809Sscottl satOrgIOContext->pTiSenseData, 486285809Sscottl interruptContext); 487285809Sscottl TI_DBG1(("satPacketCB: momory allocation fails\n")); 488285809Sscottl return; 489285809Sscottl } /* end memory allocation */ 490285809Sscottl 491285809Sscottl satNewIOContext = satPrepareNewIO(satNewIntIo, 492285809Sscottl tiOrgIORequest, 493285809Sscottl satDevData, 494285809Sscottl scsiCmnd, 495285809Sscottl satOrgIOContext 496285809Sscottl ); 497285809Sscottl /* sends request sense to ATAPI device for acquiring sense information */ 498285809Sscottl status = satRequestSenseForATAPI(tiRoot, 499285809Sscottl &satNewIntIo->satIntTiIORequest, 500285809Sscottl satNewIOContext->ptiDeviceHandle, 501285809Sscottl &satNewIntIo->satIntTiScsiXchg, 502285809Sscottl satNewIOContext 503285809Sscottl ); 504285809Sscottl if (status != tiSuccess) 505285809Sscottl { 506285809Sscottl satFreeIntIoResource( tiRoot, 507285809Sscottl satDevData, 508285809Sscottl satNewIntIo); 509285809Sscottl /* just translate the ATAPI error register to sense information */ 510285809Sscottl satTranslateATAPIErrorsToSCSIErrors( 511285809Sscottl scsiCmnd->cdb[0], 512285809Sscottl agFirstDword->D2H.status, 513285809Sscottl agFirstDword->D2H.error, 514285809Sscottl &bSenseKey, 515285809Sscottl &bSenseCodeInfo 516285809Sscottl ); 517285809Sscottl satSetSensePayload(pSense, bSenseKey, 0, bSenseCodeInfo, satOrgIOContext); 518285809Sscottl ostiInitiatorIOCompleted( tiRoot, 519285809Sscottl tdIORequestBody->tiIORequest, 520285809Sscottl tiIOSuccess, 521285809Sscottl SCSI_STAT_CHECK_CONDITION, 522285809Sscottl satOrgIOContext->pTiSenseData, 523285809Sscottl interruptContext); 524285809Sscottl TI_DBG1(("satPacketCB: failed to call satRequestSenseForATAPI()\n")); 525285809Sscottl } 526285809Sscottl } 527285809Sscottl else if (agIOStatus != OSSA_IO_SUCCESS) 528285809Sscottl { 529285809Sscottl TI_DBG1(("satPacketCB: wrong. agIOStatus != OSSA_IO_SUCCESS, status %d\n", agIOStatus)); 530285809Sscottl itdsatProcessAbnormalCompletion( 531285809Sscottl agRoot, 532285809Sscottl agIORequest, 533285809Sscottl agIOStatus, 534285809Sscottl agFirstDword, 535285809Sscottl agIOInfoLen, 536285809Sscottl agParam, 537285809Sscottl satIOContext); 538285809Sscottl } 539285809Sscottl else 540285809Sscottl { 541285809Sscottl TI_DBG1(("satPacketCB: Unknown error \n")); 542285809Sscottl ostiInitiatorIOCompleted( tiRoot, 543285809Sscottl tdIORequestBody->tiIORequest, 544285809Sscottl tiIOFailed, 545285809Sscottl tiDetailOtherError, 546285809Sscottl agNULL, 547285809Sscottl interruptContext); 548285809Sscottl } 549285809Sscottl} 550285809Sscottl/***************************************************************************** 551285809Sscottl*! \brief satRequestSenseForATAPICB 552285809Sscottl* 553285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 554285809Sscottl* This CB routine deals with normal non-chained data I/O SATA request. 555285809Sscottl* 556285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 557285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 558285809Sscottl* \param agIOStatus: Status of completed I/O. 559285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 560285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 561285809Sscottl* length. 562285809Sscottl* \param agParam: Additional info based on status. 563285809Sscottl* \param ioContext: Pointer to satIOContext_t. 564285809Sscottl* 565285809Sscottl* \return: none 566285809Sscottl* 567285809Sscottl*****************************************************************************/ 568285809Sscottlvoid satRequestSenseForATAPICB( 569285809Sscottl agsaRoot_t *agRoot, 570285809Sscottl agsaIORequest_t *agIORequest, 571285809Sscottl bit32 agIOStatus, 572285809Sscottl agsaFisHeader_t *agFirstDword, 573285809Sscottl bit32 agIOInfoLen, 574285809Sscottl void *agParam, 575285809Sscottl void *ioContext 576285809Sscottl ) 577285809Sscottl{ 578285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 579285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 580285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 581285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 582285809Sscottl tdIORequestBody_t *tdIORequestBody; 583285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 584285809Sscottl satIOContext_t *satIOContext; 585285809Sscottl satIOContext_t *satOrgIOContext; 586285809Sscottl satInternalIo_t *satIntIo; 587285809Sscottl satDeviceData_t *satDevData; 588285809Sscottl tiIORequest_t *tiOrgIORequest; 589285809Sscottl bit32 interruptContext = osData->IntContext; 590285809Sscottl 591285809Sscottl TI_DBG4(("satPacketCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 592285809Sscottl 593285809Sscottl /* internally generate tiIOContext */ 594285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 595285809Sscottl satIOContext = (satIOContext_t *) ioContext; 596285809Sscottl satIntIo = satIOContext->satIntIoContext; 597285809Sscottl satDevData = satIOContext->pSatDevData; 598285809Sscottl 599285809Sscottl /*ttttttthe one */ 600285809Sscottl if (satIntIo == agNULL) 601285809Sscottl { 602285809Sscottl TI_DBG4(("satPacketCB: External satInternalIo_t satIntIoContext\n")); 603285809Sscottl satOrgIOContext = satIOContext; 604285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 605285809Sscottl } 606285809Sscottl else 607285809Sscottl { 608285809Sscottl TI_DBG4(("satPacketCB: Internal satInternalIo_t satIntIoContext\n")); 609285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 610285809Sscottl if (satOrgIOContext == agNULL) 611285809Sscottl { 612285809Sscottl TI_DBG4(("satPacketCB: satOrgIOContext is NULL, wrong\n")); 613285809Sscottl return; 614285809Sscottl } 615285809Sscottl else 616285809Sscottl { 617285809Sscottl TI_DBG4(("satPacketCB: satOrgIOContext is NOT NULL\n")); 618285809Sscottl } 619285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 620285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 621285809Sscottl } 622285809Sscottl 623285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 624285809Sscottl 625285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 626285809Sscottl tdIORequestBody->ioStarted = agFALSE; 627285809Sscottl 628285809Sscottl /* copy the request sense buffer to original IO buffer*/ 629285809Sscottl if (satIntIo != agNULL) 630285809Sscottl { 631285809Sscottl osti_memcpy(satOrgIOContext->pTiSenseData->senseData, satIntIo->satIntDmaMem.virtPtr, SENSE_DATA_LENGTH); 632285809Sscottl satOrgIOContext->pTiSenseData->senseLen = SENSE_DATA_LENGTH; 633285809Sscottl /* interal structure free */ 634285809Sscottl satFreeIntIoResource( tiRoot, satDevData, satIntIo); 635285809Sscottl } 636285809Sscottl 637285809Sscottl /* notify the OS to complete this SRB */ 638285809Sscottl ostiInitiatorIOCompleted( tiRoot, 639285809Sscottl tiOrgIORequest, 640285809Sscottl tiIOSuccess, 641285809Sscottl SCSI_STAT_CHECK_CONDITION, 642285809Sscottl satOrgIOContext->pTiSenseData, 643285809Sscottl interruptContext); 644285809Sscottl} 645285809Sscottl/***************************************************************************** 646285809Sscottl*! \brief satSetFeaturesPIOCB 647285809Sscottl* 648285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 649285809Sscottl* This CB routine deals with normal non-chained data I/O SATA request. 650285809Sscottl* 651285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 652285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 653285809Sscottl* \param agIOStatus: Status of completed I/O. 654285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 655285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 656285809Sscottl* length. 657285809Sscottl* \param agParam: Additional info based on status. 658285809Sscottl* \param ioContext: Pointer to satIOContext_t. 659285809Sscottl* 660285809Sscottl* \return: none 661285809Sscottl* 662285809Sscottl*****************************************************************************/ 663285809Sscottlvoid satSetFeaturesPIOCB( 664285809Sscottl agsaRoot_t *agRoot, 665285809Sscottl agsaIORequest_t *agIORequest, 666285809Sscottl bit32 agIOStatus, 667285809Sscottl agsaFisHeader_t *agFirstDword, 668285809Sscottl bit32 agIOInfoLen, 669285809Sscottl void *agParam, 670285809Sscottl void *ioContext 671285809Sscottl ) 672285809Sscottl{ 673285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 674285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 675285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 676285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 677285809Sscottl tdIORequestBody_t *tdIORequestBody; 678285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 679285809Sscottl satIOContext_t *satIOContext; 680285809Sscottl satIOContext_t *satOrgIOContext; 681285809Sscottl satIOContext_t *satNewIOContext; 682285809Sscottl satInternalIo_t *satIntIo; 683285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 684285809Sscottl satDeviceData_t *satDevData; 685285809Sscottl tiIORequest_t *tiOrgIORequest; 686285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 687285809Sscottl bit32 status; 688285809Sscottl 689285809Sscottl TI_DBG3(("satSetFeaturesPIOCB start\n")); 690285809Sscottl 691285809Sscottl /* internally generate tiIOContext */ 692285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 693285809Sscottl satIOContext = (satIOContext_t *) ioContext; 694285809Sscottl satIntIo = satIOContext->satIntIoContext; 695285809Sscottl satDevData = satIOContext->pSatDevData; 696285809Sscottl 697285809Sscottl /*ttttttthe one */ 698285809Sscottl if (satIntIo == agNULL) 699285809Sscottl { 700285809Sscottl TI_DBG4(("satSetFeaturesPIOCB: External satInternalIo_t satIntIoContext\n")); 701285809Sscottl satOrgIOContext = satIOContext; 702285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 703285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 704285809Sscottl } 705285809Sscottl else 706285809Sscottl { 707285809Sscottl TI_DBG4(("satSetFeaturesPIOCB: Internal satInternalIo_t satIntIoContext\n")); 708285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 709285809Sscottl if (satOrgIOContext == agNULL) 710285809Sscottl { 711285809Sscottl TI_DBG4(("satSetFeaturesPIOCB: satOrgIOContext is NULL, wrong\n")); 712285809Sscottl return; 713285809Sscottl } 714285809Sscottl else 715285809Sscottl { 716285809Sscottl TI_DBG4(("satSetFeaturesPIOCB: satOrgIOContext is NOT NULL\n")); 717285809Sscottl } 718285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 719285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 720285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 721285809Sscottl } 722285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 723285809Sscottl 724285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 725285809Sscottl tdIORequestBody->ioStarted = agFALSE; 726285809Sscottl 727285809Sscottl /* interal structure free */ 728285809Sscottl satFreeIntIoResource(tiRoot, 729285809Sscottl satDevData, 730285809Sscottl satIntIo); 731285809Sscottl 732285809Sscottl /*if the ATAPI device support DMA, then enble this feature*/ 733285809Sscottl if (satDevData->satDMASupport && satDevData->satDMAEnabled) 734285809Sscottl { 735285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 736285809Sscottl tiOrgIORequest, 737285809Sscottl satDevData, 738285809Sscottl 0, 739285809Sscottl satNewIntIo); 740285809Sscottl if (satNewIntIo == agNULL) 741285809Sscottl { 742285809Sscottl TI_DBG1(("satSetFeaturesPIOCB: momory allocation fails\n")); 743285809Sscottl return; 744285809Sscottl } /* end memory allocation */ 745285809Sscottl 746285809Sscottl satNewIOContext = satPrepareNewIO(satNewIntIo, 747285809Sscottl tiOrgIORequest, 748285809Sscottl satDevData, 749285809Sscottl scsiCmnd, 750285809Sscottl satOrgIOContext 751285809Sscottl ); 752285809Sscottl /* sends either ATA SET FEATURES based on DMA bit */ 753285809Sscottl status = satSetFeatures(tiRoot, 754285809Sscottl &satNewIntIo->satIntTiIORequest, 755285809Sscottl satNewIOContext->ptiDeviceHandle, 756285809Sscottl &satNewIntIo->satIntTiScsiXchg, 757285809Sscottl satNewIOContext, 758285809Sscottl agTRUE 759285809Sscottl ); 760285809Sscottl if (status != tiSuccess) 761285809Sscottl { 762285809Sscottl satFreeIntIoResource( tiRoot, satDevData, satNewIntIo); 763285809Sscottl TI_DBG1(("satSetFeaturesPIOCB: failed to call satSetFeatures()\n")); 764285809Sscottl } 765285809Sscottl } 766285809Sscottl} 767285809Sscottl 768285809Sscottl/***************************************************************************** 769285809Sscottl*! \brief satSetFeaturesCB 770285809Sscottl* 771285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 772285809Sscottl* This CB routine deals with normal non-chained data I/O SATA request. 773285809Sscottl* 774285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 775285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 776285809Sscottl* \param agIOStatus: Status of completed I/O. 777285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 778285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 779285809Sscottl* length. 780285809Sscottl* \param agParam: Additional info based on status. 781285809Sscottl* \param ioContext: Pointer to satIOContext_t. 782285809Sscottl* 783285809Sscottl* \return: none 784285809Sscottl* 785285809Sscottl*****************************************************************************/ 786285809Sscottlvoid satSetFeaturesCB( 787285809Sscottl agsaRoot_t *agRoot, 788285809Sscottl agsaIORequest_t *agIORequest, 789285809Sscottl bit32 agIOStatus, 790285809Sscottl agsaFisHeader_t *agFirstDword, 791285809Sscottl bit32 agIOInfoLen, 792285809Sscottl void *agParam, 793285809Sscottl void *ioContext 794285809Sscottl ) 795285809Sscottl{ 796285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 797285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 798285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 799285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 800285809Sscottl tdIORequestBody_t *tdIORequestBody; 801285809Sscottl tdIORequestBody_t *tdOrgIORequestBody = agNULL; 802285809Sscottl satIOContext_t *satIOContext; 803285809Sscottl satIOContext_t *satOrgIOContext; 804285809Sscottl satInternalIo_t *satIntIo; 805285809Sscottl satDeviceData_t *satDevData; 806285809Sscottl tdsaPortContext_t *onePortContext = agNULL; 807285809Sscottl tiPortalContext_t *tiPortalContext = agNULL; 808285809Sscottl tdsaDeviceData_t *oneDeviceData = agNULL; 809285809Sscottl bit8 PhyID =0; 810285809Sscottl TI_DBG3(("satSetFeaturesCB start\n")); 811285809Sscottl 812285809Sscottl /* internally generate tiIOContext */ 813285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 814285809Sscottl satIOContext = (satIOContext_t *) ioContext; 815285809Sscottl satIntIo = satIOContext->satIntIoContext; 816285809Sscottl satDevData = satIOContext->pSatDevData; 817285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tdIORequestBody->tiDevHandle->tdData; 818285809Sscottl onePortContext = oneDeviceData->tdPortContext; 819285809Sscottl if (onePortContext == agNULL) 820285809Sscottl { 821285809Sscottl TI_DBG4(("satSetFeaturesCB: onePortContext is NULL, wrong\n")); 822285809Sscottl return; 823285809Sscottl } 824285809Sscottl tiPortalContext = onePortContext->tiPortalContext; 825285809Sscottl PhyID = oneDeviceData->phyID; 826285809Sscottl /*ttttttthe one */ 827285809Sscottl if (satIntIo == agNULL) 828285809Sscottl { 829285809Sscottl TI_DBG4(("satSetFeaturesCB: External satInternalIo_t satIntIoContext\n")); 830285809Sscottl satOrgIOContext = satIOContext; 831285809Sscottl } 832285809Sscottl else 833285809Sscottl { 834285809Sscottl TI_DBG4(("satSetFeaturesCB: Internal satInternalIo_t satIntIoContext\n")); 835285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 836285809Sscottl if (satOrgIOContext == agNULL) 837285809Sscottl { 838285809Sscottl TI_DBG4(("satSetFeaturesCB: satOrgIOContext is NULL, wrong\n")); 839285809Sscottl return; 840285809Sscottl } 841285809Sscottl else 842285809Sscottl { 843285809Sscottl TI_DBG4(("satSetFeaturesCB: satOrgIOContext is NOT NULL\n")); 844285809Sscottl } 845285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 846285809Sscottl } 847285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 848285809Sscottl 849285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 850285809Sscottl tdIORequestBody->ioStarted = agFALSE; 851285809Sscottl 852285809Sscottl /* interal structure free */ 853285809Sscottl satFreeIntIoResource(tiRoot, 854285809Sscottl satDevData, 855285809Sscottl satIntIo); 856285809Sscottl 857285809Sscottl 858285809Sscottl /* clean up TD layer's IORequestBody */ 859285809Sscottl if (tdOrgIORequestBody!= agNULL) 860285809Sscottl { 861285809Sscottl ostiFreeMemory(tiRoot, 862285809Sscottl tdOrgIORequestBody->IOType.InitiatorTMIO.osMemHandle, 863285809Sscottl sizeof(tdIORequestBody_t) 864285809Sscottl ); 865285809Sscottl } 866285809Sscottl 867285809Sscottl if (onePortContext != agNULL) 868285809Sscottl { 869285809Sscottl /* this condition is for tdsaDiscoveryStartIDDevCB routine*/ 870285809Sscottl if (onePortContext->DiscoveryState == ITD_DSTATE_COMPLETED) 871285809Sscottl { 872285809Sscottl TI_DBG1(("satSetFeaturesCB: ID completed after discovery is done; tiDeviceArrival\n")); 873285809Sscottl /* in case registration is finished after discovery is finished */ 874285809Sscottl ostiInitiatorEvent( 875285809Sscottl tiRoot, 876285809Sscottl tiPortalContext, 877285809Sscottl agNULL, 878285809Sscottl tiIntrEventTypeDeviceChange, 879285809Sscottl tiDeviceArrival, 880285809Sscottl agNULL 881285809Sscottl ); 882285809Sscottl return; 883285809Sscottl } 884285809Sscottl TI_DBG2(("satSetFeaturesCB: pid %d\n", tdsaAllShared->Ports[PhyID].portContext->id)); 885285809Sscottl /* the below codes is for satAddSATAIDDevCB routine*/ 886285809Sscottl /* notifying link up */ 887285809Sscottl ostiPortEvent ( 888285809Sscottl tiRoot, 889285809Sscottl tiPortLinkUp, 890285809Sscottl tiSuccess, 891285809Sscottl (void *)tdsaAllShared->Ports[PhyID].tiPortalContext 892285809Sscottl ); 893285809Sscottl #ifdef INITIATOR_DRIVER 894285809Sscottl /* triggers discovery */ 895285809Sscottl ostiPortEvent( 896285809Sscottl tiRoot, 897285809Sscottl tiPortDiscoveryReady, 898285809Sscottl tiSuccess, 899285809Sscottl (void *) tdsaAllShared->Ports[PhyID].tiPortalContext 900285809Sscottl ); 901285809Sscottl #endif 902285809Sscottl } 903285809Sscottl else 904285809Sscottl { 905285809Sscottl TI_DBG1(("satSetFeaturesCB: onePortContext is NULL, wrong\n")); 906285809Sscottl } 907285809Sscottl} 908285809Sscottl/***************************************************************************** 909285809Sscottl*! \brief satDeviceResetCB 910285809Sscottl* 911285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 912285809Sscottl* This CB routine deals with normal non-chained data I/O SATA request. 913285809Sscottl* 914285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 915285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 916285809Sscottl* \param agIOStatus: Status of completed I/O. 917285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 918285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 919285809Sscottl* length. 920285809Sscottl* \param agParam: Additional info based on status. 921285809Sscottl* \param ioContext: Pointer to satIOContext_t. 922285809Sscottl* 923285809Sscottl* \return: none 924285809Sscottl* 925285809Sscottl*****************************************************************************/ 926285809Sscottlvoid satDeviceResetCB( 927285809Sscottl agsaRoot_t *agRoot, 928285809Sscottl agsaIORequest_t *agIORequest, 929285809Sscottl bit32 agIOStatus, 930285809Sscottl agsaFisHeader_t *agFirstDword, 931285809Sscottl bit32 agIOInfoLen, 932285809Sscottl void *agParam, 933285809Sscottl void *ioContext 934285809Sscottl ) 935285809Sscottl{ 936285809Sscottl /* callback for satResetDevice */ 937285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 938285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 939285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 940285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 941285809Sscottl tdIORequestBody_t *tdIORequestBody; 942285809Sscottl tdIORequestBody_t *tdOrgIORequestBody = agNULL; 943285809Sscottl satIOContext_t *satIOContext; 944285809Sscottl satIOContext_t *satOrgIOContext; 945285809Sscottl// satIOContext_t *satNewIOContext; 946285809Sscottl satInternalIo_t *satIntIo; 947285809Sscottl// satInternalIo_t *satNewIntIo = agNULL; 948285809Sscottl satDeviceData_t *satDevData; 949285809Sscottl tiIORequest_t *tiOrgIORequest; 950285809Sscottl#ifdef TD_DEBUG_ENABLE 951285809Sscottl bit32 ataStatus = 0; 952285809Sscottl bit32 ataError; 953285809Sscottl agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 954285809Sscottl#endif 955285809Sscottl// bit32 status; 956285809Sscottl bit32 report = agFALSE; 957285809Sscottl bit32 AbortTM = agFALSE; 958285809Sscottl 959285809Sscottl TI_DBG1(("satDeviceResetCB: start\n")); 960285809Sscottl 961285809Sscottl TI_DBG6(("satDeviceResetCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 962285809Sscottl 963285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 964285809Sscottl satIOContext = (satIOContext_t *) ioContext; 965285809Sscottl satIntIo = satIOContext->satIntIoContext; 966285809Sscottl satDevData = satIOContext->pSatDevData; 967285809Sscottl 968285809Sscottl if (satIntIo == agNULL) 969285809Sscottl { 970285809Sscottl TI_DBG6(("satDeviceResetCB: External, OS generated\n")); 971285809Sscottl satOrgIOContext = satIOContext; 972285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 973285809Sscottl } 974285809Sscottl else 975285809Sscottl { 976285809Sscottl TI_DBG6(("satDeviceResetCB: Internal, TD generated\n")); 977285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 978285809Sscottl if (satOrgIOContext == agNULL) 979285809Sscottl { 980285809Sscottl TI_DBG6(("satDeviceResetCB: satOrgIOContext is NULL, wrong\n")); 981285809Sscottl return; 982285809Sscottl } 983285809Sscottl else 984285809Sscottl { 985285809Sscottl TI_DBG6(("satDeviceResetCB: satOrgIOContext is NOT NULL\n")); 986285809Sscottl } 987285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 988285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 989285809Sscottl } 990285809Sscottl 991285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 992285809Sscottl tdIORequestBody->ioStarted = agFALSE; 993285809Sscottl 994285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 995285809Sscottl { 996285809Sscottl TI_DBG1(("satDeviceResetCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 997285809Sscottl 998285809Sscottl if (satOrgIOContext->NotifyOS == agTRUE) 999285809Sscottl { 1000285809Sscottl ostiInitiatorEvent( tiRoot, 1001285809Sscottl NULL, 1002285809Sscottl NULL, 1003285809Sscottl tiIntrEventTypeTaskManagement, 1004285809Sscottl tiTMFailed, 1005285809Sscottl tiOrgIORequest ); 1006285809Sscottl } 1007285809Sscottl 1008285809Sscottl satDevData->satTmTaskTag = agNULL; 1009285809Sscottl 1010285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1011285809Sscottl 1012285809Sscottl satFreeIntIoResource( tiRoot, 1013285809Sscottl satDevData, 1014285809Sscottl satIntIo); 1015285809Sscottl return; 1016285809Sscottl } 1017285809Sscottl 1018285809Sscottl if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 1019285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 1020285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 1021285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 1022285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 1023285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 1024285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 1025285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR || 1026285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 1027285809Sscottl ) 1028285809Sscottl { 1029285809Sscottl TI_DBG1(("satDeviceResetCB: OSSA_IO_OPEN_CNX_ERROR\n")); 1030285809Sscottl 1031285809Sscottl if (satOrgIOContext->NotifyOS == agTRUE) 1032285809Sscottl { 1033285809Sscottl ostiInitiatorEvent( tiRoot, 1034285809Sscottl NULL, 1035285809Sscottl NULL, 1036285809Sscottl tiIntrEventTypeTaskManagement, 1037285809Sscottl tiTMFailed, 1038285809Sscottl tiOrgIORequest ); 1039285809Sscottl } 1040285809Sscottl 1041285809Sscottl satDevData->satTmTaskTag = agNULL; 1042285809Sscottl 1043285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1044285809Sscottl 1045285809Sscottl satFreeIntIoResource( tiRoot, 1046285809Sscottl satDevData, 1047285809Sscottl satIntIo); 1048285809Sscottl return; 1049285809Sscottl } 1050285809Sscottl 1051285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 1052285809Sscottl { 1053285809Sscottl /* only agsaFisPioSetup_t is expected */ 1054285809Sscottl#ifdef TD_DEBUG_ENABLE 1055285809Sscottl satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 1056285809Sscottl ataStatus = satPIOSetupHeader->status; /* ATA Status register */ 1057285809Sscottl ataError = satPIOSetupHeader->error; /* ATA Eror register */ 1058285809Sscottl#endif 1059285809Sscottl TI_DBG1(("satDeviceResetCB: ataStatus 0x%x ataError 0x%x\n", ataStatus, ataError)); 1060285809Sscottl 1061285809Sscottl if (satOrgIOContext->NotifyOS == agTRUE) 1062285809Sscottl { 1063285809Sscottl ostiInitiatorEvent( tiRoot, 1064285809Sscottl NULL, 1065285809Sscottl NULL, 1066285809Sscottl tiIntrEventTypeTaskManagement, 1067285809Sscottl tiTMFailed, 1068285809Sscottl tiOrgIORequest ); 1069285809Sscottl } 1070285809Sscottl 1071285809Sscottl satDevData->satTmTaskTag = agNULL; 1072285809Sscottl 1073285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1074285809Sscottl 1075285809Sscottl satFreeIntIoResource( tiRoot, 1076285809Sscottl satDevData, 1077285809Sscottl satIntIo); 1078285809Sscottl return; 1079285809Sscottl } 1080285809Sscottl 1081285809Sscottl /* success */ 1082285809Sscottl if (satOrgIOContext->TMF == AG_ABORT_TASK) 1083285809Sscottl { 1084285809Sscottl AbortTM = agTRUE; 1085285809Sscottl } 1086285809Sscottl 1087285809Sscottl if (satOrgIOContext->NotifyOS == agTRUE) 1088285809Sscottl { 1089285809Sscottl report = agTRUE; 1090285809Sscottl } 1091285809Sscottl 1092285809Sscottl if (AbortTM == agTRUE) 1093285809Sscottl { 1094285809Sscottl TI_DBG1(("satDeResetDeviceCB: calling satAbort\n")); 1095285809Sscottl satAbort(agRoot, satOrgIOContext->satToBeAbortedIOContext); 1096285809Sscottl } 1097285809Sscottl satDevData->satTmTaskTag = agNULL; 1098285809Sscottl 1099285809Sscottl satDevData->satDriveState = SAT_DEV_STATE_NORMAL; 1100285809Sscottl 1101285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1102285809Sscottl 1103285809Sscottl TI_DBG1(("satDeviceResetCB: satPendingIO %d satNCQMaxIO %d\n", satDevData->satPendingIO, satDevData->satNCQMaxIO )); 1104285809Sscottl TI_DBG1(("satDeviceResetCB: satPendingNCQIO %d satPendingNONNCQIO %d\n", satDevData->satPendingNCQIO, satDevData->satPendingNONNCQIO)); 1105285809Sscottl 1106285809Sscottl satFreeIntIoResource( tiRoot, 1107285809Sscottl satDevData, 1108285809Sscottl satIntIo); 1109285809Sscottl 1110285809Sscottl /* clean up TD layer's IORequestBody */ 1111285809Sscottl if (tdOrgIORequestBody != agNULL) 1112285809Sscottl { 1113285809Sscottl ostiFreeMemory( 1114285809Sscottl tiRoot, 1115285809Sscottl tdOrgIORequestBody->IOType.InitiatorTMIO.osMemHandle, 1116285809Sscottl sizeof(tdIORequestBody_t) 1117285809Sscottl ); 1118285809Sscottl } 1119285809Sscottl else 1120285809Sscottl { 1121285809Sscottl TI_DBG1(("satDeviceResetCB: tdOrgIORequestBody is NULL, wrong\n")); 1122285809Sscottl } 1123285809Sscottl 1124285809Sscottl 1125285809Sscottl if (report) 1126285809Sscottl { 1127285809Sscottl ostiInitiatorEvent( tiRoot, 1128285809Sscottl NULL, 1129285809Sscottl NULL, 1130285809Sscottl tiIntrEventTypeTaskManagement, 1131285809Sscottl tiTMOK, 1132285809Sscottl tiOrgIORequest ); 1133285809Sscottl } 1134285809Sscottl 1135285809Sscottl 1136285809Sscottl TI_DBG5(("satDeviceResetCB: device %p pending IO %d\n", satDevData, satDevData->satPendingIO)); 1137285809Sscottl TI_DBG6(("satDeviceResetCB: end\n")); 1138285809Sscottl return; 1139285809Sscottl} 1140285809Sscottl 1141285809Sscottl/***************************************************************************** 1142285809Sscottl*! \brief satExecuteDeviceDiagnosticCB 1143285809Sscottl* 1144285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 1145285809Sscottl* This CB routine deals with normal non-chained data I/O SATA request. 1146285809Sscottl* 1147285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 1148285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 1149285809Sscottl* \param agIOStatus: Status of completed I/O. 1150285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 1151285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 1152285809Sscottl* length. 1153285809Sscottl* \param agParam: Additional info based on status. 1154285809Sscottl* \param ioContext: Pointer to satIOContext_t. 1155285809Sscottl* 1156285809Sscottl* \return: none 1157285809Sscottl* 1158285809Sscottl*****************************************************************************/ 1159285809Sscottlvoid satExecuteDeviceDiagnosticCB( 1160285809Sscottl agsaRoot_t *agRoot, 1161285809Sscottl agsaIORequest_t *agIORequest, 1162285809Sscottl bit32 agIOStatus, 1163285809Sscottl agsaFisHeader_t *agFirstDword, 1164285809Sscottl bit32 agIOInfoLen, 1165285809Sscottl void *agParam, 1166285809Sscottl void *ioContext 1167285809Sscottl ) 1168285809Sscottl{ 1169285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 1170285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 1171285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 1172285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 1173285809Sscottl tdIORequestBody_t *tdIORequestBody; 1174285809Sscottl satIOContext_t *satIOContext; 1175285809Sscottl satIOContext_t *satOrgIOContext; 1176285809Sscottl satInternalIo_t *satIntIo; 1177285809Sscottl satDeviceData_t *satDevData; 1178285809Sscottl 1179285809Sscottl TI_DBG3(("satExecuteDeviceDiagnosticCB start\n")); 1180285809Sscottl 1181285809Sscottl /* internally generate tiIOContext */ 1182285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 1183285809Sscottl satIOContext = (satIOContext_t *) ioContext; 1184285809Sscottl satIntIo = satIOContext->satIntIoContext; 1185285809Sscottl satDevData = satIOContext->pSatDevData; 1186285809Sscottl 1187285809Sscottl /*ttttttthe one */ 1188285809Sscottl if (satIntIo == agNULL) 1189285809Sscottl { 1190285809Sscottl TI_DBG4(("satExecuteDeviceDiagnosticCB: External satInternalIo_t satIntIoContext\n")); 1191285809Sscottl satOrgIOContext = satIOContext; 1192285809Sscottl } 1193285809Sscottl else 1194285809Sscottl { 1195285809Sscottl TI_DBG4(("satExecuteDeviceDiagnosticCB: Internal satInternalIo_t satIntIoContext\n")); 1196285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 1197285809Sscottl if (satOrgIOContext == agNULL) 1198285809Sscottl { 1199285809Sscottl TI_DBG4(("satExecuteDeviceDiagnosticCB: satOrgIOContext is NULL, wrong\n")); 1200285809Sscottl return; 1201285809Sscottl } 1202285809Sscottl else 1203285809Sscottl { 1204285809Sscottl TI_DBG4(("satExecuteDeviceDiagnosticCB: satOrgIOContext is NOT NULL\n")); 1205285809Sscottl } 1206285809Sscottl } 1207285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1208285809Sscottl 1209285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 1210285809Sscottl tdIORequestBody->ioStarted = agFALSE; 1211285809Sscottl 1212285809Sscottl /* interal structure free */ 1213285809Sscottl satFreeIntIoResource(tiRoot, 1214285809Sscottl satDevData, 1215285809Sscottl satIntIo); 1216285809Sscottl} 1217285809Sscottl/***************************************************************************** 1218285809Sscottl*! \brief satNonChainedDataIOCB 1219285809Sscottl* 1220285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 1221285809Sscottl* This CB routine deals with normal non-chained data I/O SATA request. 1222285809Sscottl* 1223285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 1224285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 1225285809Sscottl* \param agIOStatus: Status of completed I/O. 1226285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 1227285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 1228285809Sscottl* length. 1229285809Sscottl* \param agParam: Additional info based on status. 1230285809Sscottl* \param ioContext: Pointer to satIOContext_t. 1231285809Sscottl* 1232285809Sscottl* \return: none 1233285809Sscottl* 1234285809Sscottl*****************************************************************************/ 1235285809Sscottl 1236285809Sscottlvoid satNonChainedDataIOCB( 1237285809Sscottl agsaRoot_t *agRoot, 1238285809Sscottl agsaIORequest_t *agIORequest, 1239285809Sscottl bit32 agIOStatus, 1240285809Sscottl agsaFisHeader_t *agFirstDword, 1241285809Sscottl bit32 agIOInfoLen, 1242285809Sscottl void *agParam, 1243285809Sscottl void *ioContext 1244285809Sscottl ) 1245285809Sscottl{ 1246285809Sscottl 1247285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 1248285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 1249285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 1250285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 1251285809Sscottl tdIORequestBody_t *tdIORequestBody; 1252285809Sscottl bit32 interruptContext = osData->IntContext; 1253285809Sscottl satIOContext_t *satIOContext; 1254285809Sscottl satInternalIo_t *SatIntIo; 1255285809Sscottl satDeviceData_t *SatDevData; 1256285809Sscottl 1257285809Sscottl TI_DBG6(("satNonChainedDataIOCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 1258285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 1259285809Sscottl 1260285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 1261285809Sscottl satIOContext = (satIOContext_t *) ioContext; 1262285809Sscottl SatIntIo = satIOContext->satIntIoContext; 1263285809Sscottl SatDevData = satIOContext->pSatDevData; 1264285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1265285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 1266285809Sscottl tdIORequestBody->ioStarted = agFALSE; 1267285809Sscottl 1268285809Sscottl /* interal structure free */ 1269285809Sscottl satFreeIntIoResource( tiRoot, 1270285809Sscottl SatDevData, 1271285809Sscottl SatIntIo); 1272285809Sscottl 1273285809Sscottl /* Process completion */ 1274285809Sscottl if( (agIOStatus == OSSA_IO_SUCCESS) && (agIOInfoLen == 0)) 1275285809Sscottl { 1276285809Sscottl TI_DBG5(("satNonChainedDataIOCB: success\n")); 1277285809Sscottl TI_DBG5(("satNonChainedDataIOCB: success agIORequest %p\n", agIORequest)); 1278285809Sscottl /* 1279285809Sscottl * Command was completed OK, this is the normal path. 1280285809Sscottl * Now call the OS-App Specific layer about this completion. 1281285809Sscottl */ 1282285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1283285809Sscottl tdIORequestBody->tiIORequest, 1284285809Sscottl tiIOSuccess, 1285285809Sscottl SCSI_STAT_GOOD, 1286285809Sscottl agNULL, 1287285809Sscottl interruptContext); 1288285809Sscottl } 1289285809Sscottl else 1290285809Sscottl { 1291285809Sscottl TI_DBG1(("satNonChainedDataIOCB: calling itdsatProcessAbnormalCompletion\n")); 1292285809Sscottl /* More checking needed */ 1293285809Sscottl itdsatProcessAbnormalCompletion( agRoot, 1294285809Sscottl agIORequest, 1295285809Sscottl agIOStatus, 1296285809Sscottl agFirstDword, 1297285809Sscottl agIOInfoLen, 1298285809Sscottl agParam, 1299285809Sscottl satIOContext); 1300285809Sscottl } 1301285809Sscottl 1302285809Sscottl return; 1303285809Sscottl 1304285809Sscottl 1305285809Sscottl} 1306285809Sscottl/***************************************************************************** 1307285809Sscottl*! \brief satChainedDataIOCB 1308285809Sscottl* 1309285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 1310285809Sscottl* This CB routine deals with normal chained data I/O SATA request. 1311285809Sscottl* 1312285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 1313285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 1314285809Sscottl* \param agIOStatus: Status of completed I/O. 1315285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 1316285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 1317285809Sscottl* length. 1318285809Sscottl* \param agParam: Additional info based on status. 1319285809Sscottl* \param ioContext: Pointer to satIOContext_t. 1320285809Sscottl* 1321285809Sscottl* \return: none 1322285809Sscottl* 1323285809Sscottl*****************************************************************************/ 1324285809Sscottlvoid satChainedDataIOCB( 1325285809Sscottl agsaRoot_t *agRoot, 1326285809Sscottl agsaIORequest_t *agIORequest, 1327285809Sscottl bit32 agIOStatus, 1328285809Sscottl agsaFisHeader_t *agFirstDword, 1329285809Sscottl bit32 agIOInfoLen, 1330285809Sscottl void *agParam, 1331285809Sscottl void *ioContext 1332285809Sscottl ) 1333285809Sscottl{ 1334285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 1335285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 1336285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 1337285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 1338285809Sscottl tdIORequestBody_t *tdIORequestBody; 1339285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 1340285809Sscottl satIOContext_t *satIOContext; 1341285809Sscottl satIOContext_t *satOrgIOContext; 1342285809Sscottl satIOContext_t *satNewIOContext; 1343285809Sscottl satInternalIo_t *satIntIo; 1344285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 1345285809Sscottl satDeviceData_t *satDevData; 1346285809Sscottl scsiRspSense_t *pSense; 1347285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 1348285809Sscottl tiIORequest_t *tiOrgIORequest; 1349285809Sscottl 1350285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 1351285809Sscottl bit32 ataStatus = 0; 1352285809Sscottl bit32 status = tiError; 1353285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 1354285809Sscottl bit32 dataLength; 1355285809Sscottl 1356285809Sscottl TI_DBG6(("satChainedDataIOCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 1357285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 1358285809Sscottl 1359285809Sscottl 1360285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 1361285809Sscottl satIOContext = (satIOContext_t *) ioContext; 1362285809Sscottl if (satIOContext == agNULL) 1363285809Sscottl { 1364285809Sscottl TI_DBG1(("satChainedDataIOCB: satIOContext is NULL\n")); 1365285809Sscottl return; 1366285809Sscottl } 1367285809Sscottl satIntIo = satIOContext->satIntIoContext; 1368285809Sscottl satDevData = satIOContext->pSatDevData; 1369285809Sscottl hostToDevFis = satIOContext->pFis; 1370285809Sscottl 1371285809Sscottl if (satIntIo == agNULL) 1372285809Sscottl { 1373285809Sscottl TI_DBG5(("satChainedDataIOCB: External satInternalIo_t satIntIoContext\n")); 1374285809Sscottl satOrgIOContext = satIOContext; 1375285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 1376285809Sscottl pSense = satIOContext->pSense; 1377285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 1378285809Sscottl } 1379285809Sscottl else 1380285809Sscottl { 1381285809Sscottl TI_DBG5(("satChainedDataIOCB: Internal satInternalIo_t satIntIoContext\n")); 1382285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 1383285809Sscottl if (satOrgIOContext == agNULL) 1384285809Sscottl { 1385285809Sscottl TI_DBG5(("satChainedDataIOCB: satOrgIOContext is NULL\n")); 1386285809Sscottl } 1387285809Sscottl else 1388285809Sscottl { 1389285809Sscottl TI_DBG5(("satChainedDataIOCB: satOrgIOContext is NOT NULL\n")); 1390285809Sscottl } 1391285809Sscottl 1392285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 1393285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 1394285809Sscottl 1395285809Sscottl pSense = satOrgIOContext->pSense; 1396285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 1397285809Sscottl } 1398285809Sscottl 1399285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 1400285809Sscottl tdIORequestBody->ioStarted = agFALSE; 1401285809Sscottl 1402285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 1403285809Sscottl { 1404285809Sscottl TI_DBG1(("satChainedDataIOCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 1405285809Sscottl satSetSensePayload( pSense, 1406285809Sscottl SCSI_SNSKEY_NO_SENSE, 1407285809Sscottl 0, 1408285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1409285809Sscottl satOrgIOContext); 1410285809Sscottl 1411285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1412285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1413285809Sscottl tiIOSuccess, 1414285809Sscottl SCSI_STAT_CHECK_CONDITION, 1415285809Sscottl satOrgIOContext->pTiSenseData, 1416285809Sscottl satOrgIOContext->interruptContext ); 1417285809Sscottl 1418285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1419285809Sscottl 1420285809Sscottl satFreeIntIoResource( tiRoot, 1421285809Sscottl satDevData, 1422285809Sscottl satIntIo); 1423285809Sscottl return; 1424285809Sscottl } 1425285809Sscottl 1426285809Sscottl /* 1427285809Sscottl checking IO status, FIS type and error status 1428285809Sscottl */ 1429285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 1430285809Sscottl { 1431285809Sscottl /* agsaFisPioSetup_t or agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for read 1432285809Sscottl agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for write 1433285809Sscottl first, assumed to be Reg Device to Host FIS 1434285809Sscottl This is OK to just find fis type 1435285809Sscottl */ 1436285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 1437285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 1438285809Sscottl /* for debugging */ 1439285809Sscottl if( (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) && 1440285809Sscottl (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 1441285809Sscottl (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 1442285809Sscottl ) 1443285809Sscottl { 1444285809Sscottl TI_DBG1(("satChainedDataIOCB: FAILED, Wrong FIS type 0x%x\n", statDevToHostFisHeader->fisType)); 1445285809Sscottl } 1446285809Sscottl 1447285809Sscottl /* for debugging */ 1448285809Sscottl if ( (ataStatus & ERR_ATA_STATUS_MASK) || 1449285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 1450285809Sscottl ) 1451285809Sscottl { 1452285809Sscottl TI_DBG1(("satChainedDataIOCB: FAILED, error status and command 0x%x\n", hostToDevFis->h.command)); 1453285809Sscottl } 1454285809Sscottl 1455285809Sscottl /* the function below handles abort case */ 1456285809Sscottl itdsatDelayedProcessAbnormalCompletion(agRoot, 1457285809Sscottl agIORequest, 1458285809Sscottl agIOStatus, 1459285809Sscottl agFirstDword, 1460285809Sscottl agIOInfoLen, 1461285809Sscottl agParam, 1462285809Sscottl satIOContext); 1463285809Sscottl 1464285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1465285809Sscottl satFreeIntIoResource( tiRoot, 1466285809Sscottl satDevData, 1467285809Sscottl satIntIo); 1468285809Sscottl return; 1469285809Sscottl } /* end of error */ 1470285809Sscottl 1471285809Sscottl switch (hostToDevFis->h.command) 1472285809Sscottl { 1473285809Sscottl case SAT_READ_DMA: /* fall through */ 1474285809Sscottl case SAT_READ_SECTORS: /* fall through */ 1475285809Sscottl case SAT_READ_DMA_EXT: /* fall through */ 1476285809Sscottl case SAT_READ_SECTORS_EXT: /* fall through */ 1477285809Sscottl case SAT_READ_FPDMA_QUEUED: /* fall through */ 1478285809Sscottl case SAT_WRITE_DMA: /* fall through */ 1479285809Sscottl case SAT_WRITE_SECTORS:/* fall through */ 1480285809Sscottl case SAT_WRITE_DMA_FUA_EXT: /* fall through */ 1481285809Sscottl case SAT_WRITE_DMA_EXT: /* fall through */ 1482285809Sscottl case SAT_WRITE_SECTORS_EXT: /* fall through */ 1483285809Sscottl case SAT_WRITE_FPDMA_QUEUED: 1484285809Sscottl 1485285809Sscottl TI_DBG5(("satChainedDataIOCB: READ/WRITE success case\n")); 1486285809Sscottl 1487285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1488285809Sscottl 1489285809Sscottl /* done with internally genereated SAT_SMART_RETURN_STATUS */ 1490285809Sscottl satFreeIntIoResource( tiRoot, 1491285809Sscottl satDevData, 1492285809Sscottl satIntIo); 1493285809Sscottl /* let's loop till TL */ 1494285809Sscottl 1495285809Sscottl /* lba = lba + tl 1496285809Sscottl loopnum--; 1497285809Sscottl if (loopnum == 0) done 1498285809Sscottl */ 1499285809Sscottl (satOrgIOContext->LoopNum)--; 1500285809Sscottl if (satOrgIOContext->LoopNum == 0) 1501285809Sscottl { 1502285809Sscottl /* done with read */ 1503285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1504285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1505285809Sscottl tiIOSuccess, 1506285809Sscottl SCSI_STAT_GOOD, 1507285809Sscottl agNULL, 1508285809Sscottl satOrgIOContext->interruptContext ); 1509285809Sscottl return; 1510285809Sscottl } 1511285809Sscottl if (satOrgIOContext->superIOFlag) 1512285809Sscottl { 1513285809Sscottl dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 1514285809Sscottl } 1515285809Sscottl else 1516285809Sscottl { 1517285809Sscottl dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 1518285809Sscottl } 1519285809Sscottl 1520285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 1521285809Sscottl tiOrgIORequest, 1522285809Sscottl satDevData, 1523285809Sscottl dataLength, 1524285809Sscottl satNewIntIo); 1525285809Sscottl if (satNewIntIo == agNULL) 1526285809Sscottl { 1527285809Sscottl /* memory allocation failure */ 1528285809Sscottl satFreeIntIoResource( tiRoot, 1529285809Sscottl satDevData, 1530285809Sscottl satNewIntIo); 1531285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1532285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1533285809Sscottl tiIOFailed, 1534285809Sscottl tiDetailOtherError, 1535285809Sscottl agNULL, 1536285809Sscottl satOrgIOContext->interruptContext ); 1537285809Sscottl 1538285809Sscottl TI_DBG1(("satChainedDataIOCB: momory allocation fails\n")); 1539285809Sscottl return; 1540285809Sscottl } /* end of memory allocation failure */ 1541285809Sscottl 1542285809Sscottl /* 1543285809Sscottl * Need to initialize all the fields within satIOContext 1544285809Sscottl */ 1545285809Sscottl 1546285809Sscottl satNewIOContext = satPrepareNewIO( 1547285809Sscottl satNewIntIo, 1548285809Sscottl tiOrgIORequest, 1549285809Sscottl satDevData, 1550285809Sscottl scsiCmnd, 1551285809Sscottl satOrgIOContext 1552285809Sscottl ); 1553285809Sscottl 1554285809Sscottl /* sending another ATA command */ 1555285809Sscottl switch (scsiCmnd->cdb[0]) 1556285809Sscottl { 1557285809Sscottl case SCSIOPC_READ_6: 1558285809Sscottl /* no loop should occur with READ6 since it fits in one ATA command */ 1559285809Sscottl break; 1560285809Sscottl case SCSIOPC_READ_10: /* fall through */ 1561285809Sscottl case SCSIOPC_READ_12: /* fall through */ 1562285809Sscottl case SCSIOPC_READ_16: /* fall through */ 1563285809Sscottl status = satRead_1( tiRoot, 1564285809Sscottl &satNewIntIo->satIntTiIORequest, 1565285809Sscottl satNewIOContext->ptiDeviceHandle, 1566285809Sscottl &satNewIntIo->satIntTiScsiXchg, 1567285809Sscottl satNewIOContext); 1568285809Sscottl break; 1569285809Sscottl case SCSIOPC_WRITE_6: 1570285809Sscottl /* no loop should occur with WRITE6 since it fits in one ATA command */ 1571285809Sscottl break; 1572285809Sscottl case SCSIOPC_WRITE_10: /* fall through */ 1573285809Sscottl case SCSIOPC_WRITE_12: /* fall through */ 1574285809Sscottl case SCSIOPC_WRITE_16: /* fall through */ 1575285809Sscottl status = satWrite_1( tiRoot, 1576285809Sscottl &satNewIntIo->satIntTiIORequest, 1577285809Sscottl satNewIOContext->ptiDeviceHandle, 1578285809Sscottl &satNewIntIo->satIntTiScsiXchg, 1579285809Sscottl satNewIOContext); 1580285809Sscottl break; 1581285809Sscottl default: 1582285809Sscottl TI_DBG1(("satChainedDataIOCB: success but default case scsi cmd 0x%x ata cmd 0x%x\n",scsiCmnd->cdb[0], hostToDevFis->h.command)); 1583285809Sscottl status = tiError; 1584285809Sscottl break; 1585285809Sscottl } 1586285809Sscottl 1587285809Sscottl 1588285809Sscottl 1589285809Sscottl if (status != tiSuccess) 1590285809Sscottl { 1591285809Sscottl satFreeIntIoResource( tiRoot, 1592285809Sscottl satDevData, 1593285809Sscottl satNewIntIo); 1594285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1595285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1596285809Sscottl tiIOFailed, 1597285809Sscottl tiDetailOtherError, 1598285809Sscottl agNULL, 1599285809Sscottl satOrgIOContext->interruptContext ); 1600285809Sscottl TI_DBG1(("satChainedDataIOCB: calling satRead10_1 fails\n")); 1601285809Sscottl return; 1602285809Sscottl } 1603285809Sscottl 1604285809Sscottl break; 1605285809Sscottl 1606285809Sscottl 1607285809Sscottl default: 1608285809Sscottl TI_DBG1(("satChainedDataIOCB: success but default case command 0x%x\n",hostToDevFis->h.command)); 1609285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1610285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1611285809Sscottl tiIOFailed, 1612285809Sscottl tiDetailOtherError, 1613285809Sscottl agNULL, 1614285809Sscottl satOrgIOContext->interruptContext ); 1615285809Sscottl 1616285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1617285809Sscottl 1618285809Sscottl satFreeIntIoResource( tiRoot, 1619285809Sscottl satDevData, 1620285809Sscottl satIntIo); 1621285809Sscottl 1622285809Sscottl break; 1623285809Sscottl } 1624285809Sscottl 1625285809Sscottl 1626285809Sscottl return; 1627285809Sscottl} 1628285809Sscottlvoid satNonChainedWriteNVerifyCB( 1629285809Sscottl agsaRoot_t *agRoot, 1630285809Sscottl agsaIORequest_t *agIORequest, 1631285809Sscottl bit32 agIOStatus, 1632285809Sscottl agsaFisHeader_t *agFirstDword, 1633285809Sscottl bit32 agIOInfoLen, 1634285809Sscottl void *agParam, 1635285809Sscottl void *ioContext 1636285809Sscottl ) 1637285809Sscottl{ 1638285809Sscottl 1639285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 1640285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 1641285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 1642285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 1643285809Sscottl tdIORequestBody_t *tdIORequestBody; 1644285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 1645285809Sscottl satIOContext_t *satIOContext; 1646285809Sscottl satIOContext_t *satOrgIOContext; 1647285809Sscottl satIOContext_t *satNewIOContext; 1648285809Sscottl satInternalIo_t *satIntIo; 1649285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 1650285809Sscottl satDeviceData_t *satDevData; 1651285809Sscottl scsiRspSense_t *pSense; 1652285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 1653285809Sscottl tiIORequest_t *tiOrgIORequest; 1654285809Sscottl 1655285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 1656285809Sscottl bit32 ataStatus = 0; 1657285809Sscottl bit32 status; 1658285809Sscottl tiScsiInitiatorRequest_t *tiScsiRequest; /* tiScsiXchg */ 1659285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 1660285809Sscottl agsaFisSetDevBitsHeader_t *statSetDevBitFisHeader = agNULL; 1661285809Sscottl 1662285809Sscottl TI_DBG5(("satNonChainedWriteNVerifyCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 1663285809Sscottl 1664285809Sscottl /* internally generate tiIOContext */ 1665285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 1666285809Sscottl satIOContext = (satIOContext_t *) ioContext; 1667285809Sscottl satIntIo = satIOContext->satIntIoContext; 1668285809Sscottl satDevData = satIOContext->pSatDevData; 1669285809Sscottl hostToDevFis = satIOContext->pFis; 1670285809Sscottl 1671285809Sscottl /* SPC: Self-Test Result Log page */ 1672285809Sscottl tiScsiRequest = satIOContext->tiScsiXchg; 1673285809Sscottl 1674285809Sscottl if (satIntIo == agNULL) 1675285809Sscottl { 1676285809Sscottl TI_DBG4(("satNonChainedWriteNVerifyCB: External satInternalIo_t satIntIoContext\n")); 1677285809Sscottl satOrgIOContext = satIOContext; 1678285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 1679285809Sscottl pSense = satOrgIOContext->pSense; 1680285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 1681285809Sscottl } 1682285809Sscottl else 1683285809Sscottl { 1684285809Sscottl TI_DBG4(("satNonChainedWriteNVerifyCB: Internal satInternalIo_t satIntIoContext\n")); 1685285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 1686285809Sscottl if (satOrgIOContext == agNULL) 1687285809Sscottl { 1688285809Sscottl TI_DBG4(("satNonChainedWriteNVerifyCB: satOrgIOContext is NULL, wrong\n")); 1689285809Sscottl return; 1690285809Sscottl } 1691285809Sscottl else 1692285809Sscottl { 1693285809Sscottl TI_DBG4(("satNonChainedWriteNVerifyCB: satOrgIOContext is NOT NULL\n")); 1694285809Sscottl } 1695285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 1696285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 1697285809Sscottl 1698285809Sscottl pSense = satOrgIOContext->pSense; 1699285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 1700285809Sscottl } 1701285809Sscottl 1702285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 1703285809Sscottl tdIORequestBody->ioStarted = agFALSE; 1704285809Sscottl 1705285809Sscottl 1706285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 1707285809Sscottl { 1708285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 1709285809Sscottl ostiInitiatorIOCompleted ( 1710285809Sscottl tiRoot, 1711285809Sscottl tiOrgIORequest, 1712285809Sscottl tiIOFailed, 1713285809Sscottl tiDetailOtherError, 1714285809Sscottl agNULL, 1715285809Sscottl satOrgIOContext->interruptContext 1716285809Sscottl ); 1717285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1718285809Sscottl 1719285809Sscottl satFreeIntIoResource( tiRoot, 1720285809Sscottl satDevData, 1721285809Sscottl satIntIo); 1722285809Sscottl return; 1723285809Sscottl } 1724285809Sscottl 1725285809Sscottl 1726285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 1727285809Sscottl { 1728285809Sscottl /* 1729285809Sscottl FIS type should be either REG_DEV_TO_HOST_FIS or SET_DEV_BITS_FIS 1730285809Sscottl */ 1731285809Sscottl /* First, assumed to be Reg Device to Host FIS */ 1732285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 1733285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 1734285809Sscottl } 1735285809Sscottl 1736285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 1737285809Sscottl { 1738285809Sscottl if (statDevToHostFisHeader->fisType == SET_DEV_BITS_FIS) 1739285809Sscottl { 1740285809Sscottl statSetDevBitFisHeader = (agsaFisSetDevBitsHeader_t *)&(agFirstDword->D2H); 1741285809Sscottl 1742285809Sscottl /* Get ATA Status register */ 1743285809Sscottl ataStatus = (statSetDevBitFisHeader->statusHi_Lo & 0x70); /* bits 4,5,6 */ 1744285809Sscottl ataStatus = ataStatus | (statSetDevBitFisHeader->statusHi_Lo & 0x07); /* bits 0,1,2 */ 1745285809Sscottl 1746285809Sscottl /* ATA Eror register */ 1747285809Sscottl } 1748285809Sscottl } 1749285809Sscottl 1750285809Sscottl 1751285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 1752285809Sscottl { 1753285809Sscottl /* 1754285809Sscottl checking IO status, FIS type and error status 1755285809Sscottl FIS type should be either REG_DEV_TO_HOST_FIS or SET_DEV_BITS_FIS 1756285809Sscottl Both have fisType in the same location 1757285809Sscottl */ 1758285809Sscottl if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 1759285809Sscottl (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS)) || 1760285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 1761285809Sscottl ) 1762285809Sscottl { 1763285809Sscottl /* for debugging */ 1764285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 1765285809Sscottl { 1766285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: FAILED, NOT IO_SUCCESS\n")); 1767285809Sscottl } 1768285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 1769285809Sscottl { 1770285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 1771285809Sscottl } 1772285809Sscottl else if (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 1773285809Sscottl { 1774285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 1775285809Sscottl } 1776285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 1777285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 1778285809Sscottl ) 1779285809Sscottl { 1780285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: FAILED, FAILED, error status\n")); 1781285809Sscottl } 1782285809Sscottl 1783285809Sscottl 1784285809Sscottl /* Process abort case */ 1785285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 1786285809Sscottl { 1787285809Sscottl satProcessAbort(tiRoot, 1788285809Sscottl tiOrgIORequest, 1789285809Sscottl satOrgIOContext 1790285809Sscottl ); 1791285809Sscottl 1792285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1793285809Sscottl 1794285809Sscottl satFreeIntIoResource( tiRoot, 1795285809Sscottl satDevData, 1796285809Sscottl satIntIo); 1797285809Sscottl return; 1798285809Sscottl } 1799285809Sscottl 1800285809Sscottl /* for debugging */ 1801285809Sscottl switch (hostToDevFis->h.command) 1802285809Sscottl { 1803285809Sscottl case SAT_WRITE_DMA_FUA_EXT: 1804285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: SAT_WRITE_DMA_FUA_EXT\n")); 1805285809Sscottl break; 1806285809Sscottl case SAT_WRITE_DMA_EXT: 1807285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: SAT_WRITE_DMA_EXT\n")); 1808285809Sscottl break; 1809285809Sscottl case SAT_WRITE_SECTORS_EXT: 1810285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: SAT_WRITE_SECTORS_EXT\n")); 1811285809Sscottl break; 1812285809Sscottl case SAT_WRITE_FPDMA_QUEUED: 1813285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: SAT_WRITE_FPDMA_QUEUED\n")); 1814285809Sscottl break; 1815285809Sscottl case SAT_READ_VERIFY_SECTORS: 1816285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS\n")); 1817285809Sscottl break; 1818285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 1819285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS_EXT\n")); 1820285809Sscottl break; 1821285809Sscottl default: 1822285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: error default case command 0x%x\n", hostToDevFis->h.command)); 1823285809Sscottl break; 1824285809Sscottl } 1825285809Sscottl 1826285809Sscottl satSetSensePayload( pSense, 1827285809Sscottl SCSI_SNSKEY_NO_SENSE, 1828285809Sscottl 0, 1829285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1830285809Sscottl satOrgIOContext); 1831285809Sscottl 1832285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1833285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1834285809Sscottl tiIOSuccess, 1835285809Sscottl SCSI_STAT_CHECK_CONDITION, 1836285809Sscottl satOrgIOContext->pTiSenseData, 1837285809Sscottl satOrgIOContext->interruptContext ); 1838285809Sscottl 1839285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1840285809Sscottl 1841285809Sscottl satFreeIntIoResource( tiRoot, 1842285809Sscottl satDevData, 1843285809Sscottl satIntIo); 1844285809Sscottl return; 1845285809Sscottl } /* end error checking */ 1846285809Sscottl } 1847285809Sscottl 1848285809Sscottl /* process success from this point on */ 1849285809Sscottl 1850285809Sscottl switch (hostToDevFis->h.command) 1851285809Sscottl { 1852285809Sscottl case SAT_WRITE_DMA_FUA_EXT: 1853285809Sscottl TI_DBG5(("satNonChainedWriteNVerifyCB: SAT_WRITE_DMA_FUA_EXT success\n")); 1854285809Sscottl break; 1855285809Sscottl case SAT_WRITE_DMA_EXT: 1856285809Sscottl TI_DBG5(("satNonChainedWriteNVerifyCB: SAT_WRITE_DMA_EXT success\n")); 1857285809Sscottl break; 1858285809Sscottl case SAT_WRITE_SECTORS_EXT: 1859285809Sscottl TI_DBG5(("satNonChainedWriteNVerifyCB: SAT_WRITE_SECTORS_EXT succes\n")); 1860285809Sscottl 1861285809Sscottl break; 1862285809Sscottl case SAT_WRITE_FPDMA_QUEUED: 1863285809Sscottl TI_DBG5(("satNonChainedWriteNVerifyCB: SAT_WRITE_FPDMA_QUEUED succes\n")); 1864285809Sscottl break; 1865285809Sscottl case SAT_READ_VERIFY_SECTORS: 1866285809Sscottl TI_DBG5(("satNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS succes\n")); 1867285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1868285809Sscottl 1869285809Sscottl /* free */ 1870285809Sscottl satFreeIntIoResource( tiRoot, 1871285809Sscottl satDevData, 1872285809Sscottl satIntIo); 1873285809Sscottl 1874285809Sscottl /* return stat_good */ 1875285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1876285809Sscottl tiOrgIORequest, 1877285809Sscottl tiIOSuccess, 1878285809Sscottl SCSI_STAT_GOOD, 1879285809Sscottl agNULL, 1880285809Sscottl satOrgIOContext->interruptContext ); 1881285809Sscottl return; 1882285809Sscottl break; 1883285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 1884285809Sscottl TI_DBG5(("satNonChainedWriteNVerifyCB: SAT_READ_VERIFY_SECTORS_EXT succes\n")); 1885285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1886285809Sscottl 1887285809Sscottl /* free */ 1888285809Sscottl satFreeIntIoResource( tiRoot, 1889285809Sscottl satDevData, 1890285809Sscottl satIntIo); 1891285809Sscottl 1892285809Sscottl /* return stat_good */ 1893285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1894285809Sscottl tiOrgIORequest, 1895285809Sscottl tiIOSuccess, 1896285809Sscottl SCSI_STAT_GOOD, 1897285809Sscottl agNULL, 1898285809Sscottl satOrgIOContext->interruptContext ); 1899285809Sscottl return; 1900285809Sscottl break; 1901285809Sscottl default: 1902285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: error default case command 0x%x success\n", hostToDevFis->h.command)); 1903285809Sscottl 1904285809Sscottl satSetSensePayload( pSense, 1905285809Sscottl SCSI_SNSKEY_NO_SENSE, 1906285809Sscottl 0, 1907285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1908285809Sscottl satOrgIOContext); 1909285809Sscottl 1910285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1911285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1912285809Sscottl tiIOSuccess, 1913285809Sscottl SCSI_STAT_CHECK_CONDITION, 1914285809Sscottl satOrgIOContext->pTiSenseData, 1915285809Sscottl satOrgIOContext->interruptContext ); 1916285809Sscottl 1917285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1918285809Sscottl 1919285809Sscottl satFreeIntIoResource( tiRoot, 1920285809Sscottl satDevData, 1921285809Sscottl satIntIo); 1922285809Sscottl return; 1923285809Sscottl break; 1924285809Sscottl } 1925285809Sscottl 1926285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 1927285809Sscottl 1928285809Sscottl /* free */ 1929285809Sscottl satFreeIntIoResource( tiRoot, 1930285809Sscottl satDevData, 1931285809Sscottl satIntIo); 1932285809Sscottl 1933285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 1934285809Sscottl tiOrgIORequest, 1935285809Sscottl satDevData, 1936285809Sscottl 0, 1937285809Sscottl satNewIntIo); 1938285809Sscottl if (satNewIntIo == agNULL) 1939285809Sscottl { 1940285809Sscottl /* memory allocation failure */ 1941285809Sscottl satFreeIntIoResource( tiRoot, 1942285809Sscottl satDevData, 1943285809Sscottl satNewIntIo); 1944285809Sscottl 1945285809Sscottl satSetSensePayload( pSense, 1946285809Sscottl SCSI_SNSKEY_NO_SENSE, 1947285809Sscottl 0, 1948285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1949285809Sscottl satOrgIOContext); 1950285809Sscottl 1951285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1952285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1953285809Sscottl tiIOSuccess, 1954285809Sscottl SCSI_STAT_CHECK_CONDITION, 1955285809Sscottl satOrgIOContext->pTiSenseData, 1956285809Sscottl satOrgIOContext->interruptContext ); 1957285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: momory allocation fails\n")); 1958285809Sscottl return; 1959285809Sscottl } /* end memory allocation */ 1960285809Sscottl 1961285809Sscottl satNewIOContext = satPrepareNewIO( 1962285809Sscottl satNewIntIo, 1963285809Sscottl tiOrgIORequest, 1964285809Sscottl satDevData, 1965285809Sscottl scsiCmnd, 1966285809Sscottl satOrgIOContext 1967285809Sscottl ); 1968285809Sscottl 1969285809Sscottl /* sends ATA verify command(READ_VERIFY_SECTORS or READ_VERIFY_SECTORS_EXT) */ 1970285809Sscottl status = satNonChainedWriteNVerify_Verify(tiRoot, 1971285809Sscottl &satNewIntIo->satIntTiIORequest, 1972285809Sscottl satNewIOContext->ptiDeviceHandle, 1973285809Sscottl tiScsiRequest, /* orginal from OS layer */ 1974285809Sscottl satNewIOContext 1975285809Sscottl ); 1976285809Sscottl 1977285809Sscottl 1978285809Sscottl if (status != tiSuccess) 1979285809Sscottl { 1980285809Sscottl /* sending ATA command fails */ 1981285809Sscottl satFreeIntIoResource( tiRoot, 1982285809Sscottl satDevData, 1983285809Sscottl satNewIntIo); 1984285809Sscottl satSetSensePayload( pSense, 1985285809Sscottl SCSI_SNSKEY_NO_SENSE, 1986285809Sscottl 0, 1987285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 1988285809Sscottl satOrgIOContext); 1989285809Sscottl 1990285809Sscottl ostiInitiatorIOCompleted( tiRoot, 1991285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 1992285809Sscottl tiIOSuccess, 1993285809Sscottl SCSI_STAT_CHECK_CONDITION, 1994285809Sscottl satOrgIOContext->pTiSenseData, 1995285809Sscottl satOrgIOContext->interruptContext ); 1996285809Sscottl TI_DBG1(("satNonChainedWriteNVerifyCB: calling satWriteAndVerify10_1 fails\n")); 1997285809Sscottl return; 1998285809Sscottl } /* end send fails */ 1999285809Sscottl 2000285809Sscottl return; 2001285809Sscottl} 2002285809Sscottl 2003285809Sscottl 2004285809Sscottlvoid satChainedWriteNVerifyCB( 2005285809Sscottl agsaRoot_t *agRoot, 2006285809Sscottl agsaIORequest_t *agIORequest, 2007285809Sscottl bit32 agIOStatus, 2008285809Sscottl agsaFisHeader_t *agFirstDword, 2009285809Sscottl bit32 agIOInfoLen, 2010285809Sscottl void *agParam, 2011285809Sscottl void *ioContext 2012285809Sscottl ) 2013285809Sscottl{ 2014285809Sscottl /* 2015285809Sscottl send write in loop 2016285809Sscottl then, send verify in loop 2017285809Sscottl */ 2018285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 2019285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 2020285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 2021285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 2022285809Sscottl tdIORequestBody_t *tdIORequestBody; 2023285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 2024285809Sscottl satIOContext_t *satIOContext; 2025285809Sscottl satIOContext_t *satOrgIOContext; 2026285809Sscottl satIOContext_t *satNewIOContext; 2027285809Sscottl satInternalIo_t *satIntIo; 2028285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 2029285809Sscottl satDeviceData_t *satDevData; 2030285809Sscottl scsiRspSense_t *pSense; 2031285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 2032285809Sscottl tiIORequest_t *tiOrgIORequest; 2033285809Sscottl 2034285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 2035285809Sscottl bit32 ataStatus = 0; 2036285809Sscottl bit32 dataLength; 2037285809Sscottl bit32 status = tiError; 2038285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 2039285809Sscottl 2040285809Sscottl TI_DBG6(("satChainedWriteNVerifyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 2041285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 2042285809Sscottl 2043285809Sscottl 2044285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 2045285809Sscottl satIOContext = (satIOContext_t *) ioContext; 2046285809Sscottl satIntIo = satIOContext->satIntIoContext; 2047285809Sscottl satDevData = satIOContext->pSatDevData; 2048285809Sscottl hostToDevFis = satIOContext->pFis; 2049285809Sscottl 2050285809Sscottl if (satIntIo == agNULL) 2051285809Sscottl { 2052285809Sscottl TI_DBG5(("satChainedWriteNVerifyCB: External satInternalIo_t satIntIoContext\n")); 2053285809Sscottl satOrgIOContext = satIOContext; 2054285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 2055285809Sscottl pSense = satIOContext->pSense; 2056285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 2057285809Sscottl } 2058285809Sscottl else 2059285809Sscottl { 2060285809Sscottl TI_DBG5(("satChainedWriteNVerifyCB: Internal satInternalIo_t satIntIoContext\n")); 2061285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 2062285809Sscottl if (satOrgIOContext == agNULL) 2063285809Sscottl { 2064285809Sscottl TI_DBG5(("satChainedWriteNVerifyCB: satOrgIOContext is NULL, wrong\n")); 2065285809Sscottl return; 2066285809Sscottl } 2067285809Sscottl else 2068285809Sscottl { 2069285809Sscottl TI_DBG5(("satChainedWriteNVerifyCB: satOrgIOContext is NOT NULL\n")); 2070285809Sscottl } 2071285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 2072285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 2073285809Sscottl 2074285809Sscottl pSense = satOrgIOContext->pSense; 2075285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 2076285809Sscottl } 2077285809Sscottl 2078285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 2079285809Sscottl tdIORequestBody->ioStarted = agFALSE; 2080285809Sscottl 2081285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 2082285809Sscottl { 2083285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 2084285809Sscottl satSetSensePayload( pSense, 2085285809Sscottl SCSI_SNSKEY_NO_SENSE, 2086285809Sscottl 0, 2087285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 2088285809Sscottl satOrgIOContext); 2089285809Sscottl 2090285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2091285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 2092285809Sscottl tiIOSuccess, 2093285809Sscottl SCSI_STAT_CHECK_CONDITION, 2094285809Sscottl satOrgIOContext->pTiSenseData, 2095285809Sscottl satOrgIOContext->interruptContext ); 2096285809Sscottl 2097285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 2098285809Sscottl 2099285809Sscottl satFreeIntIoResource( tiRoot, 2100285809Sscottl satDevData, 2101285809Sscottl satIntIo); 2102285809Sscottl return; 2103285809Sscottl } 2104285809Sscottl 2105285809Sscottl /* 2106285809Sscottl checking IO status, FIS type and error status 2107285809Sscottl */ 2108285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 2109285809Sscottl { 2110285809Sscottl /* agsaFisPioSetup_t or agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for read 2111285809Sscottl agsaFisRegDeviceToHost_t or agsaFisSetDevBits_t for write 2112285809Sscottl first, assumed to be Reg Device to Host FIS 2113285809Sscottl This is OK to just find fis type 2114285809Sscottl */ 2115285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 2116285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 2117285809Sscottl /* for debugging */ 2118285809Sscottl if( (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) && 2119285809Sscottl (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 2120285809Sscottl (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 2121285809Sscottl ) 2122285809Sscottl { 2123285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: FAILED, Wrong FIS type 0x%x\n", statDevToHostFisHeader->fisType)); 2124285809Sscottl } 2125285809Sscottl 2126285809Sscottl /* for debugging */ 2127285809Sscottl if ( (ataStatus & ERR_ATA_STATUS_MASK) || 2128285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 2129285809Sscottl ) 2130285809Sscottl { 2131285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: FAILED, error status and command 0x%x\n", hostToDevFis->h.command)); 2132285809Sscottl } 2133285809Sscottl 2134285809Sscottl /* the function below handles abort case */ 2135285809Sscottl itdsatDelayedProcessAbnormalCompletion(agRoot, 2136285809Sscottl agIORequest, 2137285809Sscottl agIOStatus, 2138285809Sscottl agFirstDword, 2139285809Sscottl agIOInfoLen, 2140285809Sscottl agParam, 2141285809Sscottl satIOContext); 2142285809Sscottl 2143285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 2144285809Sscottl satFreeIntIoResource( tiRoot, 2145285809Sscottl satDevData, 2146285809Sscottl satIntIo); 2147285809Sscottl return; 2148285809Sscottl } /* end of error */ 2149285809Sscottl 2150285809Sscottl /* process the success case */ 2151285809Sscottl switch (hostToDevFis->h.command) 2152285809Sscottl { 2153285809Sscottl case SAT_WRITE_DMA: /* fall through */ 2154285809Sscottl case SAT_WRITE_SECTORS:/* fall through */ 2155285809Sscottl// case SAT_WRITE_DMA_FUA_EXT: /* fall through */ 2156285809Sscottl case SAT_WRITE_DMA_EXT: /* fall through */ 2157285809Sscottl case SAT_WRITE_SECTORS_EXT: /* fall through */ 2158285809Sscottl case SAT_WRITE_FPDMA_QUEUED: 2159285809Sscottl 2160285809Sscottl TI_DBG5(("satChainedWriteNVerifyCB: WRITE success case\n")); 2161285809Sscottl 2162285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 2163285809Sscottl 2164285809Sscottl /* done with internally genereated SAT_SMART_RETURN_STATUS */ 2165285809Sscottl satFreeIntIoResource( tiRoot, 2166285809Sscottl satDevData, 2167285809Sscottl satIntIo); 2168285809Sscottl /* let's loop till TL */ 2169285809Sscottl 2170285809Sscottl 2171285809Sscottl (satOrgIOContext->LoopNum)--; 2172285809Sscottl 2173285809Sscottl if (satOrgIOContext->superIOFlag) 2174285809Sscottl { 2175285809Sscottl dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 2176285809Sscottl } 2177285809Sscottl else 2178285809Sscottl { 2179285809Sscottl dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 2180285809Sscottl } 2181285809Sscottl 2182285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 2183285809Sscottl tiOrgIORequest, 2184285809Sscottl satDevData, 2185285809Sscottl dataLength, 2186285809Sscottl satNewIntIo); 2187285809Sscottl if (satNewIntIo == agNULL) 2188285809Sscottl { 2189285809Sscottl /* memory allocation failure */ 2190285809Sscottl satFreeIntIoResource( tiRoot, 2191285809Sscottl satDevData, 2192285809Sscottl satNewIntIo); 2193285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2194285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 2195285809Sscottl tiIOFailed, 2196285809Sscottl tiDetailOtherError, 2197285809Sscottl agNULL, 2198285809Sscottl satOrgIOContext->interruptContext ); 2199285809Sscottl 2200285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: momory allocation fails\n")); 2201285809Sscottl return; 2202285809Sscottl } /* end of memory allocation failure */ 2203285809Sscottl 2204285809Sscottl /* 2205285809Sscottl * Need to initialize all the fields within satIOContext 2206285809Sscottl */ 2207285809Sscottl 2208285809Sscottl satNewIOContext = satPrepareNewIO( 2209285809Sscottl satNewIntIo, 2210285809Sscottl tiOrgIORequest, 2211285809Sscottl satDevData, 2212285809Sscottl scsiCmnd, 2213285809Sscottl satOrgIOContext 2214285809Sscottl ); 2215285809Sscottl 2216285809Sscottl if (satOrgIOContext->LoopNum == 0) 2217285809Sscottl { 2218285809Sscottl /* 2219285809Sscottl done with write 2220285809Sscottl start with verify 2221285809Sscottl */ 2222285809Sscottl satOrgIOContext->LoopNum = satOrgIOContext->LoopNum2; 2223285809Sscottl status = satChainedWriteNVerify_Start_Verify(tiRoot, 2224285809Sscottl &satNewIntIo->satIntTiIORequest, 2225285809Sscottl satNewIOContext->ptiDeviceHandle, 2226285809Sscottl &satNewIntIo->satIntTiScsiXchg, 2227285809Sscottl satNewIOContext); 2228285809Sscottl } 2229285809Sscottl else 2230285809Sscottl { 2231285809Sscottl status = satChainedWriteNVerify_Write(tiRoot, 2232285809Sscottl &satNewIntIo->satIntTiIORequest, 2233285809Sscottl satNewIOContext->ptiDeviceHandle, 2234285809Sscottl &satNewIntIo->satIntTiScsiXchg, 2235285809Sscottl satNewIOContext); 2236285809Sscottl } 2237285809Sscottl 2238285809Sscottl if (status != tiSuccess) 2239285809Sscottl { 2240285809Sscottl satFreeIntIoResource( tiRoot, 2241285809Sscottl satDevData, 2242285809Sscottl satNewIntIo); 2243285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2244285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 2245285809Sscottl tiIOFailed, 2246285809Sscottl tiDetailOtherError, 2247285809Sscottl agNULL, 2248285809Sscottl satOrgIOContext->interruptContext ); 2249285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: calling satChainedWriteNVerify_Write fails\n")); 2250285809Sscottl return; 2251285809Sscottl } 2252285809Sscottl 2253285809Sscottl break; 2254285809Sscottl 2255285809Sscottl case SAT_READ_VERIFY_SECTORS: /* fall through */ 2256285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 2257285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 2258285809Sscottl 2259285809Sscottl /* done with internally genereated SAT_SMART_RETURN_STATUS */ 2260285809Sscottl satFreeIntIoResource( tiRoot, 2261285809Sscottl satDevData, 2262285809Sscottl satIntIo); 2263285809Sscottl /* let's loop till TL */ 2264285809Sscottl 2265285809Sscottl /* lba = lba + tl 2266285809Sscottl loopnum--; 2267285809Sscottl if (loopnum == 0) done 2268285809Sscottl */ 2269285809Sscottl (satOrgIOContext->LoopNum)--; 2270285809Sscottl if (satOrgIOContext->LoopNum == 0) 2271285809Sscottl { 2272285809Sscottl /* 2273285809Sscottl done with write and verify 2274285809Sscottl */ 2275285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2276285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 2277285809Sscottl tiIOSuccess, 2278285809Sscottl SCSI_STAT_GOOD, 2279285809Sscottl agNULL, 2280285809Sscottl satOrgIOContext->interruptContext ); 2281285809Sscottl return; 2282285809Sscottl } 2283285809Sscottl 2284285809Sscottl if (satOrgIOContext->superIOFlag) 2285285809Sscottl { 2286285809Sscottl dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 2287285809Sscottl } 2288285809Sscottl else 2289285809Sscottl { 2290285809Sscottl dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 2291285809Sscottl } 2292285809Sscottl 2293285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 2294285809Sscottl tiOrgIORequest, 2295285809Sscottl satDevData, 2296285809Sscottl dataLength, 2297285809Sscottl satNewIntIo); 2298285809Sscottl if (satNewIntIo == agNULL) 2299285809Sscottl { 2300285809Sscottl /* memory allocation failure */ 2301285809Sscottl satFreeIntIoResource( tiRoot, 2302285809Sscottl satDevData, 2303285809Sscottl satNewIntIo); 2304285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2305285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 2306285809Sscottl tiIOFailed, 2307285809Sscottl tiDetailOtherError, 2308285809Sscottl agNULL, 2309285809Sscottl satOrgIOContext->interruptContext ); 2310285809Sscottl 2311285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: momory allocation fails\n")); 2312285809Sscottl return; 2313285809Sscottl } /* end of memory allocation failure */ 2314285809Sscottl 2315285809Sscottl /* 2316285809Sscottl * Need to initialize all the fields within satIOContext 2317285809Sscottl */ 2318285809Sscottl 2319285809Sscottl satNewIOContext = satPrepareNewIO( 2320285809Sscottl satNewIntIo, 2321285809Sscottl tiOrgIORequest, 2322285809Sscottl satDevData, 2323285809Sscottl scsiCmnd, 2324285809Sscottl satOrgIOContext 2325285809Sscottl ); 2326285809Sscottl status = satChainedWriteNVerify_Verify(tiRoot, 2327285809Sscottl &satNewIntIo->satIntTiIORequest, 2328285809Sscottl satNewIOContext->ptiDeviceHandle, 2329285809Sscottl &satNewIntIo->satIntTiScsiXchg, 2330285809Sscottl satNewIOContext); 2331285809Sscottl 2332285809Sscottl if (status != tiSuccess) 2333285809Sscottl { 2334285809Sscottl satFreeIntIoResource( tiRoot, 2335285809Sscottl satDevData, 2336285809Sscottl satNewIntIo); 2337285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2338285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 2339285809Sscottl tiIOFailed, 2340285809Sscottl tiDetailOtherError, 2341285809Sscottl agNULL, 2342285809Sscottl satOrgIOContext->interruptContext ); 2343285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: calling satChainedWriteNVerify_Verify fails\n")); 2344285809Sscottl return; 2345285809Sscottl } 2346285809Sscottl 2347285809Sscottl break; 2348285809Sscottl 2349285809Sscottl default: 2350285809Sscottl TI_DBG1(("satChainedWriteNVerifyCB: success but default case command 0x%x\n",hostToDevFis->h.command)); 2351285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2352285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 2353285809Sscottl tiIOFailed, 2354285809Sscottl tiDetailOtherError, 2355285809Sscottl agNULL, 2356285809Sscottl satOrgIOContext->interruptContext ); 2357285809Sscottl 2358285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 2359285809Sscottl 2360285809Sscottl satFreeIntIoResource( tiRoot, 2361285809Sscottl satDevData, 2362285809Sscottl satIntIo); 2363285809Sscottl 2364285809Sscottl break; 2365285809Sscottl } 2366285809Sscottl 2367285809Sscottl 2368285809Sscottl return; 2369285809Sscottl} 2370285809Sscottl/***************************************************************************** 2371285809Sscottl*! \brief itdsatProcessAbnormalCompletion 2372285809Sscottl* 2373285809Sscottl* This routine is called to complete error case for SATA request previously 2374285809Sscottl* issued to the LL Layer in saSATAStart() 2375285809Sscottl* 2376285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 2377285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 2378285809Sscottl* \param agIOStatus: Status of completed I/O. 2379285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 2380285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 2381285809Sscottl* length. 2382285809Sscottl* \param agParam: Additional info based on status. 2383285809Sscottl* \param ioContext: Pointer to satIOContext_t. 2384285809Sscottl* 2385285809Sscottl* \return: none 2386285809Sscottl* 2387285809Sscottl*****************************************************************************/ 2388285809Sscottlvoid itdsatProcessAbnormalCompletion( 2389285809Sscottl agsaRoot_t *agRoot, 2390285809Sscottl agsaIORequest_t *agIORequest, 2391285809Sscottl bit32 agIOStatus, 2392285809Sscottl agsaFisHeader_t *agFirstDword, 2393285809Sscottl bit32 agIOInfoLen, 2394285809Sscottl void *agParam, 2395285809Sscottl satIOContext_t *satIOContext 2396285809Sscottl ) 2397285809Sscottl{ 2398285809Sscottl 2399285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 2400285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 2401285809Sscottl bit32 interruptContext = osData->IntContext; 2402285809Sscottl tdIORequestBody_t *tdIORequestBody; 2403285809Sscottl satDeviceData_t *pSatDevData; 2404285809Sscottl tiDeviceHandle_t *tiDeviceHandle; 2405285809Sscottl tdsaDeviceData_t *oneDeviceData = agNULL; 2406285809Sscottl agsaDevHandle_t *agDevHandle = agNULL; 2407285809Sscottl 2408285809Sscottl TI_DBG5(("itdsatProcessAbnormalCompletion: agIORequest=%p agIOStatus=0x%x agIOInfoLen=%d\n", 2409285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 2410285809Sscottl 2411285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 2412285809Sscottl pSatDevData = satIOContext->pSatDevData; 2413285809Sscottl tiDeviceHandle = satIOContext->ptiDeviceHandle; 2414285809Sscottl 2415285809Sscottl /* Get into the detail */ 2416285809Sscottl switch(agIOStatus) 2417285809Sscottl { 2418285809Sscottl case OSSA_IO_SUCCESS: 2419285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_SUCCESS agIOInfoLen %d calling osSatIOCompleted\n", agIOInfoLen)); 2420285809Sscottl /* 2421285809Sscottl * At this point agIOInfoLen should be non-zero and there is valid FIS 2422285809Sscottl * to read. Pass this info to the SAT layer in order to do the ATA status 2423285809Sscottl * to SCSI status translation. 2424285809Sscottl */ 2425285809Sscottl osSatIOCompleted( tiRoot, 2426285809Sscottl tdIORequestBody->tiIORequest, 2427285809Sscottl agFirstDword, 2428285809Sscottl agIOInfoLen, 2429285809Sscottl agParam, 2430285809Sscottl satIOContext, 2431285809Sscottl interruptContext); 2432285809Sscottl break; 2433285809Sscottl 2434285809Sscottl 2435285809Sscottl case OSSA_IO_ABORTED: 2436285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORTED\n")); 2437285809Sscottl 2438285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2439285809Sscottl tdIORequestBody->tiIORequest, 2440285809Sscottl tiIOFailed, 2441285809Sscottl tiDetailAborted, 2442285809Sscottl agNULL, 2443285809Sscottl interruptContext); 2444285809Sscottl 2445285809Sscottl if ( pSatDevData->satTmTaskTag != agNULL ) 2446285809Sscottl { 2447285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: TM callback\n")); 2448285809Sscottl if (tiDeviceHandle == agNULL) 2449285809Sscottl { 2450285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2451285809Sscottl } 2452285809Sscottl /* TM completed */ 2453285809Sscottl ostiInitiatorEvent( tiRoot, 2454285809Sscottl agNULL, /* portalContext not used */ 2455285809Sscottl tiDeviceHandle, 2456285809Sscottl tiIntrEventTypeTaskManagement, 2457285809Sscottl tiTMOK, 2458285809Sscottl pSatDevData->satTmTaskTag); 2459285809Sscottl /* 2460285809Sscottl * Reset flag 2461285809Sscottl */ 2462285809Sscottl pSatDevData->satTmTaskTag = agNULL; 2463285809Sscottl } 2464285809Sscottl 2465285809Sscottl /* 2466285809Sscottl * Check if we are in recovery mode and need to update the recovery flag 2467285809Sscottl */ 2468285809Sscottl if ((pSatDevData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 2469285809Sscottl (pSatDevData->satPendingIO == 0 )) 2470285809Sscottl { 2471285809Sscottl pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL; 2472285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: STATE NORMAL.\n")); 2473285809Sscottl } 2474285809Sscottl 2475285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: satDriveState %d\n", pSatDevData->satDriveState)); 2476285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO )); 2477285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO)); 2478285809Sscottl 2479285809Sscottl break; 2480285809Sscottl case OSSA_IO_UNDERFLOW: 2481285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_UNDERFLOW\n")); 2482285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2483285809Sscottl tdIORequestBody->tiIORequest, 2484285809Sscottl tiIOUnderRun, 2485285809Sscottl agIOInfoLen, 2486285809Sscottl agNULL, 2487285809Sscottl interruptContext); 2488285809Sscottl break; 2489285809Sscottl 2490285809Sscottl 2491285809Sscottl case OSSA_IO_FAILED: 2492285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_FAILED\n")); 2493285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2494285809Sscottl tdIORequestBody->tiIORequest, 2495285809Sscottl tiIOFailed, 2496285809Sscottl tiDetailOtherError, 2497285809Sscottl agNULL, 2498285809Sscottl interruptContext); 2499285809Sscottl break; 2500285809Sscottl 2501285809Sscottl case OSSA_IO_ABORT_RESET: 2502285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORT_RESET\n")); 2503285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2504285809Sscottl tdIORequestBody->tiIORequest, 2505285809Sscottl tiIOFailed, 2506285809Sscottl tiDetailAbortReset, 2507285809Sscottl agNULL, 2508285809Sscottl interruptContext); 2509285809Sscottl /* 2510285809Sscottl * Check if we are in recovery mode and need to update the recovery flag 2511285809Sscottl */ 2512285809Sscottl if ((pSatDevData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 2513285809Sscottl (pSatDevData->satPendingIO == 0 )) 2514285809Sscottl { 2515285809Sscottl pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL; 2516285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: STATE NORMAL.\n")); 2517285809Sscottl } 2518285809Sscottl 2519285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: satDriveState %d\n", pSatDevData->satDriveState)); 2520285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO )); 2521285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO)); 2522285809Sscottl 2523285809Sscottl break; 2524285809Sscottl 2525285809Sscottl 2526285809Sscottl case OSSA_IO_NO_DEVICE: 2527285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_NO_DEVICE\n")); 2528285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2529285809Sscottl tdIORequestBody->tiIORequest, 2530285809Sscottl tiIOFailed, 2531285809Sscottl tiDetailNoLogin, 2532285809Sscottl agNULL, 2533285809Sscottl interruptContext); 2534285809Sscottl break; 2535285809Sscottl 2536285809Sscottl case OSSA_IO_PROG_ERROR: 2537285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_PROG_ERROR\n")); 2538285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2539285809Sscottl tdIORequestBody->tiIORequest, 2540285809Sscottl tiIOFailed, 2541285809Sscottl tiDetailOtherError, 2542285809Sscottl agNULL, 2543285809Sscottl interruptContext); 2544285809Sscottl break; 2545285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: /* fall through */ 2546285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION: /* fall through */ 2547285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_BREAK: /* fall through */ 2548285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: /* fall through */ 2549285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION: /* fall through */ 2550285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: /* fall through */ 2551285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION: /* fall through */ 2552285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR: /* fall through */ 2553285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_* 0x%x\n", agIOStatus)); 2554285809Sscottl if (tiDeviceHandle == agNULL) 2555285809Sscottl { 2556285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2557285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2558285809Sscottl tdIORequestBody->tiIORequest, 2559285809Sscottl tiIOFailed, 2560285809Sscottl tiDetailOtherError, 2561285809Sscottl agNULL, 2562285809Sscottl interruptContext); 2563285809Sscottl return; 2564285809Sscottl } 2565285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 2566285809Sscottl if (oneDeviceData == agNULL) 2567285809Sscottl { 2568285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: wrong, oneDeviceData is NULL\n")); 2569285809Sscottl } 2570285809Sscottl else 2571285809Sscottl { 2572285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: did %d\n", oneDeviceData->id)); 2573285809Sscottl } 2574285809Sscottl 2575285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2576285809Sscottl tdIORequestBody->tiIORequest, 2577285809Sscottl tiIOFailed, 2578285809Sscottl tiDetailOtherError, 2579285809Sscottl agNULL, 2580285809Sscottl interruptContext); 2581285809Sscottl break; 2582285809Sscottl 2583285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY: 2584285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY\n")); 2585285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2586285809Sscottl tdIORequestBody->tiIORequest, 2587285809Sscottl tiIOFailed, 2588285809Sscottl tiDetailOtherError, //tiDetailNoDeviceError, //tiDetailAborted, 2589285809Sscottl agNULL, 2590285809Sscottl interruptContext); 2591285809Sscottl break; 2592285809Sscottl 2593285809Sscottl case OSSA_IO_XFER_ERROR_BREAK: /* fall throuth */ 2594285809Sscottl case OSSA_IO_XFER_ERROR_PHY_NOT_READY: /* fall throuth */ 2595285809Sscottl case OSSA_IO_XFER_ERROR_PEER_ABORTED: /* fall throuth */ 2596285809Sscottl case OSSA_IO_XFER_ERROR_DMA: /* fall throuth */ 2597285809Sscottl case OSSA_IO_XFER_ERROR_SATA_LINK_TIMEOUT: /* fall throuth */ 2598285809Sscottl case OSSA_IO_XFER_ERROR_ABORTED_DUE_TO_SRST: /* fall throuth */ 2599285809Sscottl case OSSA_IO_XFER_ERROR_REJECTED_NCQ_MODE: /* fall throuth */ 2600285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_ERROR_* 0x%x\n", agIOStatus)); 2601285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2602285809Sscottl tdIORequestBody->tiIORequest, 2603285809Sscottl tiIOFailed, 2604285809Sscottl tiDetailOtherError, 2605285809Sscottl agNULL, 2606285809Sscottl interruptContext); 2607285809Sscottl break; 2608285809Sscottl case OSSA_IO_DS_IN_ERROR: 2609285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_IN_ERROR\n")); 2610285809Sscottl if (tiDeviceHandle == agNULL) 2611285809Sscottl { 2612285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2613285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2614285809Sscottl tdIORequestBody->tiIORequest, 2615285809Sscottl tiIOFailed, 2616285809Sscottl tiDetailOtherError, 2617285809Sscottl agNULL, 2618285809Sscottl interruptContext); 2619285809Sscottl return; 2620285809Sscottl } 2621285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 2622285809Sscottl if (oneDeviceData == agNULL) 2623285809Sscottl { 2624285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: wrong, oneDeviceData is NULL\n")); 2625285809Sscottl } 2626285809Sscottl else 2627285809Sscottl { 2628285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: did %d\n", oneDeviceData->id)); 2629285809Sscottl } 2630285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2631285809Sscottl tdIORequestBody->tiIORequest, 2632285809Sscottl tiIOFailed, 2633285809Sscottl tiDetailOtherError, 2634285809Sscottl agNULL, 2635285809Sscottl interruptContext); 2636285809Sscottl break; 2637285809Sscottl case OSSA_IO_DS_NON_OPERATIONAL: 2638285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_NON_OPERATIONAL\n")); 2639285809Sscottl if (tiDeviceHandle == agNULL) 2640285809Sscottl { 2641285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2642285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2643285809Sscottl tdIORequestBody->tiIORequest, 2644285809Sscottl tiIOFailed, 2645285809Sscottl tiDetailOtherError, 2646285809Sscottl agNULL, 2647285809Sscottl interruptContext); 2648285809Sscottl return; 2649285809Sscottl } 2650285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 2651285809Sscottl if (oneDeviceData == agNULL) 2652285809Sscottl { 2653285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: wrong, oneDeviceData is NULL\n")); 2654285809Sscottl } 2655285809Sscottl else 2656285809Sscottl { 2657285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: did %d\n", oneDeviceData->id)); 2658285809Sscottl agDevHandle = oneDeviceData->agDevHandle; 2659285809Sscottl if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && 2660285809Sscottl oneDeviceData->tdPortContext != agNULL ) 2661285809Sscottl { 2662285809Sscottl saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_OPERATIONAL); 2663285809Sscottl } 2664285809Sscottl } 2665285809Sscottl 2666285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2667285809Sscottl tdIORequestBody->tiIORequest, 2668285809Sscottl tiIOFailed, 2669285809Sscottl tiDetailOtherError, 2670285809Sscottl agNULL, 2671285809Sscottl interruptContext); 2672285809Sscottl break; 2673285809Sscottl case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS: /* fall through */ 2674285809Sscottl case OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH: 2675285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = ENCRYPTION ERROR 0x%x\n", agIOStatus)); 2676285809Sscottl itdsatEncryptionHandler(agRoot, 2677285809Sscottl agIORequest, 2678285809Sscottl agIOStatus, 2679285809Sscottl agIOInfoLen, 2680285809Sscottl agParam, 2681285809Sscottl 0); 2682285809Sscottl break; 2683285809Sscottl case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH: /* fall through */ 2684285809Sscottl case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH: /* fall through */ 2685285809Sscottl case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH: 2686285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = DIF ERROR 0x%x\n", agIOStatus)); 2687285809Sscottl itdsatDifHandler(agRoot, 2688285809Sscottl agIORequest, 2689285809Sscottl agIOStatus, 2690285809Sscottl agIOInfoLen, 2691285809Sscottl agParam, 2692285809Sscottl 0); 2693285809Sscottl break; 2694285809Sscottl default: 2695285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 2696285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: agIOStatus = unknown 0x%x\n", agIOStatus)); 2697285809Sscottl if (oneDeviceData != agNULL) 2698285809Sscottl { 2699285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: did %d\n", oneDeviceData->id)); 2700285809Sscottl } 2701285809Sscottl else 2702285809Sscottl { 2703285809Sscottl TI_DBG1(("itdsatProcessAbnormalCompletion: oneDeviceData is NULL\n")); 2704285809Sscottl } 2705285809Sscottl 2706285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2707285809Sscottl tdIORequestBody->tiIORequest, 2708285809Sscottl tiIOFailed, 2709285809Sscottl tiDetailOtherError, 2710285809Sscottl agNULL, 2711285809Sscottl interruptContext); 2712285809Sscottl break; 2713285809Sscottl 2714285809Sscottl } /* switch */ 2715285809Sscottl} 2716285809Sscottl 2717285809Sscottl 2718285809Sscottl/***************************************************************************** 2719285809Sscottl*! \brief itdsatDelayedProcessAbnormalCompletion 2720285809Sscottl* 2721285809Sscottl* This routine is called to complete error case for SATA request previously 2722285809Sscottl* issued to the LL Layer in saSATAStart(). 2723285809Sscottl* This is used when command is chained. 2724285809Sscottl* 2725285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 2726285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 2727285809Sscottl* \param agIOStatus: Status of completed I/O. 2728285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 2729285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 2730285809Sscottl* length. 2731285809Sscottl* \param agParam: Additional info based on status. 2732285809Sscottl* \param ioContext: Pointer to satIOContext_t. 2733285809Sscottl* 2734285809Sscottl* \return: none 2735285809Sscottl* 2736285809Sscottl*****************************************************************************/ 2737285809Sscottlvoid itdsatDelayedProcessAbnormalCompletion( 2738285809Sscottl agsaRoot_t *agRoot, 2739285809Sscottl agsaIORequest_t *agIORequest, 2740285809Sscottl bit32 agIOStatus, 2741285809Sscottl agsaFisHeader_t *agFirstDword, 2742285809Sscottl bit32 agIOInfoLen, 2743285809Sscottl void *agParam, 2744285809Sscottl satIOContext_t *satIOContext 2745285809Sscottl ) 2746285809Sscottl{ 2747285809Sscottl 2748285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 2749285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 2750285809Sscottl bit32 interruptContext = osData->IntContext; 2751285809Sscottl tdIORequestBody_t *tdIORequestBody; 2752285809Sscottl satDeviceData_t *pSatDevData; 2753285809Sscottl tiDeviceHandle_t *tiDeviceHandle; 2754285809Sscottl tdsaDeviceData_t *oneDeviceData = agNULL; 2755285809Sscottl agsaDevHandle_t *agDevHandle = agNULL; 2756285809Sscottl 2757285809Sscottl TI_DBG5(("itdsatDelayedProcessAbnormalCompletion: agIORequest=%p agIOStatus=0x%x agIOInfoLen=%d\n", 2758285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 2759285809Sscottl 2760285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 2761285809Sscottl pSatDevData = satIOContext->pSatDevData; 2762285809Sscottl tiDeviceHandle = satIOContext->ptiDeviceHandle; 2763285809Sscottl 2764285809Sscottl /* Get into the detail */ 2765285809Sscottl switch(agIOStatus) 2766285809Sscottl { 2767285809Sscottl case OSSA_IO_SUCCESS: 2768285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_SUCCESS calling osSatIOCompleted\n")); 2769285809Sscottl /* do nothing */ 2770285809Sscottl break; 2771285809Sscottl 2772285809Sscottl 2773285809Sscottl case OSSA_IO_ABORTED: 2774285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORTED\n")); 2775285809Sscottl 2776285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2777285809Sscottl tdIORequestBody->tiIORequest, 2778285809Sscottl tiIOFailed, 2779285809Sscottl tiDetailAborted, 2780285809Sscottl agNULL, 2781285809Sscottl interruptContext); 2782285809Sscottl 2783285809Sscottl if ( pSatDevData->satTmTaskTag != agNULL ) 2784285809Sscottl { 2785285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: TM callback\n")); 2786285809Sscottl if (tiDeviceHandle == agNULL) 2787285809Sscottl { 2788285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2789285809Sscottl } 2790285809Sscottl /* TM completed */ 2791285809Sscottl ostiInitiatorEvent( tiRoot, 2792285809Sscottl agNULL, /* portalContext not used */ 2793285809Sscottl tiDeviceHandle, 2794285809Sscottl tiIntrEventTypeTaskManagement, 2795285809Sscottl tiTMOK, 2796285809Sscottl pSatDevData->satTmTaskTag); 2797285809Sscottl /* 2798285809Sscottl * Reset flag 2799285809Sscottl */ 2800285809Sscottl pSatDevData->satTmTaskTag = agNULL; 2801285809Sscottl } 2802285809Sscottl 2803285809Sscottl /* 2804285809Sscottl * Check if we are in recovery mode and need to update the recovery flag 2805285809Sscottl */ 2806285809Sscottl if ((pSatDevData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 2807285809Sscottl (pSatDevData->satPendingIO == 0 )) 2808285809Sscottl { 2809285809Sscottl pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL; 2810285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: STATE NORMAL.\n")); 2811285809Sscottl } 2812285809Sscottl 2813285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: satDriveState %d\n", pSatDevData->satDriveState)); 2814285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO )); 2815285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO)); 2816285809Sscottl 2817285809Sscottl break; 2818285809Sscottl case OSSA_IO_UNDERFLOW: 2819285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_UNDERFLOW\n")); 2820285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2821285809Sscottl tdIORequestBody->tiIORequest, 2822285809Sscottl tiIOUnderRun, 2823285809Sscottl agIOInfoLen, 2824285809Sscottl agNULL, 2825285809Sscottl interruptContext); 2826285809Sscottl break; 2827285809Sscottl 2828285809Sscottl 2829285809Sscottl case OSSA_IO_FAILED: 2830285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_FAILED\n")); 2831285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2832285809Sscottl tdIORequestBody->tiIORequest, 2833285809Sscottl tiIOFailed, 2834285809Sscottl tiDetailOtherError, 2835285809Sscottl agNULL, 2836285809Sscottl interruptContext); 2837285809Sscottl break; 2838285809Sscottl 2839285809Sscottl case OSSA_IO_ABORT_RESET: 2840285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_ABORT_RESET\n")); 2841285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2842285809Sscottl tdIORequestBody->tiIORequest, 2843285809Sscottl tiIOFailed, 2844285809Sscottl tiDetailAbortReset, 2845285809Sscottl agNULL, 2846285809Sscottl interruptContext); 2847285809Sscottl /* 2848285809Sscottl * Check if we are in recovery mode and need to update the recovery flag 2849285809Sscottl */ 2850285809Sscottl if ((pSatDevData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 2851285809Sscottl (pSatDevData->satPendingIO == 0 )) 2852285809Sscottl { 2853285809Sscottl pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL; 2854285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: STATE NORMAL.\n")); 2855285809Sscottl } 2856285809Sscottl 2857285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: satDriveState %d\n", pSatDevData->satDriveState)); 2858285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO )); 2859285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO)); 2860285809Sscottl 2861285809Sscottl break; 2862285809Sscottl 2863285809Sscottl 2864285809Sscottl case OSSA_IO_NO_DEVICE: 2865285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_NO_DEVICE\n")); 2866285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2867285809Sscottl tdIORequestBody->tiIORequest, 2868285809Sscottl tiIOFailed, 2869285809Sscottl tiDetailNoLogin, 2870285809Sscottl agNULL, 2871285809Sscottl interruptContext); 2872285809Sscottl break; 2873285809Sscottl 2874285809Sscottl case OSSA_IO_PROG_ERROR: 2875285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_PROG_ERROR\n")); 2876285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2877285809Sscottl tdIORequestBody->tiIORequest, 2878285809Sscottl tiIOFailed, 2879285809Sscottl tiDetailOtherError, 2880285809Sscottl agNULL, 2881285809Sscottl interruptContext); 2882285809Sscottl break; 2883285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: /* fall through */ 2884285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION: /* fall through */ 2885285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_BREAK: /* fall through */ 2886285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: /* fall through */ 2887285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION: /* fall through */ 2888285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: /* fall through */ 2889285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION: /* fall through */ 2890285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR: /* fall through */ 2891285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_* 0x%x\n", agIOStatus)); 2892285809Sscottl if (tiDeviceHandle == agNULL) 2893285809Sscottl { 2894285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2895285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2896285809Sscottl tdIORequestBody->tiIORequest, 2897285809Sscottl tiIOFailed, 2898285809Sscottl tiDetailOtherError, 2899285809Sscottl agNULL, 2900285809Sscottl interruptContext); 2901285809Sscottl return; 2902285809Sscottl } 2903285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 2904285809Sscottl if (oneDeviceData == agNULL) 2905285809Sscottl { 2906285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: wrong, oneDeviceData is NULL\n")); 2907285809Sscottl } 2908285809Sscottl else 2909285809Sscottl { 2910285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: did %d\n", oneDeviceData->id)); 2911285809Sscottl } 2912285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2913285809Sscottl tdIORequestBody->tiIORequest, 2914285809Sscottl tiIOFailed, 2915285809Sscottl tiDetailOtherError, 2916285809Sscottl agNULL, 2917285809Sscottl interruptContext); 2918285809Sscottl break; 2919285809Sscottl 2920285809Sscottl case OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY: 2921285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY\n")); 2922285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2923285809Sscottl tdIORequestBody->tiIORequest, 2924285809Sscottl tiIOFailed, 2925285809Sscottl tiDetailOtherError, //tiDetailNoDeviceError, //tiDetailAborted, 2926285809Sscottl agNULL, 2927285809Sscottl interruptContext); 2928285809Sscottl break; 2929285809Sscottl 2930285809Sscottl case OSSA_IO_XFER_ERROR_BREAK: /* fall throuth */ 2931285809Sscottl case OSSA_IO_XFER_ERROR_PHY_NOT_READY: /* fall throuth */ 2932285809Sscottl case OSSA_IO_XFER_ERROR_PEER_ABORTED: /* fall throuth */ 2933285809Sscottl case OSSA_IO_XFER_ERROR_DMA: /* fall throuth */ 2934285809Sscottl case OSSA_IO_XFER_ERROR_SATA_LINK_TIMEOUT: /* fall throuth */ 2935285809Sscottl case OSSA_IO_XFER_ERROR_ABORTED_DUE_TO_SRST: /* fall throuth */ 2936285809Sscottl case OSSA_IO_XFER_ERROR_REJECTED_NCQ_MODE: /* fall throuth */ 2937285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_XFER_ERROR_* 0x%x\n", agIOStatus)); 2938285809Sscottl 2939285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2940285809Sscottl tdIORequestBody->tiIORequest, 2941285809Sscottl tiIOFailed, 2942285809Sscottl tiDetailOtherError, 2943285809Sscottl agNULL, 2944285809Sscottl interruptContext); 2945285809Sscottl break; 2946285809Sscottl case OSSA_IO_DS_IN_ERROR: 2947285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_IN_ERROR\n")); 2948285809Sscottl if (tiDeviceHandle == agNULL) 2949285809Sscottl { 2950285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2951285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2952285809Sscottl tdIORequestBody->tiIORequest, 2953285809Sscottl tiIOFailed, 2954285809Sscottl tiDetailOtherError, 2955285809Sscottl agNULL, 2956285809Sscottl interruptContext); 2957285809Sscottl return; 2958285809Sscottl } 2959285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 2960285809Sscottl if (oneDeviceData == agNULL) 2961285809Sscottl { 2962285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: wrong, oneDeviceData is NULL\n")); 2963285809Sscottl } 2964285809Sscottl else 2965285809Sscottl { 2966285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: did %d\n", oneDeviceData->id)); 2967285809Sscottl } 2968285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2969285809Sscottl tdIORequestBody->tiIORequest, 2970285809Sscottl tiIOFailed, 2971285809Sscottl tiDetailOtherError, 2972285809Sscottl agNULL, 2973285809Sscottl interruptContext); 2974285809Sscottl break; 2975285809Sscottl case OSSA_IO_DS_NON_OPERATIONAL: 2976285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = OSSA_IO_DS_NON_OPERATIONAL\n")); 2977285809Sscottl if (tiDeviceHandle == agNULL) 2978285809Sscottl { 2979285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: wrong, tiDeviceHandle is NULL\n")); 2980285809Sscottl ostiInitiatorIOCompleted( tiRoot, 2981285809Sscottl tdIORequestBody->tiIORequest, 2982285809Sscottl tiIOFailed, 2983285809Sscottl tiDetailOtherError, 2984285809Sscottl agNULL, 2985285809Sscottl interruptContext); 2986285809Sscottl return; 2987285809Sscottl } 2988285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 2989285809Sscottl if (oneDeviceData == agNULL) 2990285809Sscottl { 2991285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: wrong, oneDeviceData is NULL\n")); 2992285809Sscottl } 2993285809Sscottl else 2994285809Sscottl { 2995285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: did %d\n", oneDeviceData->id)); 2996285809Sscottl agDevHandle = oneDeviceData->agDevHandle; 2997285809Sscottl if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE && 2998285809Sscottl oneDeviceData->tdPortContext != agNULL ) 2999285809Sscottl { 3000285809Sscottl saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_OPERATIONAL); 3001285809Sscottl } 3002285809Sscottl } 3003285809Sscottl ostiInitiatorIOCompleted( tiRoot, 3004285809Sscottl tdIORequestBody->tiIORequest, 3005285809Sscottl tiIOFailed, 3006285809Sscottl tiDetailOtherError, 3007285809Sscottl agNULL, 3008285809Sscottl interruptContext); 3009285809Sscottl break; 3010285809Sscottl case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS: /* fall through */ 3011285809Sscottl case OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH: 3012285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = ENCRYPTION ERROR 0x%x\n", agIOStatus)); 3013285809Sscottl itdsatEncryptionHandler(agRoot, 3014285809Sscottl agIORequest, 3015285809Sscottl agIOStatus, 3016285809Sscottl agIOInfoLen, 3017285809Sscottl agParam, 3018285809Sscottl 0); 3019285809Sscottl break; 3020285809Sscottl case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH: /* fall through */ 3021285809Sscottl case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH: /* fall through */ 3022285809Sscottl case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH: 3023285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = DIF ERROR 0x%x\n", agIOStatus)); 3024285809Sscottl itdsatDifHandler(agRoot, 3025285809Sscottl agIORequest, 3026285809Sscottl agIOStatus, 3027285809Sscottl agIOInfoLen, 3028285809Sscottl agParam, 3029285809Sscottl 0); 3030285809Sscottl break; 3031285809Sscottl default: 3032285809Sscottl TI_DBG1(("itdsatDelayedProcessAbnormalCompletion: agIOStatus = unknown\n")); 3033285809Sscottl ostiInitiatorIOCompleted( tiRoot, 3034285809Sscottl tdIORequestBody->tiIORequest, 3035285809Sscottl tiIOFailed, 3036285809Sscottl tiDetailOtherError, 3037285809Sscottl agNULL, 3038285809Sscottl interruptContext); 3039285809Sscottl break; 3040285809Sscottl 3041285809Sscottl } /* switch */ 3042285809Sscottl} 3043285809Sscottl 3044285809Sscottl/***************************************************************************** 3045285809Sscottl*! \brief itdsatEncryptionHandler 3046285809Sscottl* 3047285809Sscottl* Purpose: This function processes I/Os completed and returned by SATA lower 3048285809Sscottl* layer with any encryption specific agIOStatus. 3049285809Sscottl* 3050285809Sscottl* \param agRoot: pointer to port instance 3051285809Sscottl* \param agIORequest: pointer to I/O request 3052285809Sscottl* \param agIOStatus: I/O status given by LL layer 3053285809Sscottl* \param agIOInfoLen: lenth of complete SAS RESP frame 3054285809Sscottl* \param agParam A Handle used to refer to the response frame or handle 3055285809Sscottl* of abort request 3056285809Sscottl* \return: None 3057285809Sscottl* 3058285809Sscottl* 3059285809Sscottl*****************************************************************************/ 3060285809SscottlosGLOBAL void 3061285809SscottlitdsatEncryptionHandler( 3062285809Sscottl agsaRoot_t *agRoot, 3063285809Sscottl agsaIORequest_t *agIORequest, 3064285809Sscottl bit32 agIOStatus, 3065285809Sscottl bit32 agIOInfoLen, 3066285809Sscottl void *agParam, 3067285809Sscottl bit32 agOtherInfo 3068285809Sscottl ) 3069285809Sscottl{ 3070285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3071285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3072285809Sscottl bit32 intContext = osData->IntContext; 3073285809Sscottl bit32 errorDetail = tiDetailOtherError; 3074285809Sscottl tdIORequestBody_t *tdIORequestBody; 3075285809Sscottl TI_DBG1(("itdsatEncryptionHandler: start\n")); 3076285809Sscottl TI_DBG1(("itdsatEncryptionHandler: agIOStatus 0x%x\n", agIOStatus)); 3077285809Sscottl 3078285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 3079285809Sscottl 3080285809Sscottl switch (agIOStatus) 3081285809Sscottl { 3082285809Sscottl case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS: 3083285809Sscottl TI_DBG1(("itdsatEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS\n")); 3084285809Sscottl errorDetail = tiDetailDekKeyCacheMiss; 3085285809Sscottl break; 3086285809Sscottl case OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID: 3087285809Sscottl TI_DBG1(("itdsatEncryptionHandler: OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID\n")); 3088285809Sscottl errorDetail = tiDetailCipherModeInvalid; 3089285809Sscottl break; 3090285809Sscottl case OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH: 3091285809Sscottl TI_DBG1(("itdsatEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH\n")); 3092285809Sscottl errorDetail = tiDetailDekIVMismatch; 3093285809Sscottl break; 3094285809Sscottl case OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR: 3095285809Sscottl TI_DBG1(("itdsatEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR\n")); 3096285809Sscottl errorDetail = tiDetailDekRamInterfaceError; 3097285809Sscottl break; 3098285809Sscottl default: 3099285809Sscottl TI_DBG1(("itdsatEncryptionHandler: other error!!! 0x%x\n", agIOStatus)); 3100285809Sscottl errorDetail = tiDetailOtherError; 3101285809Sscottl break; 3102285809Sscottl } 3103285809Sscottl 3104285809Sscottl ostiInitiatorIOCompleted ( 3105285809Sscottl tiRoot, 3106285809Sscottl tdIORequestBody->tiIORequest, 3107285809Sscottl tiIOEncryptError, 3108285809Sscottl errorDetail, 3109285809Sscottl agNULL, 3110285809Sscottl intContext 3111285809Sscottl ); 3112285809Sscottl return; 3113285809Sscottl} 3114285809Sscottl 3115285809Sscottl/***************************************************************************** 3116285809Sscottl*! \brief itdsatDifHandler 3117285809Sscottl* 3118285809Sscottl* Purpose: This function processes I/Os completed and returned by SATA lower 3119285809Sscottl* layer with any DIF specific agIOStatus. 3120285809Sscottl* 3121285809Sscottl* \param agRoot: pointer to port instance 3122285809Sscottl* \param agIORequest: pointer to I/O request 3123285809Sscottl* \param agIOStatus: I/O status given by LL layer 3124285809Sscottl* \param agIOInfoLen: lenth of complete SAS RESP frame 3125285809Sscottl* \param agParam A Handle used to refer to the response frame or handle 3126285809Sscottl* of abort request 3127285809Sscottl* \return: None 3128285809Sscottl* 3129285809Sscottl* 3130285809Sscottl*****************************************************************************/ 3131285809SscottlosGLOBAL void 3132285809SscottlitdsatDifHandler( 3133285809Sscottl agsaRoot_t *agRoot, 3134285809Sscottl agsaIORequest_t *agIORequest, 3135285809Sscottl bit32 agIOStatus, 3136285809Sscottl bit32 agIOInfoLen, 3137285809Sscottl void *agParam, 3138285809Sscottl bit32 agOtherInfo 3139285809Sscottl ) 3140285809Sscottl{ 3141285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3142285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3143285809Sscottl bit32 intContext = osData->IntContext; 3144285809Sscottl bit32 errorDetail = tiDetailOtherError; 3145285809Sscottl tdIORequestBody_t *tdIORequestBody; 3146285809Sscottl#ifdef TD_DEBUG_ENABLE 3147285809Sscottl agsaDifDetails_t *DifDetail; 3148285809Sscottl#endif 3149285809Sscottl 3150285809Sscottl TI_DBG2(("itdsatDifHandler: start\n")); 3151285809Sscottl TI_DBG2(("itdsatDifHandler: agIOStatus 0x%x\n", agIOStatus)); 3152285809Sscottl 3153285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 3154285809Sscottl#ifdef TD_DEBUG_ENABLE 3155285809Sscottl DifDetail = (agsaDifDetails_t *)agParam; 3156285809Sscottl#endif 3157285809Sscottl switch (agIOStatus) 3158285809Sscottl { 3159285809Sscottl case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH: 3160285809Sscottl TI_DBG1(("itdsatDifHandler: OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH\n")); 3161285809Sscottl errorDetail = tiDetailDifAppTagMismatch; 3162285809Sscottl break; 3163285809Sscottl case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH: 3164285809Sscottl TI_DBG1(("itdsatDifHandler: OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH\n")); 3165285809Sscottl errorDetail = tiDetailDifRefTagMismatch; 3166285809Sscottl break; 3167285809Sscottl case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH: 3168285809Sscottl TI_DBG1(("itdsatDifHandler: OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH\n")); 3169285809Sscottl errorDetail = tiDetailDifCrcMismatch; 3170285809Sscottl break; 3171285809Sscottl default: 3172285809Sscottl TI_DBG1(("itdsatDifHandler: other error!!! 0x%x\n", agIOStatus)); 3173285809Sscottl errorDetail = tiDetailOtherError; 3174285809Sscottl break; 3175285809Sscottl } 3176285809Sscottl 3177285809Sscottl TI_DBG1(("smsatDifHandler: DIF detail UpperLBA 0x%08x LowerLBA 0x%08x\n", DifDetail->UpperLBA, DifDetail->LowerLBA)); 3178285809Sscottl 3179285809Sscottl ostiInitiatorIOCompleted ( 3180285809Sscottl tiRoot, 3181285809Sscottl tdIORequestBody->tiIORequest, 3182285809Sscottl tiIODifError, 3183285809Sscottl errorDetail, 3184285809Sscottl agNULL, 3185285809Sscottl intContext 3186285809Sscottl ); 3187285809Sscottl return; 3188285809Sscottl} 3189285809Sscottl 3190285809Sscottl/*****************************************************************************/ 3191285809Sscottl/*! \brief satProcessAbort 3192285809Sscottl * 3193285809Sscottl * This function processes abort. 3194285809Sscottl * 3195285809Sscottl * \param tiRoot: Pointer to TISA initiator driver/port instance. 3196285809Sscottl * \param tiIORequest: Pointer to TISA I/O request context for this I/O. 3197285809Sscottl * \param satIOContext_t: Pointer to the SAT IO Context 3198285809Sscottl * 3199285809Sscottl * \return 3200285809Sscottl * None 3201285809Sscottl */ 3202285809Sscottl/*****************************************************************************/ 3203285809Sscottlvoid satProcessAbort( 3204285809Sscottl tiRoot_t *tiRoot, 3205285809Sscottl tiIORequest_t *tiIORequest, 3206285809Sscottl satIOContext_t *satIOContext 3207285809Sscottl ) 3208285809Sscottl{ 3209285809Sscottl satDeviceData_t *pSatDevData; 3210285809Sscottl //tiDeviceHandle_t *tiDeviceHandle; 3211285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 3212285809Sscottl 3213285809Sscottl TI_DBG5(("satProcessAbort: start\n")); 3214285809Sscottl 3215285809Sscottl pSatDevData = satIOContext->pSatDevData; 3216285809Sscottl //tiDeviceHandle = satIOContext->ptiDeviceHandle; 3217285809Sscottl hostToDevFis = satIOContext->pFis; 3218285809Sscottl if ( (hostToDevFis->h.command == SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE) && 3219285809Sscottl (hostToDevFis->d.lbaLow != 0x01 && hostToDevFis->d.lbaLow != 0x02) 3220285809Sscottl ) 3221285809Sscottl { 3222285809Sscottl /* no completion for send diagnotic in background. It is done in satSendDiagnostic() */ 3223285809Sscottl ostiInitiatorIOCompleted( tiRoot, 3224285809Sscottl tiIORequest, 3225285809Sscottl tiIOFailed, 3226285809Sscottl tiDetailAborted, 3227285809Sscottl agNULL, 3228285809Sscottl satIOContext->interruptContext); 3229285809Sscottl } 3230285809Sscottl 3231285809Sscottl if ( pSatDevData->satTmTaskTag != agNULL ) 3232285809Sscottl { 3233285809Sscottl TI_DBG1(("satProcessAbort: TM callback\n")); 3234285809Sscottl /* 3235285809Sscottl * Reset flag 3236285809Sscottl */ 3237285809Sscottl pSatDevData->satTmTaskTag = agNULL; 3238285809Sscottl } 3239285809Sscottl 3240285809Sscottl /* 3241285809Sscottl * Check if we are in recovery mode and need to update the recovery flag 3242285809Sscottl */ 3243285809Sscottl if ((pSatDevData->satDriveState == SAT_DEV_STATE_IN_RECOVERY ) && 3244285809Sscottl (pSatDevData->satPendingIO == 0 )) 3245285809Sscottl { 3246285809Sscottl pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL; 3247285809Sscottl TI_DBG1(("satProcessAbort: STATE NORMAL.\n")); 3248285809Sscottl } 3249285809Sscottl TI_DBG1(("satProcessAbort: satDriveState %d\n", pSatDevData->satDriveState)); 3250285809Sscottl TI_DBG1(("satProcessAbort: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO )); 3251285809Sscottl TI_DBG1(("satProcessAbort: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO)); 3252285809Sscottl 3253285809Sscottl 3254285809Sscottl 3255285809Sscottl return; 3256285809Sscottl} 3257285809Sscottl 3258285809Sscottl/***************************************************************************** 3259285809Sscottl*! \brief satNonDataIOCB 3260285809Sscottl* 3261285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 3262285809Sscottl* This CB routine deals with non-data I/O SATA request. 3263285809Sscottl* 3264285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 3265285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 3266285809Sscottl* \param agIOStatus: Status of completed I/O. 3267285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 3268285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 3269285809Sscottl* length. 3270285809Sscottl* \param agParam: Additional info based on status. 3271285809Sscottl* \param ioContext: Pointer to satIOContext_t. 3272285809Sscottl* 3273285809Sscottl* \return: none 3274285809Sscottl* 3275285809Sscottl*****************************************************************************/ 3276285809Sscottlvoid satNonDataIOCB( 3277285809Sscottl agsaRoot_t *agRoot, 3278285809Sscottl agsaIORequest_t *agIORequest, 3279285809Sscottl bit32 agIOStatus, 3280285809Sscottl agsaFisHeader_t *agFirstDword, 3281285809Sscottl bit32 agIOInfoLen, 3282285809Sscottl void *agParam, 3283285809Sscottl void *ioContext 3284285809Sscottl ) 3285285809Sscottl{ 3286285809Sscottl 3287285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3288285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3289285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 3290285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 3291285809Sscottl tdIORequestBody_t *tdIORequestBody; 3292285809Sscottl bit32 interruptContext = osData->IntContext; 3293285809Sscottl satIOContext_t *satIOContext; 3294285809Sscottl 3295285809Sscottl TI_DBG5(("satNonDataIOCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 3296285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 3297285809Sscottl 3298285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 3299285809Sscottl satIOContext = (satIOContext_t *) ioContext; 3300285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 3301285809Sscottl 3302285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 3303285809Sscottl tdIORequestBody->ioStarted = agFALSE; 3304285809Sscottl 3305285809Sscottl /* Process completion */ 3306285809Sscottl if( (agIOStatus == OSSA_IO_SUCCESS) && (agIOInfoLen==0)) 3307285809Sscottl { 3308285809Sscottl /* 3309285809Sscottl * !!! We expect that agIOInfoLen should be non-zero !!!!. 3310285809Sscottl * Now call the OS-App Specific layer about this unexpected completion. 3311285809Sscottl */ 3312285809Sscottl TI_DBG1(("satNonDataIOCB: *** ERROR*** agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 3313285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 3314285809Sscottl 3315285809Sscottl ostiInitiatorIOCompleted( tiRoot, 3316285809Sscottl tdIORequestBody->tiIORequest, 3317285809Sscottl tiIOFailed, 3318285809Sscottl tiDetailOtherError, 3319285809Sscottl agNULL, 3320285809Sscottl interruptContext); 3321285809Sscottl } 3322285809Sscottl else 3323285809Sscottl { 3324285809Sscottl /* More checking needed, for non-data IO this should be the normal case */ 3325285809Sscottl itdsatProcessAbnormalCompletion( agRoot, 3326285809Sscottl agIORequest, 3327285809Sscottl agIOStatus, 3328285809Sscottl agFirstDword, 3329285809Sscottl agIOInfoLen, 3330285809Sscottl agParam, 3331285809Sscottl satIOContext); 3332285809Sscottl } 3333285809Sscottl 3334285809Sscottl} 3335285809Sscottl 3336285809Sscottl/***************************************************************************** 3337285809Sscottl*! \brief tdssSATADeviceTypeDecode 3338285809Sscottl* 3339285809Sscottl* This routine decodes ATA signature 3340285809Sscottl* 3341285809Sscottl* \param pSignature: ATA signature 3342285809Sscottl* 3343285809Sscottl* 3344285809Sscottl* \return: 3345285809Sscottl* TRUE if ATA signature 3346285809Sscottl* FALSE otherwise 3347285809Sscottl* 3348285809Sscottl*****************************************************************************/ 3349285809Sscottl/* 3350285809Sscottl ATA p65 3351285809Sscottl PM p65 3352285809Sscottl SATAII p79, p80 3353285809Sscottl */ 3354285809SscottlGLOBAL bit32 3355285809SscottltdssSATADeviceTypeDecode( 3356285809Sscottl bit8 *pSignature 3357285809Sscottl ) 3358285809Sscottl{ 3359285809Sscottl bit32 deviceType = UNKNOWN_DEVICE; 3360285809Sscottl 3361285809Sscottl if ( (pSignature)[0] == 0x01 && (pSignature)[1] == 0x01 3362285809Sscottl && (pSignature)[2] == 0x00 && (pSignature)[3] == 0x00 3363285809Sscottl && (pSignature)[4] == 0xA0 ) /* this is the signature of a Hitachi SATA HDD*/ 3364285809Sscottl { 3365285809Sscottl deviceType = SATA_ATA_DEVICE; 3366285809Sscottl } 3367285809Sscottl else if ( (pSignature)[0] == 0x01 && (pSignature)[1] == 0x01 3368285809Sscottl && (pSignature)[2] == 0x00 && (pSignature)[3] == 0x00 3369285809Sscottl && (pSignature)[4] == 0x00 ) 3370285809Sscottl { 3371285809Sscottl deviceType = SATA_ATA_DEVICE; 3372285809Sscottl } 3373285809Sscottl else if ( (pSignature)[0] == 0x01 && (pSignature)[1] == 0x01 3374285809Sscottl && (pSignature)[2] == 0x14 && (pSignature)[3] == 0xEB 3375285809Sscottl && ( (pSignature)[4] == 0x00 || (pSignature)[4] == 0x10) ) 3376285809Sscottl { 3377285809Sscottl deviceType = SATA_ATAPI_DEVICE; 3378285809Sscottl } 3379285809Sscottl else if ( (pSignature)[0] == 0x01 && (pSignature)[1] == 0x01 3380285809Sscottl && (pSignature)[2] == 0x69 && (pSignature)[3] == 0x96 3381285809Sscottl && (pSignature)[4] == 0x00 ) 3382285809Sscottl { 3383285809Sscottl deviceType = SATA_PM_DEVICE; 3384285809Sscottl } 3385285809Sscottl else if ( (pSignature)[0] == 0x01 && (pSignature)[1] == 0x01 3386285809Sscottl && (pSignature)[2] == 0x3C && (pSignature)[3] == 0xC3 3387285809Sscottl && (pSignature)[4] == 0x00 ) 3388285809Sscottl { 3389285809Sscottl deviceType = SATA_SEMB_DEVICE; 3390285809Sscottl } 3391285809Sscottl else if ( (pSignature)[0] == 0xFF && (pSignature)[1] == 0xFF 3392285809Sscottl && (pSignature)[2] == 0xFF && (pSignature)[3] == 0xFF 3393285809Sscottl && (pSignature)[4] == 0xFF ) 3394285809Sscottl { 3395285809Sscottl deviceType = SATA_SEMB_WO_SEP_DEVICE; 3396285809Sscottl } 3397285809Sscottl 3398285809Sscottl return deviceType; 3399285809Sscottl} 3400285809Sscottl 3401285809Sscottl/***************************************************************************** 3402285809Sscottl*! \brief ossaDiscoverSataCB 3403285809Sscottl* 3404285809Sscottl* Purpose: This function is called by lower layer to inform TD layer of 3405285809Sscottl* STP/SATA discovery results 3406285809Sscottl* 3407285809Sscottl* 3408285809Sscottl* \param agRoot Pointer to chip/driver Instance. 3409285809Sscottl* \param agPortContext Pointer to the port context of TD and Lower layer 3410285809Sscottl* \param event event type 3411285809Sscottl* \param pParm1 Pointer to data associated with event 3412285809Sscottl* \param pParm2 Pointer to data associated with event 3413285809Sscottl* 3414285809Sscottl* \return: none 3415285809Sscottl* 3416285809Sscottl* \note - For details, refer to SAS/SATA Low-Level API Specification 3417285809Sscottl* 3418285809Sscottl*****************************************************************************/ 3419285809Sscottl 3420285809SscottlosGLOBAL void ossaDiscoverSataCB( agsaRoot_t *agRoot, 3421285809Sscottl agsaPortContext_t *agPortContext, 3422285809Sscottl bit32 event, 3423285809Sscottl void *pParm1, 3424285809Sscottl void *pParm2 3425285809Sscottl ) 3426285809Sscottl{ 3427285809Sscottl tdsaRootOsData_t *osData; 3428285809Sscottl tiRoot_t *tiRoot; 3429285809Sscottl tdsaPortContext_t *onePortContext; 3430285809Sscottl tdsaDeviceData_t *oneDeviceData; 3431285809Sscottl agsaDevHandle_t *agDevHandle; 3432285809Sscottl agsaSATADeviceInfo_t *agSATADeviceInfo; 3433285809Sscottl tiPortalContext_t *tiPortalContext; 3434285809Sscottl 3435285809Sscottl bit32 devicetype = UNKNOWN_DEVICE; 3436285809Sscottl 3437285809Sscottl osData = (tdsaRootOsData_t *)agRoot->osData; 3438285809Sscottl tiRoot = (tiRoot_t *)osData->tiRoot; 3439285809Sscottl 3440285809Sscottl TI_DBG5(("ossaDiscoverSataCB: start\n")); 3441285809Sscottl 3442285809Sscottl if (agPortContext == agNULL) 3443285809Sscottl { 3444285809Sscottl TI_DBG1(("ossaDiscoverSataCB: NULL agsaPortContext; wrong\n")); 3445285809Sscottl return; 3446285809Sscottl } 3447285809Sscottl 3448285809Sscottl onePortContext = (tdsaPortContext_t *)agPortContext->osData; 3449285809Sscottl tiPortalContext = (tiPortalContext_t *)onePortContext->tiPortalContext; 3450285809Sscottl 3451285809Sscottl switch ( event ) 3452285809Sscottl { 3453285809Sscottl case OSSA_DISCOVER_STARTED: 3454285809Sscottl { 3455285809Sscottl TI_DBG5(("ossaDiscoverSataCB: STARTED\n")); 3456285809Sscottl /* Do nothing */ 3457285809Sscottl break; 3458285809Sscottl } 3459285809Sscottl 3460285809Sscottl case OSSA_DISCOVER_FOUND_DEVICE: 3461285809Sscottl { 3462285809Sscottl TI_DBG5(("ossaDiscoverSataCB: ***** FOUND DEVICE\n")); 3463285809Sscottl agDevHandle = (agsaDevHandle_t *) pParm1; 3464285809Sscottl agSATADeviceInfo = (agsaSATADeviceInfo_t *) pParm2; 3465285809Sscottl 3466285809Sscottl /* parse the device type */ 3467285809Sscottl devicetype = tdssSATADeviceTypeDecode(agSATADeviceInfo->signature); 3468285809Sscottl 3469285809Sscottl 3470285809Sscottl /* for now, TD handles only ATA Device or ATAPI Device */ 3471285809Sscottl if (devicetype == SATA_ATA_DEVICE || devicetype == SATA_ATAPI_DEVICE) 3472285809Sscottl { 3473285809Sscottl TI_DBG5(("ossaDiscoverSataCB: ***** adding ....\n")); 3474285809Sscottl /* Add SATA device */ 3475285809Sscottl tdssAddSATAToSharedcontext( onePortContext, 3476285809Sscottl agRoot, 3477285809Sscottl agDevHandle, 3478285809Sscottl agSATADeviceInfo, 3479285809Sscottl agTRUE, 3480285809Sscottl agSATADeviceInfo->stpPhyIdentifier 3481285809Sscottl ); 3482285809Sscottl#ifdef INITIATOR_DRIVER 3483285809Sscottl ostiInitiatorEvent( 3484285809Sscottl tiRoot, 3485285809Sscottl tiPortalContext, 3486285809Sscottl agNULL, 3487285809Sscottl tiIntrEventTypeDeviceChange, 3488285809Sscottl tiDeviceArrival, 3489285809Sscottl agNULL 3490285809Sscottl ); 3491285809Sscottl#endif 3492285809Sscottl } /* end of ATA_ATA_DEVICE or ATA_ATAPI_DEVICE */ 3493285809Sscottl else 3494285809Sscottl { 3495285809Sscottl TI_DBG5(("ossaDiscoverSataCB: ***** not adding ..... devicetype 0x%x\n", devicetype)); 3496285809Sscottl } 3497285809Sscottl break; 3498285809Sscottl } 3499285809Sscottl 3500285809Sscottl case OSSA_DISCOVER_REMOVED_DEVICE: 3501285809Sscottl { 3502285809Sscottl TI_DBG1(("ossaDiscoverSataCB: REMOVED_DEVICE\n")); 3503285809Sscottl agDevHandle = (agsaDevHandle_t *) pParm1; 3504285809Sscottl agSATADeviceInfo = (agsaSATADeviceInfo_t *) pParm2; 3505285809Sscottl 3506285809Sscottl oneDeviceData = (tdsaDeviceData_t *) agDevHandle->osData; 3507285809Sscottl 3508285809Sscottl TI_DBG1(("ossaDiscoverSataCB: signature: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", 3509285809Sscottl agSATADeviceInfo->signature[0], agSATADeviceInfo->signature[1], 3510285809Sscottl agSATADeviceInfo->signature[2], agSATADeviceInfo->signature[3], 3511285809Sscottl agSATADeviceInfo->signature[4], agSATADeviceInfo->signature[5], 3512285809Sscottl agSATADeviceInfo->signature[6], agSATADeviceInfo->signature[7] )); 3513285809Sscottl 3514285809Sscottl if (oneDeviceData == agNULL) 3515285809Sscottl { 3516285809Sscottl TI_DBG1(("ossaDiscoverSataCB: Wrong. DevHandle->osData is NULL but is being removed\n")); 3517285809Sscottl } 3518285809Sscottl tdssRemoveSATAFromSharedcontext( onePortContext, 3519285809Sscottl oneDeviceData, 3520285809Sscottl agRoot 3521285809Sscottl ); 3522285809Sscottl agDevHandle->osData = agNULL; 3523285809Sscottl#ifdef INITIATOR_DRIVER 3524285809Sscottl ostiInitiatorEvent( 3525285809Sscottl tiRoot, 3526285809Sscottl tiPortalContext, 3527285809Sscottl agNULL, 3528285809Sscottl tiIntrEventTypeDeviceChange, 3529285809Sscottl tiDeviceRemoval, 3530285809Sscottl agNULL 3531285809Sscottl ); 3532285809Sscottl#endif 3533285809Sscottl break; 3534285809Sscottl } 3535285809Sscottl 3536285809Sscottl case OSSA_DISCOVER_COMPLETE: 3537285809Sscottl { 3538285809Sscottl TI_DBG1(("ossaDiscoverSataCB: COMPLETE\n")); 3539285809Sscottl onePortContext->DiscoveryState = ITD_DSTATE_COMPLETED; 3540285809Sscottl TI_DBG6(("ossaDiscoverSataCB: COMPLETE pid %d\n", onePortContext->id)); 3541285809Sscottl 3542285809Sscottl /* Let OS-Apps specific layer know discovery has been successfully complete */ 3543285809Sscottl ostiInitiatorEvent( tiRoot, 3544285809Sscottl tiPortalContext, 3545285809Sscottl agNULL, 3546285809Sscottl tiIntrEventTypeDiscovery, 3547285809Sscottl tiDiscOK, 3548285809Sscottl agNULL ); 3549285809Sscottl break; 3550285809Sscottl } 3551285809Sscottl 3552285809Sscottl case OSSA_DISCOVER_ABORT: 3553285809Sscottl { 3554285809Sscottl TI_DBG1(("ossaDiscoverSataCB: OSSA_DISCOVER_ABORT\n")); 3555285809Sscottl /* Let OS-Apps specific layer know discovery has failed */ 3556285809Sscottl ostiInitiatorEvent( tiRoot, 3557285809Sscottl tiPortalContext, 3558285809Sscottl agNULL, 3559285809Sscottl tiIntrEventTypeDiscovery, 3560285809Sscottl tiDiscFailed, 3561285809Sscottl agNULL ); 3562285809Sscottl 3563285809Sscottl break; 3564285809Sscottl } 3565285809Sscottl 3566285809Sscottl default: 3567285809Sscottl { 3568285809Sscottl TI_DBG1(("ossaDiscoverSataCB: error default event 0x%x\n", event)); 3569285809Sscottl /* Let OS-Apps specific layer know discovery has failed */ 3570285809Sscottl ostiInitiatorEvent( tiRoot, 3571285809Sscottl tiPortalContext, 3572285809Sscottl agNULL, 3573285809Sscottl tiIntrEventTypeDiscovery, 3574285809Sscottl tiDiscFailed, 3575285809Sscottl agNULL ); 3576285809Sscottl break; 3577285809Sscottl } 3578285809Sscottl 3579285809Sscottl } /* end of switch */ 3580285809Sscottl 3581285809Sscottl return; 3582285809Sscottl} 3583285809Sscottl 3584285809Sscottl/***************************************************************************** 3585285809Sscottl*! \brief tdssAddSataToSharedcontext 3586285809Sscottl* 3587285809Sscottl* Purpose: This function adds a discovered SATA device to a device list of 3588285809Sscottl* a port context 3589285809Sscottl* 3590285809Sscottl* \param tsddPortContext_Instance Pointer to the target port context 3591285809Sscottl* \param agRoot Pointer to the root data structure of 3592285809Sscottl* TD and Lower layer 3593285809Sscottl* \param agDevHandle Pointer to a device handle 3594285809Sscottl* \param agSATADeviceInfo Pointer to SATA device info structure 3595285809Sscottl* \param registered indication flag for registration to LL 3596285809Sscottl* 3597285809Sscottl* \Return: none 3598285809Sscottl* 3599285809Sscottl*****************************************************************************/ 3600285809Sscottl/* split into devicedata allocation/registration and sending identify device data */ 3601285809SscottlosGLOBAL void 3602285809SscottltdssAddSATAToSharedcontext( tdsaPortContext_t *tdsaPortContext_Instance, 3603285809Sscottl agsaRoot_t *agRoot, 3604285809Sscottl agsaDevHandle_t *agDevHandle, 3605285809Sscottl agsaSATADeviceInfo_t *agSATADeviceInfo, 3606285809Sscottl bit32 registered, 3607285809Sscottl bit8 phyID 3608285809Sscottl ) 3609285809Sscottl{ 3610285809Sscottl tdsaPortContext_t *onePortContext = agNULL; 3611285809Sscottl tdList_t *PortContextList; 3612285809Sscottl tdsaDeviceData_t *oneDeviceData = agNULL; 3613285809Sscottl tdList_t *DeviceListList = agNULL; 3614285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 3615285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 3616285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 3617285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 3618285809Sscottl satDeviceData_t *pSatDevData; 3619285809Sscottl bit32 Indenom = tdsaAllShared->QueueConfig.numInboundQueues; 3620285809Sscottl bit32 Outdenom = tdsaAllShared->QueueConfig.numOutboundQueues; 3621285809Sscottl bit8 dev_s_rate = 0; 3622285809Sscottl bit8 sasorsata = 1; 3623285809Sscottl bit8 connectionRate; 3624285809Sscottl bit8 flag = 0; 3625285809Sscottl bit8 TLR = 0; 3626285809Sscottl bit32 found = agFALSE; 3627285809Sscottl TI_DBG5(("tdssAddSataToSharedcontext: start\n")); 3628285809Sscottl 3629285809Sscottl /* 3630285809Sscottl * Find a right portcontext, then get devicedata from FreeLink in DeviceList. 3631285809Sscottl * Then, add the devicedata to the portcontext. 3632285809Sscottl */ 3633285809Sscottl 3634285809Sscottl /* Find a right portcontext */ 3635285809Sscottl PortContextList = tdsaAllShared->MainPortContextList.flink; 3636285809Sscottl while (PortContextList != &(tdsaAllShared->MainPortContextList)) 3637285809Sscottl { 3638285809Sscottl onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList); 3639285809Sscottl if (onePortContext == tdsaPortContext_Instance) 3640285809Sscottl { 3641285809Sscottl TI_DBG5(("tdssAddSataToSharedcontext: found; oneportContext ID %d\n", 3642285809Sscottl onePortContext->id)); 3643285809Sscottl found = agTRUE; 3644285809Sscottl break; 3645285809Sscottl } 3646285809Sscottl PortContextList = PortContextList->flink; 3647285809Sscottl } 3648285809Sscottl 3649285809Sscottl if (found == agFALSE) 3650285809Sscottl { 3651285809Sscottl TI_DBG1(("tdssAddSataToSharedcontext: No corressponding tdsaPortContext\n")); 3652285809Sscottl return; 3653285809Sscottl } 3654285809Sscottl 3655285809Sscottl /* 3656285809Sscottl 1. add the devicedata 3657285809Sscottl 2. Send Identify Device Data 3658285809Sscottl 3. In CB of Identify Device Data (satAddSATAIDDevCB), finds out the devicedata is new or old 3659285809Sscottl */ 3660285809Sscottl 3661285809Sscottl 3662285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 3663285809Sscottl if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList))) 3664285809Sscottl { 3665285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 3666285809Sscottl TI_DBG1(("tdssAddSataToSharedcontext: ERROR empty DeviceData FreeLink\n")); 3667285809Sscottl /* notifying link up */ 3668285809Sscottl ostiPortEvent ( 3669285809Sscottl tiRoot, 3670285809Sscottl tiPortLinkUp, 3671285809Sscottl tiSuccess, 3672285809Sscottl (void *)tdsaAllShared->Ports[phyID].tiPortalContext 3673285809Sscottl ); 3674285809Sscottl#ifdef INITIATOR_DRIVER 3675285809Sscottl /* triggers discovery */ 3676285809Sscottl ostiPortEvent( 3677285809Sscottl tiRoot, 3678285809Sscottl tiPortDiscoveryReady, 3679285809Sscottl tiSuccess, 3680285809Sscottl (void *) tdsaAllShared->Ports[phyID].tiPortalContext 3681285809Sscottl ); 3682285809Sscottl#endif 3683285809Sscottl return; 3684285809Sscottl } 3685285809Sscottl 3686285809Sscottl TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList)); 3687285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 3688285809Sscottl oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList); 3689285809Sscottl TDLIST_DEQUEUE_THIS(&(oneDeviceData->FreeLink)); 3690285809Sscottl 3691285809Sscottl TI_DBG1(("tdssAddSataToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id)); 3692285809Sscottl oneDeviceData->InQID = oneDeviceData->id % Indenom; 3693285809Sscottl oneDeviceData->OutQID = oneDeviceData->id % Outdenom; 3694285809Sscottl 3695285809Sscottl pSatDevData = (satDeviceData_t *)&(oneDeviceData->satDevData); 3696285809Sscottl pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL; 3697285809Sscottl pSatDevData->satPendingIO = 0; 3698285809Sscottl pSatDevData->satNCQMaxIO = 0; 3699285809Sscottl pSatDevData->satPendingNCQIO = 0; 3700285809Sscottl pSatDevData->satPendingNONNCQIO = 0; 3701285809Sscottl pSatDevData->IDDeviceValid = agFALSE; 3702285809Sscottl pSatDevData->satDeviceType = tdssSATADeviceTypeDecode(onePortContext->remoteSignature); 3703285809Sscottl 3704285809Sscottl osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t)); 3705285809Sscottl 3706285809Sscottl onePortContext->Count++; 3707285809Sscottl oneDeviceData->DeviceType = TD_SATA_DEVICE; // either TD_SAS_DEVICE or TD_SATA_DEVICE 3708285809Sscottl oneDeviceData->agRoot = agRoot; 3709285809Sscottl// oneDeviceData->agDevHandle = agDevHandle; 3710285809Sscottl 3711285809Sscottl// agDevHandle->osData = oneDeviceData; /* TD layer */ 3712285809Sscottl oneDeviceData->tdPortContext = onePortContext; 3713285809Sscottl oneDeviceData->valid = agTRUE; 3714285809Sscottl 3715285809Sscottl oneDeviceData->directlyAttached = agTRUE; 3716285809Sscottl oneDeviceData->initiator_ssp_stp_smp = 0; 3717285809Sscottl oneDeviceData->target_ssp_stp_smp = 0x1; /* setting SATA device bit */ 3718285809Sscottl oneDeviceData->phyID = phyID; 3719285809Sscottl 3720285809Sscottl /* parse sasIDframe to fill in agDeviceInfo */ 3721285809Sscottl flag = (bit8)((phyID << 4) | TLR); 3722285809Sscottl DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT); 3723285809Sscottl DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout); 3724285809Sscottl DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0); 3725285809Sscottl //temp 3726285809Sscottl //DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 0); 3727285809Sscottl DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, flag); 3728285809Sscottl 3729285809Sscottl sasorsata = SATA_DEVICE_TYPE; /* SATA disk */ 3730285809Sscottl connectionRate = onePortContext->LinkRate; 3731285809Sscottl dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4)); 3732285809Sscottl dev_s_rate = (bit8)(dev_s_rate | connectionRate); 3733285809Sscottl DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate); 3734285809Sscottl 3735285809Sscottl DEVINFO_PUT_SAS_ADDRESSLO( 3736285809Sscottl &oneDeviceData->agDeviceInfo, 3737285809Sscottl 0 3738285809Sscottl ); 3739285809Sscottl DEVINFO_PUT_SAS_ADDRESSHI( 3740285809Sscottl &oneDeviceData->agDeviceInfo, 3741285809Sscottl 0 3742285809Sscottl ); 3743285809Sscottl 3744285809Sscottl if (pSatDevData->satDeviceType == SATA_ATAPI_DEVICE ) 3745285809Sscottl { 3746285809Sscottl oneDeviceData->agDeviceInfo.flag |= ATAPI_DEVICE_FLAG; /* ATAPI device flag*/ 3747285809Sscottl } 3748285809Sscottl 3749285809Sscottl oneDeviceData->agContext.osData = oneDeviceData; 3750285809Sscottl oneDeviceData->agContext.sdkData = agNULL; 3751285809Sscottl 3752285809Sscottl if (oneDeviceData->registered == agFALSE) 3753285809Sscottl { 3754285809Sscottl saRegisterNewDevice( /* tdssAddSATAToSharedcontext */ 3755285809Sscottl agRoot, 3756285809Sscottl &oneDeviceData->agContext, 3757285809Sscottl 0,/*tdsaRotateQnumber(tiRoot, oneDeviceData),*/ 3758285809Sscottl &oneDeviceData->agDeviceInfo, 3759285809Sscottl onePortContext->agPortContext, 3760285809Sscottl 0 3761285809Sscottl ); 3762285809Sscottl } 3763285809Sscottl return; 3764285809Sscottl} 3765285809Sscottl/***************************************************************************** 3766285809Sscottl*! \brief tdssRetrySATAID 3767285809Sscottl* 3768285809Sscottl* Purpose: This function retries identify device data to directly attached SATA 3769285809Sscottl* device after device registration 3770285809Sscottl* 3771285809Sscottl* \param tiRoot: Pointer to TISA initiator driver/port instance. 3772285809Sscottl* \param oneDeviceData Pointer to a device data 3773285809Sscottl* \Return: none 3774285809Sscottl* 3775285809Sscottl*****************************************************************************/ 3776285809SscottlosGLOBAL void 3777285809SscottltdssRetrySATAID( tiRoot_t *tiRoot, 3778285809Sscottl tdsaDeviceData_t *oneDeviceData 3779285809Sscottl ) 3780285809Sscottl{ 3781285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 3782285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 3783285809Sscottl void *osMemHandle; 3784285809Sscottl tdIORequestBody_t *tdIORequestBody; 3785285809Sscottl bit32 PhysUpper32; 3786285809Sscottl bit32 PhysLower32; 3787285809Sscottl bit32 memAllocStatus; 3788285809Sscottl agsaIORequest_t *agIORequest = agNULL; /* identify device data itself */ 3789285809Sscottl satIOContext_t *satIOContext = agNULL; 3790285809Sscottl bit32 status; 3791285809Sscottl 3792285809Sscottl TI_DBG5(("tdssRetrySATAID: start\n")); 3793285809Sscottl /* allocate identify device data and sends it */ 3794285809Sscottl /* allocation tdIORequestBody and pass it to satTM() */ 3795285809Sscottl memAllocStatus = ostiAllocMemory( 3796285809Sscottl tiRoot, 3797285809Sscottl &osMemHandle, 3798285809Sscottl (void **)&tdIORequestBody, 3799285809Sscottl &PhysUpper32, 3800285809Sscottl &PhysLower32, 3801285809Sscottl 8, 3802285809Sscottl sizeof(tdIORequestBody_t), 3803285809Sscottl agTRUE 3804285809Sscottl ); 3805285809Sscottl 3806285809Sscottl if (memAllocStatus != tiSuccess) 3807285809Sscottl { 3808285809Sscottl TI_DBG1(("tdssRetrySATAID: ostiAllocMemory failed... loc 2\n")); 3809285809Sscottl /* notifying link up */ 3810285809Sscottl ostiPortEvent ( 3811285809Sscottl tiRoot, 3812285809Sscottl tiPortLinkUp, 3813285809Sscottl tiSuccess, 3814285809Sscottl (void *)tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3815285809Sscottl ); 3816285809Sscottl#ifdef INITIATOR_DRIVER 3817285809Sscottl /* triggers discovery */ 3818285809Sscottl ostiPortEvent( 3819285809Sscottl tiRoot, 3820285809Sscottl tiPortDiscoveryReady, 3821285809Sscottl tiSuccess, 3822285809Sscottl (void *) tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3823285809Sscottl ); 3824285809Sscottl#endif 3825285809Sscottl 3826285809Sscottl return; 3827285809Sscottl } 3828285809Sscottl 3829285809Sscottl if (tdIORequestBody == agNULL) 3830285809Sscottl { 3831285809Sscottl TI_DBG1(("tdssRetrySATAID: ostiAllocMemory returned NULL tdIORequestBody loc 2\n")); 3832285809Sscottl /* notifying link up */ 3833285809Sscottl ostiPortEvent ( 3834285809Sscottl tiRoot, 3835285809Sscottl tiPortLinkUp, 3836285809Sscottl tiSuccess, 3837285809Sscottl (void *)tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3838285809Sscottl ); 3839285809Sscottl#ifdef INITIATOR_DRIVER 3840285809Sscottl /* triggers discovery */ 3841285809Sscottl ostiPortEvent( 3842285809Sscottl tiRoot, 3843285809Sscottl tiPortDiscoveryReady, 3844285809Sscottl tiSuccess, 3845285809Sscottl (void *) tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3846285809Sscottl ); 3847285809Sscottl#endif 3848285809Sscottl 3849285809Sscottl return; 3850285809Sscottl } 3851285809Sscottl 3852285809Sscottl /* setup identify device data IO structure */ 3853285809Sscottl tdIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle; 3854285809Sscottl tdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag = agNULL; 3855285809Sscottl tdIORequestBody->IOType.InitiatorTMIO.TaskTag = agNULL; 3856285809Sscottl 3857285809Sscottl /* initialize tiDevhandle */ 3858285809Sscottl tdIORequestBody->tiDevHandle = &(oneDeviceData->tiDeviceHandle); 3859285809Sscottl tdIORequestBody->tiDevHandle->tdData = oneDeviceData; 3860285809Sscottl 3861285809Sscottl /* initialize tiIORequest */ 3862285809Sscottl tdIORequestBody->tiIORequest = agNULL; 3863285809Sscottl 3864285809Sscottl /* initialize agIORequest */ 3865285809Sscottl agIORequest = &(tdIORequestBody->agIORequest); 3866285809Sscottl agIORequest->osData = (void *) tdIORequestBody; 3867285809Sscottl agIORequest->sdkData = agNULL; /* SA takes care of this */ 3868285809Sscottl 3869285809Sscottl /* set up satIOContext */ 3870285809Sscottl satIOContext = &(tdIORequestBody->transport.SATA.satIOContext); 3871285809Sscottl satIOContext->pSatDevData = &(oneDeviceData->satDevData); 3872285809Sscottl satIOContext->pFis = 3873285809Sscottl &(tdIORequestBody->transport.SATA.agSATARequestBody.fis.fisRegHostToDev); 3874285809Sscottl 3875285809Sscottl 3876285809Sscottl satIOContext->tiRequestBody = tdIORequestBody; 3877285809Sscottl satIOContext->ptiDeviceHandle = &(oneDeviceData->tiDeviceHandle); 3878285809Sscottl satIOContext->tiScsiXchg = agNULL; 3879285809Sscottl satIOContext->satIntIoContext = agNULL; 3880285809Sscottl satIOContext->satOrgIOContext = agNULL; 3881285809Sscottl 3882285809Sscottl /* followings are used only for internal IO */ 3883285809Sscottl satIOContext->currentLBA = 0; 3884285809Sscottl satIOContext->OrgTL = 0; 3885285809Sscottl 3886285809Sscottl 3887285809Sscottl satIOContext->satToBeAbortedIOContext = agNULL; 3888285809Sscottl 3889285809Sscottl satIOContext->NotifyOS = agFALSE; 3890285809Sscottl 3891285809Sscottl satIOContext->pid = tdsaAllShared->Ports[oneDeviceData->phyID].portContext->id; 3892285809Sscottl 3893285809Sscottl status = satAddSATAStartIDDev(tiRoot, 3894285809Sscottl agNULL, 3895285809Sscottl &(oneDeviceData->tiDeviceHandle), 3896285809Sscottl agNULL, 3897285809Sscottl satIOContext 3898285809Sscottl ); 3899285809Sscottl 3900285809Sscottl /* assumption; always new device data */ 3901285809Sscottl 3902285809Sscottl 3903285809Sscottl if (status == tiSuccess) 3904285809Sscottl { 3905285809Sscottl TI_DBG6(("tdssRetrySATAID: successfully sent identify device data\n")); 3906285809Sscottl TI_DBG6(("tdssRetrySATAID: one case did %d \n", oneDeviceData->id)); 3907285809Sscottl } 3908285809Sscottl else 3909285809Sscottl { 3910285809Sscottl TI_DBG1(("tdssRetrySATAID: failed in sending identify device data\n")); 3911285809Sscottl /* put onedevicedata back to free list */ 3912285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 3913285809Sscottl TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList)); 3914285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 3915285809Sscottl /* notifying link up */ 3916285809Sscottl ostiPortEvent ( 3917285809Sscottl tiRoot, 3918285809Sscottl tiPortLinkUp, 3919285809Sscottl tiSuccess, 3920285809Sscottl (void *)tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3921285809Sscottl ); 3922285809Sscottl#ifdef INITIATOR_DRIVER 3923285809Sscottl /* triggers discovery */ 3924285809Sscottl ostiPortEvent( 3925285809Sscottl tiRoot, 3926285809Sscottl tiPortDiscoveryReady, 3927285809Sscottl tiSuccess, 3928285809Sscottl (void *) tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3929285809Sscottl ); 3930285809Sscottl#endif 3931285809Sscottl 3932285809Sscottl } 3933285809Sscottl 3934285809Sscottl return; 3935285809Sscottl} 3936285809Sscottl 3937285809Sscottl/***************************************************************************** 3938285809Sscottl*! \brief tdssSubAddSATAToSharedcontext 3939285809Sscottl* 3940285809Sscottl* Purpose: This function sends identify device data to directly attached SATA 3941285809Sscottl* device after device registration 3942285809Sscottl* 3943285809Sscottl* \param tiRoot: Pointer to TISA initiator driver/port instance. 3944285809Sscottl* \param oneDeviceData Pointer to a device data 3945285809Sscottl* \Return: none 3946285809Sscottl* 3947285809Sscottl*****************************************************************************/ 3948285809SscottlosGLOBAL void 3949285809SscottltdssSubAddSATAToSharedcontext( tiRoot_t *tiRoot, 3950285809Sscottl tdsaDeviceData_t *oneDeviceData 3951285809Sscottl ) 3952285809Sscottl{ 3953285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 3954285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 3955285809Sscottl void *osMemHandle; 3956285809Sscottl tdIORequestBody_t *tdIORequestBody; 3957285809Sscottl bit32 PhysUpper32; 3958285809Sscottl bit32 PhysLower32; 3959285809Sscottl bit32 memAllocStatus; 3960285809Sscottl agsaIORequest_t *agIORequest = agNULL; /* identify device data itself */ 3961285809Sscottl satIOContext_t *satIOContext = agNULL; 3962285809Sscottl bit32 status; 3963285809Sscottl 3964285809Sscottl TI_DBG1(("tdssSubAddSATAToSharedcontext: start\n")); 3965285809Sscottl /* allocate identify device data and sends it */ 3966285809Sscottl /* allocation tdIORequestBody and pass it to satTM() */ 3967285809Sscottl memAllocStatus = ostiAllocMemory( 3968285809Sscottl tiRoot, 3969285809Sscottl &osMemHandle, 3970285809Sscottl (void **)&tdIORequestBody, 3971285809Sscottl &PhysUpper32, 3972285809Sscottl &PhysLower32, 3973285809Sscottl 8, 3974285809Sscottl sizeof(tdIORequestBody_t), 3975285809Sscottl agTRUE 3976285809Sscottl ); 3977285809Sscottl 3978285809Sscottl if (memAllocStatus != tiSuccess) 3979285809Sscottl { 3980285809Sscottl TI_DBG1(("tdssSubAddSATAToSharedcontext: ostiAllocMemory failed... loc 2\n")); 3981285809Sscottl /* notifying link up */ 3982285809Sscottl ostiPortEvent ( 3983285809Sscottl tiRoot, 3984285809Sscottl tiPortLinkUp, 3985285809Sscottl tiSuccess, 3986285809Sscottl (void *)tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3987285809Sscottl ); 3988285809Sscottl#ifdef INITIATOR_DRIVER 3989285809Sscottl /* triggers discovery */ 3990285809Sscottl ostiPortEvent( 3991285809Sscottl tiRoot, 3992285809Sscottl tiPortDiscoveryReady, 3993285809Sscottl tiSuccess, 3994285809Sscottl (void *) tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 3995285809Sscottl ); 3996285809Sscottl#endif 3997285809Sscottl 3998285809Sscottl return; 3999285809Sscottl } 4000285809Sscottl 4001285809Sscottl if (tdIORequestBody == agNULL) 4002285809Sscottl { 4003285809Sscottl TI_DBG1(("tdssSubAddSATAToSharedcontext: ostiAllocMemory returned NULL tdIORequestBody loc 2\n")); 4004285809Sscottl /* notifying link up */ 4005285809Sscottl ostiPortEvent ( 4006285809Sscottl tiRoot, 4007285809Sscottl tiPortLinkUp, 4008285809Sscottl tiSuccess, 4009285809Sscottl (void *)tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 4010285809Sscottl ); 4011285809Sscottl#ifdef INITIATOR_DRIVER 4012285809Sscottl /* triggers discovery */ 4013285809Sscottl ostiPortEvent( 4014285809Sscottl tiRoot, 4015285809Sscottl tiPortDiscoveryReady, 4016285809Sscottl tiSuccess, 4017285809Sscottl (void *) tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 4018285809Sscottl ); 4019285809Sscottl#endif 4020285809Sscottl 4021285809Sscottl return; 4022285809Sscottl } 4023285809Sscottl 4024285809Sscottl /* setup identify device data IO structure */ 4025285809Sscottl tdIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle; 4026285809Sscottl tdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag = agNULL; 4027285809Sscottl tdIORequestBody->IOType.InitiatorTMIO.TaskTag = agNULL; 4028285809Sscottl 4029285809Sscottl /* initialize tiDevhandle */ 4030285809Sscottl tdIORequestBody->tiDevHandle = &(oneDeviceData->tiDeviceHandle); 4031285809Sscottl tdIORequestBody->tiDevHandle->tdData = oneDeviceData; 4032285809Sscottl 4033285809Sscottl /* initialize tiIORequest */ 4034285809Sscottl tdIORequestBody->tiIORequest = agNULL; 4035285809Sscottl 4036285809Sscottl /* initialize agIORequest */ 4037285809Sscottl agIORequest = &(tdIORequestBody->agIORequest); 4038285809Sscottl agIORequest->osData = (void *) tdIORequestBody; 4039285809Sscottl agIORequest->sdkData = agNULL; /* SA takes care of this */ 4040285809Sscottl 4041285809Sscottl /* set up satIOContext */ 4042285809Sscottl satIOContext = &(tdIORequestBody->transport.SATA.satIOContext); 4043285809Sscottl satIOContext->pSatDevData = &(oneDeviceData->satDevData); 4044285809Sscottl satIOContext->pFis = 4045285809Sscottl &(tdIORequestBody->transport.SATA.agSATARequestBody.fis.fisRegHostToDev); 4046285809Sscottl 4047285809Sscottl 4048285809Sscottl satIOContext->tiRequestBody = tdIORequestBody; 4049285809Sscottl satIOContext->ptiDeviceHandle = &(oneDeviceData->tiDeviceHandle); 4050285809Sscottl satIOContext->tiScsiXchg = agNULL; 4051285809Sscottl satIOContext->satIntIoContext = agNULL; 4052285809Sscottl satIOContext->satOrgIOContext = agNULL; 4053285809Sscottl 4054285809Sscottl /* followings are used only for internal IO */ 4055285809Sscottl satIOContext->currentLBA = 0; 4056285809Sscottl satIOContext->OrgTL = 0; 4057285809Sscottl 4058285809Sscottl 4059285809Sscottl satIOContext->satToBeAbortedIOContext = agNULL; 4060285809Sscottl 4061285809Sscottl satIOContext->NotifyOS = agFALSE; 4062285809Sscottl 4063285809Sscottl satIOContext->pid = tdsaAllShared->Ports[oneDeviceData->phyID].portContext->id; 4064285809Sscottl 4065285809Sscottl status = satAddSATAStartIDDev(tiRoot, 4066285809Sscottl agNULL, 4067285809Sscottl &(oneDeviceData->tiDeviceHandle), 4068285809Sscottl agNULL, 4069285809Sscottl satIOContext 4070285809Sscottl ); 4071285809Sscottl 4072285809Sscottl /* assumption; always new device data */ 4073285809Sscottl 4074285809Sscottl 4075285809Sscottl if (status == tiSuccess) 4076285809Sscottl { 4077285809Sscottl TI_DBG6(("tdssSubAddSATAToSharedcontext: successfully sent identify device data\n")); 4078285809Sscottl 4079285809Sscottl /* Add the devicedata to the mainlink */ 4080285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 4081285809Sscottl TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList)); 4082285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 4083285809Sscottl TI_DBG6(("tdssSubAddSATAToSharedcontext: one case did %d \n", oneDeviceData->id)); 4084285809Sscottl } 4085285809Sscottl else 4086285809Sscottl { 4087285809Sscottl TI_DBG1(("tdssSubAddSATAToSharedcontext: failed in sending identify device data\n")); 4088285809Sscottl /* put onedevicedata back to free list */ 4089285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK); 4090285809Sscottl TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList)); 4091285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK); 4092285809Sscottl /* notifying link up */ 4093285809Sscottl ostiPortEvent ( 4094285809Sscottl tiRoot, 4095285809Sscottl tiPortLinkUp, 4096285809Sscottl tiSuccess, 4097285809Sscottl (void *)tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 4098285809Sscottl ); 4099285809Sscottl#ifdef INITIATOR_DRIVER 4100285809Sscottl /* triggers discovery */ 4101285809Sscottl ostiPortEvent( 4102285809Sscottl tiRoot, 4103285809Sscottl tiPortDiscoveryReady, 4104285809Sscottl tiSuccess, 4105285809Sscottl (void *) tdsaAllShared->Ports[oneDeviceData->phyID].tiPortalContext 4106285809Sscottl ); 4107285809Sscottl#endif 4108285809Sscottl 4109285809Sscottl } 4110285809Sscottl 4111285809Sscottl return; 4112285809Sscottl} 4113285809Sscottl 4114285809Sscottl 4115285809Sscottl/***************************************************************************** 4116285809Sscottl*! \brief tdssRemoveSATAFromSharedcontext 4117285809Sscottl* 4118285809Sscottl* Purpose: This function removes a discovered device from a device list of 4119285809Sscottl* a port context 4120285809Sscottl* 4121285809Sscottl* \param tsddPortContext_Ins Pointer to the target port context 4122285809Sscottl* \param tdsaDeviceData_Ins Pointer to the target device 4123285809Sscottl* \param agRoot Pointer to the root data structure of 4124285809Sscottl* TD and Lower layer 4125285809Sscottl 4126285809Sscottl* 4127285809Sscottl* \Return: none 4128285809Sscottl* 4129285809Sscottl*****************************************************************************/ 4130285809SscottlosGLOBAL void 4131285809SscottltdssRemoveSATAFromSharedcontext( 4132285809Sscottl tdsaPortContext_t *tdsaPortContext_Ins, 4133285809Sscottl tdsaDeviceData_t *tdsaDeviceData_ins, 4134285809Sscottl agsaRoot_t *agRoot 4135285809Sscottl ) 4136285809Sscottl{ 4137285809Sscottl TI_DBG1(("tdssRemoveSATAFromSharedcontex: start\n")); 4138285809Sscottl return; 4139285809Sscottl} 4140285809Sscottl 4141285809Sscottl 4142285809Sscottl/***************************************************************************** 4143285809Sscottl*! \brief satSetDevInfo 4144285809Sscottl* 4145285809Sscottl* Purpose: Based on ATA identify device data, this functions sets fields of 4146285809Sscottl* device data maintained in TD layer 4147285809Sscottl* 4148285809Sscottl* \param satDevData Pointer to a device data 4149285809Sscottl* \param SATAIdData Pointer to ATA identify device data 4150285809Sscottl* 4151285809Sscottl* 4152285809Sscottl* \Return: none 4153285809Sscottl* 4154285809Sscottl*****************************************************************************/ 4155285809Sscottlvoid satSetDevInfo( 4156285809Sscottl satDeviceData_t *satDevData, 4157285809Sscottl agsaSATAIdentifyData_t *SATAIdData 4158285809Sscottl ) 4159285809Sscottl{ 4160285809Sscottl TI_DBG3(("satSetDevInfo: start\n")); 4161285809Sscottl 4162285809Sscottl satDevData->satDriveState = SAT_DEV_STATE_NORMAL; 4163285809Sscottl satDevData->satFormatState = agFALSE; 4164285809Sscottl satDevData->satDeviceFaultState = agFALSE; 4165285809Sscottl satDevData->satTmTaskTag = agNULL; 4166285809Sscottl satDevData->satAbortAfterReset = agFALSE; 4167285809Sscottl satDevData->satAbortCalled = agFALSE; 4168285809Sscottl satDevData->satSectorDone = 0; 4169285809Sscottl 4170285809Sscottl /* Qeueu depth, Word 75 */ 4171285809Sscottl satDevData->satNCQMaxIO = SATAIdData->queueDepth + 1; 4172285809Sscottl TI_DBG3(("satSetDevInfo: max queue depth %d\n",satDevData->satNCQMaxIO)); 4173285809Sscottl 4174285809Sscottl /* Support NCQ, if Word 76 bit 8 is set */ 4175285809Sscottl if (SATAIdData->sataCapabilities & 0x100) 4176285809Sscottl { 4177285809Sscottl TI_DBG3(("satSetDevInfo: device supports NCQ\n")); 4178285809Sscottl satDevData->satNCQ = agTRUE; 4179285809Sscottl } 4180285809Sscottl else 4181285809Sscottl { 4182285809Sscottl TI_DBG3(("satSetDevInfo: no NCQ\n")); 4183285809Sscottl satDevData->satNCQ = agFALSE; 4184285809Sscottl } 4185285809Sscottl 4186285809Sscottl /* Support 48 bit addressing, if Word 83 bit 10 and Word 86 bit 10 are set */ 4187285809Sscottl if ((SATAIdData->commandSetSupported1 & 0x400) && 4188285809Sscottl (SATAIdData->commandSetFeatureEnabled1 & 0x400) ) 4189285809Sscottl { 4190285809Sscottl TI_DBG3(("satSetDevInfo: support 48 bit addressing\n")); 4191285809Sscottl satDevData->sat48BitSupport = agTRUE; 4192285809Sscottl } 4193285809Sscottl else 4194285809Sscottl { 4195285809Sscottl TI_DBG3(("satSetDevInfo: NO 48 bit addressing\n")); 4196285809Sscottl satDevData->sat48BitSupport = agFALSE; 4197285809Sscottl } 4198285809Sscottl 4199285809Sscottl /* Support SMART Self Test, word84 bit 1 */ 4200285809Sscottl if (SATAIdData->commandSetFeatureSupportedExt & 0x02) 4201285809Sscottl { 4202285809Sscottl TI_DBG3(("satSetDevInfo: SMART self-test supported \n")); 4203285809Sscottl satDevData->satSMARTSelfTest = agTRUE; 4204285809Sscottl } 4205285809Sscottl else 4206285809Sscottl { 4207285809Sscottl TI_DBG3(("satSetDevInfo: no SMART self-test suppored\n")); 4208285809Sscottl satDevData->satSMARTSelfTest = agFALSE; 4209285809Sscottl } 4210285809Sscottl 4211285809Sscottl 4212285809Sscottl 4213285809Sscottl /* Support SMART feature set, word82 bit 0 */ 4214285809Sscottl if (SATAIdData->commandSetSupported & 0x01) 4215285809Sscottl { 4216285809Sscottl TI_DBG3(("satSetDevInfo: SMART feature set supported \n")); 4217285809Sscottl satDevData->satSMARTFeatureSet = agTRUE; 4218285809Sscottl } 4219285809Sscottl else 4220285809Sscottl { 4221285809Sscottl TI_DBG3(("satSetDevInfo: no SMART feature set suppored\n")); 4222285809Sscottl satDevData->satSMARTFeatureSet = agFALSE; 4223285809Sscottl } 4224285809Sscottl 4225285809Sscottl 4226285809Sscottl 4227285809Sscottl /* Support SMART enabled, word85 bit 0 */ 4228285809Sscottl if (SATAIdData->commandSetFeatureEnabled & 0x01) 4229285809Sscottl { 4230285809Sscottl TI_DBG3(("satSetDevInfo: SMART enabled \n")); 4231285809Sscottl satDevData->satSMARTEnabled = agTRUE; 4232285809Sscottl } 4233285809Sscottl else 4234285809Sscottl { 4235285809Sscottl TI_DBG3(("satSetDevInfo: no SMART enabled\n")); 4236285809Sscottl satDevData->satSMARTEnabled = agFALSE; 4237285809Sscottl } 4238285809Sscottl 4239285809Sscottl satDevData->satVerifyState = 0; 4240285809Sscottl 4241285809Sscottl /* Removable Media feature set support, word82 bit 2 */ 4242285809Sscottl if (SATAIdData->commandSetSupported & 0x4) 4243285809Sscottl { 4244285809Sscottl TI_DBG3(("satSetDevInfo: Removable Media supported \n")); 4245285809Sscottl satDevData->satRemovableMedia = agTRUE; 4246285809Sscottl } 4247285809Sscottl else 4248285809Sscottl { 4249285809Sscottl TI_DBG3(("satSetDevInfo: no Removable Media suppored\n")); 4250285809Sscottl satDevData->satRemovableMedia = agFALSE; 4251285809Sscottl } 4252285809Sscottl 4253285809Sscottl /* Removable Media feature set enabled, word 85, bit 2 */ 4254285809Sscottl if (SATAIdData->commandSetFeatureEnabled & 0x4) 4255285809Sscottl { 4256285809Sscottl TI_DBG3(("satSetDevInfo: Removable Media enabled\n")); 4257285809Sscottl satDevData->satRemovableMediaEnabled = agTRUE; 4258285809Sscottl } 4259285809Sscottl else 4260285809Sscottl { 4261285809Sscottl TI_DBG3(("satSetDevInfo: no Removable Media enabled\n")); 4262285809Sscottl satDevData->satRemovableMediaEnabled = agFALSE; 4263285809Sscottl } 4264285809Sscottl 4265285809Sscottl /* DMA Support, word49 bit8 */ 4266285809Sscottl if (SATAIdData->dma_lba_iod_ios_stimer & 0x100) 4267285809Sscottl { 4268285809Sscottl TI_DBG3(("satSetDevInfo: DMA supported \n")); 4269285809Sscottl satDevData->satDMASupport = agTRUE; 4270285809Sscottl } 4271285809Sscottl else 4272285809Sscottl { 4273285809Sscottl TI_DBG3(("satSetDevInfo: no DMA suppored\n")); 4274285809Sscottl satDevData->satDMASupport = agFALSE; 4275285809Sscottl } 4276285809Sscottl 4277285809Sscottl /* DMA Enabled, word88 bit0-6, bit8-14*/ 4278285809Sscottl /* 0x7F7F = 0111 1111 0111 1111*/ 4279285809Sscottl if (SATAIdData->ultraDMAModes & 0x7F7F) 4280285809Sscottl { 4281285809Sscottl TI_DBG3(("satSetDevInfo: DMA enabled \n")); 4282285809Sscottl satDevData->satDMAEnabled = agTRUE; 4283285809Sscottl } 4284285809Sscottl else 4285285809Sscottl { 4286285809Sscottl TI_DBG3(("satSetDevInfo: no DMA enabled\n")); 4287285809Sscottl satDevData->satDMAEnabled = agFALSE; 4288285809Sscottl } 4289285809Sscottl 4290285809Sscottl /* 4291285809Sscottl setting MaxUserAddrSectors: max user addressable setctors 4292285809Sscottl word60 - 61, should be 0x 0F FF FF FF 4293285809Sscottl */ 4294285809Sscottl satDevData->satMaxUserAddrSectors 4295285809Sscottl = (SATAIdData->numOfUserAddressableSectorsHi << (8*2) ) 4296285809Sscottl + SATAIdData->numOfUserAddressableSectorsLo; 4297285809Sscottl TI_DBG3(("satSetDevInfo: MaxUserAddrSectors 0x%x decimal %d\n", satDevData->satMaxUserAddrSectors, satDevData->satMaxUserAddrSectors)); 4298285809Sscottl /* Support DMADIR, if Word 62 bit 8 is set */ 4299285809Sscottl if (SATAIdData->word62_74[0] & 0x8000) 4300285809Sscottl { 4301285809Sscottl TI_DBG3(("satSetDevInfo: DMADIR enabled\n")); 4302285809Sscottl satDevData->satDMADIRSupport = agTRUE; 4303285809Sscottl } 4304285809Sscottl else 4305285809Sscottl { 4306285809Sscottl TI_DBG3(("satSetDevInfo: DMADIR disabled\n")); 4307285809Sscottl satDevData->satDMADIRSupport = agFALSE; 4308285809Sscottl } 4309285809Sscottl 4310285809Sscottl 4311285809Sscottl /* write cache enabled for caching mode page SAT Table 67 p69, word85 bit5 */ 4312285809Sscottl if (SATAIdData->commandSetFeatureEnabled & 0x20) 4313285809Sscottl { 4314285809Sscottl TI_DBG3(("satSetDevInfo: write cache enabled\n")); 4315285809Sscottl satDevData->satWriteCacheEnabled = agTRUE; 4316285809Sscottl } 4317285809Sscottl else 4318285809Sscottl { 4319285809Sscottl TI_DBG3(("satSetDevInfo: no write cache enabled\n")); 4320285809Sscottl satDevData->satWriteCacheEnabled = agFALSE; 4321285809Sscottl } 4322285809Sscottl 4323285809Sscottl /* look ahead enabled for caching mode page SAT Table 67 p69, word85 bit6 */ 4324285809Sscottl if (SATAIdData->commandSetFeatureEnabled & 0x40) 4325285809Sscottl { 4326285809Sscottl TI_DBG3(("satSetDevInfo: look ahead enabled\n")); 4327285809Sscottl satDevData->satLookAheadEnabled = agTRUE; 4328285809Sscottl } 4329285809Sscottl else 4330285809Sscottl { 4331285809Sscottl TI_DBG3(("satSetDevInfo: no look ahead enabled\n")); 4332285809Sscottl satDevData->satLookAheadEnabled = agFALSE; 4333285809Sscottl } 4334285809Sscottl 4335285809Sscottl /* Support WWN, if Word 87 bit 8 is set */ 4336285809Sscottl if (SATAIdData->commandSetFeatureDefault & 0x100) 4337285809Sscottl { 4338285809Sscottl TI_DBG3(("satSetDevInfo: device supports WWN\n")); 4339285809Sscottl satDevData->satWWNSupport = agTRUE; 4340285809Sscottl } 4341285809Sscottl else 4342285809Sscottl { 4343285809Sscottl TI_DBG3(("satSetDevInfo: no WWN\n")); 4344285809Sscottl satDevData->satWWNSupport = agFALSE; 4345285809Sscottl } 4346285809Sscottl 4347285809Sscottl 4348285809Sscottl return; 4349285809Sscottl} 4350285809Sscottl 4351285809Sscottl/***************************************************************************** 4352285809Sscottl*! \brief satInquiryCB 4353285809Sscottl* 4354285809Sscottl* This routine is a callback function for satInquiry() 4355285809Sscottl* 4356285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 4357285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 4358285809Sscottl* \param agIOStatus: Status of completed I/O. 4359285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 4360285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 4361285809Sscottl* length. 4362285809Sscottl* \param agParam: Additional info based on status. 4363285809Sscottl* \param ioContext: Pointer to satIOContext_t. 4364285809Sscottl* 4365285809Sscottl* \return: none 4366285809Sscottl* 4367285809Sscottl*****************************************************************************/ 4368285809Sscottlvoid satInquiryCB( 4369285809Sscottl agsaRoot_t *agRoot, 4370285809Sscottl agsaIORequest_t *agIORequest, 4371285809Sscottl bit32 agIOStatus, 4372285809Sscottl agsaFisHeader_t *agFirstDword, 4373285809Sscottl bit32 agIOInfoLen, 4374285809Sscottl void *agParam, 4375285809Sscottl void *ioContext 4376285809Sscottl ) 4377285809Sscottl{ 4378285809Sscottl /* 4379285809Sscottl In the process of Inquiry 4380285809Sscottl Process SAT_IDENTIFY_DEVICE 4381285809Sscottl */ 4382285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 4383285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 4384285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 4385285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 4386285809Sscottl tdIORequestBody_t *tdIORequestBody; 4387285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 4388285809Sscottl satIOContext_t *satIOContext; 4389285809Sscottl satIOContext_t *satOrgIOContext; 4390285809Sscottl satInternalIo_t *satIntIo; 4391285809Sscottl satDeviceData_t *satDevData; 4392285809Sscottl#ifdef TD_DEBUG_ENABLE 4393285809Sscottl tdsaDeviceData_t *tdsaDeviceData; 4394285809Sscottl bit32 ataStatus = 0; 4395285809Sscottl bit32 ataError; 4396285809Sscottl agsaFisPioSetupHeader_t *satPIOSetupHeader = agNULL; 4397285809Sscottl#endif 4398285809Sscottl scsiRspSense_t *pSense; 4399285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 4400285809Sscottl tiIORequest_t *tiOrgIORequest; 4401285809Sscottl tiScsiInitiatorRequest_t *tiScsiRequest; /* TD's tiScsiXchg */ 4402285809Sscottl tiScsiInitiatorRequest_t *tiOrgScsiRequest; /* OS's tiScsiXchg */ 4403285809Sscottl agsaSATAIdentifyData_t *pSATAIdData; 4404285809Sscottl bit8 *pInquiry; 4405285809Sscottl bit8 page = 0xFF; 4406285809Sscottl bit16 *tmpptr,tmpptr_tmp; 4407285809Sscottl bit32 x; 4408285809Sscottl bit32 lenReceived; 4409285809Sscottl bit32 lenNeeded = 0; 4410285809Sscottl 4411285809Sscottl TI_DBG6(("satInquiryCB: start\n")); 4412285809Sscottl TI_DBG6(("satInquiryCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 4413285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 4414285809Sscottl satIOContext = (satIOContext_t *) ioContext; 4415285809Sscottl satIntIo = satIOContext->satIntIoContext; 4416285809Sscottl satDevData = satIOContext->pSatDevData; 4417285809Sscottl#ifdef TD_DEBUG_ENABLE 4418285809Sscottl tdsaDeviceData = (tdsaDeviceData_t *)satDevData->satSaDeviceData; 4419285809Sscottl#endif 4420285809Sscottl tiScsiRequest = satIOContext->tiScsiXchg; 4421285809Sscottl if (satIntIo == agNULL) 4422285809Sscottl { 4423285809Sscottl TI_DBG6(("satInquiryCB: External, OS generated\n")); 4424285809Sscottl pSense = satIOContext->pSense; 4425285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 4426285809Sscottl satOrgIOContext = satIOContext; 4427285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 4428285809Sscottl } 4429285809Sscottl else 4430285809Sscottl { 4431285809Sscottl TI_DBG6(("satInquiryCB: Internal, TD generated\n")); 4432285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 4433285809Sscottl if (satOrgIOContext == agNULL) 4434285809Sscottl { 4435285809Sscottl TI_DBG1(("satInquiryCB: satOrgIOContext is NULL, wrong\n")); 4436285809Sscottl return; 4437285809Sscottl } 4438285809Sscottl else 4439285809Sscottl { 4440285809Sscottl TI_DBG6(("satInquiryCB: satOrgIOContext is NOT NULL\n")); 4441285809Sscottl } 4442285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 4443285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 4444285809Sscottl pSense = satOrgIOContext->pSense; 4445285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 4446285809Sscottl } 4447285809Sscottl 4448285809Sscottl tiOrgScsiRequest = satOrgIOContext->tiScsiXchg; 4449285809Sscottl pInquiry = (bit8 *) tiOrgScsiRequest->sglVirtualAddr; 4450285809Sscottl 4451285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 4452285809Sscottl tdIORequestBody->ioStarted = agFALSE; 4453285809Sscottl 4454285809Sscottl TI_DBG3(("satInquiryCB: did %d\n", tdsaDeviceData->id)); 4455285809Sscottl 4456285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 4457285809Sscottl { 4458285809Sscottl TI_DBG1(("satInquiryCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 4459285809Sscottl if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY) 4460285809Sscottl { 4461285809Sscottl TI_DBG1(("satInquiryCB: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY\n")); 4462285809Sscottl /* should NOT be retried */ 4463285809Sscottl ostiInitiatorIOCompleted ( 4464285809Sscottl tiRoot, 4465285809Sscottl tiOrgIORequest, 4466285809Sscottl tiIOFailed, 4467285809Sscottl tiDetailNoLogin, 4468285809Sscottl agNULL, 4469285809Sscottl satOrgIOContext->interruptContext 4470285809Sscottl ); 4471285809Sscottl } 4472285809Sscottl else 4473285809Sscottl { 4474285809Sscottl TI_DBG1(("satInquiryCB: NOT OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY\n")); 4475285809Sscottl ostiInitiatorIOCompleted ( 4476285809Sscottl tiRoot, 4477285809Sscottl tiOrgIORequest, 4478285809Sscottl tiIOFailed, 4479285809Sscottl tiDetailNoLogin, 4480285809Sscottl agNULL, 4481285809Sscottl satOrgIOContext->interruptContext 4482285809Sscottl ); 4483285809Sscottl } 4484285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 4485285809Sscottl 4486285809Sscottl satFreeIntIoResource( tiRoot, 4487285809Sscottl satDevData, 4488285809Sscottl satIntIo); 4489285809Sscottl return; 4490285809Sscottl } 4491285809Sscottl if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED || 4492285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION || 4493285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BREAK || 4494285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS || 4495285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION || 4496285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED || 4497285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION || 4498285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR || 4499285809Sscottl agIOStatus == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY 4500285809Sscottl ) 4501285809Sscottl { 4502285809Sscottl TI_DBG1(("satInquiryCB: OSSA_IO_OPEN_CNX_ERROR\n")); 4503285809Sscottl 4504285809Sscottl ostiInitiatorIOCompleted ( 4505285809Sscottl tiRoot, 4506285809Sscottl tiOrgIORequest, 4507285809Sscottl tiIOFailed, 4508285809Sscottl tiDetailNoLogin, 4509285809Sscottl agNULL, 4510285809Sscottl satOrgIOContext->interruptContext 4511285809Sscottl ); 4512285809Sscottl 4513285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 4514285809Sscottl 4515285809Sscottl satFreeIntIoResource( tiRoot, 4516285809Sscottl satDevData, 4517285809Sscottl satIntIo); 4518285809Sscottl return; 4519285809Sscottl } 4520285809Sscottl 4521285809Sscottl if ( agIOStatus != OSSA_IO_SUCCESS || 4522285809Sscottl (agIOStatus == OSSA_IO_SUCCESS && agFirstDword != agNULL && agIOInfoLen != 0) 4523285809Sscottl ) 4524285809Sscottl { 4525285809Sscottl#ifdef TD_DEBUG_ENABLE 4526285809Sscottl // only agsaFisPioSetup_t is expected 4527285809Sscottl satPIOSetupHeader = (agsaFisPioSetupHeader_t *)&(agFirstDword->PioSetup); 4528285809Sscottl ataStatus = satPIOSetupHeader->status; // ATA Status register 4529285809Sscottl ataError = satPIOSetupHeader->error; // ATA Eror register 4530285809Sscottl#endif 4531285809Sscottl TI_DBG1(("satInquiryCB: ataStatus 0x%x ataError 0x%x\n", ataStatus, ataError)); 4532285809Sscottl /* Process abort case */ 4533285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 4534285809Sscottl { 4535285809Sscottl satProcessAbort(tiRoot, 4536285809Sscottl tiOrgIORequest, 4537285809Sscottl satOrgIOContext 4538285809Sscottl ); 4539285809Sscottl 4540285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 4541285809Sscottl 4542285809Sscottl satFreeIntIoResource( tiRoot, 4543285809Sscottl satDevData, 4544285809Sscottl satIntIo); 4545285809Sscottl return; 4546285809Sscottl } 4547285809Sscottl 4548285809Sscottl ostiInitiatorIOCompleted ( 4549285809Sscottl tiRoot, 4550285809Sscottl tiOrgIORequest, 4551285809Sscottl tiIOFailed, 4552285809Sscottl tiDetailOtherError, 4553285809Sscottl agNULL, 4554285809Sscottl satOrgIOContext->interruptContext 4555285809Sscottl ); 4556285809Sscottl 4557285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 4558285809Sscottl 4559285809Sscottl satFreeIntIoResource( tiRoot, 4560285809Sscottl satDevData, 4561285809Sscottl satIntIo); 4562285809Sscottl return; 4563285809Sscottl } 4564285809Sscottl 4565285809Sscottl /* success */ 4566285809Sscottl 4567285809Sscottl 4568285809Sscottl /* Convert to host endian */ 4569285809Sscottl tmpptr = (bit16*)(tiScsiRequest->sglVirtualAddr); 4570285809Sscottl for (x=0; x < sizeof(agsaSATAIdentifyData_t)/sizeof(bit16); x++) 4571285809Sscottl { 4572285809Sscottl OSSA_READ_LE_16(AGROOT, &tmpptr_tmp, tmpptr, 0); 4573285809Sscottl *tmpptr = tmpptr_tmp; 4574285809Sscottl tmpptr++; 4575285809Sscottl /*Print tmpptr_tmp here for debugging purpose*/ 4576285809Sscottl } 4577285809Sscottl 4578285809Sscottl pSATAIdData = (agsaSATAIdentifyData_t *)(tiScsiRequest->sglVirtualAddr); 4579285809Sscottl 4580285809Sscottl TI_DBG5(("satInquiryCB: OS satOrgIOContext %p \n", satOrgIOContext)); 4581285809Sscottl TI_DBG5(("satInquiryCB: TD satIOContext %p \n", satIOContext)); 4582285809Sscottl TI_DBG5(("satInquiryCB: OS tiScsiXchg %p \n", satOrgIOContext->tiScsiXchg)); 4583285809Sscottl TI_DBG5(("satInquiryCB: TD tiScsiXchg %p \n", satIOContext->tiScsiXchg)); 4584285809Sscottl 4585285809Sscottl /* copy ID Dev data to satDevData */ 4586285809Sscottl satDevData->satIdentifyData = *pSATAIdData; 4587285809Sscottl satDevData->IDDeviceValid = agTRUE; 4588285809Sscottl#ifdef TD_INTERNAL_DEBUG 4589285809Sscottl tdhexdump("satInquiryCB ID Dev data",(bit8 *)pSATAIdData, sizeof(agsaSATAIdentifyData_t)); 4590285809Sscottl tdhexdump("satInquiryCB Device ID Dev data",(bit8 *)&satDevData->satIdentifyData, sizeof(agsaSATAIdentifyData_t)); 4591285809Sscottl#endif 4592285809Sscottl// tdhexdump("satInquiryCB Device ID Dev data",(bit8 *)&satDevData->satIdentifyData, sizeof(agsaSATAIdentifyData_t)); 4593285809Sscottl 4594285809Sscottl /* set satDevData fields from IndentifyData */ 4595285809Sscottl satSetDevInfo(satDevData,pSATAIdData); 4596285809Sscottl 4597285809Sscottl lenReceived = ((scsiCmnd->cdb[3]) << 8) + scsiCmnd->cdb[4]; 4598285809Sscottl 4599285809Sscottl /* SPC-4, spec 6.4 p 141 */ 4600285809Sscottl /* EVPD bit == 0 */ 4601285809Sscottl if (!(scsiCmnd->cdb[1] & SCSI_EVPD_MASK)) 4602285809Sscottl { 4603285809Sscottl /* Returns the standard INQUIRY data */ 4604285809Sscottl lenNeeded = STANDARD_INQUIRY_SIZE; 4605285809Sscottl 4606285809Sscottl 4607285809Sscottl satInquiryStandard(pInquiry, pSATAIdData, scsiCmnd); 4608285809Sscottl //tdhexdump("satInquiryCB ***standard***", (bit8 *)pInquiry, 36); 4609285809Sscottl 4610285809Sscottl } 4611285809Sscottl else 4612285809Sscottl { 4613285809Sscottl /* EVPD bit != 0 && PAGE CODE != 0 */ 4614285809Sscottl /* returns the pages of vital product data information */ 4615285809Sscottl 4616285809Sscottl /* we must support page 00h, 83h and 89h */ 4617285809Sscottl page = scsiCmnd->cdb[2]; 4618285809Sscottl if ((page != INQUIRY_SUPPORTED_VPD_PAGE) && 4619285809Sscottl (page != INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE) && 4620285809Sscottl (page != INQUIRY_ATA_INFORMATION_VPD_PAGE)) 4621285809Sscottl { 4622285809Sscottl satSetSensePayload( pSense, 4623285809Sscottl SCSI_SNSKEY_ILLEGAL_REQUEST, 4624285809Sscottl 0, 4625285809Sscottl SCSI_SNSCODE_INVALID_FIELD_IN_CDB, 4626285809Sscottl satOrgIOContext); 4627285809Sscottl 4628285809Sscottl ostiInitiatorIOCompleted( tiRoot, 4629285809Sscottl tiOrgIORequest, 4630285809Sscottl tiIOSuccess, 4631285809Sscottl SCSI_STAT_CHECK_CONDITION, 4632285809Sscottl satOrgIOContext->pTiSenseData, 4633285809Sscottl satOrgIOContext->interruptContext ); 4634285809Sscottl 4635285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 4636285809Sscottl 4637285809Sscottl satFreeIntIoResource( tiRoot, 4638285809Sscottl satDevData, 4639285809Sscottl satIntIo); 4640285809Sscottl TI_DBG1(("satInquiryCB: invalid PAGE CODE 0x%x\n", page)); 4641285809Sscottl return; 4642285809Sscottl } 4643285809Sscottl 4644285809Sscottl /* checking length */ 4645285809Sscottl switch (page) 4646285809Sscottl { 4647285809Sscottl case INQUIRY_SUPPORTED_VPD_PAGE: 4648285809Sscottl lenNeeded = SATA_PAGE0_INQUIRY_SIZE; /* 36 */ 4649285809Sscottl break; 4650285809Sscottl case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 4651285809Sscottl if (satDevData->satWWNSupport) 4652285809Sscottl { 4653285809Sscottl lenNeeded = SATA_PAGE83_INQUIRY_WWN_SIZE; /* 16 */ 4654285809Sscottl } 4655285809Sscottl else 4656285809Sscottl { 4657285809Sscottl lenNeeded = SATA_PAGE83_INQUIRY_NO_WWN_SIZE; /* 76 */ 4658285809Sscottl } 4659285809Sscottl break; 4660285809Sscottl case INQUIRY_ATA_INFORMATION_VPD_PAGE: 4661285809Sscottl lenNeeded = SATA_PAGE89_INQUIRY_SIZE; /* 572 */ 4662285809Sscottl break; 4663285809Sscottl default: 4664285809Sscottl TI_DBG1(("satInquiryCB: wrong!!! invalid PAGE CODE 0x%x\n", page)); 4665285809Sscottl break; 4666285809Sscottl } 4667285809Sscottl 4668285809Sscottl 4669285809Sscottl /* 4670285809Sscottl * Fill in the Inquiry data depending on what Inquiry data we are returning. 4671285809Sscottl */ 4672285809Sscottl switch (page) 4673285809Sscottl { 4674285809Sscottl case INQUIRY_SUPPORTED_VPD_PAGE: 4675285809Sscottl satInquiryPage0(pInquiry, pSATAIdData); 4676285809Sscottl break; 4677285809Sscottl case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 4678285809Sscottl satInquiryPage83(pInquiry, pSATAIdData, satDevData); 4679285809Sscottl break; 4680285809Sscottl case INQUIRY_ATA_INFORMATION_VPD_PAGE: 4681285809Sscottl satInquiryPage89(pInquiry, pSATAIdData, satDevData); 4682285809Sscottl break; 4683285809Sscottl default: 4684285809Sscottl TI_DBG1(("satInquiryCB: wrong!!! invalidinvalid PAGE CODE 0x%x\n", page)); 4685285809Sscottl break; 4686285809Sscottl } 4687285809Sscottl } /* else */ 4688285809Sscottl 4689285809Sscottl TI_DBG6(("satInquiryCB: calling ostiInitiatorIOCompleted\n")); 4690285809Sscottl 4691285809Sscottl if (lenReceived > lenNeeded) 4692285809Sscottl { 4693285809Sscottl TI_DBG6(("satInquiryCB reporting underrun lenNeeded=0x%x lenReceived=0x%x tiIORequest=%p\n", 4694285809Sscottl lenNeeded, lenReceived, tiOrgIORequest)); 4695285809Sscottl 4696285809Sscottl ostiInitiatorIOCompleted( tiRoot, 4697285809Sscottl tiOrgIORequest, 4698285809Sscottl tiIOUnderRun, 4699285809Sscottl lenReceived - lenNeeded, 4700285809Sscottl agNULL, 4701285809Sscottl satOrgIOContext->interruptContext ); 4702285809Sscottl } 4703285809Sscottl else 4704285809Sscottl { 4705285809Sscottl ostiInitiatorIOCompleted( tiRoot, 4706285809Sscottl tiOrgIORequest, 4707285809Sscottl tiIOSuccess, 4708285809Sscottl SCSI_STAT_GOOD, 4709285809Sscottl agNULL, 4710285809Sscottl satOrgIOContext->interruptContext); 4711285809Sscottl } 4712285809Sscottl 4713285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 4714285809Sscottl 4715285809Sscottl satFreeIntIoResource( tiRoot, 4716285809Sscottl satDevData, 4717285809Sscottl satIntIo); 4718285809Sscottl TI_DBG5(("satInquiryCB: device %p pending IO %d\n", satDevData, satDevData->satPendingIO)); 4719285809Sscottl TI_DBG6(("satInquiryCB: end\n")); 4720285809Sscottl return; 4721285809Sscottl} 4722285809Sscottl 4723285809Sscottl 4724285809Sscottl/*****************************************************************************/ 4725285809Sscottl/*! \brief satInquiryIntCB. 4726285809Sscottl * 4727285809Sscottl * This function is part of INQUIRY SAT implementation. This is called when 4728285809Sscottl * ATA identify device data is available. 4729285809Sscottl * 4730285809Sscottl * \param tiRoot: Pointer to TISA initiator driver/port instance. 4731285809Sscottl * \param tiIORequest: Pointer to TISA I/O request context for this I/O. 4732285809Sscottl * \param tiDeviceHandle: Pointer to TISA device handle for this I/O. 4733285809Sscottl * \param tiScsiRequest: Pointer to TISA SCSI I/O request and SGL list. 4734285809Sscottl * \param satIOContext_t: Pointer to the SAT IO Context 4735285809Sscottl * 4736285809Sscottl * \return If command is started successfully 4737285809Sscottl * - \e tiSuccess: I/O request successfully initiated. 4738285809Sscottl * - \e tiBusy: No resources available, try again later. 4739285809Sscottl * - \e tiIONoDevice: Invalid device handle. 4740285809Sscottl * - \e tiError: Other errors. 4741285809Sscottl */ 4742285809Sscottl/*****************************************************************************/ 4743285809Sscottlvoid satInquiryIntCB( 4744285809Sscottl tiRoot_t *tiRoot, 4745285809Sscottl tiIORequest_t *tiIORequest, 4746285809Sscottl tiDeviceHandle_t *tiDeviceHandle, 4747285809Sscottl tiScsiInitiatorRequest_t *tiScsiRequest, 4748285809Sscottl satIOContext_t *satIOContext 4749285809Sscottl ) 4750285809Sscottl{ 4751285809Sscottl scsiRspSense_t *pSense; 4752285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 4753285809Sscottl satDeviceData_t *satDevData; 4754285809Sscottl agsaSATAIdentifyData_t *pSATAIdData; 4755285809Sscottl 4756285809Sscottl bit8 *pInquiry; 4757285809Sscottl bit8 page = 0xFF; 4758285809Sscottl bit32 lenReceived; 4759285809Sscottl bit32 lenNeeded = 0; 4760285809Sscottl 4761285809Sscottl TI_DBG6(("satInquiryIntCB: start\n")); 4762285809Sscottl 4763285809Sscottl pSense = satIOContext->pSense; 4764285809Sscottl scsiCmnd = &tiScsiRequest->scsiCmnd; 4765285809Sscottl pInquiry = (bit8 *) tiScsiRequest->sglVirtualAddr; 4766285809Sscottl satDevData = satIOContext->pSatDevData; 4767285809Sscottl pSATAIdData = &satDevData->satIdentifyData; 4768285809Sscottl 4769285809Sscottl 4770285809Sscottl lenReceived = ((scsiCmnd->cdb[3]) << 8) + scsiCmnd->cdb[4]; 4771285809Sscottl 4772285809Sscottl /* SPC-4, spec 6.4 p 141 */ 4773285809Sscottl /* EVPD bit == 0 */ 4774285809Sscottl if (!(scsiCmnd->cdb[1] & SCSI_EVPD_MASK)) 4775285809Sscottl { 4776285809Sscottl /* Returns the standard INQUIRY data */ 4777285809Sscottl lenNeeded = STANDARD_INQUIRY_SIZE; 4778285809Sscottl 4779285809Sscottl satInquiryStandard(pInquiry, pSATAIdData, scsiCmnd); 4780285809Sscottl //tdhexdump("satInquiryIntCB ***standard***", (bit8 *)pInquiry, 36); 4781285809Sscottl 4782285809Sscottl } 4783285809Sscottl else 4784285809Sscottl { 4785285809Sscottl /* EVPD bit != 0 && PAGE CODE != 0 */ 4786285809Sscottl /* returns the pages of vital product data information */ 4787285809Sscottl 4788285809Sscottl /* we must support page 00h, 83h and 89h */ 4789285809Sscottl page = scsiCmnd->cdb[2]; 4790285809Sscottl if ((page != INQUIRY_SUPPORTED_VPD_PAGE) && 4791285809Sscottl (page != INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE) && 4792285809Sscottl (page != INQUIRY_ATA_INFORMATION_VPD_PAGE) && 4793285809Sscottl (page != INQUIRY_UNIT_SERIAL_NUMBER_VPD_PAGE)) 4794285809Sscottl { 4795285809Sscottl satSetSensePayload( pSense, 4796285809Sscottl SCSI_SNSKEY_ILLEGAL_REQUEST, 4797285809Sscottl 0, 4798285809Sscottl SCSI_SNSCODE_INVALID_FIELD_IN_CDB, 4799285809Sscottl satIOContext); 4800285809Sscottl 4801285809Sscottl ostiInitiatorIOCompleted( tiRoot, 4802285809Sscottl tiIORequest, 4803285809Sscottl tiIOSuccess, 4804285809Sscottl SCSI_STAT_CHECK_CONDITION, 4805285809Sscottl satIOContext->pTiSenseData, 4806285809Sscottl satIOContext->interruptContext ); 4807285809Sscottl 4808285809Sscottl TI_DBG1(("satInquiryIntCB: invalid PAGE CODE 0x%x\n", page)); 4809285809Sscottl return; 4810285809Sscottl } 4811285809Sscottl 4812285809Sscottl /* checking length */ 4813285809Sscottl switch (page) 4814285809Sscottl { 4815285809Sscottl case INQUIRY_SUPPORTED_VPD_PAGE: 4816285809Sscottl lenNeeded = SATA_PAGE0_INQUIRY_SIZE; /* 36 */ 4817285809Sscottl break; 4818285809Sscottl case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 4819285809Sscottl if (satDevData->satWWNSupport) 4820285809Sscottl { 4821285809Sscottl lenNeeded = SATA_PAGE83_INQUIRY_WWN_SIZE; /* 16 */ 4822285809Sscottl } 4823285809Sscottl else 4824285809Sscottl { 4825285809Sscottl lenNeeded = SATA_PAGE83_INQUIRY_NO_WWN_SIZE; /* 76 */ 4826285809Sscottl } 4827285809Sscottl break; 4828285809Sscottl case INQUIRY_ATA_INFORMATION_VPD_PAGE: 4829285809Sscottl lenNeeded = SATA_PAGE89_INQUIRY_SIZE; /* 572 */ 4830285809Sscottl break; 4831285809Sscottl case INQUIRY_UNIT_SERIAL_NUMBER_VPD_PAGE: 4832285809Sscottl lenNeeded = SATA_PAGE80_INQUIRY_SIZE; /* 24 */ 4833285809Sscottl break; 4834285809Sscottl 4835285809Sscottl default: 4836285809Sscottl TI_DBG1(("satInquiryIntCB: wrong!!! invalidinvalid PAGE CODE 0x%x\n", page)); 4837285809Sscottl break; 4838285809Sscottl } 4839285809Sscottl 4840285809Sscottl 4841285809Sscottl /* 4842285809Sscottl * Fill in the Inquiry data depending on what Inquiry data we are returning. 4843285809Sscottl */ 4844285809Sscottl switch (page) 4845285809Sscottl { 4846285809Sscottl case INQUIRY_SUPPORTED_VPD_PAGE: 4847285809Sscottl satInquiryPage0(pInquiry, pSATAIdData); 4848285809Sscottl break; 4849285809Sscottl case INQUIRY_DEVICE_IDENTIFICATION_VPD_PAGE: 4850285809Sscottl satInquiryPage83(pInquiry, pSATAIdData, satDevData); 4851285809Sscottl break; 4852285809Sscottl case INQUIRY_ATA_INFORMATION_VPD_PAGE: 4853285809Sscottl satInquiryPage89(pInquiry, pSATAIdData, satDevData); 4854285809Sscottl break; 4855285809Sscottl case INQUIRY_UNIT_SERIAL_NUMBER_VPD_PAGE: 4856285809Sscottl satInquiryPage80(pInquiry, pSATAIdData); 4857285809Sscottl break; 4858285809Sscottl default: 4859285809Sscottl TI_DBG1(("satInquiryIntCB: wrong!!! invalidinvalid PAGE CODE 0x%x\n", page)); 4860285809Sscottl break; 4861285809Sscottl } 4862285809Sscottl } /* else */ 4863285809Sscottl 4864285809Sscottl TI_DBG6(("satInquiryIntCB: calling ostiInitiatorIOCompleted\n")); 4865285809Sscottl 4866285809Sscottl if (lenReceived > lenNeeded) 4867285809Sscottl { 4868285809Sscottl TI_DBG6(("satInquiryIntCB reporting underrun lenNeeded=0x%x lenReceived=0x%x tiIORequest=%p\n", 4869285809Sscottl lenNeeded, lenReceived, tiIORequest)); 4870285809Sscottl 4871285809Sscottl ostiInitiatorIOCompleted( tiRoot, 4872285809Sscottl tiIORequest, 4873285809Sscottl tiIOUnderRun, 4874285809Sscottl lenReceived - lenNeeded, 4875285809Sscottl agNULL, 4876285809Sscottl satIOContext->interruptContext ); 4877285809Sscottl } 4878285809Sscottl else 4879285809Sscottl { 4880285809Sscottl ostiInitiatorIOCompleted( tiRoot, 4881285809Sscottl tiIORequest, 4882285809Sscottl tiIOSuccess, 4883285809Sscottl SCSI_STAT_GOOD, 4884285809Sscottl agNULL, 4885285809Sscottl satIOContext->interruptContext); 4886285809Sscottl } 4887285809Sscottl 4888285809Sscottl TI_DBG5(("satInquiryIntCB: device %p pending IO %d\n", satDevData, satDevData->satPendingIO)); 4889285809Sscottl TI_DBG6(("satInquiryIntCB: end\n")); 4890285809Sscottl return; 4891285809Sscottl} 4892285809Sscottl 4893285809Sscottl 4894285809Sscottl/***************************************************************************** 4895285809Sscottl*! \brief satVerify10CB 4896285809Sscottl* 4897285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 4898285809Sscottl* This CB routine deals with Verify(10) completion. 4899285809Sscottl* 4900285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 4901285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 4902285809Sscottl* \param agIOStatus: Status of completed I/O. 4903285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 4904285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 4905285809Sscottl* length. 4906285809Sscottl* \param agParam: Additional info based on status. 4907285809Sscottl* \param ioContext: Pointer to satIOContext_t. 4908285809Sscottl* 4909285809Sscottl* \return: none 4910285809Sscottl* 4911285809Sscottl*****************************************************************************/ 4912285809Sscottlvoid satVerify10CB( 4913285809Sscottl agsaRoot_t *agRoot, 4914285809Sscottl agsaIORequest_t *agIORequest, 4915285809Sscottl bit32 agIOStatus, 4916285809Sscottl agsaFisHeader_t *agFirstDword, 4917285809Sscottl bit32 agIOInfoLen, 4918285809Sscottl void *agParam, 4919285809Sscottl void *ioContext 4920285809Sscottl ) 4921285809Sscottl{ 4922285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 4923285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 4924285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 4925285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 4926285809Sscottl tdIORequestBody_t *tdIORequestBody; 4927285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 4928285809Sscottl satIOContext_t *satIOContext; 4929285809Sscottl satIOContext_t *satOrgIOContext; 4930285809Sscottl satInternalIo_t *satIntIo; 4931285809Sscottl satDeviceData_t *satDevData; 4932285809Sscottl scsiRspSense_t *pSense; 4933285809Sscottl tiIORequest_t *tiOrgIORequest; 4934285809Sscottl 4935285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 4936285809Sscottl bit32 ataStatus = 0; 4937285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 4938285809Sscottl 4939285809Sscottl TI_DBG5(("satVerify10CB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 4940285809Sscottl 4941285809Sscottl /* internally generate tiIOContext */ 4942285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 4943285809Sscottl satIOContext = (satIOContext_t *) ioContext; 4944285809Sscottl satIntIo = satIOContext->satIntIoContext; 4945285809Sscottl satDevData = satIOContext->pSatDevData; 4946285809Sscottl hostToDevFis = satIOContext->pFis; 4947285809Sscottl 4948285809Sscottl if (satIntIo == agNULL) 4949285809Sscottl { 4950285809Sscottl TI_DBG4(("satVerify10CB: External satInternalIo_t satIntIoContext\n")); 4951285809Sscottl satOrgIOContext = satIOContext; 4952285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 4953285809Sscottl pSense = satIOContext->pSense; 4954285809Sscottl } 4955285809Sscottl else 4956285809Sscottl { 4957285809Sscottl TI_DBG4(("satVerify10CB: Internal satInternalIo_t satIntIoContext\n")); 4958285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 4959285809Sscottl if (satOrgIOContext == agNULL) 4960285809Sscottl { 4961285809Sscottl TI_DBG4(("satVerify10CB: satOrgIOContext is NULL, wrong\n")); 4962285809Sscottl return; 4963285809Sscottl } 4964285809Sscottl else 4965285809Sscottl { 4966285809Sscottl TI_DBG4(("satVerify10CB: satOrgIOContext is NOT NULL\n")); 4967285809Sscottl } 4968285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 4969285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 4970285809Sscottl pSense = satOrgIOContext->pSense; 4971285809Sscottl } 4972285809Sscottl 4973285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 4974285809Sscottl tdIORequestBody->ioStarted = agFALSE; 4975285809Sscottl 4976285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 4977285809Sscottl { 4978285809Sscottl TI_DBG1(("satVerify10CB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 4979285809Sscottl satSetSensePayload( pSense, 4980285809Sscottl SCSI_SNSKEY_NO_SENSE, 4981285809Sscottl 0, 4982285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 4983285809Sscottl satOrgIOContext); 4984285809Sscottl 4985285809Sscottl ostiInitiatorIOCompleted( tiRoot, 4986285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 4987285809Sscottl tiIOSuccess, 4988285809Sscottl SCSI_STAT_CHECK_CONDITION, 4989285809Sscottl satOrgIOContext->pTiSenseData, 4990285809Sscottl satOrgIOContext->interruptContext ); 4991285809Sscottl 4992285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 4993285809Sscottl 4994285809Sscottl satFreeIntIoResource( tiRoot, 4995285809Sscottl satDevData, 4996285809Sscottl satIntIo); 4997285809Sscottl return; 4998285809Sscottl } 4999285809Sscottl 5000285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 5001285809Sscottl { 5002285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 5003285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 5004285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 5005285809Sscottl } 5006285809Sscottl 5007285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 5008285809Sscottl { 5009285809Sscottl if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 5010285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 5011285809Sscottl ) 5012285809Sscottl { 5013285809Sscottl /* for debugging */ 5014285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 5015285809Sscottl { 5016285809Sscottl TI_DBG1(("satVerify10CB: FAILED, NOT IO_SUCCESS\n")); 5017285809Sscottl } 5018285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 5019285809Sscottl { 5020285809Sscottl TI_DBG1(("satVerify10CB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 5021285809Sscottl } 5022285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 5023285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 5024285809Sscottl ) 5025285809Sscottl { 5026285809Sscottl TI_DBG1(("satVerify10CB: FAILED, FAILED, error status\n")); 5027285809Sscottl } 5028285809Sscottl 5029285809Sscottl /* Process abort case */ 5030285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 5031285809Sscottl { 5032285809Sscottl satProcessAbort(tiRoot, 5033285809Sscottl tiOrgIORequest, 5034285809Sscottl satOrgIOContext 5035285809Sscottl ); 5036285809Sscottl 5037285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5038285809Sscottl 5039285809Sscottl satFreeIntIoResource( tiRoot, 5040285809Sscottl satDevData, 5041285809Sscottl satIntIo); 5042285809Sscottl return; 5043285809Sscottl } 5044285809Sscottl 5045285809Sscottl /* for debugging */ 5046285809Sscottl switch (hostToDevFis->h.command) 5047285809Sscottl { 5048285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 5049285809Sscottl TI_DBG1(("satVerify10CB: SAT_READ_VERIFY_SECTORS_EXT\n")); 5050285809Sscottl break; 5051285809Sscottl default: 5052285809Sscottl TI_DBG1(("satVerify10CB: error default case command 0x%x\n", hostToDevFis->h.command)); 5053285809Sscottl break; 5054285809Sscottl } 5055285809Sscottl 5056285809Sscottl satSetSensePayload( pSense, 5057285809Sscottl SCSI_SNSKEY_NO_SENSE, 5058285809Sscottl 0, 5059285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5060285809Sscottl satOrgIOContext); 5061285809Sscottl 5062285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5063285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5064285809Sscottl tiIOSuccess, 5065285809Sscottl SCSI_STAT_CHECK_CONDITION, 5066285809Sscottl satOrgIOContext->pTiSenseData, 5067285809Sscottl satOrgIOContext->interruptContext ); 5068285809Sscottl 5069285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5070285809Sscottl 5071285809Sscottl satFreeIntIoResource( tiRoot, 5072285809Sscottl satDevData, 5073285809Sscottl satIntIo); 5074285809Sscottl return; 5075285809Sscottl } /* end error checking */ 5076285809Sscottl } 5077285809Sscottl 5078285809Sscottl /* process success from this point on */ 5079285809Sscottl switch (hostToDevFis->h.command) 5080285809Sscottl { 5081285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 5082285809Sscottl TI_DBG5(("satVerify10CB: SAT_WRITE_DMA_EXT success \n")); 5083285809Sscottl 5084285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5085285809Sscottl 5086285809Sscottl satFreeIntIoResource( tiRoot, 5087285809Sscottl satDevData, 5088285809Sscottl satIntIo); 5089285809Sscottl 5090285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5091285809Sscottl tiOrgIORequest, 5092285809Sscottl tiIOSuccess, 5093285809Sscottl SCSI_STAT_GOOD, 5094285809Sscottl agNULL, 5095285809Sscottl satOrgIOContext->interruptContext); 5096285809Sscottl break; 5097285809Sscottl default: 5098285809Sscottl TI_DBG1(("satVerify10CB: success but error default case command 0x%x\n", hostToDevFis->h.command)); 5099285809Sscottl 5100285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5101285809Sscottl 5102285809Sscottl satFreeIntIoResource( tiRoot, 5103285809Sscottl satDevData, 5104285809Sscottl satIntIo); 5105285809Sscottl 5106285809Sscottl satSetSensePayload( pSense, 5107285809Sscottl SCSI_SNSKEY_NO_SENSE, 5108285809Sscottl 0, 5109285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5110285809Sscottl satOrgIOContext); 5111285809Sscottl 5112285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5113285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5114285809Sscottl tiIOSuccess, 5115285809Sscottl SCSI_STAT_CHECK_CONDITION, 5116285809Sscottl satOrgIOContext->pTiSenseData, 5117285809Sscottl satOrgIOContext->interruptContext ); 5118285809Sscottl 5119285809Sscottl break; 5120285809Sscottl } 5121285809Sscottl 5122285809Sscottl return; 5123285809Sscottl} 5124285809Sscottl 5125285809Sscottl/* similar to satVerify10CB */ 5126285809Sscottlvoid satNonChainedVerifyCB( 5127285809Sscottl agsaRoot_t *agRoot, 5128285809Sscottl agsaIORequest_t *agIORequest, 5129285809Sscottl bit32 agIOStatus, 5130285809Sscottl agsaFisHeader_t *agFirstDword, 5131285809Sscottl bit32 agIOInfoLen, 5132285809Sscottl agsaFrameHandle_t agFrameHandle, 5133285809Sscottl void *ioContext 5134285809Sscottl ) 5135285809Sscottl{ 5136285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5137285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5138285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 5139285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 5140285809Sscottl tdIORequestBody_t *tdIORequestBody; 5141285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 5142285809Sscottl satIOContext_t *satIOContext; 5143285809Sscottl satIOContext_t *satOrgIOContext; 5144285809Sscottl satInternalIo_t *satIntIo; 5145285809Sscottl satDeviceData_t *satDevData; 5146285809Sscottl scsiRspSense_t *pSense; 5147285809Sscottl tiIORequest_t *tiOrgIORequest; 5148285809Sscottl 5149285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 5150285809Sscottl bit32 ataStatus = 0; 5151285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 5152285809Sscottl 5153285809Sscottl TI_DBG5(("satNonChainedVerifyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 5154285809Sscottl 5155285809Sscottl /* internally generate tiIOContext */ 5156285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 5157285809Sscottl satIOContext = (satIOContext_t *) ioContext; 5158285809Sscottl satIntIo = satIOContext->satIntIoContext; 5159285809Sscottl satDevData = satIOContext->pSatDevData; 5160285809Sscottl hostToDevFis = satIOContext->pFis; 5161285809Sscottl 5162285809Sscottl if (satIntIo == agNULL) 5163285809Sscottl { 5164285809Sscottl TI_DBG4(("satNonChainedVerifyCB: External satInternalIo_t satIntIoContext\n")); 5165285809Sscottl satOrgIOContext = satIOContext; 5166285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 5167285809Sscottl pSense = satIOContext->pSense; 5168285809Sscottl } 5169285809Sscottl else 5170285809Sscottl { 5171285809Sscottl TI_DBG4(("satNonChainedVerifyCB: Internal satInternalIo_t satIntIoContext\n")); 5172285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 5173285809Sscottl if (satOrgIOContext == agNULL) 5174285809Sscottl { 5175285809Sscottl TI_DBG4(("satNonChainedVerifyCB: satOrgIOContext is NULL, wrong\n")); 5176285809Sscottl return; 5177285809Sscottl } 5178285809Sscottl else 5179285809Sscottl { 5180285809Sscottl TI_DBG4(("satNonChainedVerifyCB: satOrgIOContext is NOT NULL\n")); 5181285809Sscottl } 5182285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 5183285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 5184285809Sscottl pSense = satOrgIOContext->pSense; 5185285809Sscottl } 5186285809Sscottl 5187285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 5188285809Sscottl tdIORequestBody->ioStarted = agFALSE; 5189285809Sscottl 5190285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 5191285809Sscottl { 5192285809Sscottl TI_DBG1(("satNonChainedVerifyCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 5193285809Sscottl satSetSensePayload( pSense, 5194285809Sscottl SCSI_SNSKEY_NO_SENSE, 5195285809Sscottl 0, 5196285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5197285809Sscottl satOrgIOContext); 5198285809Sscottl 5199285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5200285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5201285809Sscottl tiIOSuccess, 5202285809Sscottl SCSI_STAT_CHECK_CONDITION, 5203285809Sscottl satOrgIOContext->pTiSenseData, 5204285809Sscottl satOrgIOContext->interruptContext ); 5205285809Sscottl 5206285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5207285809Sscottl 5208285809Sscottl satFreeIntIoResource( tiRoot, 5209285809Sscottl satDevData, 5210285809Sscottl satIntIo); 5211285809Sscottl return; 5212285809Sscottl } 5213285809Sscottl 5214285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 5215285809Sscottl { 5216285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 5217285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 5218285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 5219285809Sscottl } 5220285809Sscottl 5221285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 5222285809Sscottl { 5223285809Sscottl if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 5224285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 5225285809Sscottl ) 5226285809Sscottl { 5227285809Sscottl /* for debugging */ 5228285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 5229285809Sscottl { 5230285809Sscottl TI_DBG1(("satNonChainedVerifyCB: FAILED, NOT IO_SUCCESS\n")); 5231285809Sscottl } 5232285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 5233285809Sscottl { 5234285809Sscottl TI_DBG1(("satNonChainedVerifyCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 5235285809Sscottl } 5236285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 5237285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 5238285809Sscottl ) 5239285809Sscottl { 5240285809Sscottl TI_DBG1(("satNonChainedVerifyCB: FAILED, FAILED, error status\n")); 5241285809Sscottl } 5242285809Sscottl 5243285809Sscottl /* Process abort case */ 5244285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 5245285809Sscottl { 5246285809Sscottl satProcessAbort(tiRoot, 5247285809Sscottl tiOrgIORequest, 5248285809Sscottl satOrgIOContext 5249285809Sscottl ); 5250285809Sscottl 5251285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5252285809Sscottl 5253285809Sscottl satFreeIntIoResource( tiRoot, 5254285809Sscottl satDevData, 5255285809Sscottl satIntIo); 5256285809Sscottl return; 5257285809Sscottl } 5258285809Sscottl 5259285809Sscottl /* for debugging */ 5260285809Sscottl switch (hostToDevFis->h.command) 5261285809Sscottl { 5262285809Sscottl case SAT_READ_VERIFY_SECTORS: 5263285809Sscottl TI_DBG1(("satNonChainedVerifyCB: SAT_READ_VERIFY_SECTORS\n")); 5264285809Sscottl break; 5265285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 5266285809Sscottl TI_DBG1(("satNonChainedVerifyCB: SAT_READ_VERIFY_SECTORS_EXT\n")); 5267285809Sscottl break; 5268285809Sscottl default: 5269285809Sscottl TI_DBG1(("satNonChainedVerifyCB: error default case command 0x%x\n", hostToDevFis->h.command)); 5270285809Sscottl break; 5271285809Sscottl } 5272285809Sscottl 5273285809Sscottl satSetSensePayload( pSense, 5274285809Sscottl SCSI_SNSKEY_NO_SENSE, 5275285809Sscottl 0, 5276285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5277285809Sscottl satOrgIOContext); 5278285809Sscottl 5279285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5280285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5281285809Sscottl tiIOSuccess, 5282285809Sscottl SCSI_STAT_CHECK_CONDITION, 5283285809Sscottl satOrgIOContext->pTiSenseData, 5284285809Sscottl satOrgIOContext->interruptContext ); 5285285809Sscottl 5286285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5287285809Sscottl 5288285809Sscottl satFreeIntIoResource( tiRoot, 5289285809Sscottl satDevData, 5290285809Sscottl satIntIo); 5291285809Sscottl return; 5292285809Sscottl } /* end error checking */ 5293285809Sscottl } 5294285809Sscottl 5295285809Sscottl /* process success from this point on */ 5296285809Sscottl switch (hostToDevFis->h.command) 5297285809Sscottl { 5298285809Sscottl case SAT_READ_VERIFY_SECTORS: /* fall through */ 5299285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 5300285809Sscottl TI_DBG5(("satNonChainedVerifyCB: SAT_WRITE_DMA_EXT success \n")); 5301285809Sscottl 5302285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5303285809Sscottl 5304285809Sscottl satFreeIntIoResource( tiRoot, 5305285809Sscottl satDevData, 5306285809Sscottl satIntIo); 5307285809Sscottl 5308285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5309285809Sscottl tiOrgIORequest, 5310285809Sscottl tiIOSuccess, 5311285809Sscottl SCSI_STAT_GOOD, 5312285809Sscottl agNULL, 5313285809Sscottl satOrgIOContext->interruptContext); 5314285809Sscottl break; 5315285809Sscottl default: 5316285809Sscottl TI_DBG1(("satNonChainedVerifyCB: success but error default case command 0x%x\n", hostToDevFis->h.command)); 5317285809Sscottl 5318285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5319285809Sscottl 5320285809Sscottl satFreeIntIoResource( tiRoot, 5321285809Sscottl satDevData, 5322285809Sscottl satIntIo); 5323285809Sscottl 5324285809Sscottl satSetSensePayload( pSense, 5325285809Sscottl SCSI_SNSKEY_NO_SENSE, 5326285809Sscottl 0, 5327285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5328285809Sscottl satOrgIOContext); 5329285809Sscottl 5330285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5331285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5332285809Sscottl tiIOSuccess, 5333285809Sscottl SCSI_STAT_CHECK_CONDITION, 5334285809Sscottl satOrgIOContext->pTiSenseData, 5335285809Sscottl satOrgIOContext->interruptContext ); 5336285809Sscottl 5337285809Sscottl break; 5338285809Sscottl } 5339285809Sscottl 5340285809Sscottl return; 5341285809Sscottl} 5342285809Sscottl 5343285809Sscottlvoid satChainedVerifyCB( 5344285809Sscottl agsaRoot_t *agRoot, 5345285809Sscottl agsaIORequest_t *agIORequest, 5346285809Sscottl bit32 agIOStatus, 5347285809Sscottl agsaFisHeader_t *agFirstDword, 5348285809Sscottl bit32 agIOInfoLen, 5349285809Sscottl agsaFrameHandle_t agFrameHandle, 5350285809Sscottl void *ioContext 5351285809Sscottl ) 5352285809Sscottl{ 5353285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5354285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5355285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 5356285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 5357285809Sscottl tdIORequestBody_t *tdIORequestBody; 5358285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 5359285809Sscottl satIOContext_t *satIOContext; 5360285809Sscottl satIOContext_t *satOrgIOContext; 5361285809Sscottl satIOContext_t *satNewIOContext; 5362285809Sscottl satInternalIo_t *satIntIo; 5363285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 5364285809Sscottl satDeviceData_t *satDevData; 5365285809Sscottl scsiRspSense_t *pSense; 5366285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 5367285809Sscottl tiIORequest_t *tiOrgIORequest; 5368285809Sscottl 5369285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 5370285809Sscottl bit32 ataStatus = 0; 5371285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 5372285809Sscottl bit32 status = tiError; 5373285809Sscottl bit32 dataLength; 5374285809Sscottl 5375285809Sscottl TI_DBG5(("satChainedVerifyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 5376285809Sscottl 5377285809Sscottl /* internally generate tiIOContext */ 5378285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 5379285809Sscottl satIOContext = (satIOContext_t *) ioContext; 5380285809Sscottl satIntIo = satIOContext->satIntIoContext; 5381285809Sscottl satDevData = satIOContext->pSatDevData; 5382285809Sscottl hostToDevFis = satIOContext->pFis; 5383285809Sscottl 5384285809Sscottl if (satIntIo == agNULL) 5385285809Sscottl { 5386285809Sscottl TI_DBG4(("satChainedVerifyCB: External satInternalIo_t satIntIoContext\n")); 5387285809Sscottl satOrgIOContext = satIOContext; 5388285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 5389285809Sscottl pSense = satIOContext->pSense; 5390285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 5391285809Sscottl } 5392285809Sscottl else 5393285809Sscottl { 5394285809Sscottl TI_DBG4(("satChainedVerifyCB: Internal satInternalIo_t satIntIoContext\n")); 5395285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 5396285809Sscottl if (satOrgIOContext == agNULL) 5397285809Sscottl { 5398285809Sscottl TI_DBG4(("satChainedVerifyCB: satOrgIOContext is NULL, wrong\n")); 5399285809Sscottl return; 5400285809Sscottl } 5401285809Sscottl else 5402285809Sscottl { 5403285809Sscottl TI_DBG4(("satChainedVerifyCB: satOrgIOContext is NOT NULL\n")); 5404285809Sscottl } 5405285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 5406285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 5407285809Sscottl pSense = satOrgIOContext->pSense; 5408285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 5409285809Sscottl } 5410285809Sscottl 5411285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 5412285809Sscottl tdIORequestBody->ioStarted = agFALSE; 5413285809Sscottl 5414285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 5415285809Sscottl { 5416285809Sscottl TI_DBG1(("satChainedVerifyCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 5417285809Sscottl satSetSensePayload( pSense, 5418285809Sscottl SCSI_SNSKEY_NO_SENSE, 5419285809Sscottl 0, 5420285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5421285809Sscottl satOrgIOContext); 5422285809Sscottl 5423285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5424285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5425285809Sscottl tiIOSuccess, 5426285809Sscottl SCSI_STAT_CHECK_CONDITION, 5427285809Sscottl satOrgIOContext->pTiSenseData, 5428285809Sscottl satOrgIOContext->interruptContext ); 5429285809Sscottl 5430285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5431285809Sscottl 5432285809Sscottl satFreeIntIoResource( tiRoot, 5433285809Sscottl satDevData, 5434285809Sscottl satIntIo); 5435285809Sscottl return; 5436285809Sscottl } 5437285809Sscottl 5438285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 5439285809Sscottl { 5440285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 5441285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 5442285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 5443285809Sscottl } 5444285809Sscottl 5445285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 5446285809Sscottl { 5447285809Sscottl if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 5448285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 5449285809Sscottl ) 5450285809Sscottl { 5451285809Sscottl /* for debugging */ 5452285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 5453285809Sscottl { 5454285809Sscottl TI_DBG1(("satChainedVerifyCB: FAILED, NOT IO_SUCCESS\n")); 5455285809Sscottl } 5456285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 5457285809Sscottl { 5458285809Sscottl TI_DBG1(("satChainedVerifyCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 5459285809Sscottl } 5460285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 5461285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 5462285809Sscottl ) 5463285809Sscottl { 5464285809Sscottl TI_DBG1(("satChainedVerifyCB: FAILED, FAILED, error status\n")); 5465285809Sscottl } 5466285809Sscottl 5467285809Sscottl /* Process abort case */ 5468285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 5469285809Sscottl { 5470285809Sscottl satProcessAbort(tiRoot, 5471285809Sscottl tiOrgIORequest, 5472285809Sscottl satOrgIOContext 5473285809Sscottl ); 5474285809Sscottl 5475285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5476285809Sscottl 5477285809Sscottl satFreeIntIoResource( tiRoot, 5478285809Sscottl satDevData, 5479285809Sscottl satIntIo); 5480285809Sscottl return; 5481285809Sscottl } 5482285809Sscottl 5483285809Sscottl /* for debugging */ 5484285809Sscottl switch (hostToDevFis->h.command) 5485285809Sscottl { 5486285809Sscottl case SAT_READ_VERIFY_SECTORS: 5487285809Sscottl TI_DBG1(("satChainedVerifyCB: SAT_READ_VERIFY_SECTORS\n")); 5488285809Sscottl break; 5489285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 5490285809Sscottl TI_DBG1(("satChainedVerifyCB: SAT_READ_VERIFY_SECTORS_EXT\n")); 5491285809Sscottl break; 5492285809Sscottl default: 5493285809Sscottl TI_DBG1(("satChainedVerifyCB: error default case command 0x%x\n", hostToDevFis->h.command)); 5494285809Sscottl break; 5495285809Sscottl } 5496285809Sscottl 5497285809Sscottl satSetSensePayload( pSense, 5498285809Sscottl SCSI_SNSKEY_NO_SENSE, 5499285809Sscottl 0, 5500285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5501285809Sscottl satOrgIOContext); 5502285809Sscottl 5503285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5504285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5505285809Sscottl tiIOSuccess, 5506285809Sscottl SCSI_STAT_CHECK_CONDITION, 5507285809Sscottl satOrgIOContext->pTiSenseData, 5508285809Sscottl satOrgIOContext->interruptContext ); 5509285809Sscottl 5510285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5511285809Sscottl 5512285809Sscottl satFreeIntIoResource( tiRoot, 5513285809Sscottl satDevData, 5514285809Sscottl satIntIo); 5515285809Sscottl return; 5516285809Sscottl } /* end error checking */ 5517285809Sscottl } 5518285809Sscottl 5519285809Sscottl /* process success from this point on */ 5520285809Sscottl switch (hostToDevFis->h.command) 5521285809Sscottl { 5522285809Sscottl case SAT_READ_VERIFY_SECTORS: /* fall through */ 5523285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 5524285809Sscottl TI_DBG5(("satChainedVerifyCB: SAT_WRITE_DMA_EXT success \n")); 5525285809Sscottl 5526285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5527285809Sscottl 5528285809Sscottl satFreeIntIoResource( tiRoot, 5529285809Sscottl satDevData, 5530285809Sscottl satIntIo); 5531285809Sscottl 5532285809Sscottl /* let's loop till TL */ 5533285809Sscottl 5534285809Sscottl /* lba = lba + tl 5535285809Sscottl loopnum--; 5536285809Sscottl if (loopnum == 0) done 5537285809Sscottl */ 5538285809Sscottl (satOrgIOContext->LoopNum)--; 5539285809Sscottl if (satOrgIOContext->LoopNum == 0) 5540285809Sscottl { 5541285809Sscottl /* 5542285809Sscottl done with write and verify 5543285809Sscottl */ 5544285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5545285809Sscottl 5546285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5547285809Sscottl tiIOSuccess, 5548285809Sscottl SCSI_STAT_GOOD, 5549285809Sscottl agNULL, 5550285809Sscottl satOrgIOContext->interruptContext ); 5551285809Sscottl return; 5552285809Sscottl } 5553285809Sscottl 5554285809Sscottl if (satOrgIOContext->superIOFlag) 5555285809Sscottl { 5556285809Sscottl dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 5557285809Sscottl } 5558285809Sscottl else 5559285809Sscottl { 5560285809Sscottl dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 5561285809Sscottl } 5562285809Sscottl 5563285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 5564285809Sscottl tiOrgIORequest, 5565285809Sscottl satDevData, 5566285809Sscottl dataLength, 5567285809Sscottl satNewIntIo); 5568285809Sscottl if (satNewIntIo == agNULL) 5569285809Sscottl { 5570285809Sscottl /* memory allocation failure */ 5571285809Sscottl satFreeIntIoResource( tiRoot, 5572285809Sscottl satDevData, 5573285809Sscottl satNewIntIo); 5574285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5575285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5576285809Sscottl tiIOFailed, 5577285809Sscottl tiDetailOtherError, 5578285809Sscottl agNULL, 5579285809Sscottl satOrgIOContext->interruptContext ); 5580285809Sscottl 5581285809Sscottl TI_DBG1(("satChainedVerifyCB: momory allocation fails\n")); 5582285809Sscottl return; 5583285809Sscottl } /* end of memory allocation failure */ 5584285809Sscottl 5585285809Sscottl /* 5586285809Sscottl * Need to initialize all the fields within satIOContext 5587285809Sscottl */ 5588285809Sscottl 5589285809Sscottl satNewIOContext = satPrepareNewIO( 5590285809Sscottl satNewIntIo, 5591285809Sscottl tiOrgIORequest, 5592285809Sscottl satDevData, 5593285809Sscottl scsiCmnd, 5594285809Sscottl satOrgIOContext 5595285809Sscottl ); 5596285809Sscottl status = satChainedVerify(tiRoot, 5597285809Sscottl &satNewIntIo->satIntTiIORequest, 5598285809Sscottl satNewIOContext->ptiDeviceHandle, 5599285809Sscottl &satNewIntIo->satIntTiScsiXchg, 5600285809Sscottl satNewIOContext); 5601285809Sscottl 5602285809Sscottl if (status != tiSuccess) 5603285809Sscottl { 5604285809Sscottl satFreeIntIoResource( tiRoot, 5605285809Sscottl satDevData, 5606285809Sscottl satNewIntIo); 5607285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5608285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5609285809Sscottl tiIOFailed, 5610285809Sscottl tiDetailOtherError, 5611285809Sscottl agNULL, 5612285809Sscottl satOrgIOContext->interruptContext ); 5613285809Sscottl TI_DBG1(("satChainedVerifyCB: calling satChainedVerify fails\n")); 5614285809Sscottl return; 5615285809Sscottl } 5616285809Sscottl 5617285809Sscottl break; 5618285809Sscottl default: 5619285809Sscottl TI_DBG1(("satChainedVerifyCB: success but error default case command 0x%x\n", hostToDevFis->h.command)); 5620285809Sscottl 5621285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5622285809Sscottl 5623285809Sscottl satFreeIntIoResource( tiRoot, 5624285809Sscottl satDevData, 5625285809Sscottl satIntIo); 5626285809Sscottl 5627285809Sscottl satSetSensePayload( pSense, 5628285809Sscottl SCSI_SNSKEY_NO_SENSE, 5629285809Sscottl 0, 5630285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 5631285809Sscottl satOrgIOContext); 5632285809Sscottl 5633285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5634285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5635285809Sscottl tiIOSuccess, 5636285809Sscottl SCSI_STAT_CHECK_CONDITION, 5637285809Sscottl satOrgIOContext->pTiSenseData, 5638285809Sscottl satOrgIOContext->interruptContext ); 5639285809Sscottl 5640285809Sscottl break; 5641285809Sscottl } 5642285809Sscottl return; 5643285809Sscottl} 5644285809Sscottl 5645285809Sscottl/***************************************************************************** 5646285809Sscottl*! \brief satTestUnitReadyCB 5647285809Sscottl* 5648285809Sscottl* This routine is a callback function for satTestUnitReady() 5649285809Sscottl* 5650285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 5651285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 5652285809Sscottl* \param agIOStatus: Status of completed I/O. 5653285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 5654285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 5655285809Sscottl* length. 5656285809Sscottl* \param agParam: Additional info based on status. 5657285809Sscottl* \param ioContext: Pointer to satIOContext_t. 5658285809Sscottl* 5659285809Sscottl* \return: none 5660285809Sscottl* 5661285809Sscottl*****************************************************************************/ 5662285809Sscottlvoid satTestUnitReadyCB( 5663285809Sscottl agsaRoot_t *agRoot, 5664285809Sscottl agsaIORequest_t *agIORequest, 5665285809Sscottl bit32 agIOStatus, 5666285809Sscottl agsaFisHeader_t *agFirstDword, 5667285809Sscottl bit32 agIOInfoLen, 5668285809Sscottl void *agParam, 5669285809Sscottl void *ioContext 5670285809Sscottl ) 5671285809Sscottl{ 5672285809Sscottl /* 5673285809Sscottl In the process of TestUnitReady 5674285809Sscottl Process SAT_GET_MEDIA_STATUS 5675285809Sscottl Process SAT_CHECK_POWER_MODE 5676285809Sscottl */ 5677285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 5678285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 5679285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 5680285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 5681285809Sscottl tdIORequestBody_t *tdIORequestBody; 5682285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 5683285809Sscottl satIOContext_t *satIOContext; 5684285809Sscottl satIOContext_t *satOrgIOContext; 5685285809Sscottl satIOContext_t *satNewIOContext; 5686285809Sscottl satInternalIo_t *satIntIo; 5687285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 5688285809Sscottl satDeviceData_t *satDevData; 5689285809Sscottl scsiRspSense_t *pSense; 5690285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 5691285809Sscottl tiIORequest_t *tiOrgIORequest; 5692285809Sscottl 5693285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 5694285809Sscottl bit32 ataStatus = 0; 5695285809Sscottl bit32 ataError; 5696285809Sscottl 5697285809Sscottl bit32 status; 5698285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 5699285809Sscottl 5700285809Sscottl TI_DBG6(("satTestUnitReadyCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 5701285809Sscottl 5702285809Sscottl /* internally generate tiIOContext */ 5703285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 5704285809Sscottl satIOContext = (satIOContext_t *) ioContext; 5705285809Sscottl satIntIo = satIOContext->satIntIoContext; 5706285809Sscottl satDevData = satIOContext->pSatDevData; 5707285809Sscottl hostToDevFis = satIOContext->pFis; 5708285809Sscottl 5709285809Sscottl if (satIntIo == agNULL) 5710285809Sscottl { 5711285809Sscottl TI_DBG5(("satTestUnitReadyCB: no internal satInternalIo_t satIntIoContext\n")); 5712285809Sscottl pSense = satIOContext->pSense; 5713285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 5714285809Sscottl satOrgIOContext = satIOContext; 5715285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 5716285809Sscottl } 5717285809Sscottl else 5718285809Sscottl { 5719285809Sscottl TI_DBG5(("satTestUnitReadyCB: yes internal satInternalIo_t satIntIoContext\n")); 5720285809Sscottl 5721285809Sscottl /* orginal tiIOContext */ 5722285809Sscottl tiOrgIORequest = (tiIORequest_t *)satIOContext->satIntIoContext->satOrgTiIORequest; 5723285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)tiOrgIORequest->tdData; 5724285809Sscottl satOrgIOContext = &(tdOrgIORequestBody->transport.SATA.satIOContext); 5725285809Sscottl 5726285809Sscottl pSense = satOrgIOContext->pSense; 5727285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 5728285809Sscottl } 5729285809Sscottl 5730285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 5731285809Sscottl tdIORequestBody->ioStarted = agFALSE; 5732285809Sscottl 5733285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 5734285809Sscottl { 5735285809Sscottl TI_DBG1(("satTestUnitReadyCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 5736285809Sscottl satSetSensePayload( pSense, 5737285809Sscottl SCSI_SNSKEY_NOT_READY, 5738285809Sscottl 0, 5739285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 5740285809Sscottl satOrgIOContext); 5741285809Sscottl 5742285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5743285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5744285809Sscottl tiIOSuccess, 5745285809Sscottl SCSI_STAT_CHECK_CONDITION, 5746285809Sscottl satOrgIOContext->pTiSenseData, 5747285809Sscottl satOrgIOContext->interruptContext ); 5748285809Sscottl 5749285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5750285809Sscottl 5751285809Sscottl satFreeIntIoResource( tiRoot, 5752285809Sscottl satDevData, 5753285809Sscottl satIntIo); 5754285809Sscottl 5755285809Sscottl return; 5756285809Sscottl } 5757285809Sscottl /* 5758285809Sscottl HW checks an error for us and the results is agIOStatus 5759285809Sscottl */ 5760285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 5761285809Sscottl { 5762285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 5763285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 5764285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 5765285809Sscottl ataError = statDevToHostFisHeader->error; /* ATA Eror register */ 5766285809Sscottl 5767285809Sscottl if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 5768285809Sscottl { 5769285809Sscottl TI_DBG1(("satTestUnitReadyCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 5770285809Sscottl } 5771285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 5772285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 5773285809Sscottl ) 5774285809Sscottl { 5775285809Sscottl TI_DBG1(("satTestUnitReadyCB: FAILED, FAILED, error status\n")); 5776285809Sscottl } 5777285809Sscottl 5778285809Sscottl /* Process abort case */ 5779285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 5780285809Sscottl { 5781285809Sscottl satProcessAbort(tiRoot, 5782285809Sscottl tiOrgIORequest, 5783285809Sscottl satOrgIOContext 5784285809Sscottl ); 5785285809Sscottl 5786285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5787285809Sscottl 5788285809Sscottl satFreeIntIoResource( tiRoot, 5789285809Sscottl satDevData, 5790285809Sscottl satIntIo); 5791285809Sscottl return; 5792285809Sscottl } 5793285809Sscottl 5794285809Sscottl switch (hostToDevFis->h.command) 5795285809Sscottl { 5796285809Sscottl case SAT_GET_MEDIA_STATUS: 5797285809Sscottl TI_DBG1(("satTestUnitReadyCB: SAT_GET_MEDIA_STATUS failed \n")); 5798285809Sscottl 5799285809Sscottl /* checking NM bit */ 5800285809Sscottl if (ataError & SCSI_NM_MASK) 5801285809Sscottl { 5802285809Sscottl satSetSensePayload( pSense, 5803285809Sscottl SCSI_SNSKEY_NOT_READY, 5804285809Sscottl 0, 5805285809Sscottl SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 5806285809Sscottl satOrgIOContext); 5807285809Sscottl } 5808285809Sscottl else 5809285809Sscottl { 5810285809Sscottl satSetSensePayload( pSense, 5811285809Sscottl SCSI_SNSKEY_NOT_READY, 5812285809Sscottl 0, 5813285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 5814285809Sscottl satOrgIOContext); 5815285809Sscottl } 5816285809Sscottl 5817285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5818285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5819285809Sscottl tiIOSuccess, 5820285809Sscottl SCSI_STAT_CHECK_CONDITION, 5821285809Sscottl satOrgIOContext->pTiSenseData, 5822285809Sscottl satOrgIOContext->interruptContext ); 5823285809Sscottl 5824285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5825285809Sscottl 5826285809Sscottl satFreeIntIoResource( tiRoot, 5827285809Sscottl satDevData, 5828285809Sscottl satIntIo); 5829285809Sscottl break; 5830285809Sscottl case SAT_CHECK_POWER_MODE: 5831285809Sscottl TI_DBG1(("satTestUnitReadyCB: SAT_CHECK_POWER_MODE failed \n")); 5832285809Sscottl satSetSensePayload( pSense, 5833285809Sscottl SCSI_SNSKEY_NOT_READY, 5834285809Sscottl 0, 5835285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_DOES_NOT_RESPOND_TO_SELECTION, 5836285809Sscottl satOrgIOContext); 5837285809Sscottl 5838285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5839285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5840285809Sscottl tiIOSuccess, 5841285809Sscottl SCSI_STAT_CHECK_CONDITION, 5842285809Sscottl satOrgIOContext->pTiSenseData, 5843285809Sscottl satOrgIOContext->interruptContext ); 5844285809Sscottl 5845285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5846285809Sscottl 5847285809Sscottl satFreeIntIoResource( tiRoot, 5848285809Sscottl satDevData, 5849285809Sscottl satIntIo); 5850285809Sscottl break; 5851285809Sscottl default: 5852285809Sscottl TI_DBG1(("satTestUnitReadyCB: default failed command %d\n", hostToDevFis->h.command)); 5853285809Sscottl 5854285809Sscottl satSetSensePayload( pSense, 5855285809Sscottl SCSI_SNSKEY_NOT_READY, 5856285809Sscottl 0, 5857285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 5858285809Sscottl satOrgIOContext); 5859285809Sscottl 5860285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5861285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5862285809Sscottl tiIOSuccess, 5863285809Sscottl SCSI_STAT_CHECK_CONDITION, 5864285809Sscottl satOrgIOContext->pTiSenseData, 5865285809Sscottl satOrgIOContext->interruptContext ); 5866285809Sscottl 5867285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5868285809Sscottl 5869285809Sscottl satFreeIntIoResource( tiRoot, 5870285809Sscottl satDevData, 5871285809Sscottl satIntIo); 5872285809Sscottl break; 5873285809Sscottl 5874285809Sscottl } 5875285809Sscottl return; 5876285809Sscottl }/* end error */ 5877285809Sscottl 5878285809Sscottl /* ATA command completes sucessfully */ 5879285809Sscottl switch (hostToDevFis->h.command) 5880285809Sscottl { 5881285809Sscottl case SAT_GET_MEDIA_STATUS: 5882285809Sscottl 5883285809Sscottl TI_DBG5(("satTestUnitReadyCB: SAT_GET_MEDIA_STATUS success\n")); 5884285809Sscottl 5885285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5886285809Sscottl 5887285809Sscottl satFreeIntIoResource( tiRoot, 5888285809Sscottl satDevData, 5889285809Sscottl satIntIo); 5890285809Sscottl 5891285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 5892285809Sscottl tiOrgIORequest, 5893285809Sscottl satDevData, 5894285809Sscottl 0, 5895285809Sscottl satNewIntIo); 5896285809Sscottl if (satNewIntIo == agNULL) 5897285809Sscottl { 5898285809Sscottl /* memory allocation failure */ 5899285809Sscottl satFreeIntIoResource( tiRoot, 5900285809Sscottl satDevData, 5901285809Sscottl satNewIntIo); 5902285809Sscottl satSetSensePayload( pSense, 5903285809Sscottl SCSI_SNSKEY_NOT_READY, 5904285809Sscottl 0, 5905285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 5906285809Sscottl satOrgIOContext); 5907285809Sscottl 5908285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5909285809Sscottl tiOrgIORequest, 5910285809Sscottl tiIOSuccess, 5911285809Sscottl SCSI_STAT_CHECK_CONDITION, 5912285809Sscottl satOrgIOContext->pTiSenseData, 5913285809Sscottl satOrgIOContext->interruptContext ); 5914285809Sscottl 5915285809Sscottl TI_DBG1(("satTestUnitReadyCB: momory allocation fails\n")); 5916285809Sscottl return; 5917285809Sscottl } 5918285809Sscottl 5919285809Sscottl /* 5920285809Sscottl * Need to initialize all the fields within satIOContext 5921285809Sscottl */ 5922285809Sscottl 5923285809Sscottl satNewIOContext = satPrepareNewIO( 5924285809Sscottl satNewIntIo, 5925285809Sscottl tiOrgIORequest, 5926285809Sscottl satDevData, 5927285809Sscottl scsiCmnd, 5928285809Sscottl satOrgIOContext 5929285809Sscottl ); 5930285809Sscottl 5931285809Sscottl /* sends SAT_CHECK_POWER_MODE */ 5932285809Sscottl status = satTestUnitReady_1( tiRoot, 5933285809Sscottl &satNewIntIo->satIntTiIORequest, 5934285809Sscottl satNewIOContext->ptiDeviceHandle, 5935285809Sscottl &satNewIntIo->satIntTiScsiXchg, 5936285809Sscottl satNewIOContext); 5937285809Sscottl 5938285809Sscottl if (status != tiSuccess) 5939285809Sscottl { 5940285809Sscottl /* sending SAT_CHECK_POWER_MODE fails */ 5941285809Sscottl satFreeIntIoResource( tiRoot, 5942285809Sscottl satDevData, 5943285809Sscottl satNewIntIo); 5944285809Sscottl satSetSensePayload( pSense, 5945285809Sscottl SCSI_SNSKEY_NOT_READY, 5946285809Sscottl 0, 5947285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 5948285809Sscottl satOrgIOContext); 5949285809Sscottl 5950285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5951285809Sscottl tiOrgIORequest, 5952285809Sscottl tiIOSuccess, 5953285809Sscottl SCSI_STAT_CHECK_CONDITION, 5954285809Sscottl satOrgIOContext->pTiSenseData, 5955285809Sscottl satOrgIOContext->interruptContext ); 5956285809Sscottl 5957285809Sscottl TI_DBG1(("satTestUnitReadyCB: calling satTestUnitReady_1 fails\n")); 5958285809Sscottl return; 5959285809Sscottl } 5960285809Sscottl 5961285809Sscottl break; 5962285809Sscottl case SAT_CHECK_POWER_MODE: 5963285809Sscottl TI_DBG5(("satTestUnitReadyCB: SAT_CHECK_POWER_MODE success\n")); 5964285809Sscottl 5965285809Sscottl 5966285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5967285809Sscottl 5968285809Sscottl satFreeIntIoResource( tiRoot, 5969285809Sscottl satDevData, 5970285809Sscottl satIntIo); 5971285809Sscottl 5972285809Sscottl /* returns good status */ 5973285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5974285809Sscottl tiOrgIORequest, 5975285809Sscottl tiIOSuccess, 5976285809Sscottl SCSI_STAT_GOOD, 5977285809Sscottl agNULL, 5978285809Sscottl satOrgIOContext->interruptContext ); 5979285809Sscottl 5980285809Sscottl break; 5981285809Sscottl default: 5982285809Sscottl TI_DBG1(("satTestUnitReadyCB: default success command %d\n", hostToDevFis->h.command)); 5983285809Sscottl satSetSensePayload( pSense, 5984285809Sscottl SCSI_SNSKEY_NOT_READY, 5985285809Sscottl 0, 5986285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_CAUSE_NOT_REPORTABLE, 5987285809Sscottl satOrgIOContext); 5988285809Sscottl 5989285809Sscottl ostiInitiatorIOCompleted( tiRoot, 5990285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 5991285809Sscottl tiIOSuccess, 5992285809Sscottl SCSI_STAT_CHECK_CONDITION, 5993285809Sscottl satOrgIOContext->pTiSenseData, 5994285809Sscottl satOrgIOContext->interruptContext ); 5995285809Sscottl 5996285809Sscottl 5997285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 5998285809Sscottl 5999285809Sscottl satFreeIntIoResource( tiRoot, 6000285809Sscottl satDevData, 6001285809Sscottl satIntIo); 6002285809Sscottl break; 6003285809Sscottl } 6004285809Sscottl 6005285809Sscottl return; 6006285809Sscottl} 6007285809Sscottl 6008285809Sscottl/***************************************************************************** 6009285809Sscottl*! \brief satWriteSame10CB 6010285809Sscottl* 6011285809Sscottl* This routine is a callback function for satWriteSame10() 6012285809Sscottl* 6013285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 6014285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 6015285809Sscottl* \param agIOStatus: Status of completed I/O. 6016285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 6017285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 6018285809Sscottl* length. 6019285809Sscottl* \param agParam: Additional info based on status. 6020285809Sscottl* \param ioContext: Pointer to satIOContext_t. 6021285809Sscottl* 6022285809Sscottl* \return: none 6023285809Sscottl* 6024285809Sscottl*****************************************************************************/ 6025285809Sscottlvoid satWriteSame10CB( 6026285809Sscottl agsaRoot_t *agRoot, 6027285809Sscottl agsaIORequest_t *agIORequest, 6028285809Sscottl bit32 agIOStatus, 6029285809Sscottl agsaFisHeader_t *agFirstDword, 6030285809Sscottl bit32 agIOInfoLen, 6031285809Sscottl void *agParam, 6032285809Sscottl void *ioContext 6033285809Sscottl ) 6034285809Sscottl{ 6035285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6036285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6037285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 6038285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 6039285809Sscottl tdIORequestBody_t *tdIORequestBody; 6040285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 6041285809Sscottl tdIORequestBody_t *tdNewIORequestBody; 6042285809Sscottl satIOContext_t *satIOContext; 6043285809Sscottl satIOContext_t *satOrgIOContext; 6044285809Sscottl satIOContext_t *satNewIOContext; 6045285809Sscottl satInternalIo_t *satIntIo; 6046285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 6047285809Sscottl satDeviceData_t *satDevData; 6048285809Sscottl scsiRspSense_t *pSense; 6049285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 6050285809Sscottl tiIORequest_t *tiOrgIORequest; 6051285809Sscottl 6052285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 6053285809Sscottl bit32 ataStatus = 0; 6054285809Sscottl bit32 status; 6055285809Sscottl 6056285809Sscottl bit32 sectorcount = 0; 6057285809Sscottl bit32 lba = 0, tl = 0; 6058285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 6059285809Sscottl agsaFisSetDevBitsHeader_t *statSetDevBitFisHeader = agNULL; 6060285809Sscottl 6061285809Sscottl TI_DBG5(("satWriteSame10CB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 6062285809Sscottl 6063285809Sscottl /* internally generate tiIOContext */ 6064285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 6065285809Sscottl satIOContext = (satIOContext_t *) ioContext; 6066285809Sscottl satIntIo = satIOContext->satIntIoContext; 6067285809Sscottl satDevData = satIOContext->pSatDevData; 6068285809Sscottl hostToDevFis = satIOContext->pFis; 6069285809Sscottl 6070285809Sscottl if (satIntIo == agNULL) 6071285809Sscottl { 6072285809Sscottl TI_DBG4(("satWriteSame10CB: External satInternalIo_t satIntIoContext\n")); 6073285809Sscottl satOrgIOContext = satIOContext; 6074285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 6075285809Sscottl pSense = satIOContext->pSense; 6076285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 6077285809Sscottl } 6078285809Sscottl else 6079285809Sscottl { 6080285809Sscottl TI_DBG4(("satWriteSame10CB: Internal satInternalIo_t satIntIoContext\n")); 6081285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 6082285809Sscottl if (satOrgIOContext == agNULL) 6083285809Sscottl { 6084285809Sscottl TI_DBG4(("satWriteSame10CB: satOrgIOContext is NULL, wrong\n")); 6085285809Sscottl return; 6086285809Sscottl } 6087285809Sscottl else 6088285809Sscottl { 6089285809Sscottl TI_DBG4(("satWriteSame10CB: satOrgIOContext is NOT NULL\n")); 6090285809Sscottl } 6091285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 6092285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 6093285809Sscottl 6094285809Sscottl pSense = satOrgIOContext->pSense; 6095285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 6096285809Sscottl } 6097285809Sscottl 6098285809Sscottl 6099285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 6100285809Sscottl tdIORequestBody->ioStarted = agFALSE; 6101285809Sscottl 6102285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 6103285809Sscottl { 6104285809Sscottl TI_DBG1(("satWriteSame10CB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 6105285809Sscottl satSetSensePayload( pSense, 6106285809Sscottl SCSI_SNSKEY_NO_SENSE, 6107285809Sscottl 0, 6108285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6109285809Sscottl satOrgIOContext); 6110285809Sscottl 6111285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6112285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 6113285809Sscottl tiIOSuccess, 6114285809Sscottl SCSI_STAT_CHECK_CONDITION, 6115285809Sscottl satOrgIOContext->pTiSenseData, 6116285809Sscottl satOrgIOContext->interruptContext ); 6117285809Sscottl 6118285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6119285809Sscottl 6120285809Sscottl satFreeIntIoResource( tiRoot, 6121285809Sscottl satDevData, 6122285809Sscottl satIntIo); 6123285809Sscottl return; 6124285809Sscottl } 6125285809Sscottl 6126285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 6127285809Sscottl { 6128285809Sscottl /* FP, DMA and PIO write */ 6129285809Sscottl /* First, assumed to be Reg Device to Host FIS */ 6130285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 6131285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 6132285809Sscottl } 6133285809Sscottl 6134285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 6135285809Sscottl { 6136285809Sscottl if (statDevToHostFisHeader->fisType == SET_DEV_BITS_FIS) 6137285809Sscottl { 6138285809Sscottl statSetDevBitFisHeader = (agsaFisSetDevBitsHeader_t *)&(agFirstDword->D2H); 6139285809Sscottl 6140285809Sscottl /* Get ATA Status register */ 6141285809Sscottl ataStatus = (statSetDevBitFisHeader->statusHi_Lo & 0x70); /* bits 4,5,6 */ 6142285809Sscottl ataStatus = ataStatus | (statSetDevBitFisHeader->statusHi_Lo & 0x07); /* bits 0,1,2 */ 6143285809Sscottl 6144285809Sscottl /* ATA Eror register */ 6145285809Sscottl 6146285809Sscottl } 6147285809Sscottl } 6148285809Sscottl 6149285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 6150285809Sscottl { 6151285809Sscottl /* 6152285809Sscottl checking IO status, FIS type and error status 6153285809Sscottl FIS type should be either REG_DEV_TO_HOST_FIS or SET_DEV_BITS_FIS 6154285809Sscottl */ 6155285809Sscottl if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 6156285809Sscottl (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS)) || 6157285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 6158285809Sscottl ) 6159285809Sscottl { 6160285809Sscottl /* for debugging */ 6161285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 6162285809Sscottl { 6163285809Sscottl TI_DBG1(("satWriteSame10CB: FAILED, NOT IO_SUCCESS\n")); 6164285809Sscottl } 6165285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 6166285809Sscottl { 6167285809Sscottl TI_DBG1(("satWriteSame10CB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 6168285809Sscottl } 6169285809Sscottl else if (statDevToHostFisHeader->fisType != SET_DEV_BITS_FIS) 6170285809Sscottl { 6171285809Sscottl TI_DBG1(("satWriteSame10CB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 6172285809Sscottl } 6173285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 6174285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 6175285809Sscottl ) 6176285809Sscottl { 6177285809Sscottl TI_DBG1(("satWriteSame10CB: FAILED, FAILED, error status\n")); 6178285809Sscottl } 6179285809Sscottl 6180285809Sscottl /* Process abort case */ 6181285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 6182285809Sscottl { 6183285809Sscottl satProcessAbort(tiRoot, 6184285809Sscottl tiOrgIORequest, 6185285809Sscottl satOrgIOContext 6186285809Sscottl ); 6187285809Sscottl 6188285809Sscottl 6189285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6190285809Sscottl 6191285809Sscottl satFreeIntIoResource( tiRoot, 6192285809Sscottl satDevData, 6193285809Sscottl satIntIo); 6194285809Sscottl return; 6195285809Sscottl } 6196285809Sscottl 6197285809Sscottl /* for debugging */ 6198285809Sscottl switch (hostToDevFis->h.command) 6199285809Sscottl { 6200285809Sscottl case SAT_WRITE_DMA_EXT: 6201285809Sscottl TI_DBG1(("satWriteSame10CB: SAT_WRITE_DMA_EXT\n")); 6202285809Sscottl break; 6203285809Sscottl case SAT_WRITE_SECTORS_EXT: 6204285809Sscottl TI_DBG1(("satWriteSame10CB: SAT_WRITE_SECTORS_EXT\n")); 6205285809Sscottl break; 6206285809Sscottl case SAT_WRITE_FPDMA_QUEUED: 6207285809Sscottl TI_DBG1(("satWriteSame10CB: SAT_WRITE_FPDMA_QUEUED\n")); 6208285809Sscottl break; 6209285809Sscottl default: 6210285809Sscottl TI_DBG1(("satWriteSame10CB: error default case command 0x%x\n", hostToDevFis->h.command)); 6211285809Sscottl break; 6212285809Sscottl } 6213285809Sscottl 6214285809Sscottl satSetSensePayload( pSense, 6215285809Sscottl SCSI_SNSKEY_NO_SENSE, 6216285809Sscottl 0, 6217285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6218285809Sscottl satOrgIOContext); 6219285809Sscottl 6220285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6221285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 6222285809Sscottl tiIOSuccess, 6223285809Sscottl SCSI_STAT_CHECK_CONDITION, 6224285809Sscottl satOrgIOContext->pTiSenseData, 6225285809Sscottl satOrgIOContext->interruptContext ); 6226285809Sscottl 6227285809Sscottl 6228285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6229285809Sscottl 6230285809Sscottl satFreeIntIoResource( tiRoot, 6231285809Sscottl satDevData, 6232285809Sscottl satIntIo); 6233285809Sscottl return; 6234285809Sscottl } /* end error */ 6235285809Sscottl } 6236285809Sscottl 6237285809Sscottl /* process success from this point on */ 6238285809Sscottl /* 6239285809Sscottl note: inefficient implementation until a single block can be manipulated 6240285809Sscottl */ 6241285809Sscottl 6242285809Sscottl if (hostToDevFis->h.command == SAT_WRITE_DMA_EXT) 6243285809Sscottl { 6244285809Sscottl TI_DBG5(("satWriteSame10CB: SAT_WRITE_DMA_EXT success\n")); 6245285809Sscottl } 6246285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT) 6247285809Sscottl { 6248285809Sscottl TI_DBG5(("satWriteSame10CB: SAT_WRITE_SECTORS_EXT success\n")); 6249285809Sscottl } 6250285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED) 6251285809Sscottl { 6252285809Sscottl TI_DBG5(("satWriteSame10CB: SAT_WRITE_FPDMA_QUEUED success\n")); 6253285809Sscottl } 6254285809Sscottl else 6255285809Sscottl { 6256285809Sscottl TI_DBG1(("satWriteSame10CB: error case command 0x%x success\n", hostToDevFis->h.command)); 6257285809Sscottl satSetSensePayload( pSense, 6258285809Sscottl SCSI_SNSKEY_NO_SENSE, 6259285809Sscottl 0, 6260285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6261285809Sscottl satOrgIOContext); 6262285809Sscottl 6263285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6264285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 6265285809Sscottl tiIOSuccess, 6266285809Sscottl SCSI_STAT_CHECK_CONDITION, 6267285809Sscottl satOrgIOContext->pTiSenseData, 6268285809Sscottl satOrgIOContext->interruptContext ); 6269285809Sscottl 6270285809Sscottl 6271285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6272285809Sscottl 6273285809Sscottl satFreeIntIoResource( tiRoot, 6274285809Sscottl satDevData, 6275285809Sscottl satIntIo); 6276285809Sscottl return; 6277285809Sscottl } 6278285809Sscottl 6279285809Sscottl 6280285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6281285809Sscottl 6282285809Sscottl /* free */ 6283285809Sscottl satFreeIntIoResource( tiRoot, 6284285809Sscottl satDevData, 6285285809Sscottl satIntIo); 6286285809Sscottl 6287285809Sscottl /* 6288285809Sscottl increment LBA by one, keeping the same sector count(1) 6289285809Sscottl sends another ATA command with the changed parameters 6290285809Sscottl */ 6291285809Sscottl 6292285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_SATA_LOCK); 6293285809Sscottl satDevData->satSectorDone++; 6294285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_SATA_LOCK); 6295285809Sscottl 6296285809Sscottl TI_DBG1(("satWriteSame10CB: sectordone %d\n", satDevData->satSectorDone)); 6297285809Sscottl 6298285809Sscottl lba = (scsiCmnd->cdb[2] << (8*3)) + (scsiCmnd->cdb[3] << (8*2)) 6299285809Sscottl + (scsiCmnd->cdb[4] << 8) + scsiCmnd->cdb[5]; 6300285809Sscottl tl = (scsiCmnd->cdb[7] << 8) + scsiCmnd->cdb[8]; 6301285809Sscottl 6302285809Sscottl TI_DBG5(("satWriteSame10CB: lba 0x%x tl 0x%x\n", lba, tl)); 6303285809Sscottl 6304285809Sscottl if (tl == 0) 6305285809Sscottl { 6306285809Sscottl /* (satDevData->satMaxUserAddrSectors - 1) - lba*/ 6307285809Sscottl sectorcount = (0x0FFFFFFF - 1) - lba; 6308285809Sscottl } 6309285809Sscottl else 6310285809Sscottl { 6311285809Sscottl sectorcount = tl; 6312285809Sscottl } 6313285809Sscottl 6314285809Sscottl if (sectorcount <= 0) 6315285809Sscottl { 6316285809Sscottl satSetSensePayload( pSense, 6317285809Sscottl SCSI_SNSKEY_NO_SENSE, 6318285809Sscottl 0, 6319285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6320285809Sscottl satOrgIOContext); 6321285809Sscottl 6322285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6323285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 6324285809Sscottl tiIOSuccess, 6325285809Sscottl SCSI_STAT_CHECK_CONDITION, 6326285809Sscottl satOrgIOContext->pTiSenseData, 6327285809Sscottl satOrgIOContext->interruptContext ); 6328285809Sscottl TI_DBG1(("satWriteSame10CB: incorrect sectorcount 0x%x\n", sectorcount)); 6329285809Sscottl return; 6330285809Sscottl } 6331285809Sscottl 6332285809Sscottl if (sectorcount == satDevData->satSectorDone) 6333285809Sscottl { 6334285809Sscottl /* 6335285809Sscottl done with writesame 6336285809Sscottl */ 6337285809Sscottl TI_DBG1(("satWriteSame10CB: return writesame done\n")); 6338285809Sscottl satDevData->satSectorDone = 0; 6339285809Sscottl 6340285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6341285809Sscottl tiOrgIORequest, 6342285809Sscottl tiIOSuccess, 6343285809Sscottl SCSI_STAT_GOOD, 6344285809Sscottl agNULL, 6345285809Sscottl satOrgIOContext->interruptContext ); 6346285809Sscottl } 6347285809Sscottl else 6348285809Sscottl { 6349285809Sscottl /* sends another ATA command */ 6350285809Sscottl if (hostToDevFis->h.command == SAT_WRITE_DMA_EXT) 6351285809Sscottl { 6352285809Sscottl TI_DBG1(("satWriteSame10CB: sends another SAT_WRITE_DMA_EXT\n")); 6353285809Sscottl } 6354285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT) 6355285809Sscottl { 6356285809Sscottl TI_DBG1(("satWriteSame10CB: sends another SAT_WRITE_SECTORS_EXT\n")); 6357285809Sscottl } 6358285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED) 6359285809Sscottl { 6360285809Sscottl TI_DBG1(("satWriteSame10CB: sends another SAT_WRITE_FPDMA_QUEUED\n")); 6361285809Sscottl } 6362285809Sscottl 6363285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 6364285809Sscottl tiOrgIORequest, 6365285809Sscottl satDevData, 6366285809Sscottl 0, 6367285809Sscottl satNewIntIo); 6368285809Sscottl if (satNewIntIo == agNULL) 6369285809Sscottl { 6370285809Sscottl /* memory allocation failure */ 6371285809Sscottl satFreeIntIoResource( tiRoot, 6372285809Sscottl satDevData, 6373285809Sscottl satNewIntIo); 6374285809Sscottl 6375285809Sscottl satSetSensePayload( pSense, 6376285809Sscottl SCSI_SNSKEY_NO_SENSE, 6377285809Sscottl 0, 6378285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6379285809Sscottl satOrgIOContext); 6380285809Sscottl 6381285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6382285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 6383285809Sscottl tiIOSuccess, 6384285809Sscottl SCSI_STAT_CHECK_CONDITION, 6385285809Sscottl satOrgIOContext->pTiSenseData, 6386285809Sscottl satOrgIOContext->interruptContext ); 6387285809Sscottl TI_DBG1(("satWriteSame10CB: momory allocation fails\n")); 6388285809Sscottl return; 6389285809Sscottl } /* end memory allocation */ 6390285809Sscottl 6391285809Sscottl /* the one to be used */ 6392285809Sscottl tdNewIORequestBody = satNewIntIo->satIntRequestBody; 6393285809Sscottl satNewIOContext = &tdNewIORequestBody->transport.SATA.satIOContext; 6394285809Sscottl 6395285809Sscottl satNewIOContext->pSatDevData = satDevData; 6396285809Sscottl satNewIOContext->pFis = &tdNewIORequestBody->transport.SATA.agSATARequestBody.fis.fisRegHostToDev; 6397285809Sscottl satNewIOContext->pScsiCmnd = &satNewIntIo->satIntTiScsiXchg.scsiCmnd; 6398285809Sscottl /* saves scsi command for LBA and number of blocks */ 6399285809Sscottl osti_memcpy(satNewIOContext->pScsiCmnd, scsiCmnd, sizeof(tiIniScsiCmnd_t)); 6400285809Sscottl satNewIOContext->pSense = &tdNewIORequestBody->transport.SATA.sensePayload; 6401285809Sscottl satNewIOContext->pTiSenseData = &tdNewIORequestBody->transport.SATA.tiSenseData; 6402285809Sscottl satNewIOContext->pTiSenseData->senseData = satNewIOContext->pSense; 6403285809Sscottl satNewIOContext->tiRequestBody = satNewIntIo->satIntRequestBody; 6404285809Sscottl satNewIOContext->interruptContext = satNewIOContext->interruptContext; 6405285809Sscottl satNewIOContext->satIntIoContext = satNewIntIo; 6406285809Sscottl satNewIOContext->ptiDeviceHandle = satIOContext->ptiDeviceHandle; 6407285809Sscottl /* saves tiScsiXchg; only for writesame10() */ 6408285809Sscottl satNewIOContext->tiScsiXchg = satOrgIOContext->tiScsiXchg; 6409285809Sscottl 6410285809Sscottl if (hostToDevFis->h.command == SAT_WRITE_DMA_EXT) 6411285809Sscottl { 6412285809Sscottl status = satWriteSame10_1( tiRoot, 6413285809Sscottl &satNewIntIo->satIntTiIORequest, 6414285809Sscottl satNewIOContext->ptiDeviceHandle, 6415285809Sscottl &satNewIntIo->satIntTiScsiXchg, 6416285809Sscottl satNewIOContext, 6417285809Sscottl lba + satDevData->satSectorDone 6418285809Sscottl ); 6419285809Sscottl } 6420285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT) 6421285809Sscottl { 6422285809Sscottl status = satWriteSame10_2( tiRoot, 6423285809Sscottl &satNewIntIo->satIntTiIORequest, 6424285809Sscottl satNewIOContext->ptiDeviceHandle, 6425285809Sscottl &satNewIntIo->satIntTiScsiXchg, 6426285809Sscottl satNewIOContext, 6427285809Sscottl lba + satDevData->satSectorDone 6428285809Sscottl ); 6429285809Sscottl } 6430285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED) 6431285809Sscottl { 6432285809Sscottl status = satWriteSame10_3( tiRoot, 6433285809Sscottl &satNewIntIo->satIntTiIORequest, 6434285809Sscottl satNewIOContext->ptiDeviceHandle, 6435285809Sscottl &satNewIntIo->satIntTiScsiXchg, 6436285809Sscottl satNewIOContext, 6437285809Sscottl lba + satDevData->satSectorDone 6438285809Sscottl ); 6439285809Sscottl } 6440285809Sscottl else 6441285809Sscottl { 6442285809Sscottl status = tiError; 6443285809Sscottl TI_DBG1(("satWriteSame10CB: sucess but error in command 0x%x\n", hostToDevFis->h.command)); 6444285809Sscottl } 6445285809Sscottl 6446285809Sscottl if (status != tiSuccess) 6447285809Sscottl { 6448285809Sscottl /* sending ATA command fails */ 6449285809Sscottl satFreeIntIoResource( tiRoot, 6450285809Sscottl satDevData, 6451285809Sscottl satNewIntIo); 6452285809Sscottl satSetSensePayload( pSense, 6453285809Sscottl SCSI_SNSKEY_NO_SENSE, 6454285809Sscottl 0, 6455285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6456285809Sscottl satOrgIOContext); 6457285809Sscottl 6458285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6459285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 6460285809Sscottl tiIOSuccess, 6461285809Sscottl SCSI_STAT_CHECK_CONDITION, 6462285809Sscottl satOrgIOContext->pTiSenseData, 6463285809Sscottl satOrgIOContext->interruptContext ); 6464285809Sscottl TI_DBG1(("satWriteSame10CB:calling satWriteSame10_1 fails\n")); 6465285809Sscottl return; 6466285809Sscottl } /* end send fails */ 6467285809Sscottl 6468285809Sscottl } /* end sends another ATA command */ 6469285809Sscottl 6470285809Sscottl return; 6471285809Sscottl} 6472285809Sscottl/***************************************************************************** 6473285809Sscottl*! \brief satStartStopUnitCB 6474285809Sscottl* 6475285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 6476285809Sscottl* This CB routine deals with Send Diagnostic completion. 6477285809Sscottl* 6478285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 6479285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 6480285809Sscottl* \param agIOStatus: Status of completed I/O. 6481285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 6482285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 6483285809Sscottl* length. 6484285809Sscottl* \param agParam: Additional info based on status. 6485285809Sscottl* \param ioContext: Pointer to satIOContext_t. 6486285809Sscottl* 6487285809Sscottl* \return: none 6488285809Sscottl* 6489285809Sscottl*****************************************************************************/ 6490285809Sscottlvoid satStartStopUnitCB( 6491285809Sscottl agsaRoot_t *agRoot, 6492285809Sscottl agsaIORequest_t *agIORequest, 6493285809Sscottl bit32 agIOStatus, 6494285809Sscottl agsaFisHeader_t *agFirstDword, 6495285809Sscottl bit32 agIOInfoLen, 6496285809Sscottl void *agParam, 6497285809Sscottl void *ioContext 6498285809Sscottl ) 6499285809Sscottl{ 6500285809Sscottl /* 6501285809Sscottl In the process of StartStopUnit 6502285809Sscottl Process FLUSH CACHE (EXT) 6503285809Sscottl Process STANDBY 6504285809Sscottl Process READ VERIFY SECTOR(S) EXT 6505285809Sscottl Process MEDIA EJECT 6506285809Sscottl */ 6507285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 6508285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 6509285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 6510285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 6511285809Sscottl tdIORequestBody_t *tdIORequestBody; 6512285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 6513285809Sscottl satIOContext_t *satIOContext; 6514285809Sscottl satIOContext_t *satOrgIOContext; 6515285809Sscottl satIOContext_t *satNewIOContext; 6516285809Sscottl satInternalIo_t *satIntIo; 6517285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 6518285809Sscottl satDeviceData_t *satDevData; 6519285809Sscottl scsiRspSense_t *pSense; 6520285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 6521285809Sscottl tiIORequest_t *tiOrgIORequest; 6522285809Sscottl 6523285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 6524285809Sscottl bit32 ataStatus = 0; 6525285809Sscottl bit32 status; 6526285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 6527285809Sscottl 6528285809Sscottl TI_DBG5(("satStartStopUnitCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 6529285809Sscottl 6530285809Sscottl /* internally generate tiIOContext */ 6531285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 6532285809Sscottl satIOContext = (satIOContext_t *) ioContext; 6533285809Sscottl satIntIo = satIOContext->satIntIoContext; 6534285809Sscottl satDevData = satIOContext->pSatDevData; 6535285809Sscottl hostToDevFis = satIOContext->pFis; 6536285809Sscottl 6537285809Sscottl if (satIntIo == agNULL) 6538285809Sscottl { 6539285809Sscottl TI_DBG4(("satStartStopUnitCB: External satInternalIo_t satIntIoContext\n")); 6540285809Sscottl satOrgIOContext = satIOContext; 6541285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 6542285809Sscottl pSense = satIOContext->pSense; 6543285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 6544285809Sscottl } 6545285809Sscottl else 6546285809Sscottl { 6547285809Sscottl TI_DBG4(("satStartStopUnitCB: Internal satInternalIo_t satIntIoContext\n")); 6548285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 6549285809Sscottl if (satOrgIOContext == agNULL) 6550285809Sscottl { 6551285809Sscottl TI_DBG4(("satStartStopUnitCB: satOrgIOContext is NULL, wrong\n")); 6552285809Sscottl return; 6553285809Sscottl } 6554285809Sscottl else 6555285809Sscottl { 6556285809Sscottl TI_DBG4(("satStartStopUnitCB: satOrgIOContext is NOT NULL\n")); 6557285809Sscottl } 6558285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 6559285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 6560285809Sscottl 6561285809Sscottl pSense = satOrgIOContext->pSense; 6562285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 6563285809Sscottl } 6564285809Sscottl 6565285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 6566285809Sscottl tdIORequestBody->ioStarted = agFALSE; 6567285809Sscottl 6568285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 6569285809Sscottl { 6570285809Sscottl TI_DBG1(("satStartStopUnitCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 6571285809Sscottl 6572285809Sscottl /* IMMED == 0 */ 6573285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 6574285809Sscottl { 6575285809Sscottl TI_DBG1(("satStartStopUnitCB: immed bit 0\n")); 6576285809Sscottl satSetSensePayload( pSense, 6577285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6578285809Sscottl 0, 6579285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6580285809Sscottl satOrgIOContext); 6581285809Sscottl 6582285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6583285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6584285809Sscottl tiIOSuccess, 6585285809Sscottl SCSI_STAT_CHECK_CONDITION, 6586285809Sscottl satOrgIOContext->pTiSenseData, 6587285809Sscottl satOrgIOContext->interruptContext ); 6588285809Sscottl 6589285809Sscottl 6590285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6591285809Sscottl satFreeIntIoResource( tiRoot, 6592285809Sscottl satDevData, 6593285809Sscottl satIntIo); 6594285809Sscottl } 6595285809Sscottl /* IMMED == 1 */ 6596285809Sscottl if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 6597285809Sscottl { 6598285809Sscottl TI_DBG1(("satStartStopUnitCB: immed bit 1\n")); 6599285809Sscottl satSetDeferredSensePayload( pSense, 6600285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6601285809Sscottl 0, 6602285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6603285809Sscottl satOrgIOContext); 6604285809Sscottl 6605285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6606285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6607285809Sscottl tiIOSuccess, 6608285809Sscottl SCSI_STAT_CHECK_CONDITION, 6609285809Sscottl satOrgIOContext->pTiSenseData, 6610285809Sscottl satOrgIOContext->interruptContext ); 6611285809Sscottl 6612285809Sscottl 6613285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6614285809Sscottl satFreeIntIoResource( tiRoot, 6615285809Sscottl satDevData, 6616285809Sscottl satIntIo); 6617285809Sscottl } 6618285809Sscottl 6619285809Sscottl 6620285809Sscottl 6621285809Sscottl return; 6622285809Sscottl } 6623285809Sscottl 6624285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 6625285809Sscottl { 6626285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 6627285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 6628285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 6629285809Sscottl } 6630285809Sscottl /* 6631285809Sscottl checking IO status, FIS type and error status 6632285809Sscottl */ 6633285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 6634285809Sscottl { 6635285809Sscottl if( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 6636285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 6637285809Sscottl ) 6638285809Sscottl { 6639285809Sscottl /* for debugging */ 6640285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 6641285809Sscottl { 6642285809Sscottl TI_DBG1(("satStartStopUnitCB: FAILED, NOT IO_SUCCESS\n")); 6643285809Sscottl } 6644285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 6645285809Sscottl { 6646285809Sscottl TI_DBG1(("satStartStopUnitCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 6647285809Sscottl } 6648285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 6649285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 6650285809Sscottl ) 6651285809Sscottl { 6652285809Sscottl TI_DBG1(("satStartStopUnitCB: FAILED, FAILED, error status\n")); 6653285809Sscottl } 6654285809Sscottl 6655285809Sscottl 6656285809Sscottl /* Process abort case */ 6657285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 6658285809Sscottl { 6659285809Sscottl satProcessAbort(tiRoot, 6660285809Sscottl tiOrgIORequest, 6661285809Sscottl satOrgIOContext 6662285809Sscottl ); 6663285809Sscottl 6664285809Sscottl 6665285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6666285809Sscottl 6667285809Sscottl satFreeIntIoResource( tiRoot, 6668285809Sscottl satDevData, 6669285809Sscottl satIntIo); 6670285809Sscottl return; 6671285809Sscottl } 6672285809Sscottl 6673285809Sscottl switch (hostToDevFis->h.command) 6674285809Sscottl { 6675285809Sscottl case SAT_FLUSH_CACHE: /* fall through */ 6676285809Sscottl case SAT_FLUSH_CACHE_EXT: 6677285809Sscottl TI_DBG1(("satStartStopUnitCB: SAT_FLUSH_CACHE(_EXT)\n")); 6678285809Sscottl /* check immed bit in scsi command */ 6679285809Sscottl /* IMMED == 0 */ 6680285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 6681285809Sscottl { 6682285809Sscottl satSetSensePayload( pSense, 6683285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6684285809Sscottl 0, 6685285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6686285809Sscottl satOrgIOContext); 6687285809Sscottl 6688285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6689285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6690285809Sscottl tiIOSuccess, 6691285809Sscottl SCSI_STAT_CHECK_CONDITION, 6692285809Sscottl satOrgIOContext->pTiSenseData, 6693285809Sscottl satOrgIOContext->interruptContext ); 6694285809Sscottl 6695285809Sscottl 6696285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6697285809Sscottl 6698285809Sscottl satFreeIntIoResource( tiRoot, 6699285809Sscottl satDevData, 6700285809Sscottl satIntIo); 6701285809Sscottl } 6702285809Sscottl /* IMMED == 1 */ 6703285809Sscottl if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 6704285809Sscottl { 6705285809Sscottl satSetDeferredSensePayload( pSense, 6706285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6707285809Sscottl 0, 6708285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6709285809Sscottl satOrgIOContext); 6710285809Sscottl 6711285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6712285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6713285809Sscottl tiIOSuccess, 6714285809Sscottl SCSI_STAT_CHECK_CONDITION, 6715285809Sscottl satOrgIOContext->pTiSenseData, 6716285809Sscottl satOrgIOContext->interruptContext ); 6717285809Sscottl 6718285809Sscottl 6719285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6720285809Sscottl 6721285809Sscottl satFreeIntIoResource( tiRoot, 6722285809Sscottl satDevData, 6723285809Sscottl satIntIo); 6724285809Sscottl } 6725285809Sscottl break; 6726285809Sscottl case SAT_STANDBY: 6727285809Sscottl TI_DBG5(("satStartStopUnitCB: SAT_STANDBY\n")); 6728285809Sscottl /* check immed bit in scsi command */ 6729285809Sscottl /* IMMED == 0 */ 6730285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 6731285809Sscottl { 6732285809Sscottl satSetSensePayload( pSense, 6733285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6734285809Sscottl 0, 6735285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6736285809Sscottl satOrgIOContext); 6737285809Sscottl 6738285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6739285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6740285809Sscottl tiIOSuccess, 6741285809Sscottl SCSI_STAT_CHECK_CONDITION, 6742285809Sscottl satOrgIOContext->pTiSenseData, 6743285809Sscottl satOrgIOContext->interruptContext ); 6744285809Sscottl 6745285809Sscottl 6746285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6747285809Sscottl 6748285809Sscottl satFreeIntIoResource( tiRoot, 6749285809Sscottl satDevData, 6750285809Sscottl satIntIo); 6751285809Sscottl } 6752285809Sscottl /* IMMED == 1 */ 6753285809Sscottl if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 6754285809Sscottl { 6755285809Sscottl satSetDeferredSensePayload( pSense, 6756285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6757285809Sscottl 0, 6758285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6759285809Sscottl satOrgIOContext); 6760285809Sscottl 6761285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6762285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6763285809Sscottl tiIOSuccess, 6764285809Sscottl SCSI_STAT_CHECK_CONDITION, 6765285809Sscottl satOrgIOContext->pTiSenseData, 6766285809Sscottl satOrgIOContext->interruptContext ); 6767285809Sscottl 6768285809Sscottl 6769285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6770285809Sscottl 6771285809Sscottl satFreeIntIoResource( tiRoot, 6772285809Sscottl satDevData, 6773285809Sscottl satIntIo); 6774285809Sscottl } 6775285809Sscottl break; 6776285809Sscottl case SAT_READ_VERIFY_SECTORS: /* fall through */ 6777285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 6778285809Sscottl TI_DBG5(("satStartStopUnitCB: SAT_READ_VERIFY_SECTORS(_EXT)\n")); 6779285809Sscottl /* IMMED == 0 */ 6780285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 6781285809Sscottl { 6782285809Sscottl satSetSensePayload( pSense, 6783285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6784285809Sscottl 0, 6785285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6786285809Sscottl satOrgIOContext); 6787285809Sscottl 6788285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6789285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6790285809Sscottl tiIOSuccess, 6791285809Sscottl SCSI_STAT_CHECK_CONDITION, 6792285809Sscottl satOrgIOContext->pTiSenseData, 6793285809Sscottl satOrgIOContext->interruptContext ); 6794285809Sscottl 6795285809Sscottl 6796285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6797285809Sscottl 6798285809Sscottl satFreeIntIoResource( tiRoot, 6799285809Sscottl satDevData, 6800285809Sscottl satIntIo); 6801285809Sscottl } 6802285809Sscottl /* IMMED == 1 */ 6803285809Sscottl if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 6804285809Sscottl { 6805285809Sscottl satSetDeferredSensePayload( pSense, 6806285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6807285809Sscottl 0, 6808285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6809285809Sscottl satOrgIOContext); 6810285809Sscottl 6811285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6812285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6813285809Sscottl tiIOSuccess, 6814285809Sscottl SCSI_STAT_CHECK_CONDITION, 6815285809Sscottl satOrgIOContext->pTiSenseData, 6816285809Sscottl satOrgIOContext->interruptContext ); 6817285809Sscottl 6818285809Sscottl 6819285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6820285809Sscottl 6821285809Sscottl satFreeIntIoResource( tiRoot, 6822285809Sscottl satDevData, 6823285809Sscottl satIntIo); 6824285809Sscottl } 6825285809Sscottl break; 6826285809Sscottl case SAT_MEDIA_EJECT: 6827285809Sscottl TI_DBG5(("satStartStopUnitCB: SAT_MEDIA_EJECT\n")); 6828285809Sscottl /* IMMED == 0 */ 6829285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 6830285809Sscottl { 6831285809Sscottl satSetSensePayload( pSense, 6832285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6833285809Sscottl 0, 6834285809Sscottl SCSI_SNSCODE_MEDIA_LOAD_OR_EJECT_FAILED, 6835285809Sscottl satOrgIOContext); 6836285809Sscottl 6837285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6838285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6839285809Sscottl tiIOSuccess, 6840285809Sscottl SCSI_STAT_CHECK_CONDITION, 6841285809Sscottl satOrgIOContext->pTiSenseData, 6842285809Sscottl satOrgIOContext->interruptContext ); 6843285809Sscottl 6844285809Sscottl 6845285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6846285809Sscottl 6847285809Sscottl satFreeIntIoResource( tiRoot, 6848285809Sscottl satDevData, 6849285809Sscottl satIntIo); 6850285809Sscottl } 6851285809Sscottl /* IMMED == 1 */ 6852285809Sscottl if ( scsiCmnd->cdb[1] & SCSI_IMMED_MASK) 6853285809Sscottl { 6854285809Sscottl satSetDeferredSensePayload( pSense, 6855285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6856285809Sscottl 0, 6857285809Sscottl SCSI_SNSCODE_MEDIA_LOAD_OR_EJECT_FAILED, 6858285809Sscottl satOrgIOContext); 6859285809Sscottl 6860285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6861285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 6862285809Sscottl tiIOSuccess, 6863285809Sscottl SCSI_STAT_CHECK_CONDITION, 6864285809Sscottl satOrgIOContext->pTiSenseData, 6865285809Sscottl satOrgIOContext->interruptContext ); 6866285809Sscottl 6867285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6868285809Sscottl 6869285809Sscottl satFreeIntIoResource( tiRoot, 6870285809Sscottl satDevData, 6871285809Sscottl satIntIo); 6872285809Sscottl } 6873285809Sscottl break; 6874285809Sscottl default: 6875285809Sscottl /* unspecified case, return no sense and no addition info */ 6876285809Sscottl TI_DBG5(("satStartStopUnitCB: default command %d\n", hostToDevFis->h.command)); 6877285809Sscottl satSetSensePayload( pSense, 6878285809Sscottl SCSI_SNSKEY_NO_SENSE, 6879285809Sscottl 0, 6880285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 6881285809Sscottl satOrgIOContext); 6882285809Sscottl 6883285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6884285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 6885285809Sscottl tiIOSuccess, 6886285809Sscottl SCSI_STAT_CHECK_CONDITION, 6887285809Sscottl satOrgIOContext->pTiSenseData, 6888285809Sscottl satOrgIOContext->interruptContext ); 6889285809Sscottl 6890285809Sscottl 6891285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6892285809Sscottl 6893285809Sscottl satFreeIntIoResource( tiRoot, 6894285809Sscottl satDevData, 6895285809Sscottl satIntIo); 6896285809Sscottl break; 6897285809Sscottl } /* switch */ 6898285809Sscottl 6899285809Sscottl return; 6900285809Sscottl } /* error check */ 6901285809Sscottl } 6902285809Sscottl 6903285809Sscottl /* ATA command completes sucessfully */ 6904285809Sscottl switch (hostToDevFis->h.command) 6905285809Sscottl { 6906285809Sscottl case SAT_FLUSH_CACHE: /* fall through */ 6907285809Sscottl case SAT_FLUSH_CACHE_EXT: 6908285809Sscottl TI_DBG5(("satStartStopUnitCB: SAT_READ_VERIFY_SECTORS(_EXT) success case\n")); 6909285809Sscottl 6910285809Sscottl 6911285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 6912285809Sscottl 6913285809Sscottl /* done with SAT_FLUSH_CACHE(_EXT) */ 6914285809Sscottl satFreeIntIoResource( tiRoot, 6915285809Sscottl satDevData, 6916285809Sscottl satIntIo); 6917285809Sscottl 6918285809Sscottl /* at this point, successful SAT_READ_VERIFY_SECTORS(_EXT) 6919285809Sscottl send SAT_SATNDBY 6920285809Sscottl */ 6921285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 6922285809Sscottl tiOrgIORequest, 6923285809Sscottl satDevData, 6924285809Sscottl 0, 6925285809Sscottl satNewIntIo); 6926285809Sscottl if (satNewIntIo == agNULL) 6927285809Sscottl { 6928285809Sscottl /* memory allocation failure */ 6929285809Sscottl satFreeIntIoResource( tiRoot, 6930285809Sscottl satDevData, 6931285809Sscottl satNewIntIo); 6932285809Sscottl /* IMMED == 0 */ 6933285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 6934285809Sscottl { 6935285809Sscottl satSetSensePayload( pSense, 6936285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6937285809Sscottl 0, 6938285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6939285809Sscottl satOrgIOContext); 6940285809Sscottl } 6941285809Sscottl else /* IMMED == 1 */ 6942285809Sscottl { 6943285809Sscottl satSetDeferredSensePayload( pSense, 6944285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6945285809Sscottl 0, 6946285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6947285809Sscottl satOrgIOContext); 6948285809Sscottl } 6949285809Sscottl ostiInitiatorIOCompleted( tiRoot, 6950285809Sscottl tiOrgIORequest, 6951285809Sscottl tiIOSuccess, 6952285809Sscottl SCSI_STAT_CHECK_CONDITION, 6953285809Sscottl satOrgIOContext->pTiSenseData, 6954285809Sscottl satOrgIOContext->interruptContext ); 6955285809Sscottl 6956285809Sscottl TI_DBG1(("satStartStopUnitCB: momory allocation fails\n")); 6957285809Sscottl return; 6958285809Sscottl } /* end of memory allocation failure */ 6959285809Sscottl 6960285809Sscottl /* 6961285809Sscottl * Need to initialize all the fields within satIOContext 6962285809Sscottl */ 6963285809Sscottl 6964285809Sscottl satNewIOContext = satPrepareNewIO( 6965285809Sscottl satNewIntIo, 6966285809Sscottl tiOrgIORequest, 6967285809Sscottl satDevData, 6968285809Sscottl scsiCmnd, 6969285809Sscottl satOrgIOContext 6970285809Sscottl ); 6971285809Sscottl 6972285809Sscottl /* sending SAT_STANDBY */ 6973285809Sscottl status = satStartStopUnit_1( tiRoot, 6974285809Sscottl &satNewIntIo->satIntTiIORequest, 6975285809Sscottl satNewIOContext->ptiDeviceHandle, 6976285809Sscottl &satNewIntIo->satIntTiScsiXchg, 6977285809Sscottl satNewIOContext); 6978285809Sscottl 6979285809Sscottl if (status != tiSuccess) 6980285809Sscottl { 6981285809Sscottl /* sending SAT_CHECK_POWER_MODE fails */ 6982285809Sscottl satFreeIntIoResource( tiRoot, 6983285809Sscottl satDevData, 6984285809Sscottl satNewIntIo); 6985285809Sscottl 6986285809Sscottl /* IMMED == 0 */ 6987285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 6988285809Sscottl { 6989285809Sscottl satSetSensePayload( pSense, 6990285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6991285809Sscottl 0, 6992285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 6993285809Sscottl satOrgIOContext); 6994285809Sscottl } 6995285809Sscottl else /* IMMED == 1 */ 6996285809Sscottl { 6997285809Sscottl satSetDeferredSensePayload( pSense, 6998285809Sscottl SCSI_SNSKEY_ABORTED_COMMAND, 6999285809Sscottl 0, 7000285809Sscottl SCSI_SNSCODE_COMMAND_SEQUENCE_ERROR, 7001285809Sscottl satOrgIOContext); 7002285809Sscottl } 7003285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7004285809Sscottl tiOrgIORequest, 7005285809Sscottl tiIOSuccess, 7006285809Sscottl SCSI_STAT_CHECK_CONDITION, 7007285809Sscottl satOrgIOContext->pTiSenseData, 7008285809Sscottl satOrgIOContext->interruptContext ); 7009285809Sscottl 7010285809Sscottl TI_DBG1(("satStartStopUnitCB: calling satStartStopUnit_1 fails\n")); 7011285809Sscottl return; 7012285809Sscottl } 7013285809Sscottl break; 7014285809Sscottl case SAT_STANDBY: 7015285809Sscottl TI_DBG5(("satStartStopUnitCB: SAT_STANDBY success case\n")); 7016285809Sscottl 7017285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7018285809Sscottl 7019285809Sscottl /* done with SAT_STANDBY */ 7020285809Sscottl satFreeIntIoResource( tiRoot, 7021285809Sscottl satDevData, 7022285809Sscottl satIntIo); 7023285809Sscottl /* 7024285809Sscottl if immed == 0, return good status 7025285809Sscottl */ 7026285809Sscottl /* IMMED == 0 */ 7027285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 7028285809Sscottl { 7029285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7030285809Sscottl tiOrgIORequest, 7031285809Sscottl tiIOSuccess, 7032285809Sscottl SCSI_STAT_GOOD, 7033285809Sscottl agNULL, 7034285809Sscottl satOrgIOContext->interruptContext ); 7035285809Sscottl } 7036285809Sscottl satDevData->satStopState = agTRUE; 7037285809Sscottl break; 7038285809Sscottl case SAT_READ_VERIFY_SECTORS: /* fall through */ 7039285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 7040285809Sscottl TI_DBG5(("satStartStopUnitCB: SAT_READ_VERIFY_SECTORS(_EXT) success case\n")); 7041285809Sscottl 7042285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7043285809Sscottl 7044285809Sscottl /* done with SAT_READ_VERIFY_SECTORS(_EXT) */ 7045285809Sscottl satFreeIntIoResource( tiRoot, 7046285809Sscottl satDevData, 7047285809Sscottl satIntIo); 7048285809Sscottl /* 7049285809Sscottl if immed == 0, return good status 7050285809Sscottl */ 7051285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 7052285809Sscottl { 7053285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7054285809Sscottl tiOrgIORequest, 7055285809Sscottl tiIOSuccess, 7056285809Sscottl SCSI_STAT_GOOD, 7057285809Sscottl agNULL, 7058285809Sscottl satOrgIOContext->interruptContext ); 7059285809Sscottl } 7060285809Sscottl /* 7061285809Sscottl if immed == 0, return good status 7062285809Sscottl */ 7063285809Sscottl /* 7064285809Sscottl don't forget to check and set driver state; Active power state 7065285809Sscottl */ 7066285809Sscottl satDevData->satStopState = agFALSE; 7067285809Sscottl break; 7068285809Sscottl case SAT_MEDIA_EJECT: 7069285809Sscottl TI_DBG5(("satStartStopUnitCB: SAT_MEDIA_EJECT success case\n")); 7070285809Sscottl 7071285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7072285809Sscottl 7073285809Sscottl /* done with SAT_READ_VERIFY_SECTORS(_EXT) */ 7074285809Sscottl satFreeIntIoResource( tiRoot, 7075285809Sscottl satDevData, 7076285809Sscottl satIntIo); 7077285809Sscottl /* 7078285809Sscottl if immed == 0, return good status 7079285809Sscottl */ 7080285809Sscottl if (!( scsiCmnd->cdb[1] & SCSI_IMMED_MASK)) 7081285809Sscottl { 7082285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7083285809Sscottl tiOrgIORequest, 7084285809Sscottl tiIOSuccess, 7085285809Sscottl SCSI_STAT_GOOD, 7086285809Sscottl agNULL, 7087285809Sscottl satOrgIOContext->interruptContext ); 7088285809Sscottl } 7089285809Sscottl break; 7090285809Sscottl default: 7091285809Sscottl TI_DBG1(("satStartStopUnitCB:success but error default case command 0x%x\n", hostToDevFis->h.command)); 7092285809Sscottl 7093285809Sscottl /* unspecified case, return no sense and no addition info */ 7094285809Sscottl satSetSensePayload( pSense, 7095285809Sscottl SCSI_SNSKEY_NO_SENSE, 7096285809Sscottl 0, 7097285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 7098285809Sscottl satOrgIOContext); 7099285809Sscottl 7100285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7101285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 7102285809Sscottl tiIOSuccess, 7103285809Sscottl SCSI_STAT_CHECK_CONDITION, 7104285809Sscottl satOrgIOContext->pTiSenseData, 7105285809Sscottl satOrgIOContext->interruptContext ); 7106285809Sscottl 7107285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7108285809Sscottl 7109285809Sscottl satFreeIntIoResource( tiRoot, 7110285809Sscottl satDevData, 7111285809Sscottl satIntIo); 7112285809Sscottl break; 7113285809Sscottl } 7114285809Sscottl return; 7115285809Sscottl} 7116285809Sscottl 7117285809Sscottl/***************************************************************************** 7118285809Sscottl*! \brief satSendDiagnosticCB 7119285809Sscottl* 7120285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 7121285809Sscottl* This CB routine deals with Send Diagnostic completion. 7122285809Sscottl* 7123285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 7124285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 7125285809Sscottl* \param agIOStatus: Status of completed I/O. 7126285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 7127285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 7128285809Sscottl* length. 7129285809Sscottl* \param agParam: Additional info based on status. 7130285809Sscottl* \param ioContext: Pointer to satIOContext_t. 7131285809Sscottl* 7132285809Sscottl* \return: none 7133285809Sscottl* 7134285809Sscottl*****************************************************************************/ 7135285809Sscottlvoid satSendDiagnosticCB( 7136285809Sscottl agsaRoot_t *agRoot, 7137285809Sscottl agsaIORequest_t *agIORequest, 7138285809Sscottl bit32 agIOStatus, 7139285809Sscottl agsaFisHeader_t *agFirstDword, 7140285809Sscottl bit32 agIOInfoLen, 7141285809Sscottl void *agParam, 7142285809Sscottl void *ioContext 7143285809Sscottl ) 7144285809Sscottl{ 7145285809Sscottl /* 7146285809Sscottl In the process of SendDiagnotic 7147285809Sscottl Process READ VERIFY SECTOR(S) EXT two time 7148285809Sscottl Process SMART ECECUTE OFF-LINE IMMEDIATE 7149285809Sscottl */ 7150285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7151285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7152285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 7153285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 7154285809Sscottl tdIORequestBody_t *tdIORequestBody; 7155285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 7156285809Sscottl satIOContext_t *satIOContext; 7157285809Sscottl satIOContext_t *satOrgIOContext; 7158285809Sscottl satIOContext_t *satNewIOContext; 7159285809Sscottl satInternalIo_t *satIntIo; 7160285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 7161285809Sscottl satDeviceData_t *satDevData; 7162285809Sscottl scsiRspSense_t *pSense; 7163285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 7164285809Sscottl tiIORequest_t *tiOrgIORequest; 7165285809Sscottl 7166285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 7167285809Sscottl bit32 ataStatus = 0; 7168285809Sscottl bit32 status; 7169285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 7170285809Sscottl 7171285809Sscottl 7172285809Sscottl TI_DBG5(("satSendDiagnosticCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 7173285809Sscottl 7174285809Sscottl /* internally generate tiIOContext */ 7175285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 7176285809Sscottl satIOContext = (satIOContext_t *) ioContext; 7177285809Sscottl satIntIo = satIOContext->satIntIoContext; 7178285809Sscottl satDevData = satIOContext->pSatDevData; 7179285809Sscottl hostToDevFis = satIOContext->pFis; 7180285809Sscottl 7181285809Sscottl if (satIntIo == agNULL) 7182285809Sscottl { 7183285809Sscottl TI_DBG4(("satSendDiagnosticCB: External satInternalIo_t satIntIoContext\n")); 7184285809Sscottl satOrgIOContext = satIOContext; 7185285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 7186285809Sscottl pSense = satOrgIOContext->pSense; 7187285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 7188285809Sscottl } 7189285809Sscottl else 7190285809Sscottl { 7191285809Sscottl TI_DBG4(("satSendDiagnosticCB: Internal satInternalIo_t satIntIoContext\n")); 7192285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 7193285809Sscottl if (satOrgIOContext == agNULL) 7194285809Sscottl { 7195285809Sscottl TI_DBG4(("satSendDiagnosticCB: satOrgIOContext is NULL, wrong\n")); 7196285809Sscottl return; 7197285809Sscottl } 7198285809Sscottl else 7199285809Sscottl { 7200285809Sscottl TI_DBG4(("satSendDiagnosticCB: satOrgIOContext is NOT NULL\n")); 7201285809Sscottl } 7202285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 7203285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 7204285809Sscottl pSense = satOrgIOContext->pSense; 7205285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 7206285809Sscottl } 7207285809Sscottl 7208285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 7209285809Sscottl tdIORequestBody->ioStarted = agFALSE; 7210285809Sscottl 7211285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 7212285809Sscottl { 7213285809Sscottl TI_DBG1(("satSendDiagnosticCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 7214285809Sscottl satDevData->satVerifyState = 0; 7215285809Sscottl satDevData->satBGPendingDiag = agFALSE; 7216285809Sscottl 7217285809Sscottl if (hostToDevFis->d.lbaLow != 0x01 && hostToDevFis->d.lbaLow != 0x02) 7218285809Sscottl { 7219285809Sscottl /* no completion for background send diagnotic. It is done in satSendDiagnostic() */ 7220285809Sscottl ostiInitiatorIOCompleted ( 7221285809Sscottl tiRoot, 7222285809Sscottl tiOrgIORequest, 7223285809Sscottl tiIOFailed, 7224285809Sscottl tiDetailOtherError, 7225285809Sscottl agNULL, 7226285809Sscottl satOrgIOContext->interruptContext 7227285809Sscottl ); 7228285809Sscottl } 7229285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7230285809Sscottl 7231285809Sscottl satFreeIntIoResource( tiRoot, 7232285809Sscottl satDevData, 7233285809Sscottl satIntIo); 7234285809Sscottl return; 7235285809Sscottl 7236285809Sscottl } 7237285809Sscottl 7238285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 7239285809Sscottl { 7240285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 7241285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 7242285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 7243285809Sscottl } 7244285809Sscottl 7245285809Sscottl TI_DBG5(("satSendDiagnosticCB: fis command 0x%x\n", hostToDevFis->h.command)); 7246285809Sscottl 7247285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 7248285809Sscottl { 7249285809Sscottl /* 7250285809Sscottl checking IO status, FIS type and error status 7251285809Sscottl */ 7252285809Sscottl satDevData->satVerifyState = 0; 7253285809Sscottl satDevData->satBGPendingDiag = agFALSE; 7254285809Sscottl 7255285809Sscottl if( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 7256285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 7257285809Sscottl ) 7258285809Sscottl { 7259285809Sscottl 7260285809Sscottl /* for debugging */ 7261285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 7262285809Sscottl { 7263285809Sscottl if ( (hostToDevFis->h.command == SAT_SMART_RETURN_STATUS) || 7264285809Sscottl (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT) ) 7265285809Sscottl { 7266285809Sscottl TI_DBG1(("satSendDiagnosticCB: FAILED, NOT IO_SUCCESS and SAT_READ_VERIFY_SECTORS(_EXT)\n")); 7267285809Sscottl } 7268285809Sscottl else 7269285809Sscottl { 7270285809Sscottl TI_DBG1(("satSendDiagnosticCB: FAILED, NOT IO_SUCCESS and SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE\n")); 7271285809Sscottl } 7272285809Sscottl } 7273285809Sscottl 7274285809Sscottl /* for debugging */ 7275285809Sscottl if( statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 7276285809Sscottl { 7277285809Sscottl if ( (hostToDevFis->h.command == SAT_SMART_RETURN_STATUS) || 7278285809Sscottl (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT) ) 7279285809Sscottl { 7280285809Sscottl TI_DBG1(("satSendDiagnosticCB: FAILED, Wrong FIS type 0x%x and SAT_READ_VERIFY_SECTORS(_EXT)\n", statDevToHostFisHeader->fisType)); 7281285809Sscottl } 7282285809Sscottl else 7283285809Sscottl { 7284285809Sscottl TI_DBG1(("satSendDiagnosticCB: FAILED, Wrong FIS type 0x%x and SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE\n",statDevToHostFisHeader->fisType)); 7285285809Sscottl } 7286285809Sscottl } 7287285809Sscottl 7288285809Sscottl /* for debugging */ 7289285809Sscottl if ( (ataStatus & ERR_ATA_STATUS_MASK) || 7290285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 7291285809Sscottl ) 7292285809Sscottl { 7293285809Sscottl if ( (hostToDevFis->h.command == SAT_SMART_RETURN_STATUS) || 7294285809Sscottl (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT) ) 7295285809Sscottl { 7296285809Sscottl TI_DBG1(("satSendDiagnosticCB: FAILED, error status and SAT_READ_VERIFY_SECTORS(_EXT)\n")); 7297285809Sscottl } 7298285809Sscottl else 7299285809Sscottl { 7300285809Sscottl TI_DBG1(("satSendDiagnosticCB: FAILED, error status and SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE\n")); 7301285809Sscottl } 7302285809Sscottl } 7303285809Sscottl 7304285809Sscottl /* Process abort case */ 7305285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 7306285809Sscottl { 7307285809Sscottl satProcessAbort(tiRoot, 7308285809Sscottl tiOrgIORequest, 7309285809Sscottl satOrgIOContext 7310285809Sscottl ); 7311285809Sscottl 7312285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7313285809Sscottl 7314285809Sscottl satFreeIntIoResource( tiRoot, 7315285809Sscottl satDevData, 7316285809Sscottl satIntIo); 7317285809Sscottl return; 7318285809Sscottl } 7319285809Sscottl 7320285809Sscottl if ( (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS) || 7321285809Sscottl (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT) ) 7322285809Sscottl { 7323285809Sscottl /* report using the original tiIOrequst */ 7324285809Sscottl /* failed during sending SAT_READ_VERIFY_SECTORS(_EXT) */ 7325285809Sscottl satSetSensePayload( pSense, 7326285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 7327285809Sscottl 0, 7328285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 7329285809Sscottl satOrgIOContext); 7330285809Sscottl 7331285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7332285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 7333285809Sscottl tiIOSuccess, 7334285809Sscottl SCSI_STAT_CHECK_CONDITION, 7335285809Sscottl satOrgIOContext->pTiSenseData, 7336285809Sscottl satOrgIOContext->interruptContext ); 7337285809Sscottl 7338285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7339285809Sscottl 7340285809Sscottl satFreeIntIoResource( tiRoot, 7341285809Sscottl satDevData, 7342285809Sscottl satIntIo); 7343285809Sscottl return; 7344285809Sscottl } 7345285809Sscottl else 7346285809Sscottl { 7347285809Sscottl /* report using the original tiIOrequst */ 7348285809Sscottl /* failed during sending SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE */ 7349285809Sscottl satSetSensePayload( pSense, 7350285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 7351285809Sscottl 0, 7352285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 7353285809Sscottl satOrgIOContext); 7354285809Sscottl 7355285809Sscottl if (hostToDevFis->d.lbaLow != 0x01 && hostToDevFis->d.lbaLow != 0x02) 7356285809Sscottl { 7357285809Sscottl /* no completion for background send diagnotic. It is done in satSendDiagnostic() */ 7358285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7359285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 7360285809Sscottl tiIOSuccess, 7361285809Sscottl SCSI_STAT_CHECK_CONDITION, 7362285809Sscottl satOrgIOContext->pTiSenseData, 7363285809Sscottl satOrgIOContext->interruptContext ); 7364285809Sscottl 7365285809Sscottl } 7366285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7367285809Sscottl 7368285809Sscottl satFreeIntIoResource( tiRoot, 7369285809Sscottl satDevData, 7370285809Sscottl satIntIo); 7371285809Sscottl return; 7372285809Sscottl } 7373285809Sscottl } 7374285809Sscottl } 7375285809Sscottl 7376285809Sscottl /* processing success case */ 7377285809Sscottl switch (hostToDevFis->h.command) 7378285809Sscottl { 7379285809Sscottl case SAT_READ_VERIFY_SECTORS: /* fall through */ 7380285809Sscottl case SAT_READ_VERIFY_SECTORS_EXT: 7381285809Sscottl TI_DBG5(("satSendDiagnosticCB: SAT_READ_VERIFY_SECTORS(_EXT) case\n")); 7382285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_SATA_LOCK); 7383285809Sscottl satDevData->satVerifyState++; 7384285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_SATA_LOCK); 7385285809Sscottl TI_DBG5(("satSendDiagnosticCB: satVerifyState %d\n",satDevData->satVerifyState)); 7386285809Sscottl 7387285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7388285809Sscottl 7389285809Sscottl /* done with internally genereated AT_READ_VERIFY_SECTORS(_EXT) */ 7390285809Sscottl satFreeIntIoResource( tiRoot, 7391285809Sscottl satDevData, 7392285809Sscottl satIntIo); 7393285809Sscottl 7394285809Sscottl if (satDevData->satVerifyState == 3) 7395285809Sscottl { 7396285809Sscottl /* reset satVerifyState */ 7397285809Sscottl satDevData->satVerifyState = 0; 7398285809Sscottl /* return GOOD status */ 7399285809Sscottl TI_DBG5(("satSendDiagnosticCB: return GOOD status\n")); 7400285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7401285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 7402285809Sscottl tiIOSuccess, 7403285809Sscottl SCSI_STAT_GOOD, 7404285809Sscottl agNULL, 7405285809Sscottl satOrgIOContext->interruptContext ); 7406285809Sscottl return; 7407285809Sscottl } 7408285809Sscottl else 7409285809Sscottl { 7410285809Sscottl 7411285809Sscottl /* prepare SAT_READ_VERIFY_SECTORS(_EXT) */ 7412285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 7413285809Sscottl tiOrgIORequest, 7414285809Sscottl satDevData, 7415285809Sscottl 0, 7416285809Sscottl satNewIntIo); 7417285809Sscottl if (satNewIntIo == agNULL) 7418285809Sscottl { 7419285809Sscottl /* reset satVerifyState */ 7420285809Sscottl satDevData->satVerifyState = 0; 7421285809Sscottl /* memory allocation failure */ 7422285809Sscottl satFreeIntIoResource( tiRoot, 7423285809Sscottl satDevData, 7424285809Sscottl satNewIntIo); 7425285809Sscottl 7426285809Sscottl /* failed as a part of sending SAT_READ_VERIFY_SECTORS(_EXT) */ 7427285809Sscottl satSetSensePayload( pSense, 7428285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 7429285809Sscottl 0, 7430285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 7431285809Sscottl satOrgIOContext); 7432285809Sscottl 7433285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7434285809Sscottl tiOrgIORequest, 7435285809Sscottl tiIOSuccess, 7436285809Sscottl SCSI_STAT_CHECK_CONDITION, 7437285809Sscottl satOrgIOContext->pTiSenseData, 7438285809Sscottl satOrgIOContext->interruptContext ); 7439285809Sscottl 7440285809Sscottl TI_DBG1(("satSendDiagnosticCB: momory allocation fails\n")); 7441285809Sscottl return; 7442285809Sscottl } /* end of memory allocation failure */ 7443285809Sscottl 7444285809Sscottl /* 7445285809Sscottl * Need to initialize all the fields within satIOContext 7446285809Sscottl */ 7447285809Sscottl 7448285809Sscottl satNewIOContext = satPrepareNewIO( 7449285809Sscottl satNewIntIo, 7450285809Sscottl tiOrgIORequest, 7451285809Sscottl satDevData, 7452285809Sscottl scsiCmnd, 7453285809Sscottl satOrgIOContext 7454285809Sscottl ); 7455285809Sscottl 7456285809Sscottl if (satDevData->satVerifyState == 1) 7457285809Sscottl { 7458285809Sscottl /* sending SAT_CHECK_POWER_MODE */ 7459285809Sscottl status = satSendDiagnostic_1( tiRoot, 7460285809Sscottl &satNewIntIo->satIntTiIORequest, 7461285809Sscottl satNewIOContext->ptiDeviceHandle, 7462285809Sscottl &satNewIntIo->satIntTiScsiXchg, 7463285809Sscottl satNewIOContext); 7464285809Sscottl } 7465285809Sscottl else 7466285809Sscottl { 7467285809Sscottl /* satDevData->satVerifyState == 2 */ 7468285809Sscottl status = satSendDiagnostic_2( tiRoot, 7469285809Sscottl &satNewIntIo->satIntTiIORequest, 7470285809Sscottl satNewIOContext->ptiDeviceHandle, 7471285809Sscottl &satNewIntIo->satIntTiScsiXchg, 7472285809Sscottl satNewIOContext); 7473285809Sscottl } 7474285809Sscottl 7475285809Sscottl if (status != tiSuccess) 7476285809Sscottl { 7477285809Sscottl /* sending SAT_READ_VERIFY_SECTORS(_EXT) fails */ 7478285809Sscottl satFreeIntIoResource( tiRoot, 7479285809Sscottl satDevData, 7480285809Sscottl satNewIntIo); 7481285809Sscottl 7482285809Sscottl /* failed during sending SAT_READ_VERIFY_SECTORS(_EXT) */ 7483285809Sscottl satSetSensePayload( pSense, 7484285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 7485285809Sscottl 0, 7486285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_FAILED_SELF_TEST, 7487285809Sscottl satOrgIOContext); 7488285809Sscottl 7489285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7490285809Sscottl tiOrgIORequest, 7491285809Sscottl tiIOSuccess, 7492285809Sscottl SCSI_STAT_CHECK_CONDITION, 7493285809Sscottl satOrgIOContext->pTiSenseData, 7494285809Sscottl satOrgIOContext->interruptContext ); 7495285809Sscottl 7496285809Sscottl /* reset satVerifyState */ 7497285809Sscottl satDevData->satVerifyState = 0; 7498285809Sscottl TI_DBG1(("satSendDiagnosticCB: calling satSendDiagnostic_1 or _2 fails\n")); 7499285809Sscottl return; 7500285809Sscottl } 7501285809Sscottl } /* satDevData->satVerifyState == 1 or 2 */ 7502285809Sscottl 7503285809Sscottl break; 7504285809Sscottl case SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE: 7505285809Sscottl TI_DBG5(("satSendDiagnosticCB: SAT_SMART_EXEUTE_OFF_LINE_IMMEDIATE case\n")); 7506285809Sscottl 7507285809Sscottl satDevData->satBGPendingDiag = agFALSE; 7508285809Sscottl 7509285809Sscottl if (hostToDevFis->d.lbaLow == 0x01 || hostToDevFis->d.lbaLow == 0x02) 7510285809Sscottl { 7511285809Sscottl /* for background send diagnostic, no completion here. It is done already. */ 7512285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7513285809Sscottl 7514285809Sscottl /* done with AT_SMART_EXEUTE_OFF_LINE_IMMEDIATE */ 7515285809Sscottl satFreeIntIoResource( tiRoot, 7516285809Sscottl satDevData, 7517285809Sscottl satIntIo); 7518285809Sscottl TI_DBG5(("satSendDiagnosticCB: returning but no IOCompleted\n")); 7519285809Sscottl } 7520285809Sscottl else 7521285809Sscottl { 7522285809Sscottl TI_DBG5(("satSendDiagnosticCB: returning good status for senddiagnostic\n")); 7523285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7524285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 7525285809Sscottl tiIOSuccess, 7526285809Sscottl SCSI_STAT_GOOD, 7527285809Sscottl agNULL, 7528285809Sscottl satOrgIOContext->interruptContext ); 7529285809Sscottl 7530285809Sscottl 7531285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7532285809Sscottl 7533285809Sscottl /* done with AT_SMART_EXEUTE_OFF_LINE_IMMEDIATE */ 7534285809Sscottl satFreeIntIoResource( tiRoot, 7535285809Sscottl satDevData, 7536285809Sscottl satIntIo); 7537285809Sscottl } 7538285809Sscottl 7539285809Sscottl break; 7540285809Sscottl default: 7541285809Sscottl TI_DBG1(("satSendDiagnosticCB: success but error default case command 0x%x\n", hostToDevFis->h.command)); 7542285809Sscottl /* unspecified case, return no sense and no addition info */ 7543285809Sscottl satSetSensePayload( pSense, 7544285809Sscottl SCSI_SNSKEY_NO_SENSE, 7545285809Sscottl 0, 7546285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 7547285809Sscottl satOrgIOContext); 7548285809Sscottl 7549285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7550285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 7551285809Sscottl tiIOSuccess, 7552285809Sscottl SCSI_STAT_CHECK_CONDITION, 7553285809Sscottl satOrgIOContext->pTiSenseData, 7554285809Sscottl satOrgIOContext->interruptContext ); 7555285809Sscottl 7556285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7557285809Sscottl 7558285809Sscottl satFreeIntIoResource( tiRoot, 7559285809Sscottl satDevData, 7560285809Sscottl satIntIo); 7561285809Sscottl break; 7562285809Sscottl } 7563285809Sscottl return; 7564285809Sscottl} 7565285809Sscottl/***************************************************************************** 7566285809Sscottl*! \brief satRequestSenseCB 7567285809Sscottl* 7568285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 7569285809Sscottl* This CB routine deals with Request Sense completion. 7570285809Sscottl* 7571285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 7572285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 7573285809Sscottl* \param agIOStatus: Status of completed I/O. 7574285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 7575285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 7576285809Sscottl* length. 7577285809Sscottl* \param agParam: Additional info based on status. 7578285809Sscottl* \param ioContext: Pointer to satIOContext_t. 7579285809Sscottl* 7580285809Sscottl* \return: none 7581285809Sscottl* 7582285809Sscottl*****************************************************************************/ 7583285809Sscottl/* 7584285809Sscottl CB for internnaly generated SMART_RETURN_STATUS and SAT_CHECK_POWER_MODE 7585285809Sscottl in the process of RequestSense 7586285809Sscottl 7587285809Sscottl*/ 7588285809Sscottlvoid satRequestSenseCB( 7589285809Sscottl agsaRoot_t *agRoot, 7590285809Sscottl agsaIORequest_t *agIORequest, 7591285809Sscottl bit32 agIOStatus, 7592285809Sscottl agsaFisHeader_t *agFirstDword, 7593285809Sscottl bit32 agIOInfoLen, 7594285809Sscottl void *agParam, 7595285809Sscottl void *ioContext 7596285809Sscottl ) 7597285809Sscottl{ 7598285809Sscottl /* ATA Vol 1, p299 SAT_SMART_RETURN_STATUS */ 7599285809Sscottl /* 7600285809Sscottl if threshold exceeds, return SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE 7601285809Sscottl else call satRequestSense_1 to send CHECK_POWER_MODE 7602285809Sscottl */ 7603285809Sscottl 7604285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 7605285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 7606285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 7607285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 7608285809Sscottl tdIORequestBody_t *tdIORequestBody; 7609285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 7610285809Sscottl satIOContext_t *satIOContext; 7611285809Sscottl satIOContext_t *satOrgIOContext; 7612285809Sscottl satIOContext_t *satNewIOContext; 7613285809Sscottl satInternalIo_t *satIntIo; 7614285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 7615285809Sscottl satDeviceData_t *satDevData; 7616285809Sscottl scsiRspSense_t *pSense; 7617285809Sscottl tiIORequest_t *tiOrgIORequest; 7618285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 7619285809Sscottl 7620285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 7621285809Sscottl bit32 ataStatus = 0; 7622285809Sscottl bit32 status; 7623285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 7624285809Sscottl agsaFisRegD2HData_t statDevToHostFisData; 7625285809Sscottl bit32 lenReceived = 0; 7626285809Sscottl bit32 dataLength; 7627285809Sscottl 7628285809Sscottl TI_DBG4(("satRequestSenseCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 7629285809Sscottl 7630285809Sscottl /* internally generate tiIOContext */ 7631285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 7632285809Sscottl satIOContext = (satIOContext_t *) ioContext; 7633285809Sscottl satIntIo = satIOContext->satIntIoContext; 7634285809Sscottl satDevData = satIOContext->pSatDevData; 7635285809Sscottl hostToDevFis = satIOContext->pFis; 7636285809Sscottl 7637285809Sscottl /*ttttttthe one */ 7638285809Sscottl if (satIntIo == agNULL) 7639285809Sscottl { 7640285809Sscottl TI_DBG4(("satRequestSenseCB: External satInternalIo_t satIntIoContext\n")); 7641285809Sscottl satOrgIOContext = satIOContext; 7642285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 7643285809Sscottl if (satOrgIOContext->superIOFlag) 7644285809Sscottl { 7645285809Sscottl pSense = (scsiRspSense_t *)(((tiSuperScsiInitiatorRequest_t *)satOrgIOContext->tiScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 7646285809Sscottl } 7647285809Sscottl else 7648285809Sscottl { 7649285809Sscottl pSense = (scsiRspSense_t *)(((tiScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 7650285809Sscottl } 7651285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 7652285809Sscottl } 7653285809Sscottl else 7654285809Sscottl { 7655285809Sscottl TI_DBG4(("satRequestSenseCB: Internal satInternalIo_t satIntIoContext\n")); 7656285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 7657285809Sscottl if (satOrgIOContext == agNULL) 7658285809Sscottl { 7659285809Sscottl TI_DBG4(("satRequestSenseCB: satOrgIOContext is NULL, wrong\n")); 7660285809Sscottl return; 7661285809Sscottl } 7662285809Sscottl else 7663285809Sscottl { 7664285809Sscottl TI_DBG4(("satRequestSenseCB: satOrgIOContext is NOT NULL\n")); 7665285809Sscottl } 7666285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 7667285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 7668285809Sscottl 7669285809Sscottl if (satOrgIOContext->superIOFlag) 7670285809Sscottl { 7671285809Sscottl pSense = (scsiRspSense_t *)(((tiSuperScsiInitiatorRequest_t *)satOrgIOContext->tiScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 7672285809Sscottl } 7673285809Sscottl else 7674285809Sscottl { 7675285809Sscottl pSense = (scsiRspSense_t *)(((tiScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->sglVirtualAddr);//satOrgIOContext->pSense; 7676285809Sscottl } 7677285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 7678285809Sscottl } 7679285809Sscottl 7680285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 7681285809Sscottl tdIORequestBody->ioStarted = agFALSE; 7682285809Sscottl 7683285809Sscottl TI_DBG4(("satRequestSenseCB: fis command 0x%x\n", hostToDevFis->h.command)); 7684285809Sscottl 7685285809Sscottl lenReceived = scsiCmnd->cdb[4]; 7686285809Sscottl TI_DBG1(("satRequestSenseCB: lenReceived in CDB %d 0x%x\n", lenReceived,lenReceived)); 7687285809Sscottl 7688285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 7689285809Sscottl { 7690285809Sscottl TI_DBG1(("satRequestSenseCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 7691285809Sscottl ostiInitiatorIOCompleted ( 7692285809Sscottl tiRoot, 7693285809Sscottl tiOrgIORequest, 7694285809Sscottl tiIOFailed, 7695285809Sscottl tiDetailOtherError, 7696285809Sscottl agNULL, 7697285809Sscottl satOrgIOContext->interruptContext 7698285809Sscottl ); 7699285809Sscottl 7700285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7701285809Sscottl 7702285809Sscottl satFreeIntIoResource( tiRoot, 7703285809Sscottl satDevData, 7704285809Sscottl satIntIo); 7705285809Sscottl 7706285809Sscottl return; 7707285809Sscottl } 7708285809Sscottl 7709285809Sscottl /* 7710285809Sscottl checking IO status, FIS type and error status 7711285809Sscottl */ 7712285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 7713285809Sscottl { 7714285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 7715285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 7716285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 7717285809Sscottl 7718285809Sscottl /* for debugging */ 7719285809Sscottl if( statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 7720285809Sscottl { 7721285809Sscottl if (hostToDevFis->h.command == SAT_SMART_RETURN_STATUS) 7722285809Sscottl { 7723285809Sscottl TI_DBG1(("satRequestSenseCB: FAILED, Wrong FIS type 0x%x and SAT_SMART_RETURN_STATU\n", statDevToHostFisHeader->fisType)); 7724285809Sscottl } 7725285809Sscottl else 7726285809Sscottl { 7727285809Sscottl TI_DBG1(("satRequestSenseCB: FAILED, Wrong FIS type 0x%x and SAT_CHECK_POWER_MODE\n",statDevToHostFisHeader->fisType)); 7728285809Sscottl } 7729285809Sscottl } 7730285809Sscottl 7731285809Sscottl /* for debugging */ 7732285809Sscottl if ( (ataStatus & ERR_ATA_STATUS_MASK) || 7733285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 7734285809Sscottl ) 7735285809Sscottl { 7736285809Sscottl if (hostToDevFis->h.command == SAT_SMART_RETURN_STATUS) 7737285809Sscottl { 7738285809Sscottl TI_DBG1(("satRequestSenseCB: FAILED, error status and SAT_SMART_RETURN_STATU\n")); 7739285809Sscottl } 7740285809Sscottl else 7741285809Sscottl { 7742285809Sscottl TI_DBG1(("satRequestSenseCB: FAILED, error status and SAT_CHECK_POWER_MODE\n")); 7743285809Sscottl } 7744285809Sscottl } 7745285809Sscottl 7746285809Sscottl /* Process abort case */ 7747285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 7748285809Sscottl { 7749285809Sscottl satProcessAbort(tiRoot, 7750285809Sscottl tiOrgIORequest, 7751285809Sscottl satOrgIOContext 7752285809Sscottl ); 7753285809Sscottl 7754285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7755285809Sscottl 7756285809Sscottl satFreeIntIoResource( tiRoot, 7757285809Sscottl satDevData, 7758285809Sscottl satIntIo); 7759285809Sscottl return; 7760285809Sscottl } 7761285809Sscottl 7762285809Sscottl if (hostToDevFis->h.command == SAT_SMART_RETURN_STATUS) 7763285809Sscottl { 7764285809Sscottl /* report using the original tiIOrequst */ 7765285809Sscottl /* failed during sending SMART RETURN STATUS */ 7766285809Sscottl satSetSensePayload( pSense, 7767285809Sscottl SCSI_SNSKEY_NO_SENSE, 7768285809Sscottl 0, 7769285809Sscottl SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE, 7770285809Sscottl satOrgIOContext); 7771285809Sscottl 7772285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 7773285809Sscottl { 7774285809Sscottl /* underrun */ 7775285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7776285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 7777285809Sscottl tiIOUnderRun, 7778285809Sscottl lenReceived - SENSE_DATA_LENGTH, 7779285809Sscottl agNULL, 7780285809Sscottl satOrgIOContext->interruptContext ); 7781285809Sscottl } 7782285809Sscottl else 7783285809Sscottl { 7784285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7785285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 7786285809Sscottl tiIOSuccess, 7787285809Sscottl SCSI_STAT_GOOD, 7788285809Sscottl agNULL, 7789285809Sscottl satOrgIOContext->interruptContext ); 7790285809Sscottl } 7791285809Sscottl } 7792285809Sscottl else 7793285809Sscottl { 7794285809Sscottl /* report using the original tiIOrequst */ 7795285809Sscottl /* failed during sending SAT_CHECK_POWER_MODE */ 7796285809Sscottl satSetSensePayload( pSense, 7797285809Sscottl SCSI_SNSKEY_NO_SENSE, 7798285809Sscottl 0, 7799285809Sscottl SCSI_SNSCODE_LOW_POWER_CONDITION_ON, 7800285809Sscottl satOrgIOContext); 7801285809Sscottl 7802285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 7803285809Sscottl { 7804285809Sscottl /* underrun */ 7805285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7806285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 7807285809Sscottl tiIOUnderRun, 7808285809Sscottl lenReceived - SENSE_DATA_LENGTH, 7809285809Sscottl agNULL, 7810285809Sscottl satOrgIOContext->interruptContext ); 7811285809Sscottl } 7812285809Sscottl else 7813285809Sscottl { 7814285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7815285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 7816285809Sscottl tiIOSuccess, 7817285809Sscottl SCSI_STAT_GOOD, 7818285809Sscottl agNULL, 7819285809Sscottl satOrgIOContext->interruptContext ); 7820285809Sscottl } 7821285809Sscottl } 7822285809Sscottl 7823285809Sscottl 7824285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7825285809Sscottl 7826285809Sscottl satFreeIntIoResource( tiRoot, 7827285809Sscottl satDevData, 7828285809Sscottl satIntIo); 7829285809Sscottl return; 7830285809Sscottl } 7831285809Sscottl 7832285809Sscottl saFrameReadBlock(agRoot, agParam, 0, &statDevToHostFisData, sizeof(agsaFisRegD2HData_t)); 7833285809Sscottl 7834285809Sscottl switch (hostToDevFis->h.command) 7835285809Sscottl { 7836285809Sscottl case SAT_SMART_RETURN_STATUS: 7837285809Sscottl TI_DBG4(("satRequestSenseCB: SAT_SMART_RETURN_STATUS case\n")); 7838285809Sscottl if (statDevToHostFisData.lbaMid == 0xF4 || statDevToHostFisData.lbaHigh == 0x2C) 7839285809Sscottl { 7840285809Sscottl /* threshold exceeds */ 7841285809Sscottl TI_DBG1(("satRequestSenseCB: threshold exceeds\n")); 7842285809Sscottl 7843285809Sscottl 7844285809Sscottl /* report using the original tiIOrequst */ 7845285809Sscottl /* failed during sending SMART RETURN STATUS */ 7846285809Sscottl satSetSensePayload( pSense, 7847285809Sscottl SCSI_SNSKEY_NO_SENSE, 7848285809Sscottl 0, 7849285809Sscottl SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE, 7850285809Sscottl satOrgIOContext); 7851285809Sscottl 7852285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 7853285809Sscottl { 7854285809Sscottl /* underrun */ 7855285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7856285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 7857285809Sscottl tiIOUnderRun, 7858285809Sscottl lenReceived - SENSE_DATA_LENGTH, 7859285809Sscottl agNULL, 7860285809Sscottl satOrgIOContext->interruptContext ); } 7861285809Sscottl else 7862285809Sscottl { 7863285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7864285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 7865285809Sscottl tiIOSuccess, 7866285809Sscottl SCSI_STAT_GOOD, 7867285809Sscottl agNULL, 7868285809Sscottl satOrgIOContext->interruptContext ); } 7869285809Sscottl 7870285809Sscottl 7871285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7872285809Sscottl 7873285809Sscottl satFreeIntIoResource( tiRoot, 7874285809Sscottl satDevData, 7875285809Sscottl satIntIo); 7876285809Sscottl return; 7877285809Sscottl } 7878285809Sscottl 7879285809Sscottl 7880285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 7881285809Sscottl 7882285809Sscottl /* done with internally genereated SAT_SMART_RETURN_STATUS */ 7883285809Sscottl satFreeIntIoResource( tiRoot, 7884285809Sscottl satDevData, 7885285809Sscottl satIntIo); 7886285809Sscottl 7887285809Sscottl /* at this point, successful SMART_RETURN_STATUS 7888285809Sscottl xmit SAT_CHECK_POWER_MODE 7889285809Sscottl */ 7890285809Sscottl if (satOrgIOContext->superIOFlag) 7891285809Sscottl { 7892285809Sscottl dataLength = ((tiSuperScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 7893285809Sscottl } 7894285809Sscottl else 7895285809Sscottl { 7896285809Sscottl dataLength = ((tiScsiInitiatorRequest_t *) satOrgIOContext->tiScsiXchg)->scsiCmnd.expDataLength; 7897285809Sscottl } 7898285809Sscottl 7899285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 7900285809Sscottl tiOrgIORequest, 7901285809Sscottl satDevData, 7902285809Sscottl dataLength, 7903285809Sscottl satNewIntIo); 7904285809Sscottl if (satNewIntIo == agNULL) 7905285809Sscottl { 7906285809Sscottl /* memory allocation failure */ 7907285809Sscottl satFreeIntIoResource( tiRoot, 7908285809Sscottl satDevData, 7909285809Sscottl satNewIntIo); 7910285809Sscottl 7911285809Sscottl /* failed as a part of sending SMART RETURN STATUS */ 7912285809Sscottl satSetSensePayload( pSense, 7913285809Sscottl SCSI_SNSKEY_NO_SENSE, 7914285809Sscottl 0, 7915285809Sscottl SCSI_SNSCODE_HARDWARE_IMPENDING_FAILURE, 7916285809Sscottl satOrgIOContext); 7917285809Sscottl 7918285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 7919285809Sscottl { 7920285809Sscottl /* underrun */ 7921285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7922285809Sscottl tiOrgIORequest, 7923285809Sscottl tiIOUnderRun, 7924285809Sscottl lenReceived - SENSE_DATA_LENGTH, 7925285809Sscottl agNULL, 7926285809Sscottl satOrgIOContext->interruptContext ); 7927285809Sscottl } 7928285809Sscottl else 7929285809Sscottl { 7930285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7931285809Sscottl tiOrgIORequest, 7932285809Sscottl tiIOSuccess, 7933285809Sscottl SCSI_STAT_GOOD, 7934285809Sscottl agNULL, 7935285809Sscottl satOrgIOContext->interruptContext ); 7936285809Sscottl } 7937285809Sscottl 7938285809Sscottl TI_DBG1(("satRequestSenseCB: momory allocation fails\n")); 7939285809Sscottl return; 7940285809Sscottl } /* end of memory allocation failure */ 7941285809Sscottl 7942285809Sscottl 7943285809Sscottl /* 7944285809Sscottl * Need to initialize all the fields within satIOContext 7945285809Sscottl */ 7946285809Sscottl 7947285809Sscottl satNewIOContext = satPrepareNewIO( 7948285809Sscottl satNewIntIo, 7949285809Sscottl tiOrgIORequest, 7950285809Sscottl satDevData, 7951285809Sscottl scsiCmnd, 7952285809Sscottl satOrgIOContext 7953285809Sscottl ); 7954285809Sscottl 7955285809Sscottl /* sending SAT_CHECK_POWER_MODE */ 7956285809Sscottl status = satRequestSense_1( tiRoot, 7957285809Sscottl &satNewIntIo->satIntTiIORequest, 7958285809Sscottl satNewIOContext->ptiDeviceHandle, 7959285809Sscottl &satNewIntIo->satIntTiScsiXchg, 7960285809Sscottl satNewIOContext); 7961285809Sscottl 7962285809Sscottl if (status != tiSuccess) 7963285809Sscottl { 7964285809Sscottl /* sending SAT_CHECK_POWER_MODE fails */ 7965285809Sscottl satFreeIntIoResource( tiRoot, 7966285809Sscottl satDevData, 7967285809Sscottl satNewIntIo); 7968285809Sscottl 7969285809Sscottl /* failed during sending SAT_CHECK_POWER_MODE */ 7970285809Sscottl satSetSensePayload( pSense, 7971285809Sscottl SCSI_SNSKEY_NO_SENSE, 7972285809Sscottl 0, 7973285809Sscottl SCSI_SNSCODE_LOW_POWER_CONDITION_ON, 7974285809Sscottl satOrgIOContext); 7975285809Sscottl 7976285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 7977285809Sscottl { 7978285809Sscottl /* underrun */ 7979285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7980285809Sscottl tiOrgIORequest, 7981285809Sscottl tiIOUnderRun, 7982285809Sscottl lenReceived - SENSE_DATA_LENGTH, 7983285809Sscottl agNULL, 7984285809Sscottl satOrgIOContext->interruptContext ); 7985285809Sscottl } 7986285809Sscottl else 7987285809Sscottl { 7988285809Sscottl ostiInitiatorIOCompleted( tiRoot, 7989285809Sscottl tiOrgIORequest, 7990285809Sscottl tiIOSuccess, 7991285809Sscottl SCSI_STAT_GOOD, 7992285809Sscottl agNULL, 7993285809Sscottl satOrgIOContext->interruptContext ); 7994285809Sscottl } 7995285809Sscottl 7996285809Sscottl TI_DBG1(("satRequestSenseCB: calling satRequestSense_1 fails\n")); 7997285809Sscottl return; 7998285809Sscottl } 7999285809Sscottl 8000285809Sscottl break; 8001285809Sscottl case SAT_CHECK_POWER_MODE: 8002285809Sscottl TI_DBG4(("satRequestSenseCB: SAT_CHECK_POWER_MODE case\n")); 8003285809Sscottl 8004285809Sscottl /* check ATA STANDBY state */ 8005285809Sscottl if (statDevToHostFisData.sectorCount == 0x00) 8006285809Sscottl { 8007285809Sscottl /* in STANDBY */ 8008285809Sscottl TI_DBG1(("satRequestSenseCB: in standby\n")); 8009285809Sscottl 8010285809Sscottl 8011285809Sscottl /* report using the original tiIOrequst */ 8012285809Sscottl /* failed during sending SAT_CHECK_POWER_MODE */ 8013285809Sscottl satSetSensePayload( pSense, 8014285809Sscottl SCSI_SNSKEY_NO_SENSE, 8015285809Sscottl 0, 8016285809Sscottl SCSI_SNSCODE_LOW_POWER_CONDITION_ON, 8017285809Sscottl satOrgIOContext); 8018285809Sscottl 8019285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 8020285809Sscottl { 8021285809Sscottl /* underrun */ 8022285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8023285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8024285809Sscottl tiIOUnderRun, 8025285809Sscottl lenReceived - SENSE_DATA_LENGTH, 8026285809Sscottl agNULL, 8027285809Sscottl satOrgIOContext->interruptContext ); 8028285809Sscottl } 8029285809Sscottl else 8030285809Sscottl { 8031285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8032285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8033285809Sscottl tiIOSuccess, 8034285809Sscottl SCSI_STAT_GOOD, 8035285809Sscottl agNULL, 8036285809Sscottl satOrgIOContext->interruptContext ); 8037285809Sscottl } 8038285809Sscottl 8039285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8040285809Sscottl 8041285809Sscottl satFreeIntIoResource( tiRoot, 8042285809Sscottl satDevData, 8043285809Sscottl satIntIo); 8044285809Sscottl return; 8045285809Sscottl } 8046285809Sscottl 8047285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8048285809Sscottl 8049285809Sscottl /* done with internnaly generated SAT_CHECK_POWER_MODE */ 8050285809Sscottl satFreeIntIoResource( tiRoot, 8051285809Sscottl satDevData, 8052285809Sscottl satIntIo); 8053285809Sscottl 8054285809Sscottl if (satDevData->satFormatState == agTRUE) 8055285809Sscottl { 8056285809Sscottl TI_DBG1(("satRequestSenseCB: in format\n")); 8057285809Sscottl 8058285809Sscottl 8059285809Sscottl /* report using the original tiIOrequst */ 8060285809Sscottl satSetSensePayload( pSense, 8061285809Sscottl SCSI_SNSKEY_NOT_READY, 8062285809Sscottl 0, 8063285809Sscottl SCSI_SNSCODE_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS, 8064285809Sscottl satOrgIOContext); 8065285809Sscottl 8066285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 8067285809Sscottl { 8068285809Sscottl /* underrun */ 8069285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8070285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8071285809Sscottl tiIOUnderRun, 8072285809Sscottl lenReceived - SENSE_DATA_LENGTH, 8073285809Sscottl agNULL, 8074285809Sscottl satOrgIOContext->interruptContext ); 8075285809Sscottl } 8076285809Sscottl else 8077285809Sscottl { 8078285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8079285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8080285809Sscottl tiIOSuccess, 8081285809Sscottl SCSI_STAT_GOOD, 8082285809Sscottl agNULL, 8083285809Sscottl satOrgIOContext->interruptContext ); 8084285809Sscottl } 8085285809Sscottl 8086285809Sscottl return; 8087285809Sscottl } 8088285809Sscottl 8089285809Sscottl /* normal: returns good status for requestsense */ 8090285809Sscottl /* report using the original tiIOrequst */ 8091285809Sscottl satSetSensePayload( pSense, 8092285809Sscottl SCSI_SNSKEY_NO_SENSE, 8093285809Sscottl 0, 8094285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8095285809Sscottl satOrgIOContext); 8096285809Sscottl TI_DBG4(("satRequestSenseCB: returning good status for requestsense\n")); 8097285809Sscottl if (SENSE_DATA_LENGTH < lenReceived) 8098285809Sscottl { 8099285809Sscottl /* underrun */ 8100285809Sscottl TI_DBG6(("satRequestSenseCB reporting underrun lenNeeded=0x%x lenReceived=0x%x tiIORequest=%p\n", 8101285809Sscottl SENSE_DATA_LENGTH, lenReceived, tiOrgIORequest)); 8102285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8103285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8104285809Sscottl tiIOUnderRun, 8105285809Sscottl lenReceived - SENSE_DATA_LENGTH, 8106285809Sscottl agNULL, 8107285809Sscottl satOrgIOContext->interruptContext ); 8108285809Sscottl 8109285809Sscottl } 8110285809Sscottl else 8111285809Sscottl { 8112285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8113285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8114285809Sscottl tiIOSuccess, 8115285809Sscottl SCSI_STAT_GOOD, 8116285809Sscottl agNULL, 8117285809Sscottl satOrgIOContext->interruptContext ); 8118285809Sscottl } 8119285809Sscottl 8120285809Sscottl break; 8121285809Sscottl default: 8122285809Sscottl TI_DBG1(("satRequestSenseCB: success but error default case command 0x%x\n", hostToDevFis->h.command)); 8123285809Sscottl /* pSense here is a part of satOrgIOContext */ 8124285809Sscottl pSense = satOrgIOContext->pTiSenseData->senseData; 8125285809Sscottl satOrgIOContext->pTiSenseData->senseLen = SENSE_DATA_LENGTH; 8126285809Sscottl /* unspecified case, return no sense and no addition info */ 8127285809Sscottl satSetSensePayload( pSense, 8128285809Sscottl SCSI_SNSKEY_NO_SENSE, 8129285809Sscottl 0, 8130285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8131285809Sscottl satOrgIOContext); 8132285809Sscottl 8133285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8134285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8135285809Sscottl tiIOSuccess, 8136285809Sscottl SCSI_STAT_CHECK_CONDITION, 8137285809Sscottl satOrgIOContext->pTiSenseData, 8138285809Sscottl satOrgIOContext->interruptContext ); 8139285809Sscottl 8140285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8141285809Sscottl 8142285809Sscottl satFreeIntIoResource( tiRoot, 8143285809Sscottl satDevData, 8144285809Sscottl satIntIo); 8145285809Sscottl break; 8146285809Sscottl } /* switch */ 8147285809Sscottl 8148285809Sscottl return; 8149285809Sscottl} 8150285809Sscottl 8151285809Sscottl/***************************************************************************** 8152285809Sscottl*! \brief satSynchronizeCache10n16CB 8153285809Sscottl* 8154285809Sscottl* This routine is a callback function for satSynchronizeCache10 and 8155285809Sscottl* satSynchronizeCache1016() 8156285809Sscottl* 8157285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 8158285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 8159285809Sscottl* \param agIOStatus: Status of completed I/O. 8160285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 8161285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 8162285809Sscottl* length. 8163285809Sscottl* \param agParam: Additional info based on status. 8164285809Sscottl* \param ioContext: Pointer to satIOContext_t. 8165285809Sscottl* 8166285809Sscottl* \return: none 8167285809Sscottl* 8168285809Sscottl*****************************************************************************/ 8169285809Sscottlvoid satSynchronizeCache10n16CB( 8170285809Sscottl agsaRoot_t *agRoot, 8171285809Sscottl agsaIORequest_t *agIORequest, 8172285809Sscottl bit32 agIOStatus, 8173285809Sscottl agsaFisHeader_t *agFirstDword, 8174285809Sscottl bit32 agIOInfoLen, 8175285809Sscottl void *agParam, 8176285809Sscottl void *ioContext 8177285809Sscottl ) 8178285809Sscottl{ 8179285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8180285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8181285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8182285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8183285809Sscottl tdIORequestBody_t *tdIORequestBody; 8184285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 8185285809Sscottl satIOContext_t *satIOContext; 8186285809Sscottl satIOContext_t *satOrgIOContext; 8187285809Sscottl satInternalIo_t *satIntIo; 8188285809Sscottl satDeviceData_t *satDevData; 8189285809Sscottl 8190285809Sscottl scsiRspSense_t *pSense; 8191285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 8192285809Sscottl tiIORequest_t *tiOrgIORequest; 8193285809Sscottl 8194285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 8195285809Sscottl bit32 ataStatus = 0; 8196285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 8197285809Sscottl 8198285809Sscottl TI_DBG5(("satSynchronizeCache10n16CB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 8199285809Sscottl 8200285809Sscottl /* internally generate tiIOContext */ 8201285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 8202285809Sscottl satIOContext = (satIOContext_t *) ioContext; 8203285809Sscottl satIntIo = satIOContext->satIntIoContext; 8204285809Sscottl satDevData = satIOContext->pSatDevData; 8205285809Sscottl hostToDevFis = satIOContext->pFis; 8206285809Sscottl 8207285809Sscottl /* SPC: Self-Test Result Log page */ 8208285809Sscottl 8209285809Sscottl if (satIntIo == agNULL) 8210285809Sscottl { 8211285809Sscottl TI_DBG4(("satSynchronizeCache10n16CB: External satInternalIo_t satIntIoContext\n")); 8212285809Sscottl satOrgIOContext = satIOContext; 8213285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 8214285809Sscottl pSense = satIOContext->pSense; 8215285809Sscottl scsiCmnd = satIOContext->pScsiCmnd; 8216285809Sscottl } 8217285809Sscottl else 8218285809Sscottl { 8219285809Sscottl TI_DBG4(("satSynchronizeCache10n16CB: Internal satInternalIo_t satIntIoContext\n")); 8220285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 8221285809Sscottl if (satOrgIOContext == agNULL) 8222285809Sscottl { 8223285809Sscottl TI_DBG4(("satSynchronizeCache10n16CB: satOrgIOContext is NULL, wrong\n")); 8224285809Sscottl return; 8225285809Sscottl } 8226285809Sscottl else 8227285809Sscottl { 8228285809Sscottl TI_DBG4(("satSynchronizeCache10n16CB: satOrgIOContext is NOT NULL\n")); 8229285809Sscottl } 8230285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 8231285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 8232285809Sscottl 8233285809Sscottl pSense = satOrgIOContext->pSense; 8234285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 8235285809Sscottl } 8236285809Sscottl 8237285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 8238285809Sscottl tdIORequestBody->ioStarted = agFALSE; 8239285809Sscottl 8240285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 8241285809Sscottl { 8242285809Sscottl TI_DBG1(("satSynchronizeCache10n16CB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 8243285809Sscottl 8244285809Sscottl ostiInitiatorIOCompleted ( 8245285809Sscottl tiRoot, 8246285809Sscottl tiOrgIORequest, 8247285809Sscottl tiIOFailed, 8248285809Sscottl tiDetailOtherError, 8249285809Sscottl agNULL, 8250285809Sscottl satOrgIOContext->interruptContext 8251285809Sscottl ); 8252285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8253285809Sscottl 8254285809Sscottl satFreeIntIoResource( tiRoot, 8255285809Sscottl satDevData, 8256285809Sscottl satIntIo); 8257285809Sscottl return; 8258285809Sscottl } 8259285809Sscottl 8260285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 8261285809Sscottl { 8262285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 8263285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 8264285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 8265285809Sscottl } 8266285809Sscottl 8267285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 8268285809Sscottl { 8269285809Sscottl if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 8270285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 8271285809Sscottl ) 8272285809Sscottl { 8273285809Sscottl /* for debugging */ 8274285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 8275285809Sscottl { 8276285809Sscottl TI_DBG1(("satSynchronizeCache10n16CB: FAILED, NOT IO_SUCCESS\n")); 8277285809Sscottl } 8278285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 8279285809Sscottl { 8280285809Sscottl TI_DBG1(("satSynchronizeCache10n16CB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 8281285809Sscottl } 8282285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 8283285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 8284285809Sscottl ) 8285285809Sscottl { 8286285809Sscottl TI_DBG1(("satSynchronizeCache10n16CB: FAILED, FAILED, error status\n")); 8287285809Sscottl } 8288285809Sscottl 8289285809Sscottl 8290285809Sscottl /* Process abort case */ 8291285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 8292285809Sscottl { 8293285809Sscottl satProcessAbort(tiRoot, 8294285809Sscottl tiOrgIORequest, 8295285809Sscottl satOrgIOContext 8296285809Sscottl ); 8297285809Sscottl 8298285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8299285809Sscottl 8300285809Sscottl satFreeIntIoResource( tiRoot, 8301285809Sscottl satDevData, 8302285809Sscottl satIntIo); 8303285809Sscottl return; 8304285809Sscottl } 8305285809Sscottl 8306285809Sscottl switch (hostToDevFis->h.command) 8307285809Sscottl { 8308285809Sscottl case SAT_FLUSH_CACHE: 8309285809Sscottl TI_DBG1(("satSynchronizeCache10n16CB: SAT_FLUSH_CACHE failed\n")); 8310285809Sscottl /* checking IMMED bit */ 8311285809Sscottl if (scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK) 8312285809Sscottl { 8313285809Sscottl satSetDeferredSensePayload( pSense, 8314285809Sscottl SCSI_SNSKEY_NO_SENSE, 8315285809Sscottl 0, 8316285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8317285809Sscottl satOrgIOContext); 8318285809Sscottl } 8319285809Sscottl else 8320285809Sscottl { 8321285809Sscottl satSetDeferredSensePayload( pSense, 8322285809Sscottl SCSI_SNSKEY_NO_SENSE, 8323285809Sscottl 0, 8324285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8325285809Sscottl satOrgIOContext); 8326285809Sscottl } 8327285809Sscottl 8328285809Sscottl 8329285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8330285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8331285809Sscottl tiIOSuccess, 8332285809Sscottl SCSI_STAT_CHECK_CONDITION, 8333285809Sscottl satOrgIOContext->pTiSenseData, 8334285809Sscottl satOrgIOContext->interruptContext ); 8335285809Sscottl 8336285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8337285809Sscottl 8338285809Sscottl satFreeIntIoResource( tiRoot, 8339285809Sscottl satDevData, 8340285809Sscottl satIntIo); 8341285809Sscottl return; 8342285809Sscottl break; 8343285809Sscottl case SAT_FLUSH_CACHE_EXT: 8344285809Sscottl TI_DBG1(("satSynchronizeCache10n16CB: SAT_FLUSH_CACHE_EXT failed\n")); 8345285809Sscottl /* checking IMMED bit */ 8346285809Sscottl if (scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK) 8347285809Sscottl { 8348285809Sscottl satSetDeferredSensePayload( pSense, 8349285809Sscottl SCSI_SNSKEY_NO_SENSE, 8350285809Sscottl 0, 8351285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8352285809Sscottl satOrgIOContext); 8353285809Sscottl } 8354285809Sscottl else 8355285809Sscottl { 8356285809Sscottl satSetDeferredSensePayload( pSense, 8357285809Sscottl SCSI_SNSKEY_NO_SENSE, 8358285809Sscottl 0, 8359285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8360285809Sscottl satOrgIOContext); 8361285809Sscottl } 8362285809Sscottl 8363285809Sscottl 8364285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8365285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8366285809Sscottl tiIOSuccess, 8367285809Sscottl SCSI_STAT_CHECK_CONDITION, 8368285809Sscottl satOrgIOContext->pTiSenseData, 8369285809Sscottl satOrgIOContext->interruptContext ); 8370285809Sscottl 8371285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8372285809Sscottl 8373285809Sscottl satFreeIntIoResource( tiRoot, 8374285809Sscottl satDevData, 8375285809Sscottl satIntIo); 8376285809Sscottl return; 8377285809Sscottl break; 8378285809Sscottl default: 8379285809Sscottl TI_DBG1(("satSynchronizeCache10n16CB: error unknown command 0x%x\n", hostToDevFis->h.command)); 8380285809Sscottl satSetSensePayload( pSense, 8381285809Sscottl SCSI_SNSKEY_NO_SENSE, 8382285809Sscottl 0, 8383285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8384285809Sscottl satOrgIOContext); 8385285809Sscottl 8386285809Sscottl 8387285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8388285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8389285809Sscottl tiIOSuccess, 8390285809Sscottl SCSI_STAT_CHECK_CONDITION, 8391285809Sscottl satOrgIOContext->pTiSenseData, 8392285809Sscottl satOrgIOContext->interruptContext ); 8393285809Sscottl 8394285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8395285809Sscottl 8396285809Sscottl satFreeIntIoResource( tiRoot, 8397285809Sscottl satDevData, 8398285809Sscottl satIntIo); 8399285809Sscottl return; 8400285809Sscottl break; 8401285809Sscottl } 8402285809Sscottl 8403285809Sscottl return; 8404285809Sscottl } /* end of error checking */ 8405285809Sscottl } 8406285809Sscottl 8407285809Sscottl /* prcessing the success case */ 8408285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8409285809Sscottl 8410285809Sscottl satFreeIntIoResource( tiRoot, 8411285809Sscottl satDevData, 8412285809Sscottl satIntIo); 8413285809Sscottl 8414285809Sscottl 8415285809Sscottl switch (hostToDevFis->h.command) 8416285809Sscottl { 8417285809Sscottl case SAT_FLUSH_CACHE: 8418285809Sscottl TI_DBG5(("satSynchronizeCache10n16CB: SAT_FLUSH_CACHE success\n")); 8419285809Sscottl 8420285809Sscottl /* checking IMMED bit */ 8421285809Sscottl if ( !(scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK)) 8422285809Sscottl { 8423285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8424285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8425285809Sscottl tiIOSuccess, 8426285809Sscottl SCSI_STAT_GOOD, 8427285809Sscottl agNULL, 8428285809Sscottl satOrgIOContext->interruptContext ); 8429285809Sscottl return; 8430285809Sscottl } 8431285809Sscottl 8432285809Sscottl 8433285809Sscottl break; 8434285809Sscottl case SAT_FLUSH_CACHE_EXT: 8435285809Sscottl TI_DBG5(("satSynchronizeCache10n16CB: SAT_FLUSH_CACHE_EXT success\n")); 8436285809Sscottl 8437285809Sscottl /* checking IMMED bit */ 8438285809Sscottl if ( !(scsiCmnd->cdb[1] & SCSI_FLUSH_CACHE_IMMED_MASK)) 8439285809Sscottl { 8440285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8441285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8442285809Sscottl tiIOSuccess, 8443285809Sscottl SCSI_STAT_GOOD, 8444285809Sscottl agNULL, 8445285809Sscottl satOrgIOContext->interruptContext ); 8446285809Sscottl return; 8447285809Sscottl } 8448285809Sscottl 8449285809Sscottl break; 8450285809Sscottl default: 8451285809Sscottl TI_DBG5(("satSynchronizeCache10n16CB: error unknown command 0x%x\n", hostToDevFis->h.command)); 8452285809Sscottl satSetSensePayload( pSense, 8453285809Sscottl SCSI_SNSKEY_NO_SENSE, 8454285809Sscottl 0, 8455285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8456285809Sscottl satOrgIOContext); 8457285809Sscottl 8458285809Sscottl 8459285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8460285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8461285809Sscottl tiIOSuccess, 8462285809Sscottl SCSI_STAT_CHECK_CONDITION, 8463285809Sscottl satOrgIOContext->pTiSenseData, 8464285809Sscottl satOrgIOContext->interruptContext ); 8465285809Sscottl 8466285809Sscottl return; 8467285809Sscottl break; 8468285809Sscottl } 8469285809Sscottl 8470285809Sscottl return; 8471285809Sscottl} 8472285809Sscottl 8473285809Sscottl/***************************************************************************** 8474285809Sscottl*! \brief satModeSelect6n10CB 8475285809Sscottl* 8476285809Sscottl* This routine is a callback function for satModeSelect6() and 8477285809Sscottl* satModeSelect10() 8478285809Sscottl* 8479285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 8480285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 8481285809Sscottl* \param agIOStatus: Status of completed I/O. 8482285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 8483285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 8484285809Sscottl* length. 8485285809Sscottl* \param agParam: Additional info based on status. 8486285809Sscottl* \param ioContext: Pointer to satIOContext_t. 8487285809Sscottl* 8488285809Sscottl* \return: none 8489285809Sscottl* 8490285809Sscottl*****************************************************************************/ 8491285809Sscottlvoid satModeSelect6n10CB( 8492285809Sscottl agsaRoot_t *agRoot, 8493285809Sscottl agsaIORequest_t *agIORequest, 8494285809Sscottl bit32 agIOStatus, 8495285809Sscottl agsaFisHeader_t *agFirstDword, 8496285809Sscottl bit32 agIOInfoLen, 8497285809Sscottl void *agParam, 8498285809Sscottl void *ioContext 8499285809Sscottl ) 8500285809Sscottl{ 8501285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8502285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8503285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8504285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8505285809Sscottl tdIORequestBody_t *tdIORequestBody; 8506285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 8507285809Sscottl satIOContext_t *satIOContext; 8508285809Sscottl satIOContext_t *satOrgIOContext; 8509285809Sscottl satIOContext_t *satNewIOContext; 8510285809Sscottl satInternalIo_t *satIntIo; 8511285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 8512285809Sscottl satDeviceData_t *satDevData; 8513285809Sscottl scsiRspSense_t *pSense; 8514285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 8515285809Sscottl tiIORequest_t *tiOrgIORequest; 8516285809Sscottl 8517285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 8518285809Sscottl bit32 ataStatus = 0; 8519285809Sscottl bit32 status; 8520285809Sscottl tiScsiInitiatorRequest_t *tiScsiRequest; /* tiScsiXchg */ 8521285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 8522285809Sscottl 8523285809Sscottl TI_DBG5(("satModeSelect6n10CB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 8524285809Sscottl 8525285809Sscottl /* internally generate tiIOContext */ 8526285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 8527285809Sscottl satIOContext = (satIOContext_t *) ioContext; 8528285809Sscottl satIntIo = satIOContext->satIntIoContext; 8529285809Sscottl satDevData = satIOContext->pSatDevData; 8530285809Sscottl hostToDevFis = satIOContext->pFis; 8531285809Sscottl 8532285809Sscottl if (satIntIo == agNULL) 8533285809Sscottl { 8534285809Sscottl TI_DBG4(("satModeSelect6n10CB: External satInternalIo_t satIntIoContext\n")); 8535285809Sscottl satOrgIOContext = satIOContext; 8536285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 8537285809Sscottl tiScsiRequest = satOrgIOContext->tiScsiXchg; 8538285809Sscottl pSense = satOrgIOContext->pSense; 8539285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 8540285809Sscottl } 8541285809Sscottl else 8542285809Sscottl { 8543285809Sscottl TI_DBG4(("satModeSelect6n10CB: Internal satInternalIo_t satIntIoContext\n")); 8544285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 8545285809Sscottl if (satOrgIOContext == agNULL) 8546285809Sscottl { 8547285809Sscottl TI_DBG4(("satModeSelect6n10CB: satOrgIOContext is NULL, wrong\n")); 8548285809Sscottl return; 8549285809Sscottl } 8550285809Sscottl else 8551285809Sscottl { 8552285809Sscottl TI_DBG4(("satModeSelect6n10CB: satOrgIOContext is NOT NULL\n")); 8553285809Sscottl } 8554285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 8555285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 8556285809Sscottl 8557285809Sscottl tiScsiRequest = satOrgIOContext->tiScsiXchg; 8558285809Sscottl pSense = satOrgIOContext->pSense; 8559285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 8560285809Sscottl } 8561285809Sscottl 8562285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 8563285809Sscottl tdIORequestBody->ioStarted = agFALSE; 8564285809Sscottl 8565285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 8566285809Sscottl { 8567285809Sscottl TI_DBG1(("satModeSelect6n10CB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 8568285809Sscottl ostiInitiatorIOCompleted ( 8569285809Sscottl tiRoot, 8570285809Sscottl tiOrgIORequest, 8571285809Sscottl tiIOFailed, 8572285809Sscottl tiDetailOtherError, 8573285809Sscottl agNULL, 8574285809Sscottl satOrgIOContext->interruptContext 8575285809Sscottl ); 8576285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8577285809Sscottl 8578285809Sscottl satFreeIntIoResource( tiRoot, 8579285809Sscottl satDevData, 8580285809Sscottl satIntIo); 8581285809Sscottl return; 8582285809Sscottl } 8583285809Sscottl 8584285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 8585285809Sscottl { 8586285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 8587285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 8588285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 8589285809Sscottl } 8590285809Sscottl 8591285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 8592285809Sscottl { 8593285809Sscottl if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 8594285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 8595285809Sscottl ) 8596285809Sscottl { 8597285809Sscottl /* for debugging */ 8598285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 8599285809Sscottl { 8600285809Sscottl TI_DBG1(("satModeSelect6n10CB FAILED, NOT IO_SUCCESS\n")); 8601285809Sscottl } 8602285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 8603285809Sscottl { 8604285809Sscottl TI_DBG1(("satModeSelect6n10CB FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 8605285809Sscottl } 8606285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 8607285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 8608285809Sscottl ) 8609285809Sscottl { 8610285809Sscottl TI_DBG1(("satModeSelect6n10CB FAILED, FAILED, error status\n")); 8611285809Sscottl } 8612285809Sscottl 8613285809Sscottl /* Process abort case */ 8614285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 8615285809Sscottl { 8616285809Sscottl satProcessAbort(tiRoot, 8617285809Sscottl tiOrgIORequest, 8618285809Sscottl satOrgIOContext 8619285809Sscottl ); 8620285809Sscottl 8621285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8622285809Sscottl 8623285809Sscottl satFreeIntIoResource( tiRoot, 8624285809Sscottl satDevData, 8625285809Sscottl satIntIo); 8626285809Sscottl return; 8627285809Sscottl } 8628285809Sscottl 8629285809Sscottl /* for debugging */ 8630285809Sscottl if (hostToDevFis->h.command == SAT_SET_FEATURES) 8631285809Sscottl { 8632285809Sscottl if ((hostToDevFis->h.features == 0x82) || (hostToDevFis->h.features == 0x02)) 8633285809Sscottl { 8634285809Sscottl TI_DBG1(("satModeSelect6n10CB 1 SAT_SET_FEATURES failed, feature 0x%x\n", hostToDevFis->h.features)); 8635285809Sscottl } 8636285809Sscottl else if ((hostToDevFis->h.features == 0xAA) || (hostToDevFis->h.features == 0x55)) 8637285809Sscottl { 8638285809Sscottl TI_DBG1(("ssatModeSelect6n10CB 2 SAT_SET_FEATURES failed, feature 0x%x\n", hostToDevFis->h.features)); 8639285809Sscottl } 8640285809Sscottl else 8641285809Sscottl { 8642285809Sscottl TI_DBG1(("satModeSelect6n10CB error unknown command 0x%x feature 0x%x\n", hostToDevFis->h.command, hostToDevFis->h.features)); 8643285809Sscottl } 8644285809Sscottl } 8645285809Sscottl else if (hostToDevFis->h.command == SAT_SMART) 8646285809Sscottl { 8647285809Sscottl if ((hostToDevFis->h.features == SAT_SMART_ENABLE_OPERATIONS) || (hostToDevFis->h.features == SAT_SMART_DISABLE_OPERATIONS)) 8648285809Sscottl { 8649285809Sscottl TI_DBG1(("satModeSelect6n10CB SAT_SMART_ENABLE/DISABLE_OPERATIONS failed, feature 0x%x\n", hostToDevFis->h.features)); 8650285809Sscottl } 8651285809Sscottl else 8652285809Sscottl { 8653285809Sscottl TI_DBG1(("satModeSelect6n10CB error unknown command 0x%x feature 0x%x\n", hostToDevFis->h.command, hostToDevFis->h.features)); 8654285809Sscottl } 8655285809Sscottl } 8656285809Sscottl else 8657285809Sscottl { 8658285809Sscottl TI_DBG1(("satModeSelect6n10CB error default case command 0x%x\n", hostToDevFis->h.command)); 8659285809Sscottl } 8660285809Sscottl 8661285809Sscottl 8662285809Sscottl satSetSensePayload( pSense, 8663285809Sscottl SCSI_SNSKEY_NO_SENSE, 8664285809Sscottl 0, 8665285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8666285809Sscottl satOrgIOContext); 8667285809Sscottl 8668285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8669285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8670285809Sscottl tiIOSuccess, 8671285809Sscottl SCSI_STAT_CHECK_CONDITION, 8672285809Sscottl satOrgIOContext->pTiSenseData, 8673285809Sscottl satOrgIOContext->interruptContext ); 8674285809Sscottl 8675285809Sscottl 8676285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8677285809Sscottl 8678285809Sscottl satFreeIntIoResource( tiRoot, 8679285809Sscottl satDevData, 8680285809Sscottl satIntIo); 8681285809Sscottl return; 8682285809Sscottl } /* error checking */ 8683285809Sscottl } 8684285809Sscottl 8685285809Sscottl 8686285809Sscottl /* prcessing the success case */ 8687285809Sscottl 8688285809Sscottl 8689285809Sscottl if (hostToDevFis->h.command == SAT_SET_FEATURES) 8690285809Sscottl { 8691285809Sscottl if ((hostToDevFis->h.features == 0x82) || (hostToDevFis->h.features == 0x02)) 8692285809Sscottl { 8693285809Sscottl TI_DBG5(("satModeSelect6n10CB 1 SAT_SET_FEATURES success, feature 0x%x\n", hostToDevFis->h.features)); 8694285809Sscottl 8695285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8696285809Sscottl 8697285809Sscottl satFreeIntIoResource( tiRoot, 8698285809Sscottl satDevData, 8699285809Sscottl satIntIo); 8700285809Sscottl 8701285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 8702285809Sscottl tiOrgIORequest, 8703285809Sscottl satDevData, 8704285809Sscottl 0, 8705285809Sscottl satNewIntIo); 8706285809Sscottl if (satNewIntIo == agNULL) 8707285809Sscottl { 8708285809Sscottl /* memory allocation failure */ 8709285809Sscottl satFreeIntIoResource( tiRoot, 8710285809Sscottl satDevData, 8711285809Sscottl satNewIntIo); 8712285809Sscottl 8713285809Sscottl satSetSensePayload( pSense, 8714285809Sscottl SCSI_SNSKEY_NO_SENSE, 8715285809Sscottl 0, 8716285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8717285809Sscottl satOrgIOContext); 8718285809Sscottl 8719285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8720285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8721285809Sscottl tiIOSuccess, 8722285809Sscottl SCSI_STAT_CHECK_CONDITION, 8723285809Sscottl satOrgIOContext->pTiSenseData, 8724285809Sscottl satOrgIOContext->interruptContext ); 8725285809Sscottl TI_DBG1(("satModeSelect6n10CB: momory allocation fails\n")); 8726285809Sscottl return; 8727285809Sscottl } /* end memory allocation */ 8728285809Sscottl 8729285809Sscottl satNewIOContext = satPrepareNewIO( 8730285809Sscottl satNewIntIo, 8731285809Sscottl tiOrgIORequest, 8732285809Sscottl satDevData, 8733285809Sscottl scsiCmnd, 8734285809Sscottl satOrgIOContext 8735285809Sscottl ); 8736285809Sscottl /* sends either ATA SET FEATURES based on DRA bit */ 8737285809Sscottl status = satModeSelect6n10_1( tiRoot, 8738285809Sscottl &satNewIntIo->satIntTiIORequest, 8739285809Sscottl satNewIOContext->ptiDeviceHandle, 8740285809Sscottl tiScsiRequest, /* orginal from OS layer */ 8741285809Sscottl satNewIOContext 8742285809Sscottl ); 8743285809Sscottl 8744285809Sscottl if (status != tiSuccess) 8745285809Sscottl { 8746285809Sscottl /* sending ATA command fails */ 8747285809Sscottl satFreeIntIoResource( tiRoot, 8748285809Sscottl satDevData, 8749285809Sscottl satNewIntIo); 8750285809Sscottl satSetSensePayload( pSense, 8751285809Sscottl SCSI_SNSKEY_NO_SENSE, 8752285809Sscottl 0, 8753285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8754285809Sscottl satOrgIOContext); 8755285809Sscottl 8756285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8757285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8758285809Sscottl tiIOSuccess, 8759285809Sscottl SCSI_STAT_CHECK_CONDITION, 8760285809Sscottl satOrgIOContext->pTiSenseData, 8761285809Sscottl satOrgIOContext->interruptContext ); 8762285809Sscottl TI_DBG1(("satModeSelect6n10CB calling satModeSelect6_1 fails\n")); 8763285809Sscottl return; 8764285809Sscottl } /* end send fails */ 8765285809Sscottl return; 8766285809Sscottl } 8767285809Sscottl else if ((hostToDevFis->h.features == 0xAA) || (hostToDevFis->h.features == 0x55)) 8768285809Sscottl { 8769285809Sscottl TI_DBG5(("satModeSelect6n10CB 2 SAT_SET_FEATURES success, feature 0x%x\n", hostToDevFis->h.features)); 8770285809Sscottl 8771285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8772285809Sscottl 8773285809Sscottl satFreeIntIoResource( tiRoot, 8774285809Sscottl satDevData, 8775285809Sscottl satIntIo); 8776285809Sscottl 8777285809Sscottl /* return stat_good */ 8778285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8779285809Sscottl tiOrgIORequest, 8780285809Sscottl tiIOSuccess, 8781285809Sscottl SCSI_STAT_GOOD, 8782285809Sscottl agNULL, 8783285809Sscottl satOrgIOContext->interruptContext ); 8784285809Sscottl return; 8785285809Sscottl } 8786285809Sscottl else 8787285809Sscottl { 8788285809Sscottl TI_DBG1(("satModeSelect6n10CB error unknown command success 0x%x feature 0x%x\n", hostToDevFis->h.command, hostToDevFis->h.features)); 8789285809Sscottl 8790285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8791285809Sscottl 8792285809Sscottl satFreeIntIoResource( tiRoot, 8793285809Sscottl satDevData, 8794285809Sscottl satIntIo); 8795285809Sscottl satSetSensePayload( pSense, 8796285809Sscottl SCSI_SNSKEY_NO_SENSE, 8797285809Sscottl 0, 8798285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8799285809Sscottl satOrgIOContext); 8800285809Sscottl 8801285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8802285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8803285809Sscottl tiIOSuccess, 8804285809Sscottl SCSI_STAT_CHECK_CONDITION, 8805285809Sscottl satOrgIOContext->pTiSenseData, 8806285809Sscottl satOrgIOContext->interruptContext ); 8807285809Sscottl return; 8808285809Sscottl } 8809285809Sscottl } 8810285809Sscottl else if (hostToDevFis->h.command == SAT_SMART_ENABLE_OPERATIONS || 8811285809Sscottl hostToDevFis->h.command == SAT_SMART_DISABLE_OPERATIONS 8812285809Sscottl ) 8813285809Sscottl { 8814285809Sscottl if ((hostToDevFis->h.features == 0xD8) || (hostToDevFis->h.features == 0xD9)) 8815285809Sscottl { 8816285809Sscottl TI_DBG5(("satModeSelect6n10CB SAT_SMART_ENABLE/DISABLE_OPERATIONS success, feature 0x%x\n", hostToDevFis->h.features)); 8817285809Sscottl 8818285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8819285809Sscottl 8820285809Sscottl satFreeIntIoResource( tiRoot, 8821285809Sscottl satDevData, 8822285809Sscottl satIntIo); 8823285809Sscottl /* return stat_good */ 8824285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8825285809Sscottl tiOrgIORequest, 8826285809Sscottl tiIOSuccess, 8827285809Sscottl SCSI_STAT_GOOD, 8828285809Sscottl agNULL, 8829285809Sscottl satOrgIOContext->interruptContext ); 8830285809Sscottl return; 8831285809Sscottl } 8832285809Sscottl else 8833285809Sscottl { 8834285809Sscottl TI_DBG1(("satModeSelect6n10CB error unknown command failed 0x%x feature 0x%x\n", hostToDevFis->h.command, hostToDevFis->h.features)); 8835285809Sscottl 8836285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8837285809Sscottl 8838285809Sscottl satFreeIntIoResource( tiRoot, 8839285809Sscottl satDevData, 8840285809Sscottl satIntIo); 8841285809Sscottl satSetSensePayload( pSense, 8842285809Sscottl SCSI_SNSKEY_NO_SENSE, 8843285809Sscottl 0, 8844285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8845285809Sscottl satOrgIOContext); 8846285809Sscottl 8847285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8848285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8849285809Sscottl tiIOSuccess, 8850285809Sscottl SCSI_STAT_CHECK_CONDITION, 8851285809Sscottl satOrgIOContext->pTiSenseData, 8852285809Sscottl satOrgIOContext->interruptContext ); 8853285809Sscottl return; 8854285809Sscottl } 8855285809Sscottl } 8856285809Sscottl 8857285809Sscottl else 8858285809Sscottl { 8859285809Sscottl TI_DBG1(("satModeSelect6n10CB error default case command success 0x%x\n", hostToDevFis->h.command)); 8860285809Sscottl 8861285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8862285809Sscottl 8863285809Sscottl satFreeIntIoResource( tiRoot, 8864285809Sscottl satDevData, 8865285809Sscottl satIntIo); 8866285809Sscottl 8867285809Sscottl satSetSensePayload( pSense, 8868285809Sscottl SCSI_SNSKEY_NO_SENSE, 8869285809Sscottl 0, 8870285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 8871285809Sscottl satOrgIOContext); 8872285809Sscottl 8873285809Sscottl ostiInitiatorIOCompleted( tiRoot, 8874285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 8875285809Sscottl tiIOSuccess, 8876285809Sscottl SCSI_STAT_CHECK_CONDITION, 8877285809Sscottl satOrgIOContext->pTiSenseData, 8878285809Sscottl satOrgIOContext->interruptContext ); 8879285809Sscottl return; 8880285809Sscottl } 8881285809Sscottl 8882285809Sscottl return; 8883285809Sscottl} 8884285809Sscottl 8885285809Sscottl/***************************************************************************** 8886285809Sscottl*! \brief satSMARTEnableCB 8887285809Sscottl* 8888285809Sscottl* This routine is a callback function for satSMARTEnable() 8889285809Sscottl* 8890285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 8891285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 8892285809Sscottl* \param agIOStatus: Status of completed I/O. 8893285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 8894285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 8895285809Sscottl* length. 8896285809Sscottl* \param agParam: Additional info based on status. 8897285809Sscottl* \param ioContext: Pointer to satIOContext_t. 8898285809Sscottl* 8899285809Sscottl* \return: none 8900285809Sscottl* 8901285809Sscottl*****************************************************************************/ 8902285809Sscottlvoid satSMARTEnableCB( 8903285809Sscottl agsaRoot_t *agRoot, 8904285809Sscottl agsaIORequest_t *agIORequest, 8905285809Sscottl bit32 agIOStatus, 8906285809Sscottl agsaFisHeader_t *agFirstDword, 8907285809Sscottl bit32 agIOInfoLen, 8908285809Sscottl void *agParam, 8909285809Sscottl void *ioContext 8910285809Sscottl ) 8911285809Sscottl{ 8912285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 8913285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 8914285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 8915285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 8916285809Sscottl tdIORequestBody_t *tdIORequestBody; 8917285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 8918285809Sscottl satIOContext_t *satIOContext; 8919285809Sscottl satIOContext_t *satOrgIOContext; 8920285809Sscottl satIOContext_t *satNewIOContext; 8921285809Sscottl satInternalIo_t *satIntIo; 8922285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 8923285809Sscottl satDeviceData_t *satDevData; 8924285809Sscottl tiIORequest_t *tiOrgIORequest; 8925285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 8926285809Sscottl bit32 status; 8927285809Sscottl 8928285809Sscottl TI_DBG4(("satSMARTEnableCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 8929285809Sscottl 8930285809Sscottl /* internally generate tiIOContext */ 8931285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 8932285809Sscottl satIOContext = (satIOContext_t *) ioContext; 8933285809Sscottl satIntIo = satIOContext->satIntIoContext; 8934285809Sscottl satDevData = satIOContext->pSatDevData; 8935285809Sscottl 8936285809Sscottl /*ttttttthe one */ 8937285809Sscottl if (satIntIo == agNULL) 8938285809Sscottl { 8939285809Sscottl TI_DBG4(("satSMARTEnableCB: External satInternalIo_t satIntIoContext\n")); 8940285809Sscottl satOrgIOContext = satIOContext; 8941285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 8942285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 8943285809Sscottl } 8944285809Sscottl else 8945285809Sscottl { 8946285809Sscottl TI_DBG4(("satSMARTEnableCB: Internal satInternalIo_t satIntIoContext\n")); 8947285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 8948285809Sscottl if (satOrgIOContext == agNULL) 8949285809Sscottl { 8950285809Sscottl TI_DBG4(("satSMARTEnableCB: satOrgIOContext is NULL, wrong\n")); 8951285809Sscottl return; 8952285809Sscottl } 8953285809Sscottl else 8954285809Sscottl { 8955285809Sscottl TI_DBG4(("satSMARTEnableCB: satOrgIOContext is NOT NULL\n")); 8956285809Sscottl } 8957285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 8958285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 8959285809Sscottl 8960285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 8961285809Sscottl } 8962285809Sscottl 8963285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 8964285809Sscottl tdIORequestBody->ioStarted = agFALSE; 8965285809Sscottl 8966285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 8967285809Sscottl { 8968285809Sscottl TI_DBG1(("satSMARTEnableCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 8969285809Sscottl ostiInitiatorIOCompleted ( 8970285809Sscottl tiRoot, 8971285809Sscottl tiOrgIORequest, 8972285809Sscottl tiIOFailed, 8973285809Sscottl tiDetailOtherError, 8974285809Sscottl agNULL, 8975285809Sscottl satOrgIOContext->interruptContext 8976285809Sscottl ); 8977285809Sscottl 8978285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 8979285809Sscottl 8980285809Sscottl satFreeIntIoResource( tiRoot, 8981285809Sscottl satDevData, 8982285809Sscottl satIntIo); 8983285809Sscottl 8984285809Sscottl return; 8985285809Sscottl } 8986285809Sscottl 8987285809Sscottl /* 8988285809Sscottl checking IO status, FIS type and error status 8989285809Sscottl */ 8990285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 8991285809Sscottl { 8992285809Sscottl TI_DBG1(("satSMARTEnableCB: not success status, status %d\n", agIOStatus)); 8993285809Sscottl ostiInitiatorIOCompleted ( 8994285809Sscottl tiRoot, 8995285809Sscottl tiOrgIORequest, 8996285809Sscottl tiIOFailed, 8997285809Sscottl tiDetailOtherError, 8998285809Sscottl agNULL, 8999285809Sscottl satOrgIOContext->interruptContext 9000285809Sscottl ); 9001285809Sscottl 9002285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9003285809Sscottl 9004285809Sscottl satFreeIntIoResource( tiRoot, 9005285809Sscottl satDevData, 9006285809Sscottl satIntIo); 9007285809Sscottl 9008285809Sscottl return; 9009285809Sscottl } 9010285809Sscottl 9011285809Sscottl /* process success case */ 9012285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9013285809Sscottl 9014285809Sscottl satFreeIntIoResource( tiRoot, 9015285809Sscottl satDevData, 9016285809Sscottl satIntIo); 9017285809Sscottl 9018285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 9019285809Sscottl tiOrgIORequest, 9020285809Sscottl satDevData, 9021285809Sscottl 512, 9022285809Sscottl satNewIntIo); 9023285809Sscottl 9024285809Sscottl if (satNewIntIo == agNULL) 9025285809Sscottl { 9026285809Sscottl /* memory allocation failure */ 9027285809Sscottl satFreeIntIoResource( tiRoot, 9028285809Sscottl satDevData, 9029285809Sscottl satNewIntIo); 9030285809Sscottl 9031285809Sscottl ostiInitiatorIOCompleted ( 9032285809Sscottl tiRoot, 9033285809Sscottl tiOrgIORequest, 9034285809Sscottl tiIOFailed, 9035285809Sscottl tiDetailOtherError, 9036285809Sscottl agNULL, 9037285809Sscottl satOrgIOContext->interruptContext 9038285809Sscottl ); 9039285809Sscottl return; 9040285809Sscottl } 9041285809Sscottl 9042285809Sscottl satNewIOContext = satPrepareNewIO( 9043285809Sscottl satNewIntIo, 9044285809Sscottl tiOrgIORequest, 9045285809Sscottl satDevData, 9046285809Sscottl scsiCmnd, 9047285809Sscottl satOrgIOContext 9048285809Sscottl ); 9049285809Sscottl 9050285809Sscottl status = satLogSense_1(tiRoot, 9051285809Sscottl &satNewIntIo->satIntTiIORequest, 9052285809Sscottl satNewIOContext->ptiDeviceHandle, 9053285809Sscottl &satNewIntIo->satIntTiScsiXchg, 9054285809Sscottl satNewIOContext); 9055285809Sscottl 9056285809Sscottl if (status != tiSuccess) 9057285809Sscottl { 9058285809Sscottl /* sending SAT_CHECK_POWER_MODE fails */ 9059285809Sscottl satFreeIntIoResource( tiRoot, 9060285809Sscottl satDevData, 9061285809Sscottl satNewIntIo); 9062285809Sscottl 9063285809Sscottl ostiInitiatorIOCompleted ( 9064285809Sscottl tiRoot, 9065285809Sscottl tiOrgIORequest, 9066285809Sscottl tiIOFailed, 9067285809Sscottl tiDetailOtherError, 9068285809Sscottl agNULL, 9069285809Sscottl satOrgIOContext->interruptContext 9070285809Sscottl ); 9071285809Sscottl 9072285809Sscottl return; 9073285809Sscottl } 9074285809Sscottl 9075285809Sscottl return; 9076285809Sscottl} 9077285809Sscottl 9078285809Sscottl 9079285809Sscottl/***************************************************************************** 9080285809Sscottl*! \brief satLogSenseCB 9081285809Sscottl* 9082285809Sscottl* This routine is a callback function for satLogSense() 9083285809Sscottl* 9084285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 9085285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 9086285809Sscottl* \param agIOStatus: Status of completed I/O. 9087285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 9088285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 9089285809Sscottl* length. 9090285809Sscottl* \param agParam: Additional info based on status. 9091285809Sscottl* \param ioContext: Pointer to satIOContext_t. 9092285809Sscottl* 9093285809Sscottl* \return: none 9094285809Sscottl* 9095285809Sscottl*****************************************************************************/ 9096285809Sscottlvoid satLogSenseCB( 9097285809Sscottl agsaRoot_t *agRoot, 9098285809Sscottl agsaIORequest_t *agIORequest, 9099285809Sscottl bit32 agIOStatus, 9100285809Sscottl agsaFisHeader_t *agFirstDword, 9101285809Sscottl bit32 agIOInfoLen, 9102285809Sscottl void *agParam, 9103285809Sscottl void *ioContext 9104285809Sscottl ) 9105285809Sscottl{ 9106285809Sscottl 9107285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 9108285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 9109285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 9110285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 9111285809Sscottl tdIORequestBody_t *tdIORequestBody; 9112285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 9113285809Sscottl satIOContext_t *satIOContext; 9114285809Sscottl satIOContext_t *satOrgIOContext; 9115285809Sscottl satInternalIo_t *satIntIo; 9116285809Sscottl satDeviceData_t *satDevData; 9117285809Sscottl 9118285809Sscottl scsiRspSense_t *pSense; 9119285809Sscottl tiIORequest_t *tiOrgIORequest; 9120285809Sscottl 9121285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 9122285809Sscottl bit32 ataStatus = 0; 9123285809Sscottl tiScsiInitiatorRequest_t *tiScsiRequest; /* tiScsiXchg */ 9124285809Sscottl tiScsiInitiatorRequest_t *tiOrgScsiRequest; /* tiScsiXchg */ 9125285809Sscottl satReadLogExtSelfTest_t *virtAddr1; 9126285809Sscottl satSmartReadLogSelfTest_t *virtAddr2; 9127285809Sscottl bit8 *pLogPage; 9128285809Sscottl bit8 SelfTestExecutionStatus = 0; 9129285809Sscottl bit32 i = 0; 9130285809Sscottl 9131285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 9132285809Sscottl agsaFisRegD2HData_t statDevToHostFisData; 9133285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 9134285809Sscottl bit32 lenReceived = 0; 9135285809Sscottl 9136285809Sscottl TI_DBG5(("satLogSenseCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 9137285809Sscottl 9138285809Sscottl /* internally generate tiIOContext */ 9139285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 9140285809Sscottl satIOContext = (satIOContext_t *) ioContext; 9141285809Sscottl if (satIOContext == agNULL) 9142285809Sscottl { 9143285809Sscottl TI_DBG1(("satLogSenseCB: satIOContext is NULL\n")); 9144285809Sscottl return; 9145285809Sscottl } 9146285809Sscottl satIntIo = satIOContext->satIntIoContext; 9147285809Sscottl satDevData = satIOContext->pSatDevData; 9148285809Sscottl hostToDevFis = satIOContext->pFis; 9149285809Sscottl 9150285809Sscottl if (satIntIo == agNULL) 9151285809Sscottl { 9152285809Sscottl TI_DBG4(("satLogSenseCB: External satInternalIo_t satIntIoContext\n")); 9153285809Sscottl satOrgIOContext = satIOContext; 9154285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 9155285809Sscottl pSense = satOrgIOContext->pSense; 9156285809Sscottl tiOrgScsiRequest = satOrgIOContext->tiScsiXchg; 9157285809Sscottl /* SCSI command response payload to OS layer */ 9158285809Sscottl pLogPage = (bit8 *) tiOrgScsiRequest->sglVirtualAddr; 9159285809Sscottl /* ATA command response payload */ 9160285809Sscottl tiScsiRequest = satOrgIOContext->tiScsiXchg; 9161285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 9162285809Sscottl } 9163285809Sscottl else 9164285809Sscottl { 9165285809Sscottl TI_DBG4(("satLogSenseCB: Internal satInternalIo_t satIntIoContext\n")); 9166285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 9167285809Sscottl if (satOrgIOContext == agNULL) 9168285809Sscottl { 9169285809Sscottl TI_DBG4(("satLogSenseCB: satOrgIOContext is NULL\n")); 9170285809Sscottl } 9171285809Sscottl else 9172285809Sscottl { 9173285809Sscottl TI_DBG4(("satLogSenseCB: satOrgIOContext is NOT NULL\n")); 9174285809Sscottl } 9175285809Sscottl 9176285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 9177285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 9178285809Sscottl 9179285809Sscottl pSense = satOrgIOContext->pSense; 9180285809Sscottl tiOrgScsiRequest = satOrgIOContext->tiScsiXchg; 9181285809Sscottl /* SCSI command response payload to OS layer */ 9182285809Sscottl pLogPage = (bit8 *) tiOrgScsiRequest->sglVirtualAddr; 9183285809Sscottl /* ATA command response payload */ 9184285809Sscottl tiScsiRequest = (tiScsiInitiatorRequest_t *)&(satIntIo->satIntTiScsiXchg); 9185285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 9186285809Sscottl } 9187285809Sscottl 9188285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 9189285809Sscottl tdIORequestBody->ioStarted = agFALSE; 9190285809Sscottl 9191285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 9192285809Sscottl { 9193285809Sscottl TI_DBG1(("satLogSenseCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 9194285809Sscottl ostiInitiatorIOCompleted ( 9195285809Sscottl tiRoot, 9196285809Sscottl tiOrgIORequest, 9197285809Sscottl tiIOFailed, 9198285809Sscottl tiDetailOtherError, 9199285809Sscottl agNULL, 9200285809Sscottl satOrgIOContext->interruptContext 9201285809Sscottl ); 9202285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9203285809Sscottl 9204285809Sscottl satFreeIntIoResource( tiRoot, 9205285809Sscottl satDevData, 9206285809Sscottl satIntIo); 9207285809Sscottl return; 9208285809Sscottl } 9209285809Sscottl 9210285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 9211285809Sscottl { 9212285809Sscottl /* non-data and pio read -> device to host and pio setup fis are expected */ 9213285809Sscottl /* 9214285809Sscottl first, assumed to be Reg Device to Host FIS 9215285809Sscottl This is OK to just find fis type 9216285809Sscottl */ 9217285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 9218285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 9219285809Sscottl } 9220285809Sscottl 9221285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 9222285809Sscottl { 9223285809Sscottl if ( ((statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) && 9224285809Sscottl (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS)) || 9225285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 9226285809Sscottl ) 9227285809Sscottl { 9228285809Sscottl /* for debugging */ 9229285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 9230285809Sscottl { 9231285809Sscottl TI_DBG1(("satLogSenseCB: FAILED, NOT IO_SUCCESS\n")); 9232285809Sscottl } 9233285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 9234285809Sscottl { 9235285809Sscottl TI_DBG1(("satLogSenseCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 9236285809Sscottl } 9237285809Sscottl else if (statDevToHostFisHeader->fisType != PIO_SETUP_DEV_TO_HOST_FIS) 9238285809Sscottl { 9239285809Sscottl TI_DBG1(("satLogSenseCB: FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 9240285809Sscottl } 9241285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 9242285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 9243285809Sscottl ) 9244285809Sscottl { 9245285809Sscottl TI_DBG1(("satLogSenseCB: FAILED, FAILED, error status\n")); 9246285809Sscottl } 9247285809Sscottl 9248285809Sscottl /* Process abort case */ 9249285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 9250285809Sscottl { 9251285809Sscottl satProcessAbort(tiRoot, 9252285809Sscottl tiOrgIORequest, 9253285809Sscottl satOrgIOContext 9254285809Sscottl ); 9255285809Sscottl 9256285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9257285809Sscottl 9258285809Sscottl satFreeIntIoResource( tiRoot, 9259285809Sscottl satDevData, 9260285809Sscottl satIntIo); 9261285809Sscottl return; 9262285809Sscottl } 9263285809Sscottl 9264285809Sscottl /* for debugging */ 9265285809Sscottl if (hostToDevFis->h.command == SAT_READ_LOG_EXT) 9266285809Sscottl { 9267285809Sscottl TI_DBG1(("satLogSenseCB: SAT_READ_LOG_EXT failed\n")); 9268285809Sscottl } 9269285809Sscottl else if (hostToDevFis->h.command == SAT_SMART) 9270285809Sscottl { 9271285809Sscottl if (hostToDevFis->h.features == SAT_SMART_READ_LOG) 9272285809Sscottl { 9273285809Sscottl TI_DBG1(("satLogSenseCB: SAT_SMART_READ_LOG failed\n")); 9274285809Sscottl } 9275285809Sscottl else if (hostToDevFis->h.features == SAT_SMART_RETURN_STATUS) 9276285809Sscottl { 9277285809Sscottl TI_DBG1(("satLogSenseCB: SAT_SMART_RETURN_STATUS failed\n")); 9278285809Sscottl } 9279285809Sscottl else 9280285809Sscottl { 9281285809Sscottl TI_DBG1(("satLogSenseCB: error unknown command 0x%x feature 0x%x\n", hostToDevFis->h.command, hostToDevFis->h.features)); 9282285809Sscottl } 9283285809Sscottl } 9284285809Sscottl else 9285285809Sscottl { 9286285809Sscottl TI_DBG1(("satLogSenseCB: error default case command 0x%x\n", hostToDevFis->h.command)); 9287285809Sscottl } 9288285809Sscottl 9289285809Sscottl satSetSensePayload( pSense, 9290285809Sscottl SCSI_SNSKEY_NO_SENSE, 9291285809Sscottl 0, 9292285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 9293285809Sscottl satOrgIOContext); 9294285809Sscottl 9295285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9296285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 9297285809Sscottl tiIOSuccess, 9298285809Sscottl SCSI_STAT_CHECK_CONDITION, 9299285809Sscottl satOrgIOContext->pTiSenseData, 9300285809Sscottl satOrgIOContext->interruptContext ); 9301285809Sscottl 9302285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9303285809Sscottl 9304285809Sscottl satFreeIntIoResource( tiRoot, 9305285809Sscottl satDevData, 9306285809Sscottl satIntIo); 9307285809Sscottl return; 9308285809Sscottl 9309285809Sscottl } /* error checking */ 9310285809Sscottl } 9311285809Sscottl 9312285809Sscottl /* prcessing the success case */ 9313285809Sscottl saFrameReadBlock(agRoot, agParam, 0, &statDevToHostFisData, sizeof(agsaFisRegD2HData_t)); 9314285809Sscottl 9315285809Sscottl lenReceived = (scsiCmnd->cdb[7] << 8) + scsiCmnd->cdb[8]; 9316285809Sscottl TI_DBG5(("satLogSenseCB: lenReceived in CDB %d 0x%x\n", lenReceived,lenReceived)); 9317285809Sscottl 9318285809Sscottl 9319285809Sscottl if (hostToDevFis->h.command == SAT_READ_LOG_EXT) 9320285809Sscottl { 9321285809Sscottl TI_DBG5(("satLogSenseCB: SAT_READ_LOG_EXT success\n")); 9322285809Sscottl 9323285809Sscottl /* process log data and sends it to upper */ 9324285809Sscottl 9325285809Sscottl /* ATA: Extended Self-Test Log */ 9326285809Sscottl virtAddr1 = (satReadLogExtSelfTest_t *)(tiScsiRequest->sglVirtualAddr); 9327285809Sscottl /* 9328285809Sscottl ATA/ATAPI VOLII, p197, 287 9329285809Sscottl self-test execution status (4 bits); ((virtAddr1->byte[5] & 0xF0) >> 4) 9330285809Sscottl */ 9331285809Sscottl SelfTestExecutionStatus = (bit8)(((virtAddr1->byte[5] & 0xF0) >> 4)); 9332285809Sscottl 9333285809Sscottl /* fills in the log page from ATA log page */ 9334285809Sscottl /* SPC-4, 7.2.10, Table 216, 217, p 259 - 260 */ 9335285809Sscottl pLogPage[0] = 0x10; /* page code */ 9336285809Sscottl pLogPage[1] = 0; 9337285809Sscottl pLogPage[2] = 0x01; /* 0x190, page length */ 9338285809Sscottl pLogPage[3] = 0x90; 9339285809Sscottl 9340285809Sscottl /* SPC-4, Table 217 */ 9341285809Sscottl pLogPage[4] = 0; /* Parameter Code */ 9342285809Sscottl pLogPage[5] = 0x01; /* Parameter Code, unspecfied but ... */ 9343285809Sscottl pLogPage[6] = 3; /* unspecified but ... */ 9344285809Sscottl pLogPage[7] = 0x10; /* Parameter Length */ 9345285809Sscottl pLogPage[8] = (bit8)(0 | ((virtAddr1->byte[5] & 0xF0) >> 4)); /* Self Test Code and Self-Test Result */ 9346285809Sscottl pLogPage[9] = 0; /* self test number */ 9347285809Sscottl pLogPage[10] = virtAddr1->byte[7]; /* time stamp, MSB */ 9348285809Sscottl pLogPage[11] = virtAddr1->byte[6]; /* time stamp, LSB */ 9349285809Sscottl 9350285809Sscottl pLogPage[12] = 0; /* address of first failure MSB*/ 9351285809Sscottl pLogPage[13] = 0; /* address of first failure */ 9352285809Sscottl pLogPage[14] = virtAddr1->byte[14]; /* address of first failure */ 9353285809Sscottl pLogPage[15] = virtAddr1->byte[13]; /* address of first failure */ 9354285809Sscottl pLogPage[16] = virtAddr1->byte[12]; /* address of first failure */ 9355285809Sscottl pLogPage[17] = virtAddr1->byte[11]; /* address of first failure */ 9356285809Sscottl pLogPage[18] = virtAddr1->byte[10]; /* address of first failure */ 9357285809Sscottl pLogPage[19] = virtAddr1->byte[9]; /* address of first failure LSB */ 9358285809Sscottl 9359285809Sscottl /* SAT rev8 Table75, p 76 */ 9360285809Sscottl switch (SelfTestExecutionStatus) 9361285809Sscottl { 9362285809Sscottl case 0: 9363285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 9364285809Sscottl pLogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 9365285809Sscottl pLogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 9366285809Sscottl break; 9367285809Sscottl case 1: 9368285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 9369285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9370285809Sscottl pLogPage[22] = 0x81; 9371285809Sscottl break; 9372285809Sscottl case 2: 9373285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 9374285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9375285809Sscottl pLogPage[22] = 0x82; 9376285809Sscottl break; 9377285809Sscottl case 3: 9378285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 9379285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9380285809Sscottl pLogPage[22] = 0x83; 9381285809Sscottl break; 9382285809Sscottl case 4: 9383285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9384285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9385285809Sscottl pLogPage[22] = 0x84; 9386285809Sscottl break; 9387285809Sscottl case 5: 9388285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9389285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9390285809Sscottl pLogPage[22] = 0x85; 9391285809Sscottl break; 9392285809Sscottl case 6: 9393285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9394285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9395285809Sscottl pLogPage[22] = 0x86; 9396285809Sscottl break; 9397285809Sscottl case 7: 9398285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_MEDIUM_ERROR; 9399285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9400285809Sscottl pLogPage[22] = 0x87; 9401285809Sscottl break; 9402285809Sscottl case 8: 9403285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9404285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9405285809Sscottl pLogPage[22] = 0x88; 9406285809Sscottl break; 9407285809Sscottl case 9: /* fall through */ 9408285809Sscottl case 10:/* fall through */ 9409285809Sscottl case 11:/* fall through */ 9410285809Sscottl case 12:/* fall through */ 9411285809Sscottl case 13:/* fall through */ 9412285809Sscottl case 14: 9413285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 9414285809Sscottl pLogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 9415285809Sscottl pLogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 9416285809Sscottl break; 9417285809Sscottl case 15: 9418285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 9419285809Sscottl pLogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 9420285809Sscottl pLogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 9421285809Sscottl break; 9422285809Sscottl default: 9423285809Sscottl TI_DBG1(("satLogSenseCB: Error, incorrect SelfTestExecutionStatus 0x%x\n", SelfTestExecutionStatus)); 9424285809Sscottl 9425285809Sscottl satSetSensePayload( pSense, 9426285809Sscottl SCSI_SNSKEY_NO_SENSE, 9427285809Sscottl 0, 9428285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 9429285809Sscottl satOrgIOContext); 9430285809Sscottl 9431285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9432285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 9433285809Sscottl tiIOSuccess, 9434285809Sscottl SCSI_STAT_CHECK_CONDITION, 9435285809Sscottl satOrgIOContext->pTiSenseData, 9436285809Sscottl satOrgIOContext->interruptContext ); 9437285809Sscottl 9438285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9439285809Sscottl 9440285809Sscottl satFreeIntIoResource( tiRoot, 9441285809Sscottl satDevData, 9442285809Sscottl satIntIo); 9443285809Sscottl 9444285809Sscottl return; 9445285809Sscottl } 9446285809Sscottl 9447285809Sscottl pLogPage[23] = 0; /* vendor specific */ 9448285809Sscottl 9449285809Sscottl /* the rest of Self-test results log */ 9450285809Sscottl /* 403 is from SPC-4, 7.2.10, Table 216, p 259*/ 9451285809Sscottl for (i=24;i<=403;i++) 9452285809Sscottl { 9453285809Sscottl pLogPage[i] = 0; /* vendor specific */ 9454285809Sscottl } 9455285809Sscottl 9456285809Sscottl if (SELFTEST_RESULTS_LOG_PAGE_LENGTH < lenReceived) 9457285809Sscottl { 9458285809Sscottl TI_DBG6(("satLogSenseCB: 1st underrun lenReceived %d len %d \n", lenReceived, SELFTEST_RESULTS_LOG_PAGE_LENGTH)); 9459285809Sscottl 9460285809Sscottl /* underrun */ 9461285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9462285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 9463285809Sscottl tiIOUnderRun, 9464285809Sscottl lenReceived - SELFTEST_RESULTS_LOG_PAGE_LENGTH, 9465285809Sscottl agNULL, 9466285809Sscottl satOrgIOContext->interruptContext ); 9467285809Sscottl 9468285809Sscottl } 9469285809Sscottl else 9470285809Sscottl { 9471285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9472285809Sscottl tiOrgIORequest, 9473285809Sscottl tiIOSuccess, 9474285809Sscottl SCSI_STAT_GOOD, 9475285809Sscottl agNULL, 9476285809Sscottl satOrgIOContext->interruptContext); 9477285809Sscottl } 9478285809Sscottl 9479285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9480285809Sscottl 9481285809Sscottl satFreeIntIoResource( tiRoot, 9482285809Sscottl satDevData, 9483285809Sscottl satIntIo); 9484285809Sscottl 9485285809Sscottl return; 9486285809Sscottl } 9487285809Sscottl else if (hostToDevFis->h.command == SAT_SMART_READ_LOG 9488285809Sscottl || hostToDevFis->h.command == SAT_SMART_RETURN_STATUS) 9489285809Sscottl { 9490285809Sscottl if (hostToDevFis->h.features == 0xd5) 9491285809Sscottl { 9492285809Sscottl TI_DBG5(("satLogSenseCB: SAT_SMART_READ_LOG success\n")); 9493285809Sscottl /* process log data and sends it to upper */ 9494285809Sscottl 9495285809Sscottl /* ATA: Extended Self-Test Log */ 9496285809Sscottl virtAddr2 = (satSmartReadLogSelfTest_t *)(tiScsiRequest->sglVirtualAddr); 9497285809Sscottl /* 9498285809Sscottl SPC-4, p197, 287 9499285809Sscottl self-test execution status (4 bits); ((virtAddr2->byte[3] & 0xF0) >> 4) 9500285809Sscottl */ 9501285809Sscottl SelfTestExecutionStatus = (bit8)(((virtAddr2->byte[3] & 0xF0) >> 4)); 9502285809Sscottl 9503285809Sscottl /* fills in the log page from ATA log page */ 9504285809Sscottl /* SPC-4, 7.2.10, Table 216, 217, p 259 - 260 */ 9505285809Sscottl pLogPage[0] = 0x10; /* page code */ 9506285809Sscottl pLogPage[1] = 0; 9507285809Sscottl pLogPage[2] = 0x01; /* 0x190, page length */ 9508285809Sscottl pLogPage[3] = 0x90; /* 0x190, page length */ 9509285809Sscottl 9510285809Sscottl /* SPC-4, Table 217 */ 9511285809Sscottl pLogPage[4] = 0; /* Parameter Code */ 9512285809Sscottl pLogPage[5] = 0x01; /* Parameter Code unspecfied but ... */ 9513285809Sscottl pLogPage[6] = 3; /* unspecified but ... */ 9514285809Sscottl pLogPage[7] = 0x10; /* Parameter Length */ 9515285809Sscottl pLogPage[8] = (bit8)(0 | ((virtAddr2->byte[3] & 0xF0) >> 4)); /* Self Test Code and Self-Test Result */ 9516285809Sscottl pLogPage[9] = 0; /* self test number */ 9517285809Sscottl pLogPage[10] = virtAddr2->byte[5]; /* time stamp, MSB */ 9518285809Sscottl pLogPage[11] = virtAddr2->byte[4]; /* time stamp, LSB */ 9519285809Sscottl 9520285809Sscottl pLogPage[12] = 0; /* address of first failure MSB*/ 9521285809Sscottl pLogPage[13] = 0; /* address of first failure */ 9522285809Sscottl pLogPage[14] = 0; /* address of first failure */ 9523285809Sscottl pLogPage[15] = 0; /* address of first failure */ 9524285809Sscottl pLogPage[16] = virtAddr2->byte[10]; /* address of first failure */ 9525285809Sscottl pLogPage[17] = virtAddr2->byte[9]; /* address of first failure */ 9526285809Sscottl pLogPage[18] = virtAddr2->byte[8]; /* address of first failure */ 9527285809Sscottl pLogPage[19] = virtAddr2->byte[7]; /* address of first failure LSB */ 9528285809Sscottl 9529285809Sscottl /* SAT rev8 Table75, p 76 */ 9530285809Sscottl switch (SelfTestExecutionStatus) 9531285809Sscottl { 9532285809Sscottl case 0: 9533285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 9534285809Sscottl pLogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 9535285809Sscottl pLogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 9536285809Sscottl break; 9537285809Sscottl case 1: 9538285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 9539285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9540285809Sscottl pLogPage[22] = 0x81; 9541285809Sscottl break; 9542285809Sscottl case 2: 9543285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 9544285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9545285809Sscottl pLogPage[22] = 0x82; 9546285809Sscottl break; 9547285809Sscottl case 3: 9548285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_ABORTED_COMMAND; 9549285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9550285809Sscottl pLogPage[22] = 0x83; 9551285809Sscottl break; 9552285809Sscottl case 4: 9553285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9554285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9555285809Sscottl pLogPage[22] = 0x84; 9556285809Sscottl break; 9557285809Sscottl case 5: 9558285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9559285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9560285809Sscottl pLogPage[22] = 0x85; 9561285809Sscottl break; 9562285809Sscottl case 6: 9563285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9564285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9565285809Sscottl pLogPage[22] = 0x86; 9566285809Sscottl break; 9567285809Sscottl case 7: 9568285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_MEDIUM_ERROR; 9569285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9570285809Sscottl pLogPage[22] = 0x87; 9571285809Sscottl break; 9572285809Sscottl case 8: 9573285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_HARDWARE_ERROR; 9574285809Sscottl pLogPage[21] = (SCSI_SNSCODE_DIAGNOSTIC_FAILURE_ON_COMPONENT_NN >> 8) & 0xFF; 9575285809Sscottl pLogPage[22] = 0x88; 9576285809Sscottl break; 9577285809Sscottl case 9: /* fall through */ 9578285809Sscottl case 10:/* fall through */ 9579285809Sscottl case 11:/* fall through */ 9580285809Sscottl case 12:/* fall through */ 9581285809Sscottl case 13:/* fall through */ 9582285809Sscottl case 14: 9583285809Sscottl /* unspecified */ 9584285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 9585285809Sscottl pLogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 9586285809Sscottl pLogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 9587285809Sscottl break; 9588285809Sscottl case 15: 9589285809Sscottl pLogPage[20] = 0 | SCSI_SNSKEY_NO_SENSE; 9590285809Sscottl pLogPage[21] = (SCSI_SNSCODE_NO_ADDITIONAL_INFO >> 8) & 0xFF; 9591285809Sscottl pLogPage[22] = SCSI_SNSCODE_NO_ADDITIONAL_INFO & 0xFF; 9592285809Sscottl break; 9593285809Sscottl default: 9594285809Sscottl TI_DBG1(("satLogSenseCB: Error, incorrect SelfTestExecutionStatus 0x%x\n", SelfTestExecutionStatus)); 9595285809Sscottl 9596285809Sscottl satSetSensePayload( pSense, 9597285809Sscottl SCSI_SNSKEY_NO_SENSE, 9598285809Sscottl 0, 9599285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 9600285809Sscottl satOrgIOContext); 9601285809Sscottl 9602285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9603285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 9604285809Sscottl tiIOSuccess, 9605285809Sscottl SCSI_STAT_CHECK_CONDITION, 9606285809Sscottl satOrgIOContext->pTiSenseData, 9607285809Sscottl satOrgIOContext->interruptContext ); 9608285809Sscottl 9609285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9610285809Sscottl 9611285809Sscottl satFreeIntIoResource( tiRoot, 9612285809Sscottl satDevData, 9613285809Sscottl satIntIo); 9614285809Sscottl 9615285809Sscottl return; 9616285809Sscottl } 9617285809Sscottl 9618285809Sscottl pLogPage[23] = 0; /* vendor specific */ 9619285809Sscottl 9620285809Sscottl /* the rest of Self-test results log */ 9621285809Sscottl /* 403 is from SPC-4, 7.2.10, Table 216, p 259*/ 9622285809Sscottl for (i=24;i<=403;i++) 9623285809Sscottl { 9624285809Sscottl pLogPage[i] = 0; /* vendor specific */ 9625285809Sscottl } 9626285809Sscottl 9627285809Sscottl if (SELFTEST_RESULTS_LOG_PAGE_LENGTH < lenReceived) 9628285809Sscottl { 9629285809Sscottl TI_DBG6(("satLogSenseCB: 2nd underrun lenReceived %d len %d \n", lenReceived, SELFTEST_RESULTS_LOG_PAGE_LENGTH)); 9630285809Sscottl 9631285809Sscottl /* underrun */ 9632285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9633285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 9634285809Sscottl tiIOUnderRun, 9635285809Sscottl lenReceived - SELFTEST_RESULTS_LOG_PAGE_LENGTH, 9636285809Sscottl agNULL, 9637285809Sscottl satOrgIOContext->interruptContext ); 9638285809Sscottl 9639285809Sscottl } 9640285809Sscottl else 9641285809Sscottl { 9642285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9643285809Sscottl tiOrgIORequest, 9644285809Sscottl tiIOSuccess, 9645285809Sscottl SCSI_STAT_GOOD, 9646285809Sscottl agNULL, 9647285809Sscottl satOrgIOContext->interruptContext); 9648285809Sscottl } 9649285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9650285809Sscottl 9651285809Sscottl satFreeIntIoResource( tiRoot, 9652285809Sscottl satDevData, 9653285809Sscottl satIntIo); 9654285809Sscottl 9655285809Sscottl return; 9656285809Sscottl } 9657285809Sscottl else if (hostToDevFis->h.features == 0xda) 9658285809Sscottl { 9659285809Sscottl TI_DBG5(("satLogSenseCB: SAT_SMART_RETURN_STATUS success\n")); 9660285809Sscottl 9661285809Sscottl /* fills in the log page from ATA output */ 9662285809Sscottl /* SPC-4, 7.2.5, Table 209, 211, p 255 */ 9663285809Sscottl pLogPage[0] = 0x2F; /* page code unspecified */ 9664285809Sscottl pLogPage[1] = 0; /* reserved */ 9665285809Sscottl pLogPage[2] = 0; /* page length */ 9666285809Sscottl pLogPage[3] = 0x07; /* page length */ 9667285809Sscottl 9668285809Sscottl /* 9669285809Sscottl SPC-4, 7.2.5, Table 211, p 255 9670285809Sscottl no vendor specific field 9671285809Sscottl */ 9672285809Sscottl pLogPage[4] = 0; /* Parameter Code */ 9673285809Sscottl pLogPage[5] = 0; /* Parameter Code unspecfied but to do: */ 9674285809Sscottl pLogPage[6] = 0; /* unspecified */ 9675285809Sscottl pLogPage[7] = 0x03; /* Parameter length, unspecified */ 9676285809Sscottl 9677285809Sscottl /* SAT rev8, 10.2.3.1 Table 72, p 73 */ 9678285809Sscottl if (statDevToHostFisData.lbaMid == 0x4F || statDevToHostFisData.lbaHigh == 0xC2) 9679285809Sscottl { 9680285809Sscottl pLogPage[8] = 0; /* Sense code */ 9681285809Sscottl pLogPage[9] = 0; /* Sense code qualifier */ 9682285809Sscottl } 9683285809Sscottl else if (statDevToHostFisData.lbaMid == 0xF4 || statDevToHostFisData.lbaHigh == 0x2C) 9684285809Sscottl { 9685285809Sscottl pLogPage[8] = 0x5D; /* Sense code */ 9686285809Sscottl pLogPage[9] = 0x10; /* Sense code qualifier */ 9687285809Sscottl } 9688285809Sscottl 9689285809Sscottl /* Assumption: No support for SCT */ 9690285809Sscottl pLogPage[10] = 0xFF; /* Most Recent Temperature Reading */ 9691285809Sscottl 9692285809Sscottl if (INFORMATION_EXCEPTIONS_LOG_PAGE_LENGTH < lenReceived) 9693285809Sscottl { 9694285809Sscottl TI_DBG6(("satLogSenseCB: 3rd underrun lenReceived %d len %d \n", lenReceived, INFORMATION_EXCEPTIONS_LOG_PAGE_LENGTH)); 9695285809Sscottl 9696285809Sscottl /* underrun */ 9697285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9698285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 9699285809Sscottl tiIOUnderRun, 9700285809Sscottl lenReceived - INFORMATION_EXCEPTIONS_LOG_PAGE_LENGTH, 9701285809Sscottl agNULL, 9702285809Sscottl satOrgIOContext->interruptContext ); 9703285809Sscottl 9704285809Sscottl } 9705285809Sscottl else 9706285809Sscottl { 9707285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9708285809Sscottl tiOrgIORequest, 9709285809Sscottl tiIOSuccess, 9710285809Sscottl SCSI_STAT_GOOD, 9711285809Sscottl agNULL, 9712285809Sscottl satOrgIOContext->interruptContext); 9713285809Sscottl } 9714285809Sscottl 9715285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9716285809Sscottl 9717285809Sscottl satFreeIntIoResource( tiRoot, 9718285809Sscottl satDevData, 9719285809Sscottl satIntIo); 9720285809Sscottl 9721285809Sscottl 9722285809Sscottl return; 9723285809Sscottl } 9724285809Sscottl else 9725285809Sscottl { 9726285809Sscottl TI_DBG1(("satLogSenseCB: error unknown command success 0x%x feature 0x%x\n", hostToDevFis->h.command, hostToDevFis->h.features)); 9727285809Sscottl satSetSensePayload( pSense, 9728285809Sscottl SCSI_SNSKEY_NO_SENSE, 9729285809Sscottl 0, 9730285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 9731285809Sscottl satOrgIOContext); 9732285809Sscottl 9733285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9734285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 9735285809Sscottl tiIOSuccess, 9736285809Sscottl SCSI_STAT_CHECK_CONDITION, 9737285809Sscottl satOrgIOContext->pTiSenseData, 9738285809Sscottl satOrgIOContext->interruptContext ); 9739285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9740285809Sscottl 9741285809Sscottl satFreeIntIoResource( tiRoot, 9742285809Sscottl satDevData, 9743285809Sscottl satIntIo); 9744285809Sscottl 9745285809Sscottl return; 9746285809Sscottl } 9747285809Sscottl } 9748285809Sscottl else 9749285809Sscottl { 9750285809Sscottl TI_DBG1(("satLogSenseCB: error unknown command success 0x%x\n", hostToDevFis->h.command)); 9751285809Sscottl satSetSensePayload( pSense, 9752285809Sscottl SCSI_SNSKEY_NO_SENSE, 9753285809Sscottl 0, 9754285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 9755285809Sscottl satOrgIOContext); 9756285809Sscottl 9757285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9758285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 9759285809Sscottl tiIOSuccess, 9760285809Sscottl SCSI_STAT_CHECK_CONDITION, 9761285809Sscottl satOrgIOContext->pTiSenseData, 9762285809Sscottl satOrgIOContext->interruptContext ); 9763285809Sscottl 9764285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9765285809Sscottl 9766285809Sscottl satFreeIntIoResource( tiRoot, 9767285809Sscottl satDevData, 9768285809Sscottl satIntIo); 9769285809Sscottl 9770285809Sscottl return; 9771285809Sscottl } 9772285809Sscottl 9773285809Sscottl return; 9774285809Sscottl} 9775285809Sscottl 9776285809Sscottl/***************************************************************************** 9777285809Sscottl*! \brief satReadMediaSerialNumberCB 9778285809Sscottl* 9779285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 9780285809Sscottl* This CB routine deals with Read Media Serial Number completion. 9781285809Sscottl* 9782285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 9783285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 9784285809Sscottl* \param agIOStatus: Status of completed I/O. 9785285809Sscottl* \param agSATAParm1: Additional info based on status. 9786285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 9787285809Sscottl* length. 9788285809Sscottl* \param ioContext: Pointer to satIOContext_t. 9789285809Sscottl* 9790285809Sscottl* \return: none 9791285809Sscottl* 9792285809Sscottl*****************************************************************************/ 9793285809Sscottlvoid satReadMediaSerialNumberCB( 9794285809Sscottl agsaRoot_t *agRoot, 9795285809Sscottl agsaIORequest_t *agIORequest, 9796285809Sscottl bit32 agIOStatus, 9797285809Sscottl agsaFisHeader_t *agFirstDword, 9798285809Sscottl bit32 agIOInfoLen, 9799285809Sscottl agsaFrameHandle_t agFrameHandle, 9800285809Sscottl void *ioContext 9801285809Sscottl ) 9802285809Sscottl{ 9803285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 9804285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 9805285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 9806285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 9807285809Sscottl tdIORequestBody_t *tdIORequestBody; 9808285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 9809285809Sscottl satIOContext_t *satIOContext; 9810285809Sscottl satIOContext_t *satOrgIOContext; 9811285809Sscottl satInternalIo_t *satIntIo; 9812285809Sscottl satDeviceData_t *satDevData; 9813285809Sscottl 9814285809Sscottl scsiRspSense_t *pSense; 9815285809Sscottl tiIORequest_t *tiOrgIORequest; 9816285809Sscottl 9817285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 9818285809Sscottl tiScsiInitiatorRequest_t *tiOrgScsiRequest; /* tiScsiXchg */ 9819285809Sscottl bit8 *pMediaSerialNumber; 9820285809Sscottl 9821285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 9822285809Sscottl bit32 lenReceived = 0; 9823285809Sscottl 9824285809Sscottl TI_DBG4(("satReadMediaSerialNumberCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 9825285809Sscottl 9826285809Sscottl /* internally generate tiIOContext */ 9827285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 9828285809Sscottl satIOContext = (satIOContext_t *) ioContext; 9829285809Sscottl satIntIo = satIOContext->satIntIoContext; 9830285809Sscottl satDevData = satIOContext->pSatDevData; 9831285809Sscottl hostToDevFis = satIOContext->pFis; 9832285809Sscottl 9833285809Sscottl if (satIntIo == agNULL) 9834285809Sscottl { 9835285809Sscottl TI_DBG4(("satReadMediaSerialNumberCB: External satInternalIo_t satIntIoContext\n")); 9836285809Sscottl satOrgIOContext = satIOContext; 9837285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 9838285809Sscottl pSense = satOrgIOContext->pSense; 9839285809Sscottl tiOrgScsiRequest = satOrgIOContext->tiScsiXchg; 9840285809Sscottl /* SCSI command response payload to OS layer */ 9841285809Sscottl pMediaSerialNumber = (bit8 *) tiOrgScsiRequest->sglVirtualAddr; 9842285809Sscottl /* ATA command response payload */ 9843285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 9844285809Sscottl 9845285809Sscottl 9846285809Sscottl } 9847285809Sscottl else 9848285809Sscottl { 9849285809Sscottl TI_DBG4(("satReadMediaSerialNumberCB: Internal satInternalIo_t satIntIoContext\n")); 9850285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 9851285809Sscottl if (satOrgIOContext == agNULL) 9852285809Sscottl { 9853285809Sscottl TI_DBG4(("satReadMediaSerialNumberCB: satOrgIOContext is NULL, wrong\n")); 9854285809Sscottl return; 9855285809Sscottl } 9856285809Sscottl else 9857285809Sscottl { 9858285809Sscottl TI_DBG4(("satReadMediaSerialNumberCB: satOrgIOContext is NOT NULL\n")); 9859285809Sscottl } 9860285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 9861285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 9862285809Sscottl 9863285809Sscottl pSense = satOrgIOContext->pSense; 9864285809Sscottl tiOrgScsiRequest = satOrgIOContext->tiScsiXchg; 9865285809Sscottl /* SCSI command response payload to OS layer */ 9866285809Sscottl pMediaSerialNumber = (bit8 *) tiOrgScsiRequest->sglVirtualAddr; 9867285809Sscottl /* ATA command response payload */ 9868285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 9869285809Sscottl } 9870285809Sscottl 9871285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 9872285809Sscottl tdIORequestBody->ioStarted = agFALSE; 9873285809Sscottl 9874285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 9875285809Sscottl { 9876285809Sscottl TI_DBG1(("satReadMediaSerialNumberCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 9877285809Sscottl ostiInitiatorIOCompleted ( 9878285809Sscottl tiRoot, 9879285809Sscottl tiOrgIORequest, 9880285809Sscottl tiIOFailed, 9881285809Sscottl tiDetailOtherError, 9882285809Sscottl agNULL, 9883285809Sscottl satOrgIOContext->interruptContext 9884285809Sscottl ); 9885285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9886285809Sscottl 9887285809Sscottl satFreeIntIoResource( tiRoot, 9888285809Sscottl satDevData, 9889285809Sscottl satIntIo); 9890285809Sscottl return; 9891285809Sscottl } 9892285809Sscottl 9893285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 9894285809Sscottl { 9895285809Sscottl /* Process abort case */ 9896285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 9897285809Sscottl { 9898285809Sscottl satProcessAbort(tiRoot, 9899285809Sscottl tiOrgIORequest, 9900285809Sscottl satOrgIOContext 9901285809Sscottl ); 9902285809Sscottl 9903285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9904285809Sscottl 9905285809Sscottl satFreeIntIoResource( tiRoot, 9906285809Sscottl satDevData, 9907285809Sscottl satIntIo); 9908285809Sscottl return; 9909285809Sscottl } 9910285809Sscottl satSetSensePayload( pSense, 9911285809Sscottl SCSI_SNSKEY_NOT_READY, 9912285809Sscottl 0, 9913285809Sscottl SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 9914285809Sscottl satOrgIOContext); 9915285809Sscottl 9916285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9917285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 9918285809Sscottl tiIOSuccess, 9919285809Sscottl SCSI_STAT_CHECK_CONDITION, 9920285809Sscottl satOrgIOContext->pTiSenseData, 9921285809Sscottl satOrgIOContext->interruptContext ); 9922285809Sscottl 9923285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9924285809Sscottl 9925285809Sscottl satFreeIntIoResource( tiRoot, 9926285809Sscottl satDevData, 9927285809Sscottl satIntIo); 9928285809Sscottl return; 9929285809Sscottl } 9930285809Sscottl 9931285809Sscottl /* process success case */ 9932285809Sscottl lenReceived = (scsiCmnd->cdb[6] << (8*3)) + (scsiCmnd->cdb[7] << (8*2)) 9933285809Sscottl + (scsiCmnd->cdb[8] << 8) + scsiCmnd->cdb[9]; 9934285809Sscottl TI_DBG5(("satReadMediaSerialNumberCB: lenReceived in CDB %d 0x%x\n", lenReceived,lenReceived)); 9935285809Sscottl 9936285809Sscottl if (hostToDevFis->h.command == SAT_READ_SECTORS || 9937285809Sscottl hostToDevFis->h.command == SAT_READ_SECTORS_EXT 9938285809Sscottl ) 9939285809Sscottl { 9940285809Sscottl pMediaSerialNumber[0] = 0; 9941285809Sscottl pMediaSerialNumber[1] = 0; 9942285809Sscottl pMediaSerialNumber[2] = 0; 9943285809Sscottl pMediaSerialNumber[3] = 4; 9944285809Sscottl pMediaSerialNumber[4] = 0; 9945285809Sscottl pMediaSerialNumber[5] = 0; 9946285809Sscottl pMediaSerialNumber[6] = 0; 9947285809Sscottl pMediaSerialNumber[7] = 0; 9948285809Sscottl 9949285809Sscottl if (ZERO_MEDIA_SERIAL_NUMBER_LENGTH < lenReceived) 9950285809Sscottl { 9951285809Sscottl TI_DBG1(("satReadMediaSerialNumberCB: 1st underrun lenReceived %d len %d \n", lenReceived, ZERO_MEDIA_SERIAL_NUMBER_LENGTH)); 9952285809Sscottl 9953285809Sscottl /* underrun */ 9954285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9955285809Sscottl tiOrgIORequest, /* == satIntIo->satOrgTiIORequest */ 9956285809Sscottl tiIOUnderRun, 9957285809Sscottl lenReceived - ZERO_MEDIA_SERIAL_NUMBER_LENGTH, 9958285809Sscottl agNULL, 9959285809Sscottl satOrgIOContext->interruptContext ); 9960285809Sscottl 9961285809Sscottl } 9962285809Sscottl else 9963285809Sscottl { 9964285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9965285809Sscottl tiOrgIORequest, 9966285809Sscottl tiIOSuccess, 9967285809Sscottl SCSI_STAT_GOOD, 9968285809Sscottl agNULL, 9969285809Sscottl satOrgIOContext->interruptContext); 9970285809Sscottl } 9971285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9972285809Sscottl 9973285809Sscottl satFreeIntIoResource( tiRoot, 9974285809Sscottl satDevData, 9975285809Sscottl satIntIo); 9976285809Sscottl return; 9977285809Sscottl } 9978285809Sscottl else 9979285809Sscottl { 9980285809Sscottl TI_DBG1(("satReadMediaSerialNumberCB: error unknown command success 0x%x\n", hostToDevFis->h.command)); 9981285809Sscottl satSetSensePayload( pSense, 9982285809Sscottl SCSI_SNSKEY_NO_SENSE, 9983285809Sscottl 0, 9984285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 9985285809Sscottl satOrgIOContext); 9986285809Sscottl 9987285809Sscottl ostiInitiatorIOCompleted( tiRoot, 9988285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 9989285809Sscottl tiIOSuccess, 9990285809Sscottl SCSI_STAT_CHECK_CONDITION, 9991285809Sscottl satOrgIOContext->pTiSenseData, 9992285809Sscottl satOrgIOContext->interruptContext ); 9993285809Sscottl 9994285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 9995285809Sscottl 9996285809Sscottl satFreeIntIoResource( tiRoot, 9997285809Sscottl satDevData, 9998285809Sscottl satIntIo); 9999285809Sscottl 10000285809Sscottl return; 10001285809Sscottl } 10002285809Sscottl return; 10003285809Sscottl} 10004285809Sscottl 10005285809Sscottl/***************************************************************************** 10006285809Sscottl*! \brief satReadBufferCB 10007285809Sscottl* 10008285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 10009285809Sscottl* This CB routine deals with Read Buffer. 10010285809Sscottl* 10011285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 10012285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 10013285809Sscottl* \param agIOStatus: Status of completed I/O. 10014285809Sscottl* \param agSATAParm1: Additional info based on status. 10015285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 10016285809Sscottl* length. 10017285809Sscottl* \param ioContext: Pointer to satIOContext_t. 10018285809Sscottl* 10019285809Sscottl* \return: none 10020285809Sscottl* 10021285809Sscottl*****************************************************************************/ 10022285809Sscottlvoid satReadBufferCB( 10023285809Sscottl agsaRoot_t *agRoot, 10024285809Sscottl agsaIORequest_t *agIORequest, 10025285809Sscottl bit32 agIOStatus, 10026285809Sscottl agsaFisHeader_t *agFirstDword, 10027285809Sscottl bit32 agIOInfoLen, 10028285809Sscottl agsaFrameHandle_t agFrameHandle, 10029285809Sscottl void *ioContext 10030285809Sscottl ) 10031285809Sscottl{ 10032285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 10033285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 10034285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 10035285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 10036285809Sscottl tdIORequestBody_t *tdIORequestBody; 10037285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 10038285809Sscottl satIOContext_t *satIOContext; 10039285809Sscottl satIOContext_t *satOrgIOContext; 10040285809Sscottl satInternalIo_t *satIntIo; 10041285809Sscottl satDeviceData_t *satDevData; 10042285809Sscottl scsiRspSense_t *pSense; 10043285809Sscottl tiIORequest_t *tiOrgIORequest; 10044285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 10045285809Sscottl 10046285809Sscottl TI_DBG4(("satReadBufferCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 10047285809Sscottl 10048285809Sscottl /* internally generate tiIOContext */ 10049285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 10050285809Sscottl satIOContext = (satIOContext_t *) ioContext; 10051285809Sscottl satIntIo = satIOContext->satIntIoContext; 10052285809Sscottl satDevData = satIOContext->pSatDevData; 10053285809Sscottl hostToDevFis = satIOContext->pFis; 10054285809Sscottl 10055285809Sscottl 10056285809Sscottl if (satIntIo == agNULL) 10057285809Sscottl { 10058285809Sscottl TI_DBG4(("satReadBufferCB: External satInternalIo_t satIntIoContext\n")); 10059285809Sscottl satOrgIOContext = satIOContext; 10060285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 10061285809Sscottl pSense = satOrgIOContext->pSense; 10062285809Sscottl 10063285809Sscottl /* SCSI command response payload to OS layer */ 10064285809Sscottl 10065285809Sscottl /* ATA command response payload */ 10066285809Sscottl 10067285809Sscottl } 10068285809Sscottl else 10069285809Sscottl { 10070285809Sscottl TI_DBG4(("satReadBufferCB: Internal satInternalIo_t satIntIoContext\n")); 10071285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 10072285809Sscottl if (satOrgIOContext == agNULL) 10073285809Sscottl { 10074285809Sscottl TI_DBG4(("satReadBufferCB: satOrgIOContext is NULL, wrong\n")); 10075285809Sscottl return; 10076285809Sscottl } 10077285809Sscottl else 10078285809Sscottl { 10079285809Sscottl TI_DBG4(("satReadBufferCB: satOrgIOContext is NOT NULL\n")); 10080285809Sscottl } 10081285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 10082285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 10083285809Sscottl 10084285809Sscottl pSense = satOrgIOContext->pSense; 10085285809Sscottl 10086285809Sscottl /* SCSI command response payload to OS layer */ 10087285809Sscottl 10088285809Sscottl /* ATA command response payload */ 10089285809Sscottl 10090285809Sscottl } 10091285809Sscottl 10092285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 10093285809Sscottl tdIORequestBody->ioStarted = agFALSE; 10094285809Sscottl 10095285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 10096285809Sscottl { 10097285809Sscottl TI_DBG1(("satReadBufferCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 10098285809Sscottl ostiInitiatorIOCompleted ( 10099285809Sscottl tiRoot, 10100285809Sscottl tiOrgIORequest, 10101285809Sscottl tiIOFailed, 10102285809Sscottl tiDetailOtherError, 10103285809Sscottl agNULL, 10104285809Sscottl satOrgIOContext->interruptContext 10105285809Sscottl ); 10106285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10107285809Sscottl 10108285809Sscottl satFreeIntIoResource( tiRoot, 10109285809Sscottl satDevData, 10110285809Sscottl satIntIo); 10111285809Sscottl return; 10112285809Sscottl } 10113285809Sscottl 10114285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 10115285809Sscottl { 10116285809Sscottl /* Process abort case */ 10117285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 10118285809Sscottl { 10119285809Sscottl satProcessAbort(tiRoot, 10120285809Sscottl tiOrgIORequest, 10121285809Sscottl satOrgIOContext 10122285809Sscottl ); 10123285809Sscottl 10124285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10125285809Sscottl 10126285809Sscottl satFreeIntIoResource( tiRoot, 10127285809Sscottl satDevData, 10128285809Sscottl satIntIo); 10129285809Sscottl return; 10130285809Sscottl } 10131285809Sscottl satSetSensePayload( pSense, 10132285809Sscottl SCSI_SNSKEY_NOT_READY, 10133285809Sscottl 0, 10134285809Sscottl SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 10135285809Sscottl satOrgIOContext); 10136285809Sscottl 10137285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10138285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10139285809Sscottl tiIOSuccess, 10140285809Sscottl SCSI_STAT_CHECK_CONDITION, 10141285809Sscottl satOrgIOContext->pTiSenseData, 10142285809Sscottl satOrgIOContext->interruptContext ); 10143285809Sscottl 10144285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10145285809Sscottl 10146285809Sscottl satFreeIntIoResource( tiRoot, 10147285809Sscottl satDevData, 10148285809Sscottl satIntIo); 10149285809Sscottl return; 10150285809Sscottl } 10151285809Sscottl 10152285809Sscottl /* process success case */ 10153285809Sscottl if (hostToDevFis->h.command == SAT_READ_BUFFER ) 10154285809Sscottl { 10155285809Sscottl 10156285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10157285809Sscottl tiOrgIORequest, 10158285809Sscottl tiIOSuccess, 10159285809Sscottl SCSI_STAT_GOOD, 10160285809Sscottl agNULL, 10161285809Sscottl satOrgIOContext->interruptContext); 10162285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10163285809Sscottl 10164285809Sscottl satFreeIntIoResource( tiRoot, 10165285809Sscottl satDevData, 10166285809Sscottl satIntIo); 10167285809Sscottl return; 10168285809Sscottl } 10169285809Sscottl else 10170285809Sscottl { 10171285809Sscottl TI_DBG1(("satReadBufferCB: error unknown command success 0x%x\n", hostToDevFis->h.command)); 10172285809Sscottl satSetSensePayload( pSense, 10173285809Sscottl SCSI_SNSKEY_NO_SENSE, 10174285809Sscottl 0, 10175285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 10176285809Sscottl satOrgIOContext); 10177285809Sscottl 10178285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10179285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10180285809Sscottl tiIOSuccess, 10181285809Sscottl SCSI_STAT_CHECK_CONDITION, 10182285809Sscottl satOrgIOContext->pTiSenseData, 10183285809Sscottl satOrgIOContext->interruptContext ); 10184285809Sscottl 10185285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10186285809Sscottl 10187285809Sscottl satFreeIntIoResource( tiRoot, 10188285809Sscottl satDevData, 10189285809Sscottl satIntIo); 10190285809Sscottl 10191285809Sscottl return; 10192285809Sscottl } 10193285809Sscottl 10194285809Sscottl return; 10195285809Sscottl} 10196285809Sscottl 10197285809Sscottl/***************************************************************************** 10198285809Sscottl*! \brief satWriteBufferCB 10199285809Sscottl* 10200285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 10201285809Sscottl* This CB routine deals with Write Buffer. 10202285809Sscottl* 10203285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 10204285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 10205285809Sscottl* \param agIOStatus: Status of completed I/O. 10206285809Sscottl* \param agSATAParm1: Additional info based on status. 10207285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 10208285809Sscottl* length. 10209285809Sscottl* \param ioContext: Pointer to satIOContext_t. 10210285809Sscottl* 10211285809Sscottl* \return: none 10212285809Sscottl* 10213285809Sscottl*****************************************************************************/ 10214285809Sscottlvoid satWriteBufferCB( 10215285809Sscottl agsaRoot_t *agRoot, 10216285809Sscottl agsaIORequest_t *agIORequest, 10217285809Sscottl bit32 agIOStatus, 10218285809Sscottl agsaFisHeader_t *agFirstDword, 10219285809Sscottl bit32 agIOInfoLen, 10220285809Sscottl agsaFrameHandle_t agFrameHandle, 10221285809Sscottl void *ioContext 10222285809Sscottl ) 10223285809Sscottl{ 10224285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 10225285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 10226285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 10227285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 10228285809Sscottl tdIORequestBody_t *tdIORequestBody; 10229285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 10230285809Sscottl satIOContext_t *satIOContext; 10231285809Sscottl satIOContext_t *satOrgIOContext; 10232285809Sscottl satInternalIo_t *satIntIo; 10233285809Sscottl satDeviceData_t *satDevData; 10234285809Sscottl scsiRspSense_t *pSense; 10235285809Sscottl tiIORequest_t *tiOrgIORequest; 10236285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 10237285809Sscottl 10238285809Sscottl TI_DBG4(("satWriteBufferCB:agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 10239285809Sscottl 10240285809Sscottl /* internally generate tiIOContext */ 10241285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 10242285809Sscottl satIOContext = (satIOContext_t *) ioContext; 10243285809Sscottl satIntIo = satIOContext->satIntIoContext; 10244285809Sscottl satDevData = satIOContext->pSatDevData; 10245285809Sscottl hostToDevFis = satIOContext->pFis; 10246285809Sscottl 10247285809Sscottl 10248285809Sscottl if (satIntIo == agNULL) 10249285809Sscottl { 10250285809Sscottl TI_DBG4(("satWriteBufferCB: External satInternalIo_t satIntIoContext\n")); 10251285809Sscottl satOrgIOContext = satIOContext; 10252285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 10253285809Sscottl pSense = satOrgIOContext->pSense; 10254285809Sscottl /* SCSI command response payload to OS layer */ 10255285809Sscottl 10256285809Sscottl /* ATA command response payload */ 10257285809Sscottl 10258285809Sscottl } 10259285809Sscottl else 10260285809Sscottl { 10261285809Sscottl TI_DBG4(("satWriteBufferCB: Internal satInternalIo_t satIntIoContext\n")); 10262285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 10263285809Sscottl if (satOrgIOContext == agNULL) 10264285809Sscottl { 10265285809Sscottl TI_DBG4(("satWriteBufferCB: satOrgIOContext is NULL, wrong\n")); 10266285809Sscottl return; 10267285809Sscottl } 10268285809Sscottl else 10269285809Sscottl { 10270285809Sscottl TI_DBG4(("satWriteBufferCB: satOrgIOContext is NOT NULL\n")); 10271285809Sscottl } 10272285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 10273285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 10274285809Sscottl 10275285809Sscottl pSense = satOrgIOContext->pSense; 10276285809Sscottl /* SCSI command response payload to OS layer */ 10277285809Sscottl 10278285809Sscottl /* ATA command response payload */ 10279285809Sscottl 10280285809Sscottl } 10281285809Sscottl 10282285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 10283285809Sscottl tdIORequestBody->ioStarted = agFALSE; 10284285809Sscottl 10285285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 10286285809Sscottl { 10287285809Sscottl TI_DBG1(("satWriteBufferCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 10288285809Sscottl ostiInitiatorIOCompleted ( 10289285809Sscottl tiRoot, 10290285809Sscottl tiOrgIORequest, 10291285809Sscottl tiIOFailed, 10292285809Sscottl tiDetailOtherError, 10293285809Sscottl agNULL, 10294285809Sscottl satOrgIOContext->interruptContext 10295285809Sscottl ); 10296285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10297285809Sscottl 10298285809Sscottl satFreeIntIoResource( tiRoot, 10299285809Sscottl satDevData, 10300285809Sscottl satIntIo); 10301285809Sscottl return; 10302285809Sscottl } 10303285809Sscottl 10304285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 10305285809Sscottl { 10306285809Sscottl /* Process abort case */ 10307285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 10308285809Sscottl { 10309285809Sscottl satProcessAbort(tiRoot, 10310285809Sscottl tiOrgIORequest, 10311285809Sscottl satOrgIOContext 10312285809Sscottl ); 10313285809Sscottl 10314285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10315285809Sscottl 10316285809Sscottl satFreeIntIoResource( tiRoot, 10317285809Sscottl satDevData, 10318285809Sscottl satIntIo); 10319285809Sscottl return; 10320285809Sscottl } 10321285809Sscottl satSetSensePayload( pSense, 10322285809Sscottl SCSI_SNSKEY_NOT_READY, 10323285809Sscottl 0, 10324285809Sscottl SCSI_SNSCODE_MEDIUM_NOT_PRESENT, 10325285809Sscottl satOrgIOContext); 10326285809Sscottl 10327285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10328285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10329285809Sscottl tiIOSuccess, 10330285809Sscottl SCSI_STAT_CHECK_CONDITION, 10331285809Sscottl satOrgIOContext->pTiSenseData, 10332285809Sscottl satOrgIOContext->interruptContext ); 10333285809Sscottl 10334285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10335285809Sscottl 10336285809Sscottl satFreeIntIoResource( tiRoot, 10337285809Sscottl satDevData, 10338285809Sscottl satIntIo); 10339285809Sscottl return; 10340285809Sscottl } 10341285809Sscottl /* process success case */ 10342285809Sscottl if (hostToDevFis->h.command == SAT_WRITE_BUFFER ) 10343285809Sscottl { 10344285809Sscottl 10345285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10346285809Sscottl tiOrgIORequest, 10347285809Sscottl tiIOSuccess, 10348285809Sscottl SCSI_STAT_GOOD, 10349285809Sscottl agNULL, 10350285809Sscottl satOrgIOContext->interruptContext); 10351285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10352285809Sscottl 10353285809Sscottl satFreeIntIoResource( tiRoot, 10354285809Sscottl satDevData, 10355285809Sscottl satIntIo); 10356285809Sscottl return; 10357285809Sscottl } 10358285809Sscottl else 10359285809Sscottl { 10360285809Sscottl TI_DBG1(("satWriteBufferCB: error unknown command success 0x%x\n", hostToDevFis->h.command)); 10361285809Sscottl satSetSensePayload( pSense, 10362285809Sscottl SCSI_SNSKEY_NO_SENSE, 10363285809Sscottl 0, 10364285809Sscottl SCSI_SNSCODE_NO_ADDITIONAL_INFO, 10365285809Sscottl satOrgIOContext); 10366285809Sscottl 10367285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10368285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10369285809Sscottl tiIOSuccess, 10370285809Sscottl SCSI_STAT_CHECK_CONDITION, 10371285809Sscottl satOrgIOContext->pTiSenseData, 10372285809Sscottl satOrgIOContext->interruptContext ); 10373285809Sscottl 10374285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10375285809Sscottl 10376285809Sscottl satFreeIntIoResource( tiRoot, 10377285809Sscottl satDevData, 10378285809Sscottl satIntIo); 10379285809Sscottl 10380285809Sscottl return; 10381285809Sscottl } 10382285809Sscottl 10383285809Sscottl return; 10384285809Sscottl} 10385285809Sscottl 10386285809Sscottl/***************************************************************************** 10387285809Sscottl*! \brief satReassignBlocksCB 10388285809Sscottl* 10389285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 10390285809Sscottl* This CB routine deals with Reassign Blocks. 10391285809Sscottl* 10392285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 10393285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 10394285809Sscottl* \param agIOStatus: Status of completed I/O. 10395285809Sscottl* \param agSATAParm1: Additional info based on status. 10396285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 10397285809Sscottl* length. 10398285809Sscottl* \param ioContext: Pointer to satIOContext_t. 10399285809Sscottl* 10400285809Sscottl* \return: none 10401285809Sscottl* 10402285809Sscottl*****************************************************************************/ 10403285809Sscottlvoid satReassignBlocksCB( 10404285809Sscottl agsaRoot_t *agRoot, 10405285809Sscottl agsaIORequest_t *agIORequest, 10406285809Sscottl bit32 agIOStatus, 10407285809Sscottl agsaFisHeader_t *agFirstDword, 10408285809Sscottl bit32 agIOInfoLen, 10409285809Sscottl agsaFrameHandle_t agFrameHandle, 10410285809Sscottl void *ioContext 10411285809Sscottl ) 10412285809Sscottl{ 10413285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 10414285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 10415285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 10416285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 10417285809Sscottl tdIORequestBody_t *tdIORequestBody; 10418285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 10419285809Sscottl satIOContext_t *satIOContext; 10420285809Sscottl satIOContext_t *satOrgIOContext; 10421285809Sscottl satIOContext_t *satNewIOContext; 10422285809Sscottl satInternalIo_t *satIntIo; 10423285809Sscottl satInternalIo_t *satNewIntIo = agNULL; 10424285809Sscottl satDeviceData_t *satDevData; 10425285809Sscottl 10426285809Sscottl scsiRspSense_t *pSense; 10427285809Sscottl tiIniScsiCmnd_t *scsiCmnd; 10428285809Sscottl tiIORequest_t *tiOrgIORequest; 10429285809Sscottl 10430285809Sscottl agsaFisRegHostToDevice_t *hostToDevFis = agNULL; 10431285809Sscottl bit32 ataStatus = 0; 10432285809Sscottl bit32 status; 10433285809Sscottl tiScsiInitiatorRequest_t *tiScsiRequest; /* tiScsiXchg */ 10434285809Sscottl agsaFisRegD2HHeader_t *statDevToHostFisHeader = agNULL; 10435285809Sscottl 10436285809Sscottl TI_DBG5(("satReassignBlocksCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", agIORequest, agIOStatus, agIOInfoLen)); 10437285809Sscottl 10438285809Sscottl /* internally generate tiIOContext */ 10439285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 10440285809Sscottl satIOContext = (satIOContext_t *) ioContext; 10441285809Sscottl satIntIo = satIOContext->satIntIoContext; 10442285809Sscottl satDevData = satIOContext->pSatDevData; 10443285809Sscottl hostToDevFis = satIOContext->pFis; 10444285809Sscottl 10445285809Sscottl if (satIntIo == agNULL) 10446285809Sscottl { 10447285809Sscottl TI_DBG4(("satReassignBlocksCB: External satInternalIo_t satIntIoContext\n")); 10448285809Sscottl satOrgIOContext = satIOContext; 10449285809Sscottl tiOrgIORequest = tdIORequestBody->tiIORequest; 10450285809Sscottl tiScsiRequest = satOrgIOContext->tiScsiXchg; 10451285809Sscottl pSense = satOrgIOContext->pSense; 10452285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 10453285809Sscottl } 10454285809Sscottl else 10455285809Sscottl { 10456285809Sscottl TI_DBG4(("satReassignBlocksCB: Internal satInternalIo_t satIntIoContext\n")); 10457285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 10458285809Sscottl if (satOrgIOContext == agNULL) 10459285809Sscottl { 10460285809Sscottl TI_DBG4(("satReassignBlocksCB: satOrgIOContext is NULL, Wrong\n")); 10461285809Sscottl return; 10462285809Sscottl } 10463285809Sscottl else 10464285809Sscottl { 10465285809Sscottl TI_DBG4(("satReassignBlocksCB: satOrgIOContext is NOT NULL, Wrong\n")); 10466285809Sscottl } 10467285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 10468285809Sscottl tiOrgIORequest = (tiIORequest_t *)tdOrgIORequestBody->tiIORequest; 10469285809Sscottl 10470285809Sscottl tiScsiRequest = satOrgIOContext->tiScsiXchg; 10471285809Sscottl pSense = satOrgIOContext->pSense; 10472285809Sscottl scsiCmnd = satOrgIOContext->pScsiCmnd; 10473285809Sscottl } 10474285809Sscottl 10475285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 10476285809Sscottl tdIORequestBody->ioStarted = agFALSE; 10477285809Sscottl 10478285809Sscottl if (agFirstDword == agNULL && agIOStatus != OSSA_IO_SUCCESS) 10479285809Sscottl { 10480285809Sscottl TI_DBG1(("satReassignBlocksCB: wrong. agFirstDword is NULL when error, status %d\n", agIOStatus)); 10481285809Sscottl ostiInitiatorIOCompleted ( 10482285809Sscottl tiRoot, 10483285809Sscottl tiOrgIORequest, 10484285809Sscottl tiIOFailed, 10485285809Sscottl tiDetailOtherError, 10486285809Sscottl agNULL, 10487285809Sscottl satOrgIOContext->interruptContext 10488285809Sscottl ); 10489285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10490285809Sscottl 10491285809Sscottl satFreeIntIoResource( tiRoot, 10492285809Sscottl satDevData, 10493285809Sscottl satIntIo); 10494285809Sscottl return; 10495285809Sscottl } 10496285809Sscottl 10497285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 10498285809Sscottl { 10499285809Sscottl /* only agsaFisRegDeviceToHost_t is expected */ 10500285809Sscottl statDevToHostFisHeader = (agsaFisRegD2HHeader_t *)&(agFirstDword->D2H); 10501285809Sscottl ataStatus = statDevToHostFisHeader->status; /* ATA Status register */ 10502285809Sscottl } 10503285809Sscottl 10504285809Sscottl if (agIOStatus != OSSA_IO_SUCCESS) 10505285809Sscottl { 10506285809Sscottl if ( (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) || 10507285809Sscottl ((ataStatus & ERR_ATA_STATUS_MASK) || (ataStatus & DF_ATA_STATUS_MASK)) 10508285809Sscottl ) 10509285809Sscottl { 10510285809Sscottl /* for debugging */ 10511285809Sscottl if( agIOStatus != OSSA_IO_SUCCESS) 10512285809Sscottl { 10513285809Sscottl TI_DBG1(("satReassignBlocksCB FAILED, NOT IO_SUCCESS\n")); 10514285809Sscottl } 10515285809Sscottl else if (statDevToHostFisHeader->fisType != REG_DEV_TO_HOST_FIS) 10516285809Sscottl { 10517285809Sscottl TI_DBG1(("satReassignBlocksCB FAILED, Wrong FIS type 0x%x\n",statDevToHostFisHeader->fisType)); 10518285809Sscottl } 10519285809Sscottl else if ( (ataStatus & ERR_ATA_STATUS_MASK) || 10520285809Sscottl (ataStatus & DF_ATA_STATUS_MASK) 10521285809Sscottl ) 10522285809Sscottl { 10523285809Sscottl TI_DBG1(("satReassignBlocksCB FAILED, FAILED, error status\n")); 10524285809Sscottl } 10525285809Sscottl 10526285809Sscottl /* Process abort case */ 10527285809Sscottl if (agIOStatus == OSSA_IO_ABORTED) 10528285809Sscottl { 10529285809Sscottl satProcessAbort(tiRoot, 10530285809Sscottl tiOrgIORequest, 10531285809Sscottl satOrgIOContext 10532285809Sscottl ); 10533285809Sscottl 10534285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10535285809Sscottl 10536285809Sscottl satFreeIntIoResource( tiRoot, 10537285809Sscottl satDevData, 10538285809Sscottl satIntIo); 10539285809Sscottl return; 10540285809Sscottl } 10541285809Sscottl 10542285809Sscottl /* for debugging */ 10543285809Sscottl if (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS || 10544285809Sscottl hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT 10545285809Sscottl ) 10546285809Sscottl { 10547285809Sscottl TI_DBG1(("satReassignBlocksCB SAT_READ_VERIFY_SECTORS(_EXT) failed\n")); 10548285809Sscottl /* Verify failed; send Write with same LBA */ 10549285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10550285809Sscottl 10551285809Sscottl satFreeIntIoResource( tiRoot, 10552285809Sscottl satDevData, 10553285809Sscottl satIntIo); 10554285809Sscottl 10555285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 10556285809Sscottl tiOrgIORequest, 10557285809Sscottl satDevData, 10558285809Sscottl 512, /* writing 1 sector */ 10559285809Sscottl satNewIntIo); 10560285809Sscottl if (satNewIntIo == agNULL) 10561285809Sscottl { 10562285809Sscottl /* memory allocation failure */ 10563285809Sscottl satFreeIntIoResource( tiRoot, 10564285809Sscottl satDevData, 10565285809Sscottl satNewIntIo); 10566285809Sscottl 10567285809Sscottl satSetSensePayload( pSense, 10568285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 10569285809Sscottl 0, 10570285809Sscottl SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 10571285809Sscottl satOrgIOContext); 10572285809Sscottl 10573285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10574285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10575285809Sscottl tiIOSuccess, 10576285809Sscottl SCSI_STAT_CHECK_CONDITION, 10577285809Sscottl satOrgIOContext->pTiSenseData, 10578285809Sscottl satOrgIOContext->interruptContext ); 10579285809Sscottl TI_DBG1(("satReassignBlocksCB: momory allocation fails\n")); 10580285809Sscottl return; 10581285809Sscottl } /* end memory allocation */ 10582285809Sscottl 10583285809Sscottl satNewIOContext = satPrepareNewIO( 10584285809Sscottl satNewIntIo, 10585285809Sscottl tiOrgIORequest, 10586285809Sscottl satDevData, 10587285809Sscottl scsiCmnd, 10588285809Sscottl satOrgIOContext 10589285809Sscottl ); 10590285809Sscottl 10591285809Sscottl /* send Write with same LBA */ 10592285809Sscottl status = satReassignBlocks_2( 10593285809Sscottl tiRoot, 10594285809Sscottl &satNewIntIo->satIntTiIORequest, 10595285809Sscottl satNewIOContext->ptiDeviceHandle, 10596285809Sscottl &satNewIntIo->satIntTiScsiXchg, 10597285809Sscottl satNewIOContext, 10598285809Sscottl satOrgIOContext->LBA 10599285809Sscottl ); 10600285809Sscottl 10601285809Sscottl if (status != tiSuccess) 10602285809Sscottl { 10603285809Sscottl /* sending ATA command fails */ 10604285809Sscottl satFreeIntIoResource( tiRoot, 10605285809Sscottl satDevData, 10606285809Sscottl satNewIntIo); 10607285809Sscottl satSetSensePayload( pSense, 10608285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 10609285809Sscottl 0, 10610285809Sscottl SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 10611285809Sscottl satOrgIOContext); 10612285809Sscottl 10613285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10614285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10615285809Sscottl tiIOSuccess, 10616285809Sscottl SCSI_STAT_CHECK_CONDITION, 10617285809Sscottl satOrgIOContext->pTiSenseData, 10618285809Sscottl satOrgIOContext->interruptContext ); 10619285809Sscottl TI_DBG1(("satReassignBlocksCB calling fail 1\n")); 10620285809Sscottl return; 10621285809Sscottl } /* end send fails */ 10622285809Sscottl 10623285809Sscottl return; 10624285809Sscottl } 10625285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_DMA || 10626285809Sscottl hostToDevFis->h.command == SAT_WRITE_SECTORS || 10627285809Sscottl hostToDevFis->h.command == SAT_WRITE_DMA_EXT || 10628285809Sscottl hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT || 10629285809Sscottl hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED 10630285809Sscottl ) 10631285809Sscottl { 10632285809Sscottl TI_DBG1(("satReassignBlocksCB SAT_WRITE failed\n")); 10633285809Sscottl /* fall through */ 10634285809Sscottl } 10635285809Sscottl else 10636285809Sscottl { 10637285809Sscottl TI_DBG1(("satReassignBlocksCB error default case unexpected command 0x%x\n", hostToDevFis->h.command)); 10638285809Sscottl } 10639285809Sscottl 10640285809Sscottl 10641285809Sscottl satSetSensePayload( pSense, 10642285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 10643285809Sscottl 0, 10644285809Sscottl SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 10645285809Sscottl satOrgIOContext); 10646285809Sscottl 10647285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10648285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10649285809Sscottl tiIOSuccess, 10650285809Sscottl SCSI_STAT_CHECK_CONDITION, 10651285809Sscottl satOrgIOContext->pTiSenseData, 10652285809Sscottl satOrgIOContext->interruptContext ); 10653285809Sscottl 10654285809Sscottl 10655285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10656285809Sscottl 10657285809Sscottl satFreeIntIoResource( tiRoot, 10658285809Sscottl satDevData, 10659285809Sscottl satIntIo); 10660285809Sscottl return; 10661285809Sscottl } /* error checking */ 10662285809Sscottl } 10663285809Sscottl 10664285809Sscottl 10665285809Sscottl /* prcessing the success case */ 10666285809Sscottl if (hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS || 10667285809Sscottl hostToDevFis->h.command == SAT_READ_VERIFY_SECTORS_EXT || 10668285809Sscottl hostToDevFis->h.command == SAT_WRITE_DMA || 10669285809Sscottl hostToDevFis->h.command == SAT_WRITE_SECTORS || 10670285809Sscottl hostToDevFis->h.command == SAT_WRITE_DMA_EXT || 10671285809Sscottl hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT || 10672285809Sscottl hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED 10673285809Sscottl ) 10674285809Sscottl { 10675285809Sscottl /* next LBA; verify */ 10676285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10677285809Sscottl 10678285809Sscottl satFreeIntIoResource( tiRoot, 10679285809Sscottl satDevData, 10680285809Sscottl satIntIo); 10681285809Sscottl 10682285809Sscottl if (satOrgIOContext->ParmIndex >= satOrgIOContext->ParmLen) 10683285809Sscottl { 10684285809Sscottl TI_DBG5(("satReassignBlocksCB: GOOD status\n")); 10685285809Sscottl /* return stat_good */ 10686285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10687285809Sscottl tiOrgIORequest, 10688285809Sscottl tiIOSuccess, 10689285809Sscottl SCSI_STAT_GOOD, 10690285809Sscottl agNULL, 10691285809Sscottl satOrgIOContext->interruptContext ); 10692285809Sscottl return; 10693285809Sscottl } 10694285809Sscottl else 10695285809Sscottl { 10696285809Sscottl TI_DBG5(("satReassignBlocksCB: processing next LBA\n")); 10697285809Sscottl satNewIntIo = satAllocIntIoResource( tiRoot, 10698285809Sscottl tiOrgIORequest, 10699285809Sscottl satDevData, 10700285809Sscottl 0, 10701285809Sscottl satNewIntIo); 10702285809Sscottl if (satNewIntIo == agNULL) 10703285809Sscottl { 10704285809Sscottl /* memory allocation failure */ 10705285809Sscottl satFreeIntIoResource( tiRoot, 10706285809Sscottl satDevData, 10707285809Sscottl satNewIntIo); 10708285809Sscottl 10709285809Sscottl satSetSensePayload( pSense, 10710285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 10711285809Sscottl 0, 10712285809Sscottl SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 10713285809Sscottl satOrgIOContext); 10714285809Sscottl 10715285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10716285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10717285809Sscottl tiIOSuccess, 10718285809Sscottl SCSI_STAT_CHECK_CONDITION, 10719285809Sscottl satOrgIOContext->pTiSenseData, 10720285809Sscottl satOrgIOContext->interruptContext ); 10721285809Sscottl TI_DBG1(("satReassignBlocksCB: momory allocation fails\n")); 10722285809Sscottl return; 10723285809Sscottl } /* end memory allocation */ 10724285809Sscottl 10725285809Sscottl satNewIOContext = satPrepareNewIO( 10726285809Sscottl satNewIntIo, 10727285809Sscottl tiOrgIORequest, 10728285809Sscottl satDevData, 10729285809Sscottl scsiCmnd, 10730285809Sscottl satOrgIOContext 10731285809Sscottl ); 10732285809Sscottl 10733285809Sscottl /* send Verify with the next LBA */ 10734285809Sscottl status = satReassignBlocks_1( 10735285809Sscottl tiRoot, 10736285809Sscottl &satNewIntIo->satIntTiIORequest, 10737285809Sscottl satNewIOContext->ptiDeviceHandle, 10738285809Sscottl tiScsiRequest, /* orginal from OS layer */ 10739285809Sscottl satNewIOContext, 10740285809Sscottl satOrgIOContext 10741285809Sscottl ); 10742285809Sscottl 10743285809Sscottl if (status != tiSuccess) 10744285809Sscottl { 10745285809Sscottl /* sending ATA command fails */ 10746285809Sscottl satFreeIntIoResource( tiRoot, 10747285809Sscottl satDevData, 10748285809Sscottl satNewIntIo); 10749285809Sscottl satSetSensePayload( pSense, 10750285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 10751285809Sscottl 0, 10752285809Sscottl SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 10753285809Sscottl satOrgIOContext); 10754285809Sscottl 10755285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10756285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10757285809Sscottl tiIOSuccess, 10758285809Sscottl SCSI_STAT_CHECK_CONDITION, 10759285809Sscottl satOrgIOContext->pTiSenseData, 10760285809Sscottl satOrgIOContext->interruptContext ); 10761285809Sscottl TI_DBG1(("satReassignBlocksCB calling satModeSelect6_1 fails\n")); 10762285809Sscottl return; 10763285809Sscottl } /* end send fails */ 10764285809Sscottl } /* else */ 10765285809Sscottl return; 10766285809Sscottl 10767285809Sscottl } 10768285809Sscottl else if (hostToDevFis->h.command == SAT_WRITE_DMA || 10769285809Sscottl hostToDevFis->h.command == SAT_WRITE_SECTORS || 10770285809Sscottl hostToDevFis->h.command == SAT_WRITE_DMA_EXT || 10771285809Sscottl hostToDevFis->h.command == SAT_WRITE_SECTORS_EXT || 10772285809Sscottl hostToDevFis->h.command == SAT_WRITE_FPDMA_QUEUED 10773285809Sscottl ) 10774285809Sscottl { 10775285809Sscottl /* next LBA; verify */ 10776285809Sscottl } 10777285809Sscottl else 10778285809Sscottl { 10779285809Sscottl TI_DBG1(("satReassignBlocksCB error unknown command success 0x%x \n", hostToDevFis->h.command)); 10780285809Sscottl 10781285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 10782285809Sscottl 10783285809Sscottl satFreeIntIoResource( tiRoot, 10784285809Sscottl satDevData, 10785285809Sscottl satIntIo); 10786285809Sscottl satSetSensePayload( pSense, 10787285809Sscottl SCSI_SNSKEY_HARDWARE_ERROR, 10788285809Sscottl 0, 10789285809Sscottl SCSI_SNSCODE_WRITE_ERROR_AUTO_REALLOCATION_FAILED, 10790285809Sscottl satOrgIOContext); 10791285809Sscottl 10792285809Sscottl ostiInitiatorIOCompleted( tiRoot, 10793285809Sscottl tiOrgIORequest, /* == &satIntIo->satOrgTiIORequest */ 10794285809Sscottl tiIOSuccess, 10795285809Sscottl SCSI_STAT_CHECK_CONDITION, 10796285809Sscottl satOrgIOContext->pTiSenseData, 10797285809Sscottl satOrgIOContext->interruptContext ); 10798285809Sscottl return; 10799285809Sscottl } 10800285809Sscottl return; 10801285809Sscottl} 10802285809Sscottl/***************************************************************************** 10803285809Sscottl*! \brief satReadLogExtCB 10804285809Sscottl* 10805285809Sscottl* This routine is a callback function called from ossaSATACompleted(). 10806285809Sscottl* This CB routine deals READ LOG EXT completion. 10807285809Sscottl* 10808285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 10809285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 10810285809Sscottl* \param agIOStatus: Status of completed I/O. 10811285809Sscottl* \param agFirstDword:Pointer to the four bytes of FIS. 10812285809Sscottl* \param agIOInfoLen: Length in bytes of overrun/underrun residual or FIS 10813285809Sscottl* length. 10814285809Sscottl* \param agParam: Additional info based on status. 10815285809Sscottl* \param ioContext: Pointer to satIOContext_t. 10816285809Sscottl* 10817285809Sscottl* \return: none 10818285809Sscottl* 10819285809Sscottl*****************************************************************************/ 10820285809Sscottl/* 10821285809Sscottl SATAII spec p42 10822285809Sscottl 10823285809Sscottl*/ 10824285809Sscottlvoid satReadLogExtCB( 10825285809Sscottl agsaRoot_t *agRoot, 10826285809Sscottl agsaIORequest_t *agIORequest, 10827285809Sscottl bit32 agIOStatus, 10828285809Sscottl agsaFisHeader_t *agFirstDword, 10829285809Sscottl bit32 agIOInfoLen, 10830285809Sscottl void *agParam, 10831285809Sscottl void *ioContext 10832285809Sscottl ) 10833285809Sscottl 10834285809Sscottl{ 10835285809Sscottl 10836285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 10837285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 10838285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 10839285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 10840285809Sscottl tdIORequestBody_t *tdIORequestBody; 10841285809Sscottl satIOContext_t *satReadLogExtIOContext; 10842285809Sscottl satInternalIo_t *satIntIo; 10843285809Sscottl satDeviceData_t *satDevData; 10844285809Sscottl tdsaDeviceData_t *tdsaDeviceData; 10845285809Sscottl agsaIORequest_t *agAbortIORequest; 10846285809Sscottl tdIORequestBody_t *tdAbortIORequestBody; 10847285809Sscottl bit32 PhysUpper32; 10848285809Sscottl bit32 PhysLower32; 10849285809Sscottl bit32 memAllocStatus; 10850285809Sscottl void *osMemHandle; 10851285809Sscottl 10852285809Sscottl TI_DBG1(("satReadLogExtCB: agIORequest=%p agIOStatus=0x%x agIOInfoLen %d\n", 10853285809Sscottl agIORequest, agIOStatus, agIOInfoLen)); 10854285809Sscottl 10855285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 10856285809Sscottl satReadLogExtIOContext = (satIOContext_t *) ioContext; 10857285809Sscottl satIntIo = satReadLogExtIOContext->satIntIoContext; 10858285809Sscottl satDevData = satReadLogExtIOContext->pSatDevData; 10859285809Sscottl tdsaDeviceData = (tdsaDeviceData_t *)satDevData->satSaDeviceData; 10860285809Sscottl 10861285809Sscottl TI_DBG1(("satReadLogExtCB: did %d\n", tdsaDeviceData->id)); 10862285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satReadLogExtIOContext); 10863285809Sscottl 10864285809Sscottl 10865285809Sscottl tdIORequestBody->ioCompleted = agTRUE; 10866285809Sscottl tdIORequestBody->ioStarted = agFALSE; 10867285809Sscottl 10868285809Sscottl /* 10869285809Sscottl * If READ LOG EXT failed, we issue device reset. 10870285809Sscottl */ 10871285809Sscottl if ( agIOStatus != OSSA_IO_SUCCESS || 10872285809Sscottl (agIOStatus == OSSA_IO_SUCCESS && agFirstDword != agNULL && agIOInfoLen != 0) 10873285809Sscottl ) 10874285809Sscottl { 10875285809Sscottl TI_DBG1(("satReadLogExtCB: FAILED.\n")); 10876285809Sscottl 10877285809Sscottl satFreeIntIoResource( tiRoot, 10878285809Sscottl satDevData, 10879285809Sscottl satIntIo); 10880285809Sscottl /* Abort I/O after completion of device reset */ 10881285809Sscottl satDevData->satAbortAfterReset = agTRUE; 10882285809Sscottl#ifdef NOT_YET 10883285809Sscottl /* needs to investigate this case */ 10884285809Sscottl /* no report to OS layer */ 10885285809Sscottl satSubTM(tiRoot, 10886285809Sscottl satReadLogExtIOContext->ptiDeviceHandle, 10887285809Sscottl TD_INTERNAL_TM_RESET, 10888285809Sscottl agNULL, 10889285809Sscottl agNULL, 10890285809Sscottl agNULL, 10891285809Sscottl agFALSE); 10892285809Sscottl#endif 10893285809Sscottl return; 10894285809Sscottl } 10895285809Sscottl 10896285809Sscottl 10897285809Sscottl /*************************************************************************** 10898285809Sscottl * The following steps take place when READ LOG EXT successfully completed. 10899285809Sscottl ***************************************************************************/ 10900285809Sscottl 10901285809Sscottl /************************************************************************ 10902285809Sscottl * 10903285809Sscottl * 1. Issue abort to LL layer to all other pending I/Os for the same SATA 10904285809Sscottl * drive. 10905285809Sscottl * 10906285809Sscottl * 2. Free resource allocated for the internally generated READ LOG EXT. 10907285809Sscottl * 10908285809Sscottl * 3. At the completion of abort, in the context of ossaSATACompleted(), 10909285809Sscottl * return the I/O with error status to the OS-App Specific layer. 10910285809Sscottl * When all I/O aborts are completed, clear SATA device flag to 10911285809Sscottl * indicate ready to process new request. 10912285809Sscottl * 10913285809Sscottl ***********************************************************************/ 10914285809Sscottl 10915285809Sscottl /* 10916285809Sscottl * Issue abort to LL layer to all other pending I/Os for the same SATA drive 10917285809Sscottl */ 10918285809Sscottl /* 10919285809Sscottl replace the single IO abort with device abort 10920285809Sscottl */ 10921285809Sscottl 10922285809Sscottl TI_DBG1(("satReadLogExtCB: issuing saSATAAbort. Device Abort\n")); 10923285809Sscottl /* do not deregister this device */ 10924285809Sscottl tdsaDeviceData->OSAbortAll = agTRUE; 10925285809Sscottl 10926285809Sscottl /* allocating agIORequest for abort itself */ 10927285809Sscottl memAllocStatus = ostiAllocMemory( 10928285809Sscottl tiRoot, 10929285809Sscottl &osMemHandle, 10930285809Sscottl (void **)&tdAbortIORequestBody, 10931285809Sscottl &PhysUpper32, 10932285809Sscottl &PhysLower32, 10933285809Sscottl 8, 10934285809Sscottl sizeof(tdIORequestBody_t), 10935285809Sscottl agTRUE 10936285809Sscottl ); 10937285809Sscottl 10938285809Sscottl if (memAllocStatus != tiSuccess) 10939285809Sscottl { 10940285809Sscottl /* let os process IO */ 10941285809Sscottl TI_DBG1(("satReadLogExtCB: ostiAllocMemory failed...\n")); 10942285809Sscottl return; 10943285809Sscottl } 10944285809Sscottl 10945285809Sscottl if (tdAbortIORequestBody == agNULL) 10946285809Sscottl { 10947285809Sscottl /* let os process IO */ 10948285809Sscottl TI_DBG1(("satReadLogExtCB: ostiAllocMemory returned NULL tdAbortIORequestBody\n")); 10949285809Sscottl return; 10950285809Sscottl } 10951285809Sscottl 10952285809Sscottl /* setup task management structure */ 10953285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle; 10954285809Sscottl tdAbortIORequestBody->tiDevHandle = (tiDeviceHandle_t *)&(tdsaDeviceData->tiDeviceHandle); 10955285809Sscottl /* initialize agIORequest */ 10956285809Sscottl agAbortIORequest = &(tdAbortIORequestBody->agIORequest); 10957285809Sscottl agAbortIORequest->osData = (void *) tdAbortIORequestBody; 10958285809Sscottl agAbortIORequest->sdkData = agNULL; /* LL takes care of this */ 10959285809Sscottl 10960285809Sscottl /* 10961285809Sscottl * Issue abort 10962285809Sscottl */ 10963285809Sscottl saSATAAbort( agRoot, agAbortIORequest, 0, tdsaDeviceData->agDevHandle, 1, agNULL, agNULL); 10964285809Sscottl 10965285809Sscottl 10966285809Sscottl /* 10967285809Sscottl * Free resource allocated for the internally generated READ LOG EXT. 10968285809Sscottl */ 10969285809Sscottl satFreeIntIoResource( tiRoot, 10970285809Sscottl satDevData, 10971285809Sscottl satIntIo); 10972285809Sscottl 10973285809Sscottl /* 10974285809Sscottl * Sequence of recovery continue at some other context: 10975285809Sscottl * At the completion of abort, in the context of ossaSATACompleted(), 10976285809Sscottl * return the I/O with error status to the OS-App Specific layer. 10977285809Sscottl * When all I/O aborts are completed, clear SATA device flag to 10978285809Sscottl * indicate ready to process new request. 10979285809Sscottl */ 10980285809Sscottl 10981285809Sscottl satDevData->satDriveState = SAT_DEV_STATE_NORMAL; 10982285809Sscottl 10983285809Sscottl TI_DBG1(("satReadLogExtCB: end return\n")); 10984285809Sscottl return; 10985285809Sscottl} 10986285809Sscottl 10987285809Sscottl#ifndef FDS_SM 10988285809Sscottl/***************************************************************************** 10989285809Sscottl*! \brief ossaSATAEvent 10990285809Sscottl* 10991285809Sscottl* This routine is called to notify the OS Layer of an event associated with 10992285809Sscottl* SATA port or SATA device 10993285809Sscottl* 10994285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 10995285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 10996285809Sscottl* \param agPortContext Pointer to the port context of TD and Lower layer 10997285809Sscottl* \param agDevHandle: Pointer to a device handle 10998285809Sscottl* \param event: event type 10999285809Sscottl* 11000285809Sscottl* \return: none 11001285809Sscottl* 11002285809Sscottl*****************************************************************************/ 11003285809SscottlosGLOBAL void ossaSATAEvent( 11004285809Sscottl agsaRoot_t *agRoot, 11005285809Sscottl agsaIORequest_t *agIORequest, 11006285809Sscottl agsaPortContext_t *agPortContext, 11007285809Sscottl agsaDevHandle_t *agDevHandle, 11008285809Sscottl bit32 event, 11009285809Sscottl bit32 agIOInfoLen, 11010285809Sscottl void *agParam 11011285809Sscottl ) 11012285809Sscottl{ 11013285809Sscottl 11014285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 11015285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 11016285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 11017285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 11018285809Sscottl bit32 interruptContext = osData->IntContext; 11019285809Sscottl tdsaDeviceData_t *pDeviceData; 11020285809Sscottl satDeviceData_t *pSatDevData; 11021285809Sscottl satInternalIo_t *satIntIo = agNULL; 11022285809Sscottl bit32 status; 11023285809Sscottl satIOContext_t *satIOContext2; 11024285809Sscottl tdIORequestBody_t *tdIORequestBody; 11025285809Sscottl tiDeviceHandle_t *tiDeviceHandle; 11026285809Sscottl tiIORequest_t tiIORequestTMP; 11027285809Sscottl agsaDifDetails_t agDifDetails; 11028285809Sscottl bit8 framePayload[256]; 11029285809Sscottl bit16 frameOffset = 0; 11030285809Sscottl bit16 frameLen = 0; 11031285809Sscottl 11032285809Sscottl /* new */ 11033285809Sscottl tdsaDeviceData_t *tdsaDeviceData = agNULL; 11034285809Sscottl satIOContext_t *satIOContext; 11035285809Sscottl tdsaPortContext_t *onePortContext; 11036285809Sscottl 11037285809Sscottl if (event == OSSA_IO_XFER_ERROR_ABORTED_NCQ_MODE) 11038285809Sscottl { 11039285809Sscottl 11040285809Sscottl /************************************************************************** 11041285809Sscottl * 11042285809Sscottl * !!!! See Section 13.5.2.4 of SATA 2.5 specs. !!!! 11043285809Sscottl * !!!! If the NCQ error ends up here, it means that the device sent !!!! 11044285809Sscottl * !!!! Register Device To Host FIS (which does not have SActive !!!! 11045285809Sscottl * !!!! register) instead of Set Device Bit FIS (which has SActive !!!! 11046285809Sscottl * !!!! register). The routine osSatIOCompleted() deals with the case !!!! 11047285809Sscottl * !!!! where Set Device Bit FIS was sent by the device. !!!! 11048285809Sscottl * 11049285809Sscottl * For NCQ we need to issue READ LOG EXT command with log page 10h 11050285809Sscottl * to get the error and to allow other I/Os to continue. 11051285809Sscottl * 11052285809Sscottl * Here is the basic flow or sequence of error recovery, this sequence is 11053285809Sscottl * similar to the one described in SATA 2.5: 11054285809Sscottl * 11055285809Sscottl * 1. Set SATA device flag to indicate error condition and returning busy 11056285809Sscottl * for all new request. 11057285809Sscottl * 11058285809Sscottl * 2. Prepare READ LOG EXT page 10h command. Set flag to indicate that 11059285809Sscottl * the failed I/O has NOT been returned to the OS Layer. Send command. 11060285809Sscottl * 11061285809Sscottl * 3. When the device receives READ LOG EXT page 10h request all other 11062285809Sscottl * pending I/O are implicitly aborted. No completion (aborted) status 11063285809Sscottl * will be sent to the host for these aborted commands. 11064285809Sscottl * 11065285809Sscottl * 4. SATL receives the completion for READ LOG EXT command in 11066285809Sscottl * satReadLogExtCB(). Steps 5,6,7,8 below are the step 1,2,3,4 in 11067285809Sscottl * satReadLogExtCB(). 11068285809Sscottl * 11069285809Sscottl * 5. Check flag that indicates whether the failed I/O has been returned 11070285809Sscottl * to the OS Layer. If not, search the I/O context in device data 11071285809Sscottl * looking for a matched tag. Then return the completion of the failed 11072285809Sscottl * NCQ command with the appopriate/trasnlated SCSI status. 11073285809Sscottl * 11074285809Sscottl * 6. Issue abort to LL layer to all other pending I/Os for the same SATA 11075285809Sscottl * drive. 11076285809Sscottl * 11077285809Sscottl * 7. Free resource allocated for the internally generated READ LOG EXT. 11078285809Sscottl * 11079285809Sscottl * 8. At the completion of abort, in the context of ossaSATACompleted(), 11080285809Sscottl * return the I/O with error status to the OS-App Specific layer. 11081285809Sscottl * When all I/O aborts are completed, clear SATA device flag to 11082285809Sscottl * indicate ready to process new request. 11083285809Sscottl * 11084285809Sscottl *************************************************************************/ 11085285809Sscottl 11086285809Sscottl pDeviceData = (tdsaDeviceData_t *) agDevHandle->osData; 11087285809Sscottl pSatDevData = &pDeviceData->satDevData; 11088285809Sscottl tiDeviceHandle = &((tdsaDeviceData_t *)(pSatDevData->satSaDeviceData))->tiDeviceHandle; 11089285809Sscottl 11090285809Sscottl TI_DBG1(("ossaSATAEvent: did %d\n", pDeviceData->id)); 11091285809Sscottl 11092285809Sscottl if (pSatDevData->satDriveState == SAT_DEV_STATE_NORMAL) 11093285809Sscottl { 11094285809Sscottl TI_DBG1(("ossaSATAEvent: NCQ ERROR agDevHandle=%p.\n", agDevHandle )); 11095285809Sscottl 11096285809Sscottl /* Set flag to indicate we are in recovery */ 11097285809Sscottl pSatDevData->satDriveState = SAT_DEV_STATE_IN_RECOVERY; 11098285809Sscottl 11099285809Sscottl /* 11100285809Sscottl * Allocate resource for READ LOG EXIT page 10h 11101285809Sscottl */ 11102285809Sscottl satIntIo = satAllocIntIoResource( tiRoot, 11103285809Sscottl &(tiIORequestTMP), /* anything but NULL */ 11104285809Sscottl pSatDevData, 11105285809Sscottl sizeof (satReadLogExtPage10h_t), 11106285809Sscottl satIntIo); 11107285809Sscottl 11108285809Sscottl /* 11109285809Sscottl * If we cannot allocate resource to do the normal NCQ recovery, we 11110285809Sscottl * will do SATA device reset. 11111285809Sscottl */ 11112285809Sscottl if (satIntIo == agNULL) 11113285809Sscottl { 11114285809Sscottl /* Abort I/O after completion of device reset */ 11115285809Sscottl pSatDevData->satAbortAfterReset = agTRUE; 11116285809Sscottl TI_DBG1(("ossaSATAEvent: can't send RLE due to resource lack\n")); 11117285809Sscottl 11118285809Sscottl#ifdef NOT_YET 11119285809Sscottl /* needs to investigate this case */ 11120285809Sscottl /* no report to OS layer */ 11121285809Sscottl satSubTM(tiRoot, 11122285809Sscottl tiDeviceHandle, 11123285809Sscottl TD_INTERNAL_TM_RESET, 11124285809Sscottl agNULL, 11125285809Sscottl agNULL, 11126285809Sscottl agNULL, 11127285809Sscottl agFALSE); 11128285809Sscottl#endif 11129285809Sscottl 11130285809Sscottl return; 11131285809Sscottl } 11132285809Sscottl 11133285809Sscottl 11134285809Sscottl /* 11135285809Sscottl * Clear flag to indicate that the failed I/O has NOT been returned to the 11136285809Sscottl * OS-App specific Layer. 11137285809Sscottl */ 11138285809Sscottl satIntIo->satIntFlag = 0; 11139285809Sscottl 11140285809Sscottl /* compare to satPrepareNewIO() */ 11141285809Sscottl /* Send READ LOG EXIT page 10h command */ 11142285809Sscottl 11143285809Sscottl /* 11144285809Sscottl * Need to initialize all the fields within satIOContext except 11145285809Sscottl * reqType and satCompleteCB which will be set depending on cmd. 11146285809Sscottl */ 11147285809Sscottl 11148285809Sscottl tdIORequestBody = (tdIORequestBody_t *)satIntIo->satIntRequestBody; 11149285809Sscottl satIOContext2 = &(tdIORequestBody->transport.SATA.satIOContext); 11150285809Sscottl 11151285809Sscottl satIOContext2->pSatDevData = pSatDevData; 11152285809Sscottl satIOContext2->pFis = &(tdIORequestBody->transport.SATA.agSATARequestBody.fis.fisRegHostToDev); 11153285809Sscottl satIOContext2->pScsiCmnd = &(satIntIo->satIntTiScsiXchg.scsiCmnd); 11154285809Sscottl satIOContext2->pSense = &(tdIORequestBody->transport.SATA.sensePayload); 11155285809Sscottl satIOContext2->pTiSenseData = &(tdIORequestBody->transport.SATA.tiSenseData); 11156285809Sscottl satIOContext2->pTiSenseData->senseData = satIOContext2->pSense; 11157285809Sscottl 11158285809Sscottl satIOContext2->tiRequestBody = satIntIo->satIntRequestBody; 11159285809Sscottl satIOContext2->interruptContext = interruptContext; 11160285809Sscottl satIOContext2->satIntIoContext = satIntIo; 11161285809Sscottl 11162285809Sscottl satIOContext2->ptiDeviceHandle = tiDeviceHandle; 11163285809Sscottl satIOContext2->satOrgIOContext = agNULL; 11164285809Sscottl satIOContext2->tiScsiXchg = agNULL; 11165285809Sscottl 11166285809Sscottl status = satSendReadLogExt( tiRoot, 11167285809Sscottl &satIntIo->satIntTiIORequest, 11168285809Sscottl tiDeviceHandle, 11169285809Sscottl &satIntIo->satIntTiScsiXchg, 11170285809Sscottl satIOContext2); 11171285809Sscottl 11172285809Sscottl if (status !=tiSuccess) 11173285809Sscottl { 11174285809Sscottl TI_DBG1(("ossaSATAEvent: can't send RLE due to LL api failure\n")); 11175285809Sscottl satFreeIntIoResource( tiRoot, 11176285809Sscottl pSatDevData, 11177285809Sscottl satIntIo); 11178285809Sscottl /* Abort I/O after completion of device reset */ 11179285809Sscottl pSatDevData->satAbortAfterReset = agTRUE; 11180285809Sscottl#ifdef NOT_YET 11181285809Sscottl /* needs to investigate this case */ 11182285809Sscottl /* no report to OS layer */ 11183285809Sscottl satSubTM(tiRoot, 11184285809Sscottl tiDeviceHandle, 11185285809Sscottl TD_INTERNAL_TM_RESET, 11186285809Sscottl agNULL, 11187285809Sscottl agNULL, 11188285809Sscottl agNULL, 11189285809Sscottl agFALSE); 11190285809Sscottl#endif 11191285809Sscottl 11192285809Sscottl return; 11193285809Sscottl } 11194285809Sscottl } 11195285809Sscottl else 11196285809Sscottl { 11197285809Sscottl TI_DBG1(("ossaSATAEvent: NCQ ERROR but recovery in progress\n")); 11198285809Sscottl } 11199285809Sscottl 11200285809Sscottl } 11201285809Sscottl else if (event == OSSA_IO_XFER_CMD_FRAME_ISSUED) 11202285809Sscottl { 11203285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_XFER_CMD_FRAME_ISSUED\n")); 11204285809Sscottl } 11205285809Sscottl else if (event == OSSA_IO_XFER_PIO_SETUP_ERROR) 11206285809Sscottl { 11207285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_XFER_PIO_SETUP_ERROR\n")); 11208285809Sscottl 11209285809Sscottl } 11210285809Sscottl else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED) 11211285809Sscottl { 11212285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED\n")); 11213285809Sscottl } 11214285809Sscottl else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO) 11215285809Sscottl { 11216285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO\n")); 11217285809Sscottl } 11218285809Sscottl else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST) 11219285809Sscottl { 11220285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST\n")); 11221285809Sscottl } 11222285809Sscottl else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE) 11223285809Sscottl { 11224285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE\n")); 11225285809Sscottl } 11226285809Sscottl else if (event == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED) 11227285809Sscottl { 11228285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED\n")); 11229285809Sscottl } 11230285809Sscottl else if (event == OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH) 11231285809Sscottl { 11232285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH\n")); 11233285809Sscottl } 11234285809Sscottl else if (event == OSSA_IO_XFR_ERROR_DIF_MISMATCH || event == OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH || 11235285809Sscottl event == OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH || event == OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH) 11236285809Sscottl { 11237285809Sscottl TI_DBG1(("ossaSSPEvent: DIF related, event 0x%x\n", event)); 11238285809Sscottl /* process DIF detail information */ 11239285809Sscottl TI_DBG2(("ossaSSPEvent: agIOInfoLen %d\n", agIOInfoLen)); 11240285809Sscottl if (agParam == agNULL) 11241285809Sscottl { 11242285809Sscottl TI_DBG2(("ossaSSPEvent: agParam is NULL!!!\n")); 11243285809Sscottl return; 11244285809Sscottl } 11245285809Sscottl if (agIOInfoLen < sizeof(agsaDifDetails_t)) 11246285809Sscottl { 11247285809Sscottl TI_DBG2(("ossaSSPEvent: wrong agIOInfoLen!!! agIOInfoLen %d sizeof(agsaDifDetails_t) %d\n", agIOInfoLen, sizeof(agsaDifDetails_t))); 11248285809Sscottl return; 11249285809Sscottl } 11250285809Sscottl /* reads agsaDifDetails_t */ 11251285809Sscottl saFrameReadBlock(agRoot, agParam, 0, &agDifDetails, sizeof(agsaDifDetails_t)); 11252285809Sscottl frameOffset = (agDifDetails.ErrBoffsetEDataLen & 0xFFFF); 11253285809Sscottl frameLen = (agDifDetails.ErrBoffsetEDataLen & 0xFFFF0000) >> 16; 11254285809Sscottl 11255285809Sscottl TI_DBG2(("ossaSSPEvent: UpperLBA 0x%08x LowerLBA 0x%08x\n", agDifDetails.UpperLBA, agDifDetails.LowerLBA)); 11256285809Sscottl TI_DBG2(("ossaSSPEvent: SASAddrHI 0x%08x SASAddrLO 0x%08x\n", 11257285809Sscottl TD_GET_SAS_ADDRESSHI(agDifDetails.sasAddressHi), TD_GET_SAS_ADDRESSLO(agDifDetails.sasAddressLo))); 11258285809Sscottl TI_DBG2(("ossaSSPEvent: DIF error mask 0x%x Device ID 0x%x\n", 11259285809Sscottl (agDifDetails.DIFErrDevID) & 0xFF, (agDifDetails.DIFErrDevID & 0xFFFF0000) >> 16)); 11260285809Sscottl if (frameLen != 0 && frameLen <= 256) 11261285809Sscottl { 11262285809Sscottl saFrameReadBlock(agRoot, agParam, sizeof(agsaDifDetails_t), framePayload, frameLen); 11263285809Sscottl tdhexdump("ossaSSPEvent frame", framePayload, frameLen); 11264285809Sscottl } 11265285809Sscottl } 11266285809Sscottl else 11267285809Sscottl { 11268285809Sscottl TI_DBG1(("ossaSATAEvent: ERROR event %d agDevHandle=%p.\n", event, agDevHandle )); 11269285809Sscottl 11270285809Sscottl tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 11271285809Sscottl satIOContext = &(tdIORequestBody->transport.SATA.satIOContext); 11272285809Sscottl pSatDevData = satIOContext->pSatDevData; 11273285809Sscottl tdsaDeviceData = (tdsaDeviceData_t *)pSatDevData->satSaDeviceData; 11274285809Sscottl onePortContext = tdsaDeviceData->tdPortContext; 11275285809Sscottl TI_DBG1(("ossaSATAEvent: did %d\n", tdsaDeviceData->id)); 11276285809Sscottl 11277285809Sscottl /* send SMP_PHY_CONTROL_HARD_RESET */ 11278285809Sscottl if (event == OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY && tdsaAllShared->FCA) 11279285809Sscottl { 11280285809Sscottl if (pSatDevData->NumOfFCA <= 0) /* does SMP HARD RESET only upto one time */ 11281285809Sscottl { 11282285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; sending HARD_RESET\n")); 11283285809Sscottl pSatDevData->NumOfFCA++; 11284285809Sscottl tdsaPhyControlSend(tiRoot, 11285285809Sscottl tdsaDeviceData, 11286285809Sscottl SMP_PHY_CONTROL_HARD_RESET, 11287285809Sscottl agNULL); 11288285809Sscottl } 11289285809Sscottl else 11290285809Sscottl { 11291285809Sscottl /* given up after one time of SMP HARD RESET; */ 11292285809Sscottl TI_DBG1(("ossaSATAEvent: OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY; NO!!! sending HARD_RESET\n")); 11293285809Sscottl if (tdsaDeviceData->registered == agTRUE && tdsaAllShared->ResetInDiscovery == 0) 11294285809Sscottl { 11295285809Sscottl /* 11296285809Sscottl 1. remove this device 11297285809Sscottl 2. device removal event 11298285809Sscottl */ 11299285809Sscottl tdsaAbortAll(tiRoot, agRoot, tdsaDeviceData); 11300285809Sscottl tdsaDeviceData->valid = agFALSE; 11301285809Sscottl tdsaDeviceData->valid2 = agFALSE; 11302285809Sscottl tdsaDeviceData->registered = agFALSE; 11303285809Sscottl ostiInitiatorEvent( 11304285809Sscottl tiRoot, 11305285809Sscottl onePortContext->tiPortalContext, 11306285809Sscottl agNULL, 11307285809Sscottl tiIntrEventTypeDeviceChange, 11308285809Sscottl tiDeviceRemoval, 11309285809Sscottl agNULL 11310285809Sscottl ); 11311285809Sscottl } 11312285809Sscottl } 11313285809Sscottl } 11314285809Sscottl 11315285809Sscottl } 11316285809Sscottl} 11317285809Sscottl#endif /* FDS_SM */ 11318285809Sscottl 11319285809Sscottl/***************************************************************************** 11320285809Sscottl*! \brief itdsatErrorSATAEventHandle 11321285809Sscottl* 11322285809Sscottl* This routine is called to handle SATA error event 11323285809Sscottl* 11324285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 11325285809Sscottl* \param agIORequest: Pointer to the LL I/O request context for this I/O. 11326285809Sscottl* \param agPortContext Pointer to the port context of TD and Lower layer 11327285809Sscottl* \param agDevHandle: Pointer to a device handle 11328285809Sscottl* \param event: event type 11329285809Sscottl* \param ioContext: Pointer to satIOContext_t 11330285809Sscottl* 11331285809Sscottl* \return: none 11332285809Sscottl* 11333285809Sscottl*****************************************************************************/ 11334285809SscottlosGLOBAL void itdsatErrorSATAEventHandle( 11335285809Sscottl agsaRoot_t *agRoot, 11336285809Sscottl agsaIORequest_t *agIORequest, 11337285809Sscottl agsaPortContext_t *agPortContext, 11338285809Sscottl agsaDevHandle_t *agDevHandle, 11339285809Sscottl bit32 event, 11340285809Sscottl satIOContext_t *ioContext 11341285809Sscottl ) 11342285809Sscottl{ 11343285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 11344285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 11345285809Sscottl tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData; 11346285809Sscottl tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared; 11347285809Sscottl tdIORequestBody_t *tdOrgIORequestBody; 11348285809Sscottl satIOContext_t *satIOContext; 11349285809Sscottl satIOContext_t *satOrgIOContext; 11350285809Sscottl satInternalIo_t *satIntIo; 11351285809Sscottl satDeviceData_t *satDevData; 11352285809Sscottl bit32 interruptContext = osData->IntContext; 11353285809Sscottl 11354285809Sscottl TI_DBG1(("itdsatErrorSATAEventHandle: start\n")); 11355285809Sscottl satIOContext = (satIOContext_t *) ioContext; 11356285809Sscottl satIntIo = satIOContext->satIntIoContext; 11357285809Sscottl satDevData = satIOContext->pSatDevData; 11358285809Sscottl 11359285809Sscottl 11360285809Sscottl TI_DBG1(("itdsatErrorSATAEventHandle: event 0x%x\n", event)); 11361285809Sscottl 11362285809Sscottl if (satIntIo == agNULL) 11363285809Sscottl { 11364285809Sscottl TI_DBG1(("itdsatErrorSATAEventHandle: External, OS generated\n")); 11365285809Sscottl satOrgIOContext = satIOContext; 11366285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 11367285809Sscottl 11368285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 11369285809Sscottl 11370285809Sscottl satFreeIntIoResource( tiRoot, 11371285809Sscottl satDevData, 11372285809Sscottl satIntIo); 11373285809Sscottl 11374285809Sscottl if (event == OSSA_IO_OVERFLOW) 11375285809Sscottl { 11376285809Sscottl TI_DBG1(("itdsatErrorSATAEventHandle: tiIOOverRun\n")); 11377285809Sscottl ostiInitiatorIOCompleted( tiRoot, 11378285809Sscottl tdOrgIORequestBody->tiIORequest, 11379285809Sscottl tiIOOverRun, 11380285809Sscottl 0, 11381285809Sscottl agNULL, 11382285809Sscottl interruptContext); 11383285809Sscottl } 11384285809Sscottl else 11385285809Sscottl { 11386285809Sscottl TI_DBG1(("itdsatErrorSATAEventHandle: else\n")); 11387285809Sscottl ostiInitiatorIOCompleted( tiRoot, 11388285809Sscottl tdOrgIORequestBody->tiIORequest, 11389285809Sscottl tiIOFailed, 11390285809Sscottl tiDetailOtherError, 11391285809Sscottl agNULL, 11392285809Sscottl interruptContext); 11393285809Sscottl } 11394285809Sscottl } 11395285809Sscottl else 11396285809Sscottl { 11397285809Sscottl TI_DBG1(("itdsatErrorSATAEventHandle: Internal, TD generated\n")); 11398285809Sscottl satOrgIOContext = satIOContext->satOrgIOContext; 11399285809Sscottl if (satOrgIOContext == agNULL) 11400285809Sscottl { 11401285809Sscottl TI_DBG1(("itdsatErrorSATAEventHandle: satOrgIOContext is NULL, wrong\n")); 11402285809Sscottl return; 11403285809Sscottl } 11404285809Sscottl else 11405285809Sscottl { 11406285809Sscottl TI_DBG6(("itdsatErrorSATAEventHandle: satOrgIOContext is NOT NULL\n")); 11407285809Sscottl } 11408285809Sscottl tdOrgIORequestBody = (tdIORequestBody_t *)satOrgIOContext->tiRequestBody; 11409285809Sscottl satDecrementPendingIO(tiRoot, tdsaAllShared, satIOContext); 11410285809Sscottl 11411285809Sscottl satFreeIntIoResource( tiRoot, 11412285809Sscottl satDevData, 11413285809Sscottl satIntIo); 11414285809Sscottl 11415285809Sscottl /* clean up TD layer's IORequestBody */ 11416285809Sscottl ostiFreeMemory( 11417285809Sscottl tiRoot, 11418285809Sscottl tdOrgIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11419285809Sscottl sizeof(tdIORequestBody_t) 11420285809Sscottl ); 11421285809Sscottl 11422285809Sscottl } 11423285809Sscottl return; 11424285809Sscottl} 11425285809Sscottl 11426285809SscottlosGLOBAL void ossaSATAAbortCB( 11427285809Sscottl agsaRoot_t *agRoot, 11428285809Sscottl agsaIORequest_t *agIORequest, 11429285809Sscottl bit32 flag, 11430285809Sscottl bit32 status) 11431285809Sscottl{ 11432285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 11433285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 11434285809Sscottl tdIORequestBody_t *tdAbortIORequestBody = agNULL; 11435285809Sscottl tdsaDeviceData_t *oneDeviceData = agNULL; 11436285809Sscottl tiDeviceHandle_t *tiDeviceHandle = agNULL; 11437285809Sscottl tiIORequest_t *taskTag = agNULL; 11438285809Sscottl 11439285809Sscottl TI_DBG1(("ossaSATAAbortCB: start\n")); 11440285809Sscottl 11441285809Sscottl tdAbortIORequestBody = (tdIORequestBody_t *)agIORequest->osData; 11442285809Sscottl if (tdAbortIORequestBody == agNULL) 11443285809Sscottl { 11444285809Sscottl TI_DBG1(("ossaSATAAbortCB: tdAbortIORequestBody is NULL warning!!!!\n")); 11445285809Sscottl return; 11446285809Sscottl } 11447285809Sscottl 11448285809Sscottl if (flag == 2) 11449285809Sscottl { 11450285809Sscottl /* abort per port */ 11451285809Sscottl TI_DBG1(("ossaSATAAbortCB: abort per port\n")); 11452285809Sscottl } 11453285809Sscottl else if (flag == 1) 11454285809Sscottl { 11455285809Sscottl TI_DBG1(("ossaSATAAbortCB: abort all\n")); 11456285809Sscottl tiDeviceHandle = (tiDeviceHandle_t *)tdAbortIORequestBody->tiDevHandle; 11457285809Sscottl if (tiDeviceHandle == agNULL) 11458285809Sscottl { 11459285809Sscottl TI_DBG1(("ossaSATAAbortCB: tiDeviceHandle is NULL warning!!!!\n")); 11460285809Sscottl ostiFreeMemory( 11461285809Sscottl tiRoot, 11462285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11463285809Sscottl sizeof(tdIORequestBody_t) 11464285809Sscottl ); 11465285809Sscottl return; 11466285809Sscottl } 11467285809Sscottl 11468285809Sscottl oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData; 11469285809Sscottl if (oneDeviceData == agNULL) 11470285809Sscottl { 11471285809Sscottl TI_DBG1(("ossaSATAAbortCB: oneDeviceData is NULL warning!!!!\n")); 11472285809Sscottl ostiFreeMemory( 11473285809Sscottl tiRoot, 11474285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11475285809Sscottl sizeof(tdIORequestBody_t) 11476285809Sscottl ); 11477285809Sscottl return; 11478285809Sscottl } 11479285809Sscottl 11480285809Sscottl if (status == OSSA_IO_SUCCESS) 11481285809Sscottl { 11482285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_SUCCESS\n")); 11483285809Sscottl /* clean up TD layer's IORequestBody */ 11484285809Sscottl if (oneDeviceData->OSAbortAll == agTRUE) 11485285809Sscottl { 11486285809Sscottl oneDeviceData->OSAbortAll = agFALSE; 11487285809Sscottl ostiInitiatorEvent( tiRoot, 11488285809Sscottl agNULL, 11489285809Sscottl tiDeviceHandle, 11490285809Sscottl tiIntrEventTypeLocalAbort, 11491285809Sscottl tiAbortOK, 11492285809Sscottl agNULL); 11493285809Sscottl } 11494285809Sscottl else 11495285809Sscottl { 11496285809Sscottl TI_DBG1(("ossaSATAAbortCB: calling saDeregisterDeviceHandle did %d\n", oneDeviceData->id)); 11497285809Sscottl saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 11498285809Sscottl } 11499285809Sscottl /* callback to OS layer here ??? */ 11500285809Sscottl TI_DBG1(("ossaSATAAbortCB: did %d\n", oneDeviceData->id)); 11501285809Sscottl ostiFreeMemory( 11502285809Sscottl tiRoot, 11503285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11504285809Sscottl sizeof(tdIORequestBody_t) 11505285809Sscottl ); 11506285809Sscottl 11507285809Sscottl } 11508285809Sscottl else if (status == OSSA_IO_NOT_VALID) 11509285809Sscottl { 11510285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_NOT_VALID\n")); 11511285809Sscottl /* 11512285809Sscottl Nothing is reproted to OS layer 11513285809Sscottl */ 11514285809Sscottl if (oneDeviceData->OSAbortAll == agTRUE) 11515285809Sscottl { 11516285809Sscottl oneDeviceData->OSAbortAll = agFALSE; 11517285809Sscottl ostiInitiatorEvent( tiRoot, 11518285809Sscottl agNULL, 11519285809Sscottl tiDeviceHandle, 11520285809Sscottl tiIntrEventTypeLocalAbort, 11521285809Sscottl tiAbortFailed, 11522285809Sscottl agNULL ); 11523285809Sscottl } 11524285809Sscottl else 11525285809Sscottl { 11526285809Sscottl TI_DBG1(("ossaSATAAbortCB: calling saDeregisterDeviceHandle did %d\n", oneDeviceData->id)); 11527285809Sscottl saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 11528285809Sscottl } 11529285809Sscottl TI_DBG1(("ossaSATAAbortCB: did %d\n", oneDeviceData->id)); 11530285809Sscottl ostiFreeMemory( 11531285809Sscottl tiRoot, 11532285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11533285809Sscottl sizeof(tdIORequestBody_t) 11534285809Sscottl ); 11535285809Sscottl } 11536285809Sscottl else if (status == OSSA_IO_NO_DEVICE) 11537285809Sscottl { 11538285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_NO_DEVICE\n")); 11539285809Sscottl /* 11540285809Sscottl Nothing is reproted to OS layer 11541285809Sscottl */ 11542285809Sscottl if (oneDeviceData->OSAbortAll == agTRUE) 11543285809Sscottl { 11544285809Sscottl oneDeviceData->OSAbortAll = agFALSE; 11545285809Sscottl ostiInitiatorEvent( tiRoot, 11546285809Sscottl agNULL, 11547285809Sscottl tiDeviceHandle, 11548285809Sscottl tiIntrEventTypeLocalAbort, 11549285809Sscottl tiAbortInProgress, 11550285809Sscottl agNULL ); 11551285809Sscottl } 11552285809Sscottl else 11553285809Sscottl { 11554285809Sscottl TI_DBG1(("ossaSATAAbortCB: calling saDeregisterDeviceHandle did %d\n", oneDeviceData->id)); 11555285809Sscottl saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 11556285809Sscottl } 11557285809Sscottl TI_DBG1(("ossaSATAAbortCB: did %d\n", oneDeviceData->id)); 11558285809Sscottl ostiFreeMemory( 11559285809Sscottl tiRoot, 11560285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11561285809Sscottl sizeof(tdIORequestBody_t) 11562285809Sscottl ); 11563285809Sscottl } 11564285809Sscottl else if (status == OSSA_IO_ABORT_IN_PROGRESS) 11565285809Sscottl { 11566285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 11567285809Sscottl /* 11568285809Sscottl Nothing is reproted to OS layer 11569285809Sscottl */ 11570285809Sscottl if (oneDeviceData->OSAbortAll == agTRUE) 11571285809Sscottl { 11572285809Sscottl oneDeviceData->OSAbortAll = agFALSE; 11573285809Sscottl ostiInitiatorEvent( tiRoot, 11574285809Sscottl agNULL, 11575285809Sscottl tiDeviceHandle, 11576285809Sscottl tiIntrEventTypeLocalAbort, 11577285809Sscottl tiAbortInProgress, 11578285809Sscottl agNULL ); 11579285809Sscottl } 11580285809Sscottl else 11581285809Sscottl { 11582285809Sscottl TI_DBG1(("ossaSATAAbortCB: calling saDeregisterDeviceHandle did %d\n", oneDeviceData->id)); 11583285809Sscottl saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 11584285809Sscottl } 11585285809Sscottl TI_DBG1(("ossaSATAAbortCB: did %d\n", oneDeviceData->id)); 11586285809Sscottl ostiFreeMemory( 11587285809Sscottl tiRoot, 11588285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11589285809Sscottl sizeof(tdIORequestBody_t) 11590285809Sscottl ); 11591285809Sscottl } 11592285809Sscottl else 11593285809Sscottl { 11594285809Sscottl TI_DBG1(("ossaSATAAbortCB: unspecified status 0x%x\n", status )); 11595285809Sscottl /* 11596285809Sscottl Nothing is reproted to OS layer 11597285809Sscottl */ 11598285809Sscottl if (oneDeviceData->OSAbortAll == agTRUE) 11599285809Sscottl { 11600285809Sscottl oneDeviceData->OSAbortAll = agFALSE; 11601285809Sscottl ostiInitiatorEvent( tiRoot, 11602285809Sscottl agNULL, 11603285809Sscottl tiDeviceHandle, 11604285809Sscottl tiIntrEventTypeLocalAbort, 11605285809Sscottl tiAbortInProgress, 11606285809Sscottl agNULL ); 11607285809Sscottl } 11608285809Sscottl else 11609285809Sscottl { 11610285809Sscottl TI_DBG1(("ossaSATAAbortCB: calling saDeregisterDeviceHandle did %d\n", oneDeviceData->id)); 11611285809Sscottl saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData)); 11612285809Sscottl } 11613285809Sscottl TI_DBG1(("ossaSATAAbortCB: did %d\n", oneDeviceData->id)); 11614285809Sscottl ostiFreeMemory( 11615285809Sscottl tiRoot, 11616285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11617285809Sscottl sizeof(tdIORequestBody_t) 11618285809Sscottl ); 11619285809Sscottl } 11620285809Sscottl } 11621285809Sscottl else if (flag == 0) 11622285809Sscottl { 11623285809Sscottl TI_DBG1(("ossaSATAAbortCB: abort one\n")); 11624285809Sscottl taskTag = tdAbortIORequestBody->tiIOToBeAbortedRequest; 11625285809Sscottl 11626285809Sscottl if (status == OSSA_IO_SUCCESS) 11627285809Sscottl { 11628285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_SUCCESS\n")); 11629285809Sscottl 11630285809Sscottl ostiInitiatorEvent( tiRoot, 11631285809Sscottl agNULL, 11632285809Sscottl agNULL, 11633285809Sscottl tiIntrEventTypeLocalAbort, 11634285809Sscottl tiAbortOK, 11635285809Sscottl taskTag ); 11636285809Sscottl ostiFreeMemory( 11637285809Sscottl tiRoot, 11638285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11639285809Sscottl sizeof(tdIORequestBody_t) 11640285809Sscottl ); 11641285809Sscottl 11642285809Sscottl } 11643285809Sscottl else if (status == OSSA_IO_NOT_VALID) 11644285809Sscottl { 11645285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_NOT_VALID\n")); 11646285809Sscottl 11647285809Sscottl ostiInitiatorEvent( tiRoot, 11648285809Sscottl agNULL, 11649285809Sscottl agNULL, 11650285809Sscottl tiIntrEventTypeLocalAbort, 11651285809Sscottl tiAbortFailed, 11652285809Sscottl taskTag ); 11653285809Sscottl 11654285809Sscottl ostiFreeMemory( 11655285809Sscottl tiRoot, 11656285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11657285809Sscottl sizeof(tdIORequestBody_t) 11658285809Sscottl ); 11659285809Sscottl } 11660285809Sscottl else if (status == OSSA_IO_NO_DEVICE) 11661285809Sscottl { 11662285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_NO_DEVICE\n")); 11663285809Sscottl 11664285809Sscottl ostiInitiatorEvent( tiRoot, 11665285809Sscottl agNULL, 11666285809Sscottl agNULL, 11667285809Sscottl tiIntrEventTypeLocalAbort, 11668285809Sscottl tiAbortInProgress, 11669285809Sscottl taskTag ); 11670285809Sscottl 11671285809Sscottl ostiFreeMemory( 11672285809Sscottl tiRoot, 11673285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11674285809Sscottl sizeof(tdIORequestBody_t) 11675285809Sscottl ); 11676285809Sscottl } 11677285809Sscottl else if (status == OSSA_IO_ABORT_IN_PROGRESS) 11678285809Sscottl { 11679285809Sscottl TI_DBG1(("ossaSATAAbortCB: OSSA_IO_ABORT_IN_PROGRESS\n")); 11680285809Sscottl 11681285809Sscottl ostiInitiatorEvent( tiRoot, 11682285809Sscottl agNULL, 11683285809Sscottl agNULL, 11684285809Sscottl tiIntrEventTypeLocalAbort, 11685285809Sscottl tiAbortInProgress, 11686285809Sscottl taskTag ); 11687285809Sscottl 11688285809Sscottl ostiFreeMemory( 11689285809Sscottl tiRoot, 11690285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11691285809Sscottl sizeof(tdIORequestBody_t) 11692285809Sscottl ); 11693285809Sscottl } 11694285809Sscottl else 11695285809Sscottl { 11696285809Sscottl TI_DBG1(("ossaSATAAbortCB: unspecified status 0x%x\n", status )); 11697285809Sscottl 11698285809Sscottl ostiInitiatorEvent( tiRoot, 11699285809Sscottl agNULL, 11700285809Sscottl agNULL, 11701285809Sscottl tiIntrEventTypeLocalAbort, 11702285809Sscottl tiAbortFailed, 11703285809Sscottl taskTag ); 11704285809Sscottl 11705285809Sscottl ostiFreeMemory( 11706285809Sscottl tiRoot, 11707285809Sscottl tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle, 11708285809Sscottl sizeof(tdIORequestBody_t) 11709285809Sscottl ); 11710285809Sscottl } 11711285809Sscottl } 11712285809Sscottl else 11713285809Sscottl { 11714285809Sscottl TI_DBG1(("ossaSATAAbortCB: wrong flag %d\n", flag)); 11715285809Sscottl } 11716285809Sscottl return; 11717285809Sscottl} 11718285809Sscottl 11719285809Sscottl/***************************************************************************** 11720285809Sscottl*! \brief ossaSATADeviceResetCB 11721285809Sscottl* 11722285809Sscottl* This routine is called to complete a SATA device reset request previously 11723285809Sscottl* issued to the LL Layer in saSATADeviceReset(). 11724285809Sscottl* 11725285809Sscottl* \param agRoot: Handles for this instance of SAS/SATA hardware 11726285809Sscottl* \param agDevHandle: Pointer to a device handle 11727285809Sscottl* \param resetStatus: Reset status: 11728285809Sscottl* OSSA_SUCCESS: The reset operation completed successfully. 11729285809Sscottl* OSSA_FAILURE: The reset operation failed. 11730285809Sscottl* \param resetparm: Pointer to the Device-To-Host FIS received from the device. 11731285809Sscottl* 11732285809Sscottl* \return: none 11733285809Sscottl* 11734285809Sscottl*****************************************************************************/ 11735285809SscottlosGLOBAL void 11736285809SscottlossaSATADeviceResetCB( 11737285809Sscottl agsaRoot_t *agRoot, 11738285809Sscottl agsaDevHandle_t *agDevHandle, 11739285809Sscottl bit32 resetStatus, 11740285809Sscottl void *resetparm) 11741285809Sscottl{ 11742285809Sscottl bit32 tiResetStatus; 11743285809Sscottl tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData; 11744285809Sscottl tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot; 11745285809Sscottl tdsaDeviceData_t *pDeviceData; 11746285809Sscottl tiDeviceHandle_t *tiDeviceHandle; 11747285809Sscottl 11748285809Sscottl TI_DBG1(("ossaSATADeviceResetCB: agDevHandle=%p resetStatus=0x%x\n", 11749285809Sscottl agDevHandle, resetStatus )); 11750285809Sscottl 11751285809Sscottl pDeviceData = (tdsaDeviceData_t *) agDevHandle->osData; 11752285809Sscottl tiDeviceHandle = &(pDeviceData->tiDeviceHandle); 11753285809Sscottl 11754285809Sscottl if (resetStatus == OSSA_SUCCESS ) 11755285809Sscottl tiResetStatus = tiSuccess; 11756285809Sscottl else 11757285809Sscottl tiResetStatus = tiError; 11758285809Sscottl 11759285809Sscottl osSatResetCB( tiRoot, 11760285809Sscottl tiDeviceHandle, 11761285809Sscottl tiResetStatus, 11762285809Sscottl resetparm); 11763285809Sscottl 11764285809Sscottl} 11765285809Sscottl 11766285809Sscottl 11767285809Sscottl/*****************************************************************************/ 11768285809Sscottl/*! \brief satDecrementPendingIO 11769285809Sscottl * 11770285809Sscottl * This function decrements the number of pending IO's 11771285809Sscottl * 11772285809Sscottl * \param tiRoot: Pointer to TISA initiator driver/port instance. 11773285809Sscottl * \param tdsaAllShared: Pointer to TD context. 11774285809Sscottl * \param satIOContext_t: Pointer to the SAT IO Context 11775285809Sscottl * 11776285809Sscottl * \return 11777285809Sscottl * None 11778285809Sscottl */ 11779285809Sscottl/*****************************************************************************/ 11780285809SscottlGLOBAL void 11781285809SscottlsatDecrementPendingIO( 11782285809Sscottl tiRoot_t *tiRoot, 11783285809Sscottl tdsaContext_t *tdsaAllShared, 11784285809Sscottl satIOContext_t *satIOContext 11785285809Sscottl ) 11786285809Sscottl{ 11787285809Sscottl satDeviceData_t *satDevData; 11788285809Sscottl 11789285809Sscottl TI_DBG4(("satDecrementPendingIO: start\n")); 11790285809Sscottl 11791285809Sscottl satDevData = satIOContext->pSatDevData; 11792285809Sscottl 11793285809Sscottl if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) || 11794285809Sscottl (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) ) 11795285809Sscottl { 11796285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_SATA_LOCK); 11797285809Sscottl satDevData->satPendingNCQIO--; 11798285809Sscottl satIOContext->pSatDevData->satPendingIO--; 11799285809Sscottl TDLIST_DEQUEUE_THIS (&satIOContext->satIoContextLink); 11800285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_SATA_LOCK); 11801285809Sscottl } 11802285809Sscottl else 11803285809Sscottl { 11804285809Sscottl tdsaSingleThreadedEnter(tiRoot, TD_SATA_LOCK); 11805285809Sscottl satDevData->satPendingNONNCQIO--; 11806285809Sscottl satIOContext->pSatDevData->satPendingIO--; 11807285809Sscottl TDLIST_DEQUEUE_THIS (&satIOContext->satIoContextLink); 11808285809Sscottl tdsaSingleThreadedLeave(tiRoot, TD_SATA_LOCK); 11809285809Sscottl } 11810285809Sscottl 11811285809Sscottl return; 11812285809Sscottl} 11813285809Sscottl 11814285809SscottlGLOBAL void 11815285809SscottlsatTranslateATAPIErrorsToSCSIErrors( 11816285809Sscottl bit8 bCommand, 11817285809Sscottl bit8 bATAStatus, 11818285809Sscottl bit8 bATAError, 11819285809Sscottl bit8 *pSenseKey, 11820285809Sscottl bit16 *pSenseCodeInfo 11821285809Sscottl ) 11822285809Sscottl{ 11823285809Sscottl if (pSenseKey == agNULL || pSenseCodeInfo == agNULL) 11824285809Sscottl { 11825285809Sscottl TI_DBG0(("TranslateATAErrorsToSCSIErros: pSenseKey == agNULL || pSenseCodeInfo == agNULL\n")); 11826285809Sscottl return; 11827285809Sscottl } 11828285809Sscottl 11829285809Sscottl if((bATAStatus & ERR_ATA_STATUS_MASK) && (bATAError & NM_ATA_ERROR_MASK)) 11830285809Sscottl { 11831285809Sscottl *pSenseKey = SCSI_SNSKEY_NOT_READY; 11832285809Sscottl *pSenseCodeInfo = 0x3a00; 11833285809Sscottl } 11834285809Sscottl else if((bATAStatus & ERR_ATA_STATUS_MASK) && (bATAError & ABRT_ATA_ERROR_MASK)) 11835285809Sscottl { 11836285809Sscottl *pSenseKey = SCSI_SNSKEY_ABORTED_COMMAND; 11837285809Sscottl *pSenseCodeInfo = 0; 11838285809Sscottl } 11839285809Sscottl else if((bATAStatus & ERR_ATA_STATUS_MASK) && (bATAError & MCR_ATA_ERROR_MASK)) 11840285809Sscottl { 11841285809Sscottl *pSenseKey = SCSI_SNSKEY_UNIT_ATTENTION; 11842285809Sscottl *pSenseCodeInfo = 0x5a01; 11843285809Sscottl } 11844285809Sscottl else if((bATAStatus & ERR_ATA_STATUS_MASK) && (bATAError & IDNF_ATA_ERROR_MASK)) 11845285809Sscottl { 11846285809Sscottl *pSenseKey = SCSI_SNSKEY_MEDIUM_ERROR; 11847285809Sscottl *pSenseCodeInfo = 0x1401; 11848285809Sscottl } 11849285809Sscottl else if((bATAStatus & ERR_ATA_STATUS_MASK) && (bATAError & MC_ATA_ERROR_MASK)) 11850285809Sscottl { 11851285809Sscottl *pSenseKey = SCSI_SNSKEY_UNIT_ATTENTION; 11852285809Sscottl *pSenseCodeInfo = 0x2800; 11853285809Sscottl } 11854285809Sscottl else if((bATAStatus & ERR_ATA_STATUS_MASK) && (bATAError & UNC_ATA_ERROR_MASK)) 11855285809Sscottl { 11856285809Sscottl /*READ*/ 11857285809Sscottl *pSenseKey = SCSI_SNSKEY_MEDIUM_ERROR; 11858285809Sscottl *pSenseCodeInfo = 0x1100; 11859285809Sscottl 11860285809Sscottl /*add WRITE here */ 11861285809Sscottl } 11862285809Sscottl else if((bATAStatus & ERR_ATA_STATUS_MASK) && (bATAError & ICRC_ATA_ERROR_MASK)) 11863285809Sscottl { 11864285809Sscottl *pSenseKey = SCSI_SNSKEY_ABORTED_COMMAND; 11865285809Sscottl *pSenseCodeInfo = 0x4703; 11866285809Sscottl } 11867285809Sscottl else if((bATAStatus & DF_ATA_STATUS_MASK)) 11868285809Sscottl { 11869285809Sscottl *pSenseKey = SCSI_SNSKEY_HARDWARE_ERROR; 11870285809Sscottl *pSenseCodeInfo = 0x4400; 11871285809Sscottl } 11872285809Sscottl else 11873285809Sscottl { 11874285809Sscottl TI_DBG0(("unhandled ata error: bATAStatus = 0x%x, bATAError = 0x%x\n", 11875285809Sscottl bATAStatus, bATAError)); 11876285809Sscottl } 11877285809Sscottl 11878285809Sscottl} 11879285809Sscottl 11880285809Sscottl#endif /* #ifdef SATA_ENABLE */ 11881285809Sscottl 11882