1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
21 ********************************************************************************/
22 /*******************************************************************************/
26 * This file contains TB misc. functions
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 #include <dev/pms/config.h>
33 #include <dev/pms/freebsd/driver/common/osenv.h>
34 #include <dev/pms/freebsd/driver/common/ostypes.h>
35 #include <dev/pms/freebsd/driver/common/osdebug.h>
37 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
38 #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
39 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
41 #include <dev/pms/RefTisa/tisa/api/titypes.h>
42 #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
43 #include <dev/pms/RefTisa/tisa/api/tiapi.h>
44 #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
47 #include <dev/pms/RefTisa/sat/api/sm.h>
48 #include <dev/pms/RefTisa/sat/api/smapi.h>
49 #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
53 #include <dev/pms/RefTisa/discovery/api/dm.h>
54 #include <dev/pms/RefTisa/discovery/api/dmapi.h>
55 #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
58 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
59 #include <dev/pms/freebsd/driver/common/osstring.h>
60 #include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
62 #ifdef INITIATOR_DRIVER
63 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
64 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
65 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
69 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
70 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
71 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
74 #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
75 #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
77 /*****************************************************************************
78 *! \brief tiINIIOAbort
80 * Purpose: This function is called to abort an I/O request previously started
81 * by a call to tiINIIOStart() or tiINIIOStartDif() .
83 * \param tiRoot: Pointer to initiator driver/port instance.
84 * \param taskTag: Pointer to the associated task to be aborted
88 * tiSuccess: I/O request successfully initiated.
89 * tiBusy: No resources available, try again later.
90 * tiIONoDevice: Invalid device handle.
91 * tiError: Other errors that prevent the I/O request to be
94 *****************************************************************************/
95 #ifdef INITIATOR_DRIVER /*TBD: INITIATOR SPECIFIC API in tiapi.h (TP)*/
99 tiIORequest_t *taskTag
102 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
103 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
104 agsaRoot_t *agRoot = agNULL;
105 tdIORequestBody_t *tdIORequestBody = agNULL;
106 agsaIORequest_t *agIORequest = agNULL;
107 bit32 sasStatus = AGSA_RC_FAILURE;
108 tdsaDeviceData_t *oneDeviceData;
109 bit32 status= tiError;
110 agsaIORequest_t *agAbortIORequest;
111 tdIORequestBody_t *tdAbortIORequestBody;
114 bit32 memAllocStatus;
116 agsaDevHandle_t *agDevHandle = agNULL;
119 tdIORequestBody_t *ToBeAbortedtdIORequestBody;
120 smIORequest_t *ToBeAborted = agNULL;
122 TI_DBG2(("tiINIIOAbort: start\n"));
124 if(taskTag == agNULL)
126 TI_DBG1(("tiINIIOAbort: taskTag is NULL\n"));
130 agRoot = &(tdsaAllShared->agRootNonInt);
131 tdIORequestBody = (tdIORequestBody_t *)taskTag->tdData;
132 agIORequest = &(tdIORequestBody->agIORequest);
133 oneDeviceData = tdIORequestBody->tiDevHandle->tdData;
135 if(oneDeviceData == agNULL)
137 TI_DBG1(("tiINIIOAbort: DeviceData is NULL\n"));
141 agDevHandle = oneDeviceData->agDevHandle;
143 TI_DBG2(("tiINIIOAbort: did %d\n", oneDeviceData->id));
146 if (oneDeviceData->valid != agTRUE || oneDeviceData->registered != agTRUE ||
147 oneDeviceData->tdPortContext == agNULL )
149 TI_DBG1(("tiINIIOAbort: NO Device did %d\n", oneDeviceData->id ));
150 TI_DBG1(("tiINIIOAbort: device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
151 TI_DBG1(("tiINIIOAbort: device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
155 /* allocating agIORequest for abort itself */
156 memAllocStatus = ostiAllocMemory(
159 (void **)&tdAbortIORequestBody,
163 sizeof(tdIORequestBody_t),
166 if (memAllocStatus != tiSuccess)
168 /* let os process IO */
169 TI_DBG1(("tiINIIOAbort: ostiAllocMemory failed...\n"));
173 if (tdAbortIORequestBody == agNULL)
175 /* let os process IO */
176 TI_DBG1(("tiINIIOAbort: ostiAllocMemory returned NULL tdAbortIORequestBody\n"));
180 /* setup task management structure */
181 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle;
182 /* setting callback */
183 tdAbortIORequestBody->IOCompletionFunc = itdssIOAbortedHandler;
184 tdAbortIORequestBody->tiDevHandle = tdIORequestBody->tiDevHandle;
186 /* initialize agIORequest */
187 agAbortIORequest = &(tdAbortIORequestBody->agIORequest);
188 agAbortIORequest->osData = (void *) tdAbortIORequestBody;
189 agAbortIORequest->sdkData = agNULL; /* LL takes care of this */
191 /* remember IO to be aborted */
192 tdAbortIORequestBody->tiIOToBeAbortedRequest = taskTag;
194 if (oneDeviceData->DeviceType == TD_SAS_DEVICE)
196 sasStatus = saSSPAbort(agRoot,
198 tdsaRotateQnumber(tiRoot, oneDeviceData),
204 if (sasStatus == AGSA_RC_SUCCESS)
214 else if (oneDeviceData->DeviceType == TD_SATA_DEVICE)
216 TI_DBG2(("tiINIIOAbort: calling satIOAbort() oneDeviceData=%p\n", oneDeviceData));
218 smRoot = &(tdsaAllShared->smRoot);
219 if ( taskTag != agNULL)
221 ToBeAbortedtdIORequestBody = (tdIORequestBody_t *)taskTag->tdData;
222 ToBeAborted = &(ToBeAbortedtdIORequestBody->smIORequest);
223 status = smIOAbort(smRoot, ToBeAborted);
228 TI_DBG1(("tiINIIOAbort: taskTag is NULL!!!\n"));
235 status = satIOAbort(tiRoot, taskTag );
239 #endif /* else FDS_SM */
252 tiDeviceHandle_t *tiDeviceHandle
255 agsaRoot_t *agRoot = agNULL;
256 tdsaDeviceData_t *oneDeviceData = agNULL;
257 bit32 status = tiError;
259 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
260 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
261 smRoot_t *smRoot = &(tdsaAllShared->smRoot);
262 smDeviceHandle_t *smDeviceHandle;
265 TI_DBG1(("tiINIIOAbortAll: start\n"));
267 if (tiDeviceHandle == agNULL)
269 TI_DBG1(("tiINIIOAbortAll: tiDeviceHandle is NULL!!!\n"));
273 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
275 if (oneDeviceData == agNULL)
277 TI_DBG1(("tiINIIOAbortAll: oneDeviceData is NULL!!!\n"));
282 if (oneDeviceData->valid != agTRUE || oneDeviceData->registered != agTRUE ||
283 oneDeviceData->tdPortContext == agNULL )
285 TI_DBG1(("tiINIIOAbortAll: NO Device did %d\n", oneDeviceData->id ));
286 TI_DBG1(("tiINIIOAbortAll: device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
287 TI_DBG1(("tiINIIOAbortAll: device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
291 agRoot = oneDeviceData->agRoot;
293 if (agRoot == agNULL)
295 TI_DBG1(("tiINIIOAbortAll: agRoot is NULL!!!\n"));
299 /* this is processed in ossaSSPAbortCB, ossaSATAAbortCB, ossaSMPAbortCB */
300 if (oneDeviceData->OSAbortAll == agTRUE)
302 TI_DBG1(("tiINIIOAbortAll: already pending!!!\n"));
307 oneDeviceData->OSAbortAll = agTRUE;
311 if ( DEVICE_IS_SSP_TARGET(oneDeviceData) || DEVICE_IS_SMP_TARGET(oneDeviceData))
313 status = tdsaAbortAll(tiRoot, agRoot, oneDeviceData);
315 else if (DEVICE_IS_SATA_DEVICE(oneDeviceData) ||
316 DEVICE_IS_STP_TARGET(oneDeviceData)
319 TI_DBG2(("tiINIIOAbortAll: calling smIOAbortAll\n"));
320 smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle);
321 smDeviceHandle->tdData = oneDeviceData;
322 status = smIOAbortAll(smRoot, smDeviceHandle);
326 TI_DBG1(("tiINIIOAbortAll: unknow device type!!! 0x%x\n", oneDeviceData->target_ssp_stp_smp));
327 status = AGSA_RC_FAILURE;
330 status = tdsaAbortAll(tiRoot, agRoot, oneDeviceData);
336 #endif /* INITIATOR_DRIVER */
338 /*****************************************************************************
339 *! \brief tdsaAbortAll
341 * Purpose: This function is called to abort an all pending I/O request on a
344 * \param tiRoot: Pointer to initiator driver/port instance.
345 * \param agRoot: Pointer to chip/driver Instance.
346 * \param oneDeviceData: Pointer to the device
352 *****************************************************************************/
357 tdsaDeviceData_t *oneDeviceData
360 agsaIORequest_t *agAbortIORequest = agNULL;
361 tdIORequestBody_t *tdAbortIORequestBody = agNULL;
364 bit32 memAllocStatus;
366 bit32 status = AGSA_RC_FAILURE;
368 TI_DBG1(("tdsaAbortAll: did %d\n", oneDeviceData->id));
370 /* allocating agIORequest for abort itself */
371 memAllocStatus = ostiAllocMemory(
374 (void **)&tdAbortIORequestBody,
378 sizeof(tdIORequestBody_t),
381 if (memAllocStatus != tiSuccess)
383 /* let os process IO */
384 TI_DBG1(("tdsaAbortAll: ostiAllocMemory failed...\n"));
388 if (tdAbortIORequestBody == agNULL)
390 /* let os process IO */
391 TI_DBG1(("tdsaAbortAll: ostiAllocMemory returned NULL tdAbortIORequestBody\n"));
395 /* setup task management structure */
396 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle;
397 /* setting callback but not used later */
398 tdAbortIORequestBody->IOCompletionFunc = agNULL;
399 //tdAbortIORequestBody->IOCompletionFunc = itdssIOAbortedHandler;
401 tdAbortIORequestBody->tiDevHandle = (tiDeviceHandle_t *)&(oneDeviceData->tiDeviceHandle);
403 /* initialize agIORequest */
404 agAbortIORequest = &(tdAbortIORequestBody->agIORequest);
405 agAbortIORequest->osData = (void *) tdAbortIORequestBody;
406 agAbortIORequest->sdkData = agNULL; /* LL takes care of this */
408 if ( DEVICE_IS_SSP_TARGET(oneDeviceData))
411 status = saSSPAbort(agRoot,
413 tdsaRotateQnumber(tiRoot, oneDeviceData), //0,
414 oneDeviceData->agDevHandle,
420 else if (DEVICE_IS_SATA_DEVICE(oneDeviceData) ||
421 DEVICE_IS_STP_TARGET(oneDeviceData)
425 if (oneDeviceData->satDevData.IDDeviceValid == agFALSE)
427 TI_DBG2(("tdsaAbortAll: saSATAAbort\n"));
428 status = saSATAAbort(agRoot,
431 oneDeviceData->agDevHandle,
439 TI_DBG2(("tdsaAbortAll: saSATAAbort IDDeviceValid\n"));
440 status = saSATAAbort(agRoot,
442 tdsaRotateQnumber(tiRoot, oneDeviceData), //0,
443 oneDeviceData->agDevHandle,
450 else if (DEVICE_IS_SMP_TARGET(oneDeviceData))
453 TI_DBG2(("tdsaAbortAll: saSMPAbort \n"));
454 status = saSMPAbort(agRoot,
456 tdsaRotateQnumber(tiRoot, oneDeviceData), //0,
457 oneDeviceData->agDevHandle,
465 TI_DBG1(("tdsaAbortAll: unknown device type!!! 0x%x\n", oneDeviceData->target_ssp_stp_smp));
466 status = AGSA_RC_FAILURE;
469 if (status == AGSA_RC_SUCCESS)
475 TI_DBG1(("tdsaAbortAll: failed status=%d\n", status));
476 //failed to send abort command, we need to free the memory
479 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle,
480 sizeof(tdIORequestBody_t)
489 /*****************************************************************************
492 * Purpose: This function is called to trigger soft or hard reset
494 * \param tiRoot: Pointer to initiator driver/port instance.
495 * \param option: Options
501 *****************************************************************************/
508 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
509 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
510 agsaRoot_t *agRoot = agNULL;
513 #ifdef TI_GETFOR_ONRESET
514 agsaControllerStatus_t controllerStatus;
515 agsaForensicData_t forensicData;
518 #endif /* TI_GETFOR_ONRESET */
520 TI_DBG1(("tiCOMReset: start option 0x%x\n",option));
521 tdsaAllShared->resetCount++;
522 TI_DBG2(("tiCOMReset: reset count %d\n", tdsaAllShared->resetCount));
524 agRoot = &(tdsaAllShared->agRootNonInt);
526 if (tdsaAllShared->flags.resetInProgress == agTRUE)
528 TI_DBG1(("tiCOMReset : Reset is already in progress : \n"));
530 /* don't do anything : just return */
534 tdsaAllShared->flags.resetInProgress = agTRUE;
536 #ifdef TI_GETFOR_ONRESET
537 saGetControllerStatus(agRoot, &controllerStatus);
538 if(controllerStatus.fatalErrorInfo.errorInfo1)
541 bit8 * DirectData = (bit8 * )tdsaAllShared->FatalErrorData;
542 forensicData.DataType = TYPE_FATAL;
543 forensicData.dataBuf.directLen = (8 * 1024);
544 forensicData.dataBuf.directOffset = 0; /* current offset */
545 forensicData.dataBuf.readLen = 0; /* Data read */
547 forensicData.dataBuf.directData = DirectData;
548 status = saGetForensicData( agRoot, agNULL, &forensicData);
549 TI_DBG1(("tiCOMReset:status %d readLen 0x%x directLen 0x%x directOffset 0x%x\n",
551 forensicData.dataBuf.readLen,
552 forensicData.dataBuf.directLen,
553 forensicData.dataBuf.directOffset));
555 if( forensicData.dataBuf.readLen == forensicData.dataBuf.directLen && !status && once)
557 DirectData += forensicData.dataBuf.readLen;
560 TI_DBG1(("tiCOMReset:saGetForensicData type %d read 0x%x bytes\n", forensicData.DataType, forensicData.dataBuf.directOffset ));
563 #endif /* TI_GETFOR_ONRESET */
564 if (option == tiSoftReset)
567 TI_DBG6(("tiCOMReset: soft reset\n"));
568 saHwReset(agRoot, AGSA_SOFT_RESET, 0);
573 saHwReset(agRoot, AGSA_SOFT_RESET, 0);
576 saHwReset(agRoot, AGSA_CHIP_RESET, 0);
583 /*****************************************************************************/
584 /*! \biref tiINIReportErrorToEventLog
586 * Purpose: This function is called to report errors that needs to be logged
589 * \param tiRoot: Pointer to initiator specific root data structure for this
590 * instance of the driver.
591 * \param agEventData: Event data structure.
596 /*****************************************************************************/
597 #ifdef INITIATOR_DRIVER
599 tiINIReportErrorToEventLog(
601 tiEVTData_t *agEventData
604 TI_DBG6(("tiINIReportErrorToEventLog: start\n"));
607 #endif /* INITIATOR_DRIVER */
609 /*****************************************************************************/
610 /*! \brief ossaReenableInterrupts
613 * Purpose: This routine is called to enable interrupt
616 * \param agRoot: Pointer to chip/driver Instance.
617 * \param outboundChannelNum: Zero-base channel number
622 * \note - The scope is shared target and initiator.
625 /*****************************************************************************/
626 #ifndef ossaReenableInterrupts
628 ossaReenableInterrupts(
630 bit32 outboundChannelNum
633 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData);
657 /*****************************************************************************
658 *! \brief tiINITaskManagement
660 * Purpose: This routine is called to explicitly ask the Transport Dependent
661 * Layer to issue a Task Management command to a device.
663 * \param tiRoot: Pointer to driver instance
664 * \param tiDeviveHandle: Pointer to the device handle for this session.
665 * \param task: SAM-2 task management request.
666 * \param lun: Pointer to the SCSI-3 LUN information
667 * when applicable. Set to zero when not applicable.
668 * \param taskTag: Pointer to the associated task where the task
669 * management command is to be applied. Set to agNULL
670 * if not applicable for the specific Task Management
672 * \param currentTaskTag: The current context or task tag for this task. This
673 * task tag will be passed back in ostiInitiatorEvent()
674 * when this task management is completed.
677 * tiSuccess TM request successfully initiated.
678 * tiBusy No resources available, try again later.
679 * tiIONoDevice Invalid device handle.
680 * tiError Other errors that prevent the TM request to be started.
682 *****************************************************************************/
684 warm reset->smp phy control(hard reset) or saLocalPhyControl(AGSA_PHY_HARD_RESET)
687 #ifdef INITIATOR_DRIVER
689 tiINITaskManagement (
691 tiDeviceHandle_t *tiDeviceHandle,
694 tiIORequest_t *taskTag, /* being aborted one */
695 tiIORequest_t *currentTaskTag /* task management itself */
699 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
700 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
701 itdsaIni_t *Initiator = (itdsaIni_t *)tdsaAllShared->itdsaIni;
702 agsaRoot_t *agRoot = agNULL;
703 bit32 tiStatus = tiError;
704 bit32 notImplemented = agFALSE;
705 tdsaDeviceData_t *oneDeviceData = agNULL;
707 tdIORequestBody_t *TMtdIORequestBody;
710 bit32 memAllocStatus;
712 agsaIORequest_t *agIORequest = agNULL; /* task management itself */
713 agsaIORequest_t *agTMRequest = agNULL; /* IO being task managed */
714 agsaDevHandle_t *agDevHandle = agNULL;
715 agsaSASRequestBody_t *agSASRequestBody = agNULL;
716 agsaSSPScsiTaskMgntReq_t *agSSPTaskMgntRequest;
718 tdIORequestBody_t *tdIORequestBody;
721 smDeviceHandle_t *smDeviceHandle;
722 smIORequest_t *ToBeAborted = agNULL;
723 smIORequest_t *TaskManagement;
724 tdIORequestBody_t *ToBeAbortedtdIORequestBody;
725 tdIORequestBody_t *SMTMtdIORequestBody;
729 bit32 SMmemAllocStatus;
732 TI_DBG2(("tiINITaskManagement: start\n"));
734 /* just for testing only */
737 if(tiDeviceHandle == agNULL)
739 TI_DBG1(("tiINITaskManagement: tiDeviceHandle is NULL\n"));
743 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
744 if(oneDeviceData == agNULL)
746 TI_DBG1(("tiINITaskManagement: tiDeviceHandle=%p DeviceData is NULL\n", tiDeviceHandle));
749 TI_DBG1(("tiINITaskManagement: did %d\n", oneDeviceData->id ));
754 if (task == AG_LOGICAL_UNIT_RESET)
756 TI_DBG1(("tiINITaskManagement: failing LUN RESET for testing\n"));
765 TI_DBG6(("tiINITaskManagement: ABORT_TASK\n"));
767 case AG_ABORT_TASK_SET:
768 TI_DBG6(("tiINITaskManagement: ABORT_TASK_SET\n"));
771 TI_DBG6(("tiINITaskManagement: CLEAR_ACA\n"));
773 case AG_CLEAR_TASK_SET:
774 TI_DBG6(("tiINITaskManagement: CLEAR_TASK_SET\n"));
776 case AG_LOGICAL_UNIT_RESET:
777 TI_DBG6(("tiINITaskManagement: LOGICAL_UNIT_RESET\n"));
779 case AG_TARGET_WARM_RESET:
780 TI_DBG6(("tiINITaskManagement: TARGET_WARM_RESET\n"));
783 TI_DBG6(("tiINITaskManagement: QUERY_TASK\n"));
786 TI_DBG1(("tiINITaskManagement: notImplemented 0x%0x !!!\n",task));
787 notImplemented = agTRUE;
793 TI_DBG1(("tiINITaskManagement: not implemented 0x%0x !!!\n",task));
797 if(tiDeviceHandle == agNULL)
799 TI_DBG1(("tiINITaskManagement: tiDeviceHandle is NULL\n"));
803 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
804 if(oneDeviceData == agNULL)
806 TI_DBG1(("tiINITaskManagement: tiDeviceHandle=%p DeviceData is NULL\n", tiDeviceHandle));
811 if (oneDeviceData->valid != agTRUE || oneDeviceData->registered != agTRUE ||
812 oneDeviceData->tdPortContext == agNULL )
814 TI_DBG1(("tiINITaskManagement: NO Device did %d Addr 0x%08x:0x%08x\n", oneDeviceData->id , oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
818 /* 1. call tiINIOAbort()
819 2. call tdssTaskXmit()
822 if (oneDeviceData->DeviceType == TD_SAS_DEVICE)
824 agRoot = oneDeviceData->agRoot;
825 agDevHandle = oneDeviceData->agDevHandle;
826 TI_DBG1(("tiINITaskManagement: SAS Device\n"));
829 WARM_RESET is experimental code.
830 Needs more testing and debugging
832 if (task == AG_TARGET_WARM_RESET)
834 agsaContext_t *agContext;
835 tdsaDeviceData_t *tdsaDeviceData;
837 tdsaDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
838 currentTaskTag->tdData = tdsaDeviceData;
839 agContext = &(tdsaDeviceData->agDeviceResetContext);
840 agContext->osData = currentTaskTag;
842 TI_DBG2(("tiINITaskManagement: did %d device reset for SAS\n", oneDeviceData->id));
843 saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_IN_RECOVERY);
845 /* warm reset by saLocalPhyControl or SMP PHY control */
846 if (oneDeviceData->directlyAttached == agTRUE)
848 TI_DBG2(("tiINITaskManagement: device reset directly attached\n"));
849 saLocalPhyControl(agRoot,
851 tdsaRotateQnumber(tiRoot, oneDeviceData),
852 oneDeviceData->phyID,
860 TI_DBG2(("tiINITaskManagement: device reset expander attached\n"));
861 saStatus = tdsaPhyControlSend(tiRoot,
863 SMP_PHY_CONTROL_HARD_RESET,
865 tdsaRotateQnumber(tiRoot, oneDeviceData)
872 /* task management */
873 TI_DBG6(("tiINITaskManagement: making task management frame \n"));
874 /* 1. create task management frame
875 2. sends it using "saSSPStart()"
877 /* Allocate memory for task management */
878 memAllocStatus = ostiAllocMemory(
881 (void **)&TMtdIORequestBody,
885 sizeof(tdIORequestBody_t),
889 if (memAllocStatus != tiSuccess)
891 TI_DBG1(("tiINITaskManagement: ostiAllocMemory failed...\n"));
895 if (TMtdIORequestBody == agNULL)
897 TI_DBG1(("tiINITaskManagement: ostiAllocMemory returned NULL TMIORequestBody\n"));
902 osti_memset(TMtdIORequestBody, 0, sizeof(tdIORequestBody_t));
904 /* setup task management structure */
905 TMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle;
906 TMtdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag = currentTaskTag;
907 TMtdIORequestBody->IOType.InitiatorTMIO.TaskTag = taskTag;
909 /* let's initialize tdIOrequestBody */
910 /* initialize jump table */
912 /* direct callback for task management */
913 TMtdIORequestBody->IOCompletionFunc = itdssTaskCompleted;
915 /* TMtdIORequestBody->IOCompletionFunc = itdssIOCompleted; */
917 /* initialize tiDevhandle */
918 TMtdIORequestBody->tiDevHandle = tiDeviceHandle;
920 /* initialize tiIORequest */
921 TMtdIORequestBody->tiIORequest = currentTaskTag;
922 /* save context if we need to abort later */
923 currentTaskTag->tdData = TMtdIORequestBody;
925 /* initialize agIORequest */
926 agIORequest = &(TMtdIORequestBody->agIORequest);
927 agIORequest->osData = (void *) TMtdIORequestBody;
928 agIORequest->sdkData = agNULL; /* SA takes care of this */
931 agRequestType = AGSA_SSP_TASK_MGNT_REQ;
932 TMtdIORequestBody->agRequestType = AGSA_SSP_TASK_MGNT_REQ;
935 tdIORequestBody_t tdIORequestBody -> agSASRequestBody
937 agSASRequestBody = &(TMtdIORequestBody->transport.SAS.agSASRequestBody);
938 agSSPTaskMgntRequest = &(agSASRequestBody->sspTaskMgntReq);
940 TI_DBG2(("tiINITaskManagement: did %d LUN reset for SAS\n", oneDeviceData->id));
941 /* fill up LUN field */
944 osti_memset(agSSPTaskMgntRequest->lun, 0, 8);
948 osti_memcpy(agSSPTaskMgntRequest->lun, lun->lun, 8);
951 /* default: unconditionally set device state to SA_DS_IN_RECOVERY
955 agSSPTaskMgntRequest->tmOption = 2;
957 /* sets taskMgntFunction field */
961 agSSPTaskMgntRequest->taskMgntFunction = AGSA_ABORT_TASK;
962 /* For abort task management, unconditionally set device state to SA_DS_IN_RECOVERY
963 and if can't find, set device state to SA_DS_IN_RECOVERY
967 agSSPTaskMgntRequest->tmOption = 3;
969 case AG_ABORT_TASK_SET:
970 agSSPTaskMgntRequest->taskMgntFunction = AGSA_ABORT_TASK_SET;
973 agSSPTaskMgntRequest->taskMgntFunction = AGSA_CLEAR_ACA;
975 case AG_CLEAR_TASK_SET:
976 agSSPTaskMgntRequest->taskMgntFunction = AGSA_CLEAR_TASK_SET;
978 case AG_LOGICAL_UNIT_RESET:
979 agSSPTaskMgntRequest->taskMgntFunction = AGSA_LOGICAL_UNIT_RESET;
982 agSSPTaskMgntRequest->taskMgntFunction = AGSA_QUERY_TASK;
985 TI_DBG1(("tiINITaskManagement: notImplemented task\n"));
989 if (task == AGSA_ABORT_TASK || task == AGSA_QUERY_TASK)
991 /* set agTMRequest, which is IO being task managed */
992 tdIORequestBody = (tdIORequestBody_t *)taskTag->tdData;
993 if (tdIORequestBody == agNULL)
995 /* to be aborted IO has been completed. */
996 /* free up allocated memory */
997 TI_DBG1(("tiINITaskManagement: IO has been completed\n"));
1001 sizeof(tdIORequestBody_t)
1003 return tiIONoDevice;
1007 agTMRequest = &(tdIORequestBody->agIORequest);
1013 For LUN RESET, WARM_RESET, ABORT_TASK_SET, CLEAR_ACA and CLEAR_TASK_SET
1014 no tag to be managed.
1015 Therefore, set it to zero.
1017 agSSPTaskMgntRequest->tagOfTaskToBeManaged = 0;
1018 agTMRequest = agNULL;
1022 TDLIST_INIT_HDR(&TMtdIORequestBody->EsglPageList);
1024 if (TMtdIORequestBody->IOCompletionFunc == agNULL)
1026 TI_DBG1(("tiINITaskManagement: Error!!!!! IOCompletionFunc is NULL\n"));
1028 saStatus = saSSPStart(agRoot,
1029 agIORequest, /* task management itself */
1030 tdsaRotateQnumber(tiRoot, oneDeviceData),
1033 agSASRequestBody, /* task management itself */
1034 agTMRequest, /* io to be aborted if exits */
1038 if (saStatus == AGSA_RC_SUCCESS)
1040 Initiator->NumIOsActive++;
1041 tiStatus = tiSuccess;
1045 TI_DBG1(("tiINITaskManagement: saSSPStart failed 0x%x\n",saStatus));
1046 /* free up allocated memory */
1049 TMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
1050 sizeof(tdIORequestBody_t)
1052 if (saStatus == AGSA_RC_FAILURE)
1063 } /* end of sas device */
1066 else if (oneDeviceData->DeviceType == TD_SATA_DEVICE)
1068 agsaContext_t *agContext = agNULL;
1070 /* save the task tag in tdsaDeviceData_t structure, for handling PORT_RESET_COMPLETE hw event */
1071 agContext = &(oneDeviceData->agDeviceResetContext);
1072 agContext->osData = currentTaskTag;
1075 /* for directly attached SATA, do localphycontrol for LUN and target reset, not smTaskManagement*/
1076 if (oneDeviceData->directlyAttached == agTRUE &&
1077 (task == AG_LOGICAL_UNIT_RESET || task == AG_TARGET_WARM_RESET))
1079 agRoot = oneDeviceData->agRoot;
1080 agDevHandle = oneDeviceData->agDevHandle;
1082 currentTaskTag->tdData = oneDeviceData;
1084 if (task == AG_LOGICAL_UNIT_RESET)
1086 if ( (lun->lun[0] | lun->lun[1] | lun->lun[2] | lun->lun[3] |
1087 lun->lun[4] | lun->lun[5] | lun->lun[6] | lun->lun[7] ) != 0 )
1089 TI_DBG1(("tiINITaskManagement: *** REJECT *** LUN not zero, tiDeviceHandle=%p\n",
1094 saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_IN_RECOVERY);
1095 tiStatus = saLocalPhyControl(agRoot, agContext, tdsaRotateQnumber(tiRoot, oneDeviceData), oneDeviceData->phyID, AGSA_PHY_HARD_RESET, agNULL);
1100 smRoot = &(tdsaAllShared->smRoot);
1101 smDeviceHandle = &(oneDeviceData->smDeviceHandle);
1102 TI_DBG1(("tiINITaskManagement: FDS_SM SATA Device\n"));
1104 if ( taskTag != agNULL)
1106 ToBeAbortedtdIORequestBody = (tdIORequestBody_t *)taskTag->tdData;
1107 ToBeAborted = &(ToBeAbortedtdIORequestBody->smIORequest);
1109 SMmemAllocStatus = ostiAllocMemory(
1112 (void **)&SMTMtdIORequestBody,
1116 sizeof(tdIORequestBody_t),
1119 if (SMmemAllocStatus != tiSuccess)
1121 TI_DBG1(("tiINITaskManagement: ostiAllocMemory failed... loc 2\n"));
1125 if (SMTMtdIORequestBody == agNULL)
1127 TI_DBG1(("tiINITaskManagement: ostiAllocMemory returned NULL TMIORequestBody loc 2\n"));
1132 osti_memset(SMTMtdIORequestBody, 0, sizeof(tdIORequestBody_t));
1134 /* setup task management structure */
1135 SMTMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle = SMosMemHandle;
1136 SMTMtdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag = currentTaskTag;
1137 SMTMtdIORequestBody->IOType.InitiatorTMIO.TaskTag = taskTag;
1139 /* initialize tiDevhandle */
1140 SMTMtdIORequestBody->tiDevHandle = tiDeviceHandle;
1142 /* initialize tiIORequest */
1143 SMTMtdIORequestBody->tiIORequest = currentTaskTag;
1144 /* save context if we need to abort later */
1145 currentTaskTag->tdData = SMTMtdIORequestBody;
1147 TaskManagement = &(SMTMtdIORequestBody->smIORequest);
1149 TaskManagement->tdData = SMTMtdIORequestBody;
1150 TaskManagement->smData = &SMTMtdIORequestBody->smIORequestBody;
1152 tiStatus = smTaskManagement(smRoot,
1159 if (tiStatus != SM_RC_SUCCESS)
1161 TI_DBG1(("tiINITaskManagement: smTaskManagement failed... loc 2\n"));
1162 /* free up allocated memory */
1165 SMTMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
1166 sizeof(tdIORequestBody_t)
1172 else if (oneDeviceData->DeviceType == TD_SATA_DEVICE)
1174 agRoot = oneDeviceData->agRoot;
1175 agDevHandle = oneDeviceData->agDevHandle;
1176 TI_DBG1(("tiINITaskManagement: not FDS_SM SATA Device\n"));
1178 WARM_RESET is experimental
1179 Needs more testing and debugging
1180 Soft reset for SATA as LUN RESET tends not to work.
1183 if (task == AG_LOGICAL_UNIT_RESET || task == AG_TARGET_WARM_RESET)
1186 agsaContext_t *agContext;
1187 satDeviceData_t *satDevData;
1188 tdsaDeviceData_t *tdsaDeviceData;
1190 TI_DBG2(("tiINITaskManagement: did %d LUN reset or device reset for SATA\n", oneDeviceData->id));
1191 tdsaDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
1192 satDevData = &tdsaDeviceData->satDevData;
1193 currentTaskTag->tdData = tdsaDeviceData;
1194 agContext = &(tdsaDeviceData->agDeviceResetContext);
1195 agContext->osData = currentTaskTag;
1198 if (task == AG_LOGICAL_UNIT_RESET)
1200 if ( (lun->lun[0] | lun->lun[1] | lun->lun[2] | lun->lun[3] |
1201 lun->lun[4] | lun->lun[5] | lun->lun[6] | lun->lun[7] ) != 0 )
1203 TI_DBG1(("tiINITaskManagement: *** REJECT *** LUN not zero, tiDeviceHandle=%p\n",
1209 * Check if there is other TM request pending
1211 if (satDevData->satTmTaskTag != agNULL)
1213 TI_DBG1(("tiINITaskManagement: *** REJECT *** other TM pending, tiDeviceHandle=%p\n",
1218 satDevData->satDriveState = SAT_DEV_STATE_IN_RECOVERY;
1219 satDevData->satAbortAfterReset = agFALSE;
1221 saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_IN_RECOVERY);
1224 warm reset by saLocalPhyControl or SMP PHY control
1226 if (oneDeviceData->directlyAttached == agTRUE)
1228 TI_DBG1(("tiINITaskManagement: LUN reset or device reset directly attached\n"));
1229 saLocalPhyControl(agRoot, agContext, tdsaRotateQnumber(tiRoot, oneDeviceData), oneDeviceData->phyID, AGSA_PHY_HARD_RESET, agNULL);
1234 TI_DBG1(("tiINITaskManagement: LUN reset or device reset expander attached\n"));
1235 saStatus = tdsaPhyControlSend(tiRoot,
1237 SMP_PHY_CONTROL_HARD_RESET,
1239 tdsaRotateQnumber(tiRoot, oneDeviceData)
1246 TI_DBG2(("tiINITaskManagement: calling satTM().\n"));
1247 /* allocation tdIORequestBody and pass it to satTM() */
1248 memAllocStatus = ostiAllocMemory(
1251 (void **)&TMtdIORequestBody,
1255 sizeof(tdIORequestBody_t),
1259 if (memAllocStatus != tiSuccess)
1261 TI_DBG1(("tiINITaskManagement: ostiAllocMemory failed... loc 2\n"));
1265 if (TMtdIORequestBody == agNULL)
1267 TI_DBG1(("tiINITaskManagement: ostiAllocMemory returned NULL TMIORequestBody loc 2\n"));
1273 osti_memset(TMtdIORequestBody, 0, sizeof(tdIORequestBody_t));
1275 /* setup task management structure */
1276 TMtdIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle;
1277 TMtdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag = currentTaskTag;
1278 TMtdIORequestBody->IOType.InitiatorTMIO.TaskTag = taskTag;
1280 /* initialize tiDevhandle */
1281 TMtdIORequestBody->tiDevHandle = tiDeviceHandle;
1283 /* initialize tiIORequest */
1284 TMtdIORequestBody->tiIORequest = currentTaskTag;
1285 /* save context if we need to abort later */
1286 currentTaskTag->tdData = TMtdIORequestBody;
1288 /* initialize agIORequest */
1289 agIORequest = &(TMtdIORequestBody->agIORequest);
1290 agIORequest->osData = (void *) TMtdIORequestBody;
1291 agIORequest->sdkData = agNULL; /* SA takes care of this */
1295 tiStatus = satTM( tiRoot,
1307 #endif /* FDS_SM else*/
1311 #endif /* INITIATOR_DRIVER */
1315 tiCOMPassthroughCmndStart(
1317 tiPassthroughRequest_t *tiPassthroughRequest,
1318 tiDeviceHandle_t *tiDeviceHandle,
1319 tiPassthroughCmnd_t *tiPassthroughCmnd,
1320 void *tiPassthroughBody,
1321 tiPortalContext_t *tiportalContext,
1322 ostiPassthroughCmndEvent_t agEventCB
1325 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1326 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1327 tdsaDeviceData_t *oneDeviceData;
1328 agsaRoot_t *agRoot = agNULL;
1329 agsaIORequest_t *agIORequest = agNULL;
1330 agsaDevHandle_t *agDevHandle = agNULL;
1331 bit32 agRequestType;
1332 agsaSASRequestBody_t *agSASRequestBody = agNULL;
1334 tdPassthroughCmndBody_t *tdPTCmndBody;
1335 tdssSMPRequestBody_t *tdssSMPRequestBody;
1336 agsaSMPFrame_t *agSMPFrame;
1337 agsaSSPVSFrame_t *agSSPVendorFrame; /* RMC */
1338 bit32 SMPFn, SMPFnResult, SMPFrameLen;
1339 bit32 tiStatus = tiError;
1340 bit32 saStatus = AGSA_RC_FAILURE;
1341 tdsaPortStartInfo_t *tdsaPortStartInfo;
1342 tdsaPortContext_t *tdsaPortContext;
1344 TI_DBG2(("tiCOMPassthroughCmndStart: start\n"));
1346 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
1348 TI_DBG6(("tiCOMPassthroughCmndStart: onedevicedata %p\n", oneDeviceData));
1351 tdPTCmndBody = (tdPassthroughCmndBody_t *)tiPassthroughBody;
1354 if (tiPassthroughCmnd->passthroughCmnd != tiSMPCmnd ||
1355 tiPassthroughCmnd->passthroughCmnd != tiRMCCmnd)
1357 return tiNotSupported;
1361 if (oneDeviceData == agNULL && tiPassthroughCmnd->passthroughCmnd != tiSMPCmnd)
1363 TI_DBG1(("tiCOMPassthroughCmndStart: tiDeviceHandle=%p DeviceData is NULL\n", tiDeviceHandle ));
1364 return tiIONoDevice;
1367 /* starting IO with SAS device */
1368 if (oneDeviceData->DeviceType == TD_SAS_DEVICE)
1370 if (tiPassthroughCmnd->passthroughCmnd == tiSMPCmnd)
1372 TI_DBG2(("tiCOMPassthroughCmndStart: SMP\n"));
1373 if (oneDeviceData == agNULL)
1375 tdsaPortStartInfo = (tdsaPortStartInfo_t *)tiportalContext->tdData;
1376 tdsaPortContext = tdsaPortStartInfo->portContext;
1377 agRoot = tdsaPortContext->agRoot;
1381 agRoot = oneDeviceData->agRoot;
1382 agDevHandle = oneDeviceData->agDevHandle;
1386 tdssSMPRequestBody = &(tdPTCmndBody->protocol.SMP.SMPBody);
1387 agSASRequestBody = &(tdssSMPRequestBody->agSASRequestBody);
1388 agSMPFrame = &(agSASRequestBody->smpFrame);
1390 /* saves callback function */
1391 tdPTCmndBody->EventCB = agEventCB;
1393 /* initialize command type */
1394 tdPTCmndBody->tiPassthroughCmndType = tiSMPCmnd;
1396 /* initialize tipassthroughrequest */
1397 tdPTCmndBody->tiPassthroughRequest = tiPassthroughRequest;
1398 tiPassthroughRequest->tdData = tdPTCmndBody;
1400 /* initialize tiDevhandle */
1401 tdPTCmndBody->tiDevHandle = tiDeviceHandle;
1403 /* fill in SMP header */
1404 agSMPFrame->frameHeader.smpFrameType
1405 = tiPassthroughCmnd->protocol.SMP.SMPHeader.smpFrameType;
1406 agSMPFrame->frameHeader.smpFunction
1407 = tiPassthroughCmnd->protocol.SMP.SMPHeader.smpFunction;
1408 agSMPFrame->frameHeader.smpFunctionResult
1409 = tiPassthroughCmnd->protocol.SMP.SMPHeader.smpFunctionResult;
1410 agSMPFrame->frameHeader.smpReserved
1411 = tiPassthroughCmnd->protocol.SMP.SMPHeader.smpReserved;
1413 if (tiPassthroughCmnd->protocol.SMP.IT == SMP_INITIATOR)
1415 agRequestType = AGSA_SMP_INIT_REQ;
1419 agRequestType = AGSA_SMP_TGT_RESPONSE;
1420 /* this is only for SMP target */
1421 agSMPFrame->phyId = tiPassthroughCmnd->protocol.SMP.phyID;
1424 /* fill in payload */
1425 /* assumption: SMP payload is in tisgl1 */
1426 agSMPFrame->frameAddrUpper32 = tiPassthroughCmnd->tiSgl.upper;
1427 agSMPFrame->frameAddrLower32 = tiPassthroughCmnd->tiSgl.lower;
1429 /* This length excluding SMP header (4 bytes) and CRC field */
1430 agSMPFrame->frameLen = tiPassthroughCmnd->tiSgl.len;
1432 /* initialize agIORequest */
1435 tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
1437 agIORequest = &(tdssSMPRequestBody->agIORequest);
1438 agIORequest->osData = (void *) tdPTCmndBody;
1439 agIORequest->sdkData = agNULL; /* LL takes care of this */
1443 /* not work yet because of high priority q */
1444 saStatus = saSMPStart(
1453 if (saStatus == AGSA_RC_SUCCESS)
1455 tiStatus = tiSuccess;
1457 else if (saStatus == AGSA_RC_FAILURE)
1459 TI_DBG1(("tiCOMPassthroughCmndStart: saSMPStart failed\n"));
1465 TI_DBG1(("tiCOMPassthroughCmndStart: saSMPStart busy\n"));
1472 /* fill in SMP header */
1473 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1475 agSMPFrame->frameHeader.smpFrameType = SMP_REQUEST; /* SMP REQUEST */
1476 agRequestType = AGSA_SMP_INIT_REQ;
1481 agSMPFrame->frameHeader.smpFrameType = SMP_RESPONSE; /* SMP RESPONSE */
1482 agRequestType = AGSA_SMP_TGT_RESPONSE;
1483 switch (tdPTCmndBody->protocol.SMP.SMPFnResult)
1485 case tiSMPFunctionAccepted:
1486 SMPFnResult = SMP_FUNCTION_ACCEPTED;
1488 case tiUnknownSMPFunction:
1489 SMPFnResult = UNKNOWN_SMP_FUNCTION;
1491 case tiSMPFunctionFailed:
1492 SMPFnResult = SMP_FUNCTION_FAILED;
1494 case tiInvalidRequestFrameLength:
1495 SMPFnResult = INVALID_REQUEST_FRAME_LENGTH;
1497 case tiPhyDoesNotExist:
1498 SMPFnResult =PHY_DOES_NOT_EXIST;
1500 case tiIndexDoesNotExist:
1501 SMPFnResult = INDEX_DOES_NOT_EXIST;
1503 case tiPhyDoesNotSupportSATA:
1504 SMPFnResult = PHY_DOES_NOT_SUPPORT_SATA;
1506 case tiUnknownPhyOperation:
1507 SMPFnResult = UNKNOWN_PHY_OPERATION;
1509 case tiUnknownPhyTestFunction:
1510 SMPFnResult = UNKNOWN_PHY_TEST_FUNCTION;
1512 case tiPhyTestFunctionInProgress:
1513 SMPFnResult = PHY_TEST_FUNCTION_IN_PROGRESS;
1516 SMPFnResult = PHY_VACANT;
1520 TI_DBG1(("tiCOMPassthroughCmndStart: unknown SMP function result %d\n", tdPTCmndBody->protocol.SMP.SMPFnResult));
1523 agSMPFrame->frameHeader.smpFunctionResult = SMPFnResult;
1527 switch (tdPTCmndBody->protocol.SMP.SMPFn)
1530 SMPFn = SMP_REPORT_GENERAL;
1531 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1537 SMPFrameLen = sizeof(smpRespReportGeneral_t);
1541 case tiManufacturerInfo:
1542 SMPFn = SMP_REPORT_MANUFACTURE_INFORMATION;
1543 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1549 SMPFrameLen = sizeof(smpRespReportManufactureInfo_t);
1554 SMPFn = SMP_DISCOVER;
1555 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1557 SMPFrameLen = sizeof(smpReqDiscover_t);
1561 SMPFrameLen = sizeof(smpRespDiscover_t);
1565 case tiReportPhyErrLog:
1566 SMPFn = SMP_REPORT_PHY_ERROR_LOG;
1567 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1577 case tiReportPhySATA:
1578 SMPFn = SMP_REPORT_PHY_SATA;
1579 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1581 SMPFrameLen = sizeof(SmpReqReportPhySata_t);
1585 SMPFrameLen = sizeof(SmpRespReportPhySata_t);
1589 case tiReportRteInfo:
1590 SMPFn = SMP_REPORT_ROUTING_INFORMATION;
1591 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1593 SMPFrameLen = sizeof(SmpReqReportRouteTable_t);
1597 SMPFrameLen = sizeof(SmpRespReportRouteTable_t);
1601 case tiConfigureRteInfo:
1602 SMPFn = SMP_CONFIGURE_ROUTING_INFORMATION;;
1603 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1605 SMPFrameLen = sizeof(SmpReqConfigureRouteInformation_t);
1614 SMPFn = SMP_PHY_CONTROL;
1615 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1617 SMPFrameLen = sizeof(SmpReqPhyControl_t);
1626 SMPFn = SMP_PHY_TEST_FUNCTION;
1627 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1638 SMPFn = SMP_PMC_SPECIFIC;
1639 if (tdPTCmndBody->protocol.SMP.IT == SMP_INITIATOR)
1651 TI_DBG1(("tiCOMPassthroughCmndStart: unknown SMP function %d\n", tdPTCmndBody->protocol.SMP.SMPFn));
1654 agSMPFrame->frameHeader.smpFunction = SMPFn;
1657 /* assumption: SMP payload is in tisgl1 */
1658 agSMPFrame->frameAddrUpper32 = tdPTCmndBody->tiSgl.upper;
1659 agSMPFrame->frameAddrLower32 = tdPTCmndBody->tiSgl.lower;
1661 /* This length excluding SMP header (4 bytes) and CRC field */
1662 agSMPFrame->frameLen = SMPFrameLen;
1673 else if (tiPassthroughCmnd->passthroughCmnd == tiRMCCmnd)
1675 TI_DBG2(("tiCOMPassthroughCmndStart: RMC\n"));
1679 TI_DBG1(("tiCOMPassthroughCmndStart: unknown protocol %d\n", tiPassthroughCmnd->passthroughCmnd));
1684 else if (oneDeviceData->DeviceType == TD_SATA_DEVICE)
1686 TI_DBG1(("tiCOMPassthroughCmndStart: error !!! no SATA support\n"));
1691 TI_DBG1(("tiCOMPassthroughCmndStart: error !!! unknown devietype %d\n", oneDeviceData->DeviceType));
1701 tiCOMPassthroughCmndAbort(
1703 tiPassthroughRequest_t *taskTag
1706 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1707 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1708 agsaRoot_t *agRoot = agNULL;
1709 tdPassthroughCmndBody_t *tdPTCmndBody = agNULL;
1710 tdssSMPRequestBody_t *tdssSMPRequestBody = agNULL;
1711 agsaIORequest_t *agIORequest = agNULL;
1712 bit32 saStatus, tiStatus = tiError;
1714 TI_DBG2(("tiCOMPassthroughCmndAbort: start\n"));
1716 agRoot = &(tdsaAllShared->agRootNonInt);
1717 tdPTCmndBody = (tdPassthroughCmndBody_t *)taskTag->tdData;
1719 if (tdPTCmndBody->tiPassthroughCmndType == tiSMPCmnd)
1721 tdssSMPRequestBody = &(tdPTCmndBody->protocol.SMP.SMPBody);
1722 agIORequest = &(tdssSMPRequestBody->agIORequest);
1724 saStatus = saSMPAbort(agRoot, agIORequest);
1726 if (saStatus == AGSA_RC_SUCCESS)
1728 tiStatus = tiSuccess;
1730 else if (saStatus == AGSA_RC_FAILURE)
1732 TI_DBG1(("tiCOMPassthroughCmndAbort: saSMPAbort failed\n"));
1738 TI_DBG1(("tiCOMPassthroughCmndAbort: saSMPAbort busy\n"));
1743 else if (tdPTCmndBody->tiPassthroughCmndType == tiRMCCmnd)
1745 TI_DBG1(("tiCOMPassthroughCmndAbort: RMC passthrough command type, not yet\n"));
1750 TI_DBG1(("tiCOMPassthroughCmndAbort: unknown passthrough command type %d\n", tdPTCmndBody->tiPassthroughCmndType));
1758 tiINIPassthroughCmndRemoteAbort(
1760 tiDeviceHandle_t *tiDeviceHandle,
1761 tiPassthroughRequest_t *taskTag,
1762 tiPassthroughRequest_t *currentTaskTag,
1763 tiPortalContext_t *tiportalContext
1766 TI_DBG2(("tiINIPassthroughCmndRemoteAbort: start\n"));
1768 for SMP, nothing. Can't abot remotely
1772 #endif /* PASSTHROUGH */
1775 /*****************************************************************************
1776 *! \brief tiCOMShutDown
1778 * Purpose: This function is called to shutdown the initiator and/or target
1779 * operation. Following the completion of this call, the state is
1780 * equivalent to the state prior to tiCOMInit()
1782 * \param tiRoot: Pointer to root data structure.
1787 *****************************************************************************/
1789 tiCOMShutDown( tiRoot_t *tiRoot)
1791 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1792 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1794 // #define TI_GETFOR_ONSHUTDOWN
1795 #ifdef TI_GETFOR_ONSHUTDOWN
1796 agsaForensicData_t forensicData;
1799 #endif /* TI_GETFOR_ONSHUTDOWN */
1801 agsaRoot_t *agRoot = agNULL;
1803 TI_DBG1(("tiCOMShutDown: start\n"));
1806 agRoot = &(tdsaAllShared->agRootNonInt);
1809 2. call saHwShutdown()
1810 3. tdInitEsgl(tiRoot);
1811 4. tdsaResetComMemFlags(tiRoot)
1815 tdsaFreeCardID(tiRoot, tdsaAllShared->CardID);
1817 #ifdef TI_GETFOR_ONSHUTDOWN
1818 forensicData.DataType = TYPE_NON_FATAL;
1819 forensicData.dataBuf.directLen = (8 * 1024);
1820 forensicData.dataBuf.directOffset = 0; /* current offset */
1821 forensicData.dataBuf.directData = agNULL;
1822 forensicData.dataBuf.readLen = 0; /* Data read */
1825 status = saGetForensicData( agRoot, agNULL, &forensicData);
1827 TI_DBG1(("tiCOMShutDown:readLen 0x%x directLen 0x%x directOffset 0x%x\n",
1828 forensicData.dataBuf.readLen,
1829 forensicData.dataBuf.directLen,
1830 forensicData.dataBuf.directOffset));
1831 if( forensicData.dataBuf.readLen == forensicData.dataBuf.directLen && !status && once)
1836 TI_DBG1(("tiCOMShutDown:saGetForensicData type %d read 0x%x bytes\n", forensicData.DataType, forensicData.dataBuf.directOffset ));
1837 #endif /* TI_GETFOR_ONSHUTDOWN */
1839 saHwShutdown(agRoot);
1841 /* resets all the relevant flags */
1842 tdsaResetComMemFlags(tiRoot);
1845 * send an event to the oslayer
1857 #ifdef INITIATOR_DRIVER
1859 tiINITimerTick( tiRoot_t *tiRoot )
1862 no timer is used in SAS TD layer.
1863 Therefore, this function is null.
1865 // TI_DBG2(("tiINITimerTick: start\n"));
1866 /*itdsaProcessTimers(tiRoot);*/
1871 /*****************************************************************************/
1872 /*! \brief ossaDisableInterrupts
1875 * Purpose: This routine is called to disable interrupt
1878 * \param agRoot: Pointer to chip/driver Instance.
1879 * \param outboundChannelNum: Zero-base channel number
1884 * \note - The scope is shared target and initiator.
1887 /*****************************************************************************/
1888 #ifndef ossaDisableInterrupts
1890 ossaDisableInterrupts(
1892 bit32 outboundChannelNum
1895 tdsaRootOsData_t *osData = (tdsaRootOsData_t *) (agRoot->osData);
1897 ostiInterruptDisable(
1908 tiCOMFrameReadBlock(
1915 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1916 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
1917 agsaRoot_t *agRoot = agNULL;
1919 TI_DBG6(("tiCOMFrameReadBlock: start\n"));
1922 agRoot = &(tdsaAllShared->agRootNonInt);
1925 TI_DBG6(("tiCOMFrameReadBlock: start\n"));
1927 saFrameReadBlock(agRoot, agFrame, FrameOffset, FrameBuffer, FrameBufLen);
1934 /*****************************************************************************
1935 *! \brief tiINITransportRecovery
1937 * Purpose: This routine is called to explicitly ask the Transport Dependent
1938 * Layer to initiate the recovery for the transport/protocol specific
1939 * error for a specific device connection.
1941 * \param tiRoot: Pointer to driver instance
1942 * \param tiDeviveHandle: Pointer to the device handle for this session.
1947 *****************************************************************************/
1948 #ifdef INITIATOR_DRIVER
1950 tiINITransportRecovery (
1952 tiDeviceHandle_t *tiDeviceHandle
1955 agsaRoot_t *agRoot = agNULL;
1956 tdsaDeviceData_t *oneDeviceData = agNULL;
1957 tdsaPortContext_t *onePortContext = agNULL;
1958 tiPortalContext_t *tiPortalContext = agNULL;
1959 tiIORequest_t *currentTaskTag;
1960 agsaDevHandle_t *agDevHandle = agNULL;
1962 TI_DBG1(("tiINITransportRecovery: start\n"));
1964 if (tiDeviceHandle == agNULL)
1966 TI_DBG1(("tiINITransportRecovery: tiDeviceHandle is NULL\n"));
1971 oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
1973 if (oneDeviceData == agNULL)
1975 TI_DBG1(("tiINITransportRecovery: oneDeviceData is NULL\n"));
1980 if (oneDeviceData->valid != agTRUE || oneDeviceData->registered != agTRUE ||
1981 oneDeviceData->tdPortContext == agNULL )
1983 TI_DBG1(("tiINITransportRecovery: NO Device did %d\n", oneDeviceData->id ));
1984 TI_DBG1(("tiINITransportRecovery: device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
1985 TI_DBG1(("tiINITransportRecovery: device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
1989 onePortContext = oneDeviceData->tdPortContext;
1991 if (onePortContext == agNULL)
1993 TI_DBG1(("tiINITransportRecovery: onePortContext is NULL\n"));
1997 tiPortalContext = onePortContext->tiPortalContext;
1998 currentTaskTag = &(oneDeviceData->TransportRecoveryIO);
1999 currentTaskTag->osData = agNULL;
2000 agRoot = oneDeviceData->agRoot;
2001 agDevHandle = oneDeviceData->agDevHandle;
2003 if (oneDeviceData->DeviceType == TD_SAS_DEVICE)
2005 agsaContext_t *agContext;
2006 currentTaskTag->tdData = oneDeviceData;
2007 agContext = &(oneDeviceData->agDeviceResetContext);
2008 agContext->osData = currentTaskTag;
2009 oneDeviceData->TRflag = agTRUE;
2011 TI_DBG2(("tiINITransportRecovery: SAS device\n"));
2012 saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_IN_RECOVERY);
2014 if (oneDeviceData->directlyAttached == agTRUE)
2016 TI_DBG2(("tiINITransportRecovery: saLocalPhyControl\n"));
2017 saLocalPhyControl(agRoot, agContext, tdsaRotateQnumber(tiRoot, oneDeviceData), oneDeviceData->phyID, AGSA_PHY_HARD_RESET, agNULL);
2018 ostiInitiatorEvent(tiRoot,
2021 tiIntrEventTypeTransportRecovery,
2030 TI_DBG2(("tiINITransportRecovery: device reset expander attached\n"));
2031 tdsaPhyControlSend(tiRoot,
2033 SMP_PHY_CONTROL_HARD_RESET,
2035 tdsaRotateQnumber(tiRoot, oneDeviceData)
2037 ostiInitiatorEvent(tiRoot,
2040 tiIntrEventTypeTransportRecovery,
2047 else if (oneDeviceData->DeviceType == TD_SATA_DEVICE)
2049 agsaContext_t *agContext;
2050 currentTaskTag->tdData = oneDeviceData;
2051 agContext = &(oneDeviceData->agDeviceResetContext);
2052 agContext->osData = currentTaskTag;
2053 oneDeviceData->TRflag = agTRUE;
2055 TI_DBG2(("tiINITransportRecovery: SATA device\n"));
2056 saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_IN_RECOVERY);
2058 if (oneDeviceData->directlyAttached == agTRUE)
2060 TI_DBG2(("tiINITransportRecovery: saLocalPhyControl\n"));
2061 saLocalPhyControl(agRoot, agContext, tdsaRotateQnumber(tiRoot, oneDeviceData), oneDeviceData->phyID, AGSA_PHY_LINK_RESET, agNULL);
2062 ostiInitiatorEvent(tiRoot,
2065 tiIntrEventTypeTransportRecovery,
2074 TI_DBG2(("tiINITransportRecovery: device reset expander attached\n"));
2075 tdsaPhyControlSend(tiRoot,
2077 SMP_PHY_CONTROL_LINK_RESET,
2079 tdsaRotateQnumber(tiRoot, oneDeviceData)
2081 ostiInitiatorEvent(tiRoot,
2084 tiIntrEventTypeTransportRecovery,
2093 TI_DBG1(("tiINITransportRecovery: wrong device type %d\n", oneDeviceData->DeviceType));
2101 #if defined (INITIATOR_DRIVER) && defined (TARGET_DRIVER)
2102 /*****************************************************************************
2103 *! \brief tdsaPhyControlSend
2105 * Purpose: This function sends Phy Control to a device.
2107 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
2109 * \param oneDeviceData: Pointer to the device data.
2110 * \param phyId: Phy Identifier.
2111 * \param queueNumber: bits 0-15: inbound queue number.
2112 * bits 16-31: outbound queue number.
2119 *****************************************************************************/
2120 /* phyop of interest
2121 SMP_PHY_CONTROL_HARD_RESET or SMP_PHY_CONTROL_CLEAR_AFFILIATION
2122 if CurrentTaskTag == agNULL, clear affiliation
2123 if CurrentTaskTag != agNULL, PHY_CONTROL (device reset)
2129 tdsaDeviceData_t *oneDeviceData, /* taget disk */
2131 tiIORequest_t *CurrentTaskTag,
2139 #ifdef TARGET_DRIVER
2140 /*****************************************************************************
2141 *! \brief tdsaPhyControlSend
2143 * Purpose: This function sends Phy Control to a device.
2145 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
2147 * \param oneDeviceData: Pointer to the device data.
2148 * \param phyId: Phy Identifier.
2149 * \param queueNumber: bits 0-15: inbound queue number.
2150 * bits 16-31: outbound queue number.
2157 *****************************************************************************/
2158 /* phyop of interest
2159 SMP_PHY_CONTROL_HARD_RESET or SMP_PHY_CONTROL_CLEAR_AFFILIATION
2160 if CurrentTaskTag == agNULL, clear affiliation
2161 if CurrentTaskTag != agNULL, PHY_CONTROL (device reset)
2167 tdsaDeviceData_t *oneDeviceData, /* taget disk */
2169 tiIORequest_t *CurrentTaskTag,
2178 #ifdef INITIATOR_DRIVER
2179 /*****************************************************************************
2180 *! \brief tdsaPhyControlSend
2182 * Purpose: This function sends Phy Control to a device.
2184 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
2186 * \param oneDeviceData: Pointer to the device data.
2187 * \param phyId: Phy Identifier.
2188 * \param queueNumber: bits 0-15: inbound queue number.
2189 * bits 16-31: outbound queue number.
2196 *****************************************************************************/
2197 /* phyop of interest
2198 SMP_PHY_CONTROL_HARD_RESET or SMP_PHY_CONTROL_CLEAR_AFFILIATION
2199 if CurrentTaskTag == agNULL, clear affiliation
2200 if CurrentTaskTag != agNULL, PHY_CONTROL (device reset)
2206 tdsaDeviceData_t *oneDeviceData, /* taget disk */
2208 tiIORequest_t *CurrentTaskTag,
2213 tdsaDeviceData_t *oneExpDeviceData;
2214 tdsaPortContext_t *onePortContext;
2215 smpReqPhyControl_t smpPhyControlReq;
2219 TI_DBG3(("tdsaPhyControlSend: start\n"));
2221 agRoot = oneDeviceData->agRoot;
2222 onePortContext = oneDeviceData->tdPortContext;
2223 oneExpDeviceData = oneDeviceData->ExpDevice;
2224 phyID = oneDeviceData->phyID;
2226 if (oneDeviceData->directlyAttached == agTRUE)
2228 TI_DBG1(("tdsaPhyControlSend: Error!!! deivce is directly attached\n"));
2229 return AGSA_RC_FAILURE;
2231 if (onePortContext == agNULL)
2233 TI_DBG1(("tdsaPhyControlSend: Error!!! portcontext is NULL\n"));
2234 return AGSA_RC_FAILURE;
2237 if (oneExpDeviceData == agNULL)
2239 TI_DBG1(("tdsaPhyControlSend: Error!!! expander is NULL\n"));
2240 return AGSA_RC_FAILURE;
2243 if (phyOp == SMP_PHY_CONTROL_HARD_RESET)
2245 TI_DBG3(("tdsaPhyControlSend: SMP_PHY_CONTROL_HARD_RESET\n"));
2247 if (phyOp == SMP_PHY_CONTROL_LINK_RESET)
2249 TI_DBG3(("tdsaPhyControlSend: SMP_PHY_CONTROL_LINK_RESET\n"));
2251 if (phyOp == SMP_PHY_CONTROL_CLEAR_AFFILIATION)
2253 TI_DBG3(("tdsaPhyControlSend: SMP_PHY_CONTROL_CLEAR_AFFILIATION\n"));
2255 TI_DBG3(("tdsaPhyControlSend: target device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
2256 TI_DBG3(("tdsaPhyControlSend: target device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
2257 TI_DBG3(("tdsaPhyControlSend: expander AddrHi 0x%08x\n", oneExpDeviceData->SASAddressID.sasAddressHi));
2258 TI_DBG3(("tdsaPhyControlSend: expander AddrLo 0x%08x\n", oneExpDeviceData->SASAddressID.sasAddressLo));
2259 TI_DBG3(("tdsaPhyControlSend: did %d expander did %d phyid %d\n", oneDeviceData->id, oneExpDeviceData->id, phyID));
2262 osti_memset(&smpPhyControlReq, 0, sizeof(smpReqPhyControl_t));
2264 /* fill in SMP payload */
2265 smpPhyControlReq.phyIdentifier = phyID;
2266 smpPhyControlReq.phyOperation = phyOp;
2268 status = tdSMPStart(
2273 (bit8 *)&smpPhyControlReq,
2274 sizeof(smpReqPhyControl_t),
2283 /*****************************************************************************
2284 *! \brief tdsaPhyControlFailureRespRcvd
2286 * Purpose: This function processes the failure of Phy Control response.
2288 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
2290 * \param agRoot: Pointer to chip/driver Instance.
2291 * \param oneDeviceData: Pointer to the device data.
2292 * \param frameHeader: Pointer to SMP frame header.
2293 * \param frameHandle: A Handle used to refer to the response frame
2300 *****************************************************************************/
2302 tdsaPhyControlFailureRespRcvd(
2305 tdsaDeviceData_t *oneDeviceData,
2306 tdssSMPFrameHeader_t *frameHeader,
2307 agsaFrameHandle_t frameHandle,
2308 tiIORequest_t *CurrentTaskTag
2311 #if defined(INITIATOR_DRIVER) || defined(TD_DEBUG_ENABLE)
2312 tdsaDeviceData_t *TargetDeviceData = agNULL;
2314 #ifdef TD_DEBUG_ENABLE
2315 satDeviceData_t *pSatDevData = agNULL;
2317 // agsaDevHandle_t *agDevHandle = agNULL;
2319 TI_DBG1(("tdsaPhyControlFailureRespRcvd: start\n"));
2321 TI_DBG3(("tdsaPhyControlFailureRespRcvd: expander device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
2322 TI_DBG3(("tdsaPhyControlFailureRespRcvd: expander device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
2324 if (CurrentTaskTag != agNULL )
2326 /* This was set in tiINITaskmanagement() */
2327 #if defined(INITIATOR_DRIVER) || defined(TD_DEBUG_ENABLE)
2328 TargetDeviceData = (tdsaDeviceData_t *)CurrentTaskTag->tdData;
2330 #ifdef TD_DEBUG_ENABLE
2331 pSatDevData = (satDeviceData_t *)&(TargetDeviceData->satDevData);
2333 // agDevHandle = TargetDeviceData->agDevHandle;
2334 TI_DBG2(("tdsaPhyControlFailureRespRcvd: target AddrHi 0x%08x\n", TargetDeviceData->SASAddressID.sasAddressHi));
2335 TI_DBG2(("tdsaPhyControlFailureRespRcvd: target AddrLo 0x%08x\n", TargetDeviceData->SASAddressID.sasAddressLo));
2337 #ifdef TD_DEBUG_ENABLE
2338 TI_DBG2(("tdsaPhyControlFailureRespRcvd: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO ));
2339 TI_DBG2(("tdsaPhyControlFailureRespRcvd: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO));
2343 #ifdef INITIATOR_DRIVER
2344 if (CurrentTaskTag != agNULL )
2346 TI_DBG1(("tdsaPhyControlRespRcvd: callback to OS layer with failure\n"));
2347 if (TargetDeviceData->TRflag == agTRUE)
2349 TargetDeviceData->TRflag = agFALSE;
2350 ostiInitiatorEvent(tiRoot,
2351 TargetDeviceData->tdPortContext->tiPortalContext,
2352 &(TargetDeviceData->tiDeviceHandle),
2353 tiIntrEventTypeTransportRecovery,
2360 ostiInitiatorEvent( tiRoot,
2363 tiIntrEventTypeTaskManagement,
2371 /*****************************************************************************
2372 *! \brief tdsaPhyControlRespRcvd
2374 * Purpose: This function processes Phy Control response.
2376 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
2378 * \param agRoot: Pointer to chip/driver Instance.
2379 * \param oneDeviceData: Pointer to the device data.
2380 * \param frameHeader: Pointer to SMP frame header.
2381 * \param frameHandle: A Handle used to refer to the response frame
2388 *****************************************************************************/
2390 tdsaPhyControlRespRcvd(
2393 agsaIORequest_t *agIORequest,
2394 tdsaDeviceData_t *oneDeviceData,
2395 tdssSMPFrameHeader_t *frameHeader,
2396 agsaFrameHandle_t frameHandle,
2397 tiIORequest_t *CurrentTaskTag
2400 #if defined(INITIATOR_DRIVER) || defined(TD_DEBUG_ENABLE)
2401 tdsaDeviceData_t *TargetDeviceData = agNULL;
2403 #ifdef INITIATOR_DRIVER
2404 satDeviceData_t *pSatDevData = agNULL;
2405 agsaDevHandle_t *agDevHandle = agNULL;
2408 TI_DBG3(("tdsaPhyControlRespRcvd: start\n"));
2410 TI_DBG3(("tdsaPhyControlRespRcvd: expander device AddrHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
2411 TI_DBG3(("tdsaPhyControlRespRcvd: expander device AddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
2413 if (CurrentTaskTag != agNULL )
2415 /* This was set in tiINITaskmanagement() */
2416 #if defined(INITIATOR_DRIVER) || defined(TD_DEBUG_ENABLE)
2417 TargetDeviceData = (tdsaDeviceData_t *)CurrentTaskTag->tdData;
2419 #ifdef INITIATOR_DRIVER
2420 pSatDevData = (satDeviceData_t *)&(TargetDeviceData->satDevData);
2421 agDevHandle = TargetDeviceData->agDevHandle;
2423 TI_DBG2(("tdsaPhyControlRespRcvd: target AddrHi 0x%08x\n", TargetDeviceData->SASAddressID.sasAddressHi));
2424 TI_DBG2(("tdsaPhyControlRespRcvd: target AddrLo 0x%08x\n", TargetDeviceData->SASAddressID.sasAddressLo));
2426 #ifdef INITIATOR_DRIVER
2427 TI_DBG2(("tdsaPhyControlRespRcvd: satPendingIO %d satNCQMaxIO %d\n", pSatDevData->satPendingIO, pSatDevData->satNCQMaxIO ));
2428 TI_DBG2(("tdsaPhyControlRespRcvd: satPendingNCQIO %d satPendingNONNCQIO %d\n", pSatDevData->satPendingNCQIO, pSatDevData->satPendingNONNCQIO));
2432 #ifdef INITIATOR_DRIVER
2434 if (frameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
2436 TI_DBG3(("tdsaPhyControlRespRcvd: SMP success\n"));
2438 /* warm reset or clear affiliation is done
2439 call ostiInitiatorEvent()
2441 if (CurrentTaskTag != agNULL )
2443 TI_DBG3(("tdsaPhyControlRespRcvd: callback to OS layer with success\n"));
2444 pSatDevData->satDriveState = SAT_DEV_STATE_NORMAL;
2445 saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, TargetDeviceData), agDevHandle, SA_DS_OPERATIONAL);
2447 if (TargetDeviceData->TRflag == agTRUE)
2449 TargetDeviceData->TRflag = agFALSE;
2450 ostiInitiatorEvent(tiRoot,
2451 TargetDeviceData->tdPortContext->tiPortalContext,
2452 &(TargetDeviceData->tiDeviceHandle),
2453 tiIntrEventTypeTransportRecovery,
2460 agDevHandle = TargetDeviceData->agDevHandle;
2461 if (agDevHandle == agNULL)
2463 TI_DBG1(("tdsaPhyControlRespRcvd: wrong, agDevHandle is NULL\n"));
2465 ostiInitiatorEvent( tiRoot,
2468 tiIntrEventTypeTaskManagement,
2477 TI_DBG1(("tdsaPhyControlRespRcvd: SMP failure; result %d\n", frameHeader->smpFunctionResult));
2478 /* warm reset or clear affiliation is done
2480 if (CurrentTaskTag != agNULL )
2482 TI_DBG1(("tdsaPhyControlRespRcvd: callback to OS layer with failure\n"));
2483 if (TargetDeviceData->TRflag == agTRUE)
2485 TargetDeviceData->TRflag = agFALSE;
2486 ostiInitiatorEvent(tiRoot,
2487 TargetDeviceData->tdPortContext->tiPortalContext,
2488 &(TargetDeviceData->tiDeviceHandle),
2489 tiIntrEventTypeTransportRecovery,
2496 ostiInitiatorEvent( tiRoot,
2499 tiIntrEventTypeTaskManagement,
2511 #ifdef TARGET_DRIVER
2512 /*****************************************************************************
2513 *! \brief ttdsaAbortAll
2515 * Purpose: This function is called to abort an all pending I/O request on a
2518 * \param tiRoot: Pointer to initiator driver/port instance.
2519 * \param agRoot: Pointer to chip/driver Instance.
2520 * \param oneDeviceData: Pointer to the device
2526 *****************************************************************************/
2529 should we allocate tdAbortIORequestBody or get one from ttdsaXchg_t?
2530 Currently, we allocate tdAbortIORequestBody.
2536 tdsaDeviceData_t *oneDeviceData
2539 agsaIORequest_t *agAbortIORequest = agNULL;
2540 tdIORequestBody_t *tdAbortIORequestBody = agNULL;
2543 bit32 memAllocStatus;
2546 TI_DBG3(("tdsaAbortAll: start\n"));
2548 TI_DBG3(("tdsaAbortAll: did %d\n", oneDeviceData->id));
2551 /* allocating agIORequest for abort itself */
2552 memAllocStatus = ostiAllocMemory(
2555 (void **)&tdAbortIORequestBody,
2559 sizeof(tdIORequestBody_t),
2562 if (memAllocStatus != tiSuccess)
2564 /* let os process IO */
2565 TI_DBG1(("tdsaAbortAll: ostiAllocMemory failed...\n"));
2569 if (tdAbortIORequestBody == agNULL)
2571 /* let os process IO */
2572 TI_DBG1(("tdsaAbortAll: ostiAllocMemory returned NULL tdAbortIORequestBody\n"));
2576 /* setup task management structure */
2577 tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle;
2578 /* setting callback */
2579 /* not needed; it is already set to be ossaSSPAbortCB() */
2580 tdAbortIORequestBody->IOCompletionFunc = ttdssIOAbortedHandler;
2582 tdAbortIORequestBody->tiDevHandle = (tiDeviceHandle_t *)&(oneDeviceData->tiDeviceHandle);
2584 /* initialize agIORequest */
2585 agAbortIORequest = &(tdAbortIORequestBody->agIORequest);
2586 agAbortIORequest->osData = (void *) tdAbortIORequestBody;
2587 agAbortIORequest->sdkData = agNULL; /* LL takes care of this */
2593 oneDeviceData->agDevHandle,
2600 #endif /* TARGET_DRIVER */
2604 tdsaDeregisterDevicesInPort(
2606 tdsaPortContext_t *onePortContext
2609 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2610 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2611 tdsaDeviceData_t *oneDeviceData = agNULL;
2612 tdList_t *DeviceListList;
2613 agsaRoot_t *agRoot = agNULL;
2615 agRoot = &(tdsaAllShared->agRootNonInt);
2617 TI_DBG1(("tdsaDeregisterDevicesInPort: start\n"));
2619 /* find a device's existence */
2620 DeviceListList = tdsaAllShared->MainDeviceList.flink;
2621 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
2623 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
2624 if (oneDeviceData == agNULL)
2626 TI_DBG1(("tdsaDeregisterDevicesInPort: oneDeviceData is NULL!!!\n"));
2629 if (oneDeviceData->tdPortContext == onePortContext)
2631 TI_DBG3(("tdsaDeregisterDevicesInPort: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
2632 if ( !( DEVICE_IS_SMP_TARGET(oneDeviceData) && oneDeviceData->directlyAttached == agTRUE))
2634 saDeregisterDeviceHandle(agRoot, agNULL, oneDeviceData->agDevHandle, tdsaRotateQnumber(tiRoot, oneDeviceData));
2638 TI_DBG1(("tdsaDeregisterDevicesInPort: keeping\n"));
2639 oneDeviceData->registered = agTRUE;
2642 DeviceListList = DeviceListList->flink;
2645 TI_DBG3(("tdsaDeregisterDevicesInPort: end\n"));
2650 /******************** for debugging only ***************************/
2653 agsaSwConfig_t *SwConfig
2656 if (SwConfig == agNULL)
2658 TI_DBG6(("tdsaPrintSwConfig: SwConfig is NULL\n"));
2663 TI_DBG6(("SwConfig->maxActiveIOs %d\n", SwConfig->maxActiveIOs));
2664 TI_DBG6(("SwConfig->smpReqTimeout %d\n", SwConfig->smpReqTimeout));
2673 agsaHwConfig_t *HwConfig
2676 if (HwConfig == agNULL)
2678 TI_DBG6(("tdsaPrintHwConfig: HwConfig is NULL\n"));
2683 TI_DBG6(("HwConfig->phyCount %d\n", HwConfig->phyCount));
2689 tdssPrintSASIdentify(
2690 agsaSASIdentify_t *id
2695 TI_DBG1(("tdsaPrintSASIdentify: ID is NULL\n"));
2700 TI_DBG6(("SASID->sspTargetPort %d\n", SA_IDFRM_IS_SSP_TARGET(id)?1:0));
2701 TI_DBG6(("SASID->stpTargetPort %d\n", SA_IDFRM_IS_STP_TARGET(id)?1:0));
2702 TI_DBG6(("SASID->smpTargetPort %d\n", SA_IDFRM_IS_SMP_TARGET(id)?1:0));
2703 TI_DBG6(("SASID->sspInitiatorPort %d\n", SA_IDFRM_IS_SSP_INITIATOR(id)?1:0));
2704 TI_DBG6(("SASID->stpInitiatorPort %d\n", SA_IDFRM_IS_STP_INITIATOR(id)?1:0));
2705 TI_DBG6(("SASID->smpInitiatorPort %d\n", SA_IDFRM_IS_SMP_INITIATOR(id)?1:0));
2706 TI_DBG6(("SASID->deviceType %d\n", SA_IDFRM_GET_DEVICETTYPE(id)));
2707 TI_DBG6(("SASID->sasAddressHi 0x%x\n", SA_IDFRM_GET_SAS_ADDRESSHI(id)));
2708 TI_DBG6(("SASID->sasAddressLo 0x%x\n", SA_IDFRM_GET_SAS_ADDRESSLO(id)));
2709 TI_DBG6(("SASID->phyIdentifier 0x%x\n", id->phyIdentifier));
2717 tdsaInitTimerHandler(
2723 TI_DBG6(("tdsaInitTimerHandler: start\n"));
2728 type: 1 portcontext 2 devicedata
2729 flag: 1 FreeLink 2 MainLink
2733 print_tdlist_flink(tdList_t *hdr, int type, int flag)
2735 tdList_t *hdr_tmp1 = NULL;
2736 #ifdef TD_DEBUG_ENABLE
2737 tdsaPortContext_t *ele1;
2740 tdsaDeviceData_t *ele2;
2744 if (type == 1 && flag == 1)
2746 TI_DBG6(("PortContext and FreeLink\n"));
2748 else if (type != 1 && flag == 1)
2750 TI_DBG6(("DeviceData and FreeLink\n"));
2752 else if (type == 1 && flag != 1)
2754 TI_DBG6(("PortContext and MainLink\n"));
2758 TI_DBG6(("DeviceData and MainLink\n"));
2764 /* data structure type variable = (data structure type, file name, header of the tdList) */
2767 #ifdef TD_DEBUG_ENABLE
2768 ele1 = TDLIST_OBJECT_BASE(tdsaPortContext_t, FreeLink, hdr_tmp1);
2773 #ifdef TD_DEBUG_ENABLE
2774 ele1 = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, hdr_tmp1);
2777 TI_DBG6(("flist ele %d\n", ele1->id));
2778 TI_DBG6(("flist ele %p\n", ele1));
2779 hdr_tmp1 = hdr_tmp1->flink;
2780 } while (hdr_tmp1 != hdr);
2786 /* data structure type variable = (data structure type, file name, header of the tdList) */
2790 ele2 = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, hdr_tmp1);
2794 ele2 = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, hdr_tmp1);
2796 TI_DBG6(("flist ele %d\n", ele2->id));
2797 TI_DBG6(("flist ele %p\n", ele2));
2799 hdr_tmp1 = hdr_tmp1->flink;
2800 } while (hdr_tmp1 != hdr);
2805 /* not verified yet. 6/15/2005 */
2807 print_tdlist_blink(tdList_t *hdr, int flag)
2809 tdList_t *hdr_tmp1 = NULL;
2811 tdsaPortContext_t *ele1;
2817 /* data structure type variable = (data structure type, file name, header of the tdList) */
2821 ele1 = TDLIST_OBJECT_BASE(tdsaPortContext_t, FreeLink, hdr_tmp1);
2825 ele1 = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, hdr_tmp1);
2827 TI_DBG6(("blist ele %d\n", ele1->id));
2830 hdr_tmp1 = hdr_tmp1->blink;
2831 } while (hdr_tmp1 != hdr);
2835 /** hexidecimal dump */
2836 void tdhexdump(const char *ptitle, bit8 *pbuf, int len)
2839 TI_DBG2(("%s - hexdump(len=%d):\n", ptitle, (int)len));
2842 TI_DBG1(("pbuf is NULL\n"));
2845 for (i = 0; i < len; )
2849 TI_DBG2((" 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", pbuf[i], pbuf[i+1], pbuf[i+2], pbuf[i+3]));
2854 TI_DBG2((" 0x%02x,", pbuf[i]));
2862 tdsaSingleThreadedEnter(tiRoot_t *ptiRoot, bit32 queueId)
2864 tdsaRoot_t * tiroot = agNULL;
2866 TD_ASSERT(ptiRoot,"ptiRoot");
2867 tiroot = ptiRoot->tdData;
2869 offset = tiroot->tdsaAllShared.MaxNumLLLocks + tiroot->tdsaAllShared.MaxNumOSLocks;
2871 ostiSingleThreadedEnter(ptiRoot, queueId + offset);
2875 tdsaSingleThreadedLeave(tiRoot_t *ptiRoot, bit32 queueId)
2877 tdsaRoot_t * tiroot = agNULL;
2880 TD_ASSERT(ptiRoot,"ptiRoot");
2881 tiroot = ptiRoot->tdData;
2883 offset = tiroot->tdsaAllShared.MaxNumLLLocks + tiroot->tdsaAllShared.MaxNumOSLocks;
2885 ostiSingleThreadedLeave(ptiRoot, queueId + offset);
2890 tdsaEnter(tiRoot_t *ptiRoot, int io)
2892 ostiEnter(ptiRoot, 1, io);
2896 tdsaLeave(tiRoot_t *ptiRoot, int io)
2898 ostiLeave(ptiRoot, 1, io);