1285809Sscottl/*******************************************************************************
2285809Sscottl**
3285809Sscottl*Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
4285809Sscottl*
5285809Sscottl*Redistribution and use in source and binary forms, with or without modification, are permitted provided
6285809Sscottl*that the following conditions are met:
7285809Sscottl*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8285809Sscottl*following disclaimer.
9285809Sscottl*2. Redistributions in binary form must reproduce the above copyright notice,
10285809Sscottl*this list of conditions and the following disclaimer in the documentation and/or other materials provided
11285809Sscottl*with the distribution.
12285809Sscottl*
13285809Sscottl*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
14285809Sscottl*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15285809Sscottl*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16285809Sscottl*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17285809Sscottl*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
18285809Sscottl*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
19285809Sscottl*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20285809Sscottl*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
21285809Sscottl**
22285809Sscottl********************************************************************************/
23285809Sscottl/*****************************************************************************/
24285809Sscottl/** \file
25285809Sscottl *
26285809Sscottl * This file contains initiator CB functions
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#include <dev/pms/RefTisa/sallsdk/api/sa.h>
38285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/saapi.h>
39285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
40285809Sscottl
41285809Sscottl#include <dev/pms/RefTisa/tisa/api/titypes.h>
42285809Sscottl#include <dev/pms/RefTisa/tisa/api/ostiapi.h>
43285809Sscottl#include <dev/pms/RefTisa/tisa/api/tiapi.h>
44285809Sscottl#include <dev/pms/RefTisa/tisa/api/tiglobal.h>
45285809Sscottl
46285809Sscottl#ifdef FDS_SM
47285809Sscottl#include <dev/pms/RefTisa/sat/api/sm.h>
48285809Sscottl#include <dev/pms/RefTisa/sat/api/smapi.h>
49285809Sscottl#include <dev/pms/RefTisa/sat/api/tdsmapi.h>
50285809Sscottl#endif
51285809Sscottl
52285809Sscottl#ifdef FDS_DM
53285809Sscottl#include <dev/pms/RefTisa/discovery/api/dm.h>
54285809Sscottl#include <dev/pms/RefTisa/discovery/api/dmapi.h>
55285809Sscottl#include <dev/pms/RefTisa/discovery/api/tddmapi.h>
56285809Sscottl#endif
57285809Sscottl
58285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
59285809Sscottl#include <dev/pms/freebsd/driver/common/osstring.h>
60285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
61285809Sscottl
62285809Sscottl#ifdef INITIATOR_DRIVER
63285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
64285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
65285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
66285809Sscottl#endif
67285809Sscottl
68285809Sscottl#ifdef TARGET_DRIVER
69285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
70285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
71285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
72285809Sscottl#endif
73285809Sscottl
74285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
75285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
76285809Sscottl
77285809Sscottl/*****************************************************************************
78285809Sscottl*!  \brief  itdssTaskCompleted
79285809Sscottl*
80285809Sscottl*  Purpose: This routine is called to complete an task management request
81285809Sscottl*           previously issued to the LL Layer. All task management completes with
82285809Sscottl*           this function except query task management.
83285809Sscottl*
84285809Sscottl*   \param  agRoot:         Pointer to driver Instance.
85285809Sscottl*   \param  agIORequest:    Pointer to the I/O Request data structure for
86285809Sscottl*                           this I/O.
87285809Sscottl*   \param  agIOStatus:     Status of I/O just completed.
88285809Sscottl*   \param  agIOInfoLen:    Length of the I/O information associated with this
89285809Sscottl*                           I/O request
90285809Sscottl*   \param   agParam        A Handle used to refer to the response frame or handle
91285809Sscottl*                           of abort request
92285809Sscottl*   \param  agOtherInfo        Residual count
93285809Sscottl*   \return:                None
94285809Sscottl*
95285809Sscottl*   \note - This is a initiator specific function called by the jump table.
96285809Sscottl*
97285809Sscottl*****************************************************************************/
98285809SscottlosGLOBAL void
99285809SscottlitdssTaskCompleted(
100285809Sscottl                 agsaRoot_t             *agRoot,
101285809Sscottl                 agsaIORequest_t        *agIORequest,
102285809Sscottl                 bit32                  agIOStatus,
103285809Sscottl                 bit32                  agIOInfoLen,
104285809Sscottl                 void                   *agParam,
105285809Sscottl                 bit32                  agOtherInfo
106285809Sscottl                 )
107285809Sscottl{
108285809Sscottl  tdsaRootOsData_t            *osData = (tdsaRootOsData_t *)agRoot->osData;
109285809Sscottl  tiRoot_t                    *tiRoot = (tiRoot_t *)osData->tiRoot;
110285809Sscottl  tiIORequest_t               *taskTag = agNULL, *currentTaskTag = agNULL;
111285809Sscottl  tdIORequestBody_t           *tdIORequestBody = agNULL;
112285809Sscottl  tdIORequestBody_t           *TMtdIORequestBody = agNULL;
113285809Sscottl  tdIORequestBody_t           *AborttdIORequestBody = agNULL;
114285809Sscottl  agsaIORequest_t             *agTaskedIORequest;
115285809Sscottl  agsaSSPResponseInfoUnit_t   agSSPRespIU;
116285809Sscottl  bit8                        respData[128];
117285809Sscottl  bit32                       respLen;
118285809Sscottl#ifdef  TD_DEBUG_ENABLE
119285809Sscottl  bit32                       data_status;
120285809Sscottl#endif
121285809Sscottl  agsaSASRequestBody_t        *agSASRequestBody = agNULL;
122285809Sscottl  agsaSSPScsiTaskMgntReq_t    *agSSPTaskMgntRequest = agNULL;
123285809Sscottl  agsaIORequest_t             *agAbortIORequest;
124285809Sscottl  tdIORequestBody_t           *tdAbortIORequestBody;
125285809Sscottl  bit32                       PhysUpper32;
126285809Sscottl  bit32                       PhysLower32;
127285809Sscottl  bit32                       memAllocStatus;
128285809Sscottl  void                        *osMemHandle;
129285809Sscottl  bit32                       abortOrquery = agTRUE;
130285809Sscottl  tiDeviceHandle_t            *tiDeviceHandle = agNULL;
131285809Sscottl  tdsaDeviceData_t            *oneDeviceData = agNULL;
132285809Sscottl  agsaDevHandle_t             *agDevHandle = agNULL;
133285809Sscottl  bit32                        status = AGSA_RC_FAILURE;
134285809Sscottl
135285809Sscottl  TI_DBG2(("itdssTaskCompleted: start\n"));
136285809Sscottl
137285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
138285809Sscottl
139285809Sscottl  /* check the agIOStatus */
140285809Sscottl  currentTaskTag = tdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag;
141285809Sscottl
142285809Sscottl  if (currentTaskTag == agNULL)
143285809Sscottl  {
144285809Sscottl    TI_DBG1(("itdssTaskCompleted: currentTaskTag is NULL \n"));
145285809Sscottl	/* as the currentTaskTag is agNULL, shall not call ostiInitiatorEvent */
146285809Sscottl	#if 0
147285809Sscottl    ostiInitiatorEvent( tiRoot,
148285809Sscottl                        NULL,
149285809Sscottl                        NULL,
150285809Sscottl                        tiIntrEventTypeTaskManagement,
151285809Sscottl                        tiTMFailed,
152285809Sscottl                        currentTaskTag );
153285809Sscottl    #endif
154285809Sscottl    /* free up allocated memory */
155285809Sscottl    ostiFreeMemory(
156285809Sscottl                   tiRoot,
157285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
158285809Sscottl                   sizeof(tdIORequestBody_t)
159285809Sscottl                   );
160285809Sscottl    return;
161285809Sscottl  }
162285809Sscottl
163285809Sscottl  if (agIOStatus != OSSA_IO_SUCCESS)
164285809Sscottl  {
165285809Sscottl    TI_DBG1(("itdssTaskCompleted: agIOStatus failed and tiTMFailed\n"));
166285809Sscottl    if (agIOStatus == OSSA_IO_TM_TAG_NOT_FOUND)
167285809Sscottl    {
168285809Sscottl      TI_DBG1(("itdssTaskCompleted: agIOStatus OSSA_IO_TM_TAG_NOT_FOUND\n"));
169285809Sscottl    }
170285809Sscottl    else
171285809Sscottl    if (agIOStatus == OSSA_IO_ABORTED)
172285809Sscottl    {
173285809Sscottl      TI_DBG1(("itdssTaskCompleted: agIOStatus OSSA_IO_ABORTED\n"));
174285809Sscottl    }
175285809Sscottl    else
176285809Sscottl    {
177285809Sscottl      TI_DBG1(("itdssTaskCompleted: agIOStatus 0x%x\n", agIOStatus));
178285809Sscottl    }
179285809Sscottl    ostiInitiatorEvent( tiRoot,
180285809Sscottl                        NULL,
181285809Sscottl                        NULL,
182285809Sscottl                        tiIntrEventTypeTaskManagement,
183285809Sscottl                        tiTMFailed,
184285809Sscottl                        currentTaskTag );
185285809Sscottl    /* free up allocated memory */
186285809Sscottl    ostiFreeMemory(
187285809Sscottl                   tiRoot,
188285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
189285809Sscottl                   sizeof(tdIORequestBody_t)
190285809Sscottl                   );
191285809Sscottl    return;
192285809Sscottl  }
193285809Sscottl
194285809Sscottl  /* parse the task management response */
195285809Sscottl  /* reads agsaSSPResponseInfoUnit_t */
196285809Sscottl  saFrameReadBlock(agRoot, agParam, 0, &agSSPRespIU, sizeof(agsaSSPResponseInfoUnit_t));
197285809Sscottl#ifdef  TD_DEBUG_ENABLE
198285809Sscottl  data_status = SA_SSPRESP_GET_DATAPRES(&agSSPRespIU);
199285809Sscottl#endif
200285809Sscottl  respLen = SA_SSPRESP_GET_RESPONSEDATALEN(&agSSPRespIU);
201285809Sscottl  TI_DBG6(("itdssTaskCompleted: dataPres %d. should be 1\n", data_status));
202285809Sscottl  /* reads response data */
203285809Sscottl  saFrameReadBlock(agRoot, agParam,
204285809Sscottl                   sizeof(agsaSSPResponseInfoUnit_t),
205285809Sscottl                   respData, respLen);
206285809Sscottl  TI_DBG6(("itdssTaskCompleted: res code %d. should be 0\n", respData[3]));
207285809Sscottl
208285809Sscottl  taskTag = tdIORequestBody->IOType.InitiatorTMIO.TaskTag;
209285809Sscottl  if (taskTag == agNULL)
210285809Sscottl  {
211285809Sscottl    /* other than Abort Task or Query Task */
212285809Sscottl    TI_DBG1(("itdssTaskCompleted: taskTag is NULL\n"));
213285809Sscottl
214285809Sscottl    abortOrquery = agFALSE;
215285809Sscottl    TMtdIORequestBody = (tdIORequestBody_t *)currentTaskTag->tdData;
216285809Sscottl  }
217285809Sscottl  else
218285809Sscottl  {
219285809Sscottl    /* Abort Task or Query Task */
220285809Sscottl    TI_DBG2(("itdssTaskCompleted: taskTag is NOT NULL\n"));
221285809Sscottl    abortOrquery = agTRUE;
222285809Sscottl    TMtdIORequestBody = (tdIORequestBody_t *)currentTaskTag->tdData;
223285809Sscottl  }
224285809Sscottl
225285809Sscottl  TI_DBG2(("itdssTaskCompleted: TMtdIORequestBody %p\n", TMtdIORequestBody));
226285809Sscottl
227285809Sscottl  if (TMtdIORequestBody == agNULL)
228285809Sscottl  {
229285809Sscottl    TI_DBG1(("itdssTaskCompleted: TMtdIORequestBody is NULL \n"));
230285809Sscottl    ostiInitiatorEvent( tiRoot,
231285809Sscottl                        NULL,
232285809Sscottl                        NULL,
233285809Sscottl                        tiIntrEventTypeTaskManagement,
234285809Sscottl                        tiTMFailed,
235285809Sscottl                        currentTaskTag );
236285809Sscottl    /* free up allocated memory */
237285809Sscottl    ostiFreeMemory(
238285809Sscottl                   tiRoot,
239285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
240285809Sscottl                   sizeof(tdIORequestBody_t)
241285809Sscottl                   );
242285809Sscottl    return;
243285809Sscottl  }
244285809Sscottl
245285809Sscottl  if (agIOStatus == OSSA_IO_SUCCESS && agIOInfoLen == 0)
246285809Sscottl  {
247285809Sscottl    TI_DBG1(("itdssTaskCompleted: agIOInfoLen is zero, wrong\n"));
248285809Sscottl    ostiInitiatorEvent( tiRoot,
249285809Sscottl                        NULL,
250285809Sscottl                        NULL,
251285809Sscottl                        tiIntrEventTypeTaskManagement,
252285809Sscottl                        tiTMFailed,
253285809Sscottl                        currentTaskTag );
254285809Sscottl    /* free up allocated memory */
255285809Sscottl    ostiFreeMemory(
256285809Sscottl                   tiRoot,
257285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
258285809Sscottl                   sizeof(tdIORequestBody_t)
259285809Sscottl                   );
260285809Sscottl    return;
261285809Sscottl  }
262285809Sscottl
263285809Sscottl  agSASRequestBody = (agsaSASRequestBody_t *)&(TMtdIORequestBody->transport.SAS.agSASRequestBody);
264285809Sscottl  agSSPTaskMgntRequest = (agsaSSPScsiTaskMgntReq_t *)&(agSASRequestBody->sspTaskMgntReq);
265285809Sscottl  TI_DBG2(("itdssTaskCompleted: agSSPTaskMgntRequest->taskMgntFunction 0x%x\n", agSSPTaskMgntRequest->taskMgntFunction));
266285809Sscottl
267285809Sscottl  if ( (agSSPTaskMgntRequest->taskMgntFunction == AGSA_ABORT_TASK ||
268285809Sscottl        agSSPTaskMgntRequest->taskMgntFunction == AGSA_QUERY_TASK) &&
269285809Sscottl        abortOrquery == agFALSE
270285809Sscottl      )
271285809Sscottl  {
272285809Sscottl    TI_DBG1(("itdssTaskCompleted: incorrect tasktag, first\n"));
273285809Sscottl    ostiInitiatorEvent( tiRoot,
274285809Sscottl                        NULL,
275285809Sscottl                        NULL,
276285809Sscottl                        tiIntrEventTypeTaskManagement,
277285809Sscottl                        tiTMFailed,
278285809Sscottl                        currentTaskTag );
279285809Sscottl    /* free up allocated memory */
280285809Sscottl    ostiFreeMemory(
281285809Sscottl                   tiRoot,
282285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
283285809Sscottl                   sizeof(tdIORequestBody_t)
284285809Sscottl                   );
285285809Sscottl    return;
286285809Sscottl  }
287285809Sscottl
288285809Sscottl  if ((agSSPTaskMgntRequest->taskMgntFunction == AGSA_ABORT_TASK_SET ||
289285809Sscottl       agSSPTaskMgntRequest->taskMgntFunction == AGSA_CLEAR_TASK_SET ||
290285809Sscottl       agSSPTaskMgntRequest->taskMgntFunction == AGSA_LOGICAL_UNIT_RESET ||
291285809Sscottl       agSSPTaskMgntRequest->taskMgntFunction == AGSA_CLEAR_ACA ) &&
292285809Sscottl       abortOrquery == agTRUE
293285809Sscottl     )
294285809Sscottl  {
295285809Sscottl    TI_DBG1(("itdssTaskCompleted: incorrect tasktag, second\n"));
296285809Sscottl    ostiInitiatorEvent( tiRoot,
297285809Sscottl                        NULL,
298285809Sscottl                        NULL,
299285809Sscottl                        tiIntrEventTypeTaskManagement,
300285809Sscottl                        tiTMFailed,
301285809Sscottl                        currentTaskTag );
302285809Sscottl    /* free up allocated memory */
303285809Sscottl    ostiFreeMemory(
304285809Sscottl                   tiRoot,
305285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
306285809Sscottl                   sizeof(tdIORequestBody_t)
307285809Sscottl                   );
308285809Sscottl    return;
309285809Sscottl  }
310285809Sscottl
311285809Sscottl
312285809Sscottl  if (agSSPTaskMgntRequest->taskMgntFunction == AGSA_ABORT_TASK)
313285809Sscottl  {
314285809Sscottl    TI_DBG2(("itdssTaskCompleted: calling saSSPAbort()\n"));
315285809Sscottl    AborttdIORequestBody = (tdIORequestBody_t *)taskTag->tdData;
316285809Sscottl    if (AborttdIORequestBody == agNULL)
317285809Sscottl    {
318285809Sscottl      TI_DBG1(("itdssTaskCompleted: wrong, AborttdIORequestBody is NULL\n"));
319285809Sscottl      return;
320285809Sscottl    }
321285809Sscottl
322285809Sscottl    tiDeviceHandle = AborttdIORequestBody->tiDevHandle;
323285809Sscottl    if (tiDeviceHandle == agNULL)
324285809Sscottl    {
325285809Sscottl      TI_DBG1(("itdssTaskCompleted: wrong, tiDeviceHandle is NULL\n"));
326285809Sscottl      return;
327285809Sscottl    }
328285809Sscottl    oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
329285809Sscottl    if (oneDeviceData == agNULL)
330285809Sscottl    {
331285809Sscottl      TI_DBG1(("itdssTaskCompleted: wrong, oneDeviceData is NULL\n"));
332285809Sscottl      return;
333285809Sscottl    }
334285809Sscottl    agDevHandle = oneDeviceData->agDevHandle;
335285809Sscottl    if (agDevHandle == agNULL)
336285809Sscottl    {
337285809Sscottl      TI_DBG1(("itdssTaskCompleted: wrong, agDevHandle is NULL\n"));
338285809Sscottl    }
339285809Sscottl
340285809Sscottl    agTaskedIORequest = (agsaIORequest_t *)&(AborttdIORequestBody->agIORequest);
341285809Sscottl    if (agTaskedIORequest == agNULL)
342285809Sscottl    {
343285809Sscottl      TI_DBG1(("itdssTaskCompleted: agTaskedIORequest is NULL \n"));
344285809Sscottl      ostiInitiatorEvent( tiRoot,
345285809Sscottl                          NULL,
346285809Sscottl                          NULL,
347285809Sscottl                          tiIntrEventTypeTaskManagement,
348285809Sscottl                          tiTMFailed,
349285809Sscottl                          currentTaskTag );
350285809Sscottl      /* free up allocated memory */
351285809Sscottl      ostiFreeMemory(
352285809Sscottl                     tiRoot,
353285809Sscottl                     tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
354285809Sscottl                     sizeof(tdIORequestBody_t)
355285809Sscottl                     );
356285809Sscottl      return;
357285809Sscottl    }
358285809Sscottl
359285809Sscottl
360285809Sscottl    /* allocating agIORequest for abort itself */
361285809Sscottl    memAllocStatus = ostiAllocMemory(
362285809Sscottl                                     tiRoot,
363285809Sscottl                                     &osMemHandle,
364285809Sscottl                                     (void **)&tdAbortIORequestBody,
365285809Sscottl                                     &PhysUpper32,
366285809Sscottl                                     &PhysLower32,
367285809Sscottl                                     8,
368285809Sscottl                                     sizeof(tdIORequestBody_t),
369285809Sscottl                                     agTRUE
370285809Sscottl                                     );
371285809Sscottl    if (memAllocStatus != tiSuccess)
372285809Sscottl    {
373285809Sscottl      /* let os process IO */
374285809Sscottl      TI_DBG1(("itdssTaskCompleted: ostiAllocMemory failed...\n"));
375285809Sscottl      return;
376285809Sscottl    }
377285809Sscottl
378285809Sscottl    if (tdAbortIORequestBody == agNULL)
379285809Sscottl    {
380285809Sscottl      /* let os process IO */
381285809Sscottl      TI_DBG1(("itdssTaskCompleted: ostiAllocMemory returned NULL tdAbortIORequestBody\n"));
382285809Sscottl      return;
383285809Sscottl    }
384285809Sscottl
385285809Sscottl    /* setup task management structure */
386285809Sscottl    tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle;
387285809Sscottl    tdAbortIORequestBody->tiDevHandle = tiDeviceHandle;
388285809Sscottl    /* setting callback */
389285809Sscottl    tdAbortIORequestBody->IOCompletionFunc = itdssIOAbortedHandler;
390285809Sscottl
391285809Sscottl    /* setting to NULL because the local abort is triggered by TD layer */
392285809Sscottl    tdAbortIORequestBody->tiIOToBeAbortedRequest = agNULL;
393285809Sscottl    /* initialize agIORequest */
394285809Sscottl    agAbortIORequest = &(tdAbortIORequestBody->agIORequest);
395285809Sscottl    agAbortIORequest->osData = (void *) tdAbortIORequestBody;
396285809Sscottl    agAbortIORequest->sdkData = agNULL; /* LL takes care of this */
397285809Sscottl
398285809Sscottl    status = saSSPAbort(agRoot, agAbortIORequest, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, 0, agTaskedIORequest, agNULL);
399285809Sscottl    if (status != AGSA_RC_SUCCESS)
400285809Sscottl    {
401285809Sscottl      TI_DBG1(("itdssTaskCompleted: saSSPAbort failed agIOInfoLen is zero, wrong\n"));
402285809Sscottl      ostiFreeMemory(
403285809Sscottl                     tiRoot,
404285809Sscottl                     tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle,
405285809Sscottl                     sizeof(tdIORequestBody_t)
406285809Sscottl                     );
407285809Sscottl    }
408285809Sscottl  }
409285809Sscottl
410285809Sscottl  /*
411285809Sscottl    parse the response and based on the parse,
412285809Sscottl    set the flag
413285809Sscottl  */
414285809Sscottl  if (respData[3] == AGSA_TASK_MANAGEMENT_FUNCTION_COMPLETE ||
415285809Sscottl      respData[3] == AGSA_TASK_MANAGEMENT_FUNCTION_SUCCEEDED)
416285809Sscottl  {
417285809Sscottl    TI_DBG2(("itdssTaskCompleted: tiTMOK\n"));
418285809Sscottl    tiDeviceHandle = TMtdIORequestBody->tiDevHandle;
419285809Sscottl    if (tiDeviceHandle == agNULL)
420285809Sscottl    {
421285809Sscottl      TI_DBG1(("itdssTaskCompleted: wrong, tiDeviceHandle is NULL\n"));
422285809Sscottl      return;
423285809Sscottl    }
424285809Sscottl    oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
425285809Sscottl    if (oneDeviceData == agNULL)
426285809Sscottl    {
427285809Sscottl      TI_DBG1(("itdssTaskCompleted: wrong, oneDeviceData is NULL\n"));
428285809Sscottl      return;
429285809Sscottl    }
430285809Sscottl    agDevHandle = oneDeviceData->agDevHandle;
431285809Sscottl    if (agDevHandle == agNULL)
432285809Sscottl    {
433285809Sscottl      TI_DBG1(("itdssTaskCompleted: wrong, agDevHandle is NULL\n"));
434285809Sscottl    }
435285809Sscottl    TI_DBG2(("itdssTaskCompleted: setting Device state to SA_DS_OPERATIONAL\n"));
436285809Sscottl
437285809Sscottl    saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_OPERATIONAL);
438285809Sscottl
439285809Sscottl    ostiInitiatorEvent( tiRoot,
440285809Sscottl                        NULL,
441285809Sscottl                        NULL,
442285809Sscottl                        tiIntrEventTypeTaskManagement,
443285809Sscottl                        tiTMOK,
444285809Sscottl                        currentTaskTag );
445285809Sscottl  }
446285809Sscottl  else
447285809Sscottl  {
448285809Sscottl    TI_DBG1(("itdssTaskCompleted: tiTMFailed\n"));
449285809Sscottl    ostiInitiatorEvent( tiRoot,
450285809Sscottl                        NULL,
451285809Sscottl                        NULL,
452285809Sscottl                        tiIntrEventTypeTaskManagement,
453285809Sscottl                        tiTMFailed,
454285809Sscottl                        currentTaskTag );
455285809Sscottl
456285809Sscottl  }
457285809Sscottl
458285809Sscottl  /* free up allocated memory */
459285809Sscottl  ostiFreeMemory(
460285809Sscottl                 tiRoot,
461285809Sscottl                 tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
462285809Sscottl                 sizeof(tdIORequestBody_t)
463285809Sscottl                 );
464285809Sscottl  return;
465285809Sscottl}
466285809Sscottl
467285809Sscottl#ifdef INITIATOR_DRIVER
468285809Sscottl
469285809Sscottl/*****************************************************************************
470285809Sscottl*!  \brief  itdssQueryTaskCompleted
471285809Sscottl*
472285809Sscottl*  Purpose: This routine is called to complete an query task management request
473285809Sscottl*           previously issued to the LL Layer.
474285809Sscottl*
475285809Sscottl*   \param  agRoot:         Pointer to driver Instance.
476285809Sscottl*   \param  agIORequest:    Pointer to the I/O Request data structure for
477285809Sscottl*                           this I/O.
478285809Sscottl*   \param  agIOStatus:     Status of I/O just completed.
479285809Sscottl*   \param  agIOInfoLen:    Length of the I/O information associated with this
480285809Sscottl*                           I/O request
481285809Sscottl*   \param   agParam        A Handle used to refer to the response frame or handle
482285809Sscottl*                           of abort request
483285809Sscottl*
484285809Sscottl*   \return:                None
485285809Sscottl*
486285809Sscottl*   \note - This is a initiator specific function called by the jump table.
487285809Sscottl*
488285809Sscottl*****************************************************************************/
489285809SscottlosGLOBAL void
490285809SscottlitdssQueryTaskCompleted(
491285809Sscottl                        agsaRoot_t             *agRoot,
492285809Sscottl                        agsaIORequest_t        *agIORequest,
493285809Sscottl                        bit32                  agIOStatus,
494285809Sscottl                        bit32                  agIOInfoLen,
495285809Sscottl                        void                   *agParam,
496285809Sscottl                        bit32                  agOtherInfo
497285809Sscottl                        )
498285809Sscottl{
499285809Sscottl  tdsaRootOsData_t            *osData = (tdsaRootOsData_t *)agRoot->osData;
500285809Sscottl  tiRoot_t                    *tiRoot = (tiRoot_t *)osData->tiRoot;
501285809Sscottl  tiIORequest_t               *taskTag = agNULL;
502285809Sscottl  tdIORequestBody_t           *tdIORequestBody = agNULL;  /* query task */
503285809Sscottl  tdIORequestBody_t           *TMtdIORequestBody = agNULL; /* IO being query tasked */
504285809Sscottl  agsaIORequest_t             *agTaskedIORequest = agNULL;
505285809Sscottl  agsaSSPResponseInfoUnit_t   agSSPRespIU;
506285809Sscottl  bit8                        respData[128];
507285809Sscottl  bit32                       respLen;
508285809Sscottl#ifdef  TD_DEBUG_ENABLE
509285809Sscottl  bit32                       data_status;
510285809Sscottl#endif
511285809Sscottl  agsaSASRequestBody_t        *agSASRequestBody = agNULL;
512285809Sscottl  agsaSSPScsiTaskMgntReq_t    *agSSPTaskMgntRequest = agNULL;
513285809Sscottl  bit32                       status;
514285809Sscottl  agsaIORequest_t             *agAbortIORequest = agNULL;
515285809Sscottl  tdIORequestBody_t           *tdAbortIORequestBody = agNULL;
516285809Sscottl  bit32                       PhysUpper32;
517285809Sscottl  bit32                       PhysLower32;
518285809Sscottl  bit32                       memAllocStatus;
519285809Sscottl  void                        *osMemHandle = agNULL;
520285809Sscottl  tiDeviceHandle_t            *tiDeviceHandle = agNULL;
521285809Sscottl  tdsaDeviceData_t            *oneDeviceData = agNULL;
522285809Sscottl  agsaDevHandle_t             *agDevHandle = agNULL;
523285809Sscottl
524285809Sscottl  TI_DBG2(("itdssQueryTaskComplted: start\n"));
525285809Sscottl
526285809Sscottl  /* query task management IORequestBody */
527285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
528285809Sscottl
529285809Sscottl  /* OS's tiIORequest for this query taks, which is agNULL */
530285809Sscottl  //currentTaskTag = tdIORequestBody->IOType.InitiatorTMIO.CurrentTaskTag;
531285809Sscottl
532285809Sscottl  /*
533285809Sscottl    currentTaskTag is agNULL for query task since it is generated by
534285809Sscottl    TD layer
535285809Sscottl  */
536285809Sscottl  if (agIOStatus != OSSA_IO_SUCCESS)
537285809Sscottl  {
538285809Sscottl    /* let os process IO */
539285809Sscottl    TI_DBG1(("itdssQueryTaskComplted: agIOStatus failed and tiTMFailed\n"));
540285809Sscottl    /* free up allocated memory */
541285809Sscottl    ostiFreeMemory(
542285809Sscottl                   tiRoot,
543285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
544285809Sscottl                   sizeof(tdIORequestBody_t)
545285809Sscottl                   );
546285809Sscottl    return;
547285809Sscottl  }
548285809Sscottl  /* parse the task management response */
549285809Sscottl  /* reads agsaSSPResponseInfoUnit_t */
550285809Sscottl  saFrameReadBlock(agRoot, agParam, 0, &agSSPRespIU, sizeof(agsaSSPResponseInfoUnit_t));
551285809Sscottl#ifdef  TD_DEBUG_ENABLE
552285809Sscottl  data_status = SA_SSPRESP_GET_DATAPRES(&agSSPRespIU);
553285809Sscottl#endif
554285809Sscottl  respLen = SA_SSPRESP_GET_RESPONSEDATALEN(&agSSPRespIU);
555285809Sscottl
556285809Sscottl  TI_DBG6(("itdssQueryTaskCompleted: dataPres %d. should be 1\n", data_status));
557285809Sscottl  /* reads response data */
558285809Sscottl  saFrameReadBlock(agRoot, agParam,
559285809Sscottl                   sizeof(agsaSSPResponseInfoUnit_t),
560285809Sscottl                   respData, respLen);
561285809Sscottl
562285809Sscottl  TI_DBG6(("itdssQueryTaskCompleted: res code %d. should be 0\n", respData[3]));
563285809Sscottl
564285809Sscottl  /* IO being query tasked */
565285809Sscottl  taskTag = tdIORequestBody->IOType.InitiatorTMIO.TaskTag;
566285809Sscottl  if (taskTag == agNULL)
567285809Sscottl  {
568285809Sscottl    TI_DBG1(("itdssQueryTaskComplted: taskTag is NULL \n"));
569285809Sscottl    /* free up allocated memory */
570285809Sscottl    ostiFreeMemory(
571285809Sscottl                   tiRoot,
572285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
573285809Sscottl                   sizeof(tdIORequestBody_t)
574285809Sscottl                   );
575285809Sscottl    return;
576285809Sscottl  }
577285809Sscottl
578285809Sscottl  /* request body of IO being query tasked  */
579285809Sscottl  TMtdIORequestBody = (tdIORequestBody_t *)taskTag->tdData;
580285809Sscottl  if (TMtdIORequestBody == agNULL)
581285809Sscottl  {
582285809Sscottl    TI_DBG1(("itdssQueryTaskComplted: TMtdIORequestBody is NULL \n"));
583285809Sscottl    /* free up allocated memory */
584285809Sscottl    ostiFreeMemory(
585285809Sscottl                   tiRoot,
586285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
587285809Sscottl                   sizeof(tdIORequestBody_t)
588285809Sscottl                   );
589285809Sscottl    return;
590285809Sscottl  }
591285809Sscottl
592285809Sscottl  agTaskedIORequest = &(TMtdIORequestBody->agIORequest);
593285809Sscottl  if (agTaskedIORequest == agNULL)
594285809Sscottl  {
595285809Sscottl    TI_DBG1(("itdssQueryTaskComplted: agTaskedIORequest is NULL \n"));
596285809Sscottl    /* free up allocated memory */
597285809Sscottl    ostiFreeMemory(
598285809Sscottl                   tiRoot,
599285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
600285809Sscottl                   sizeof(tdIORequestBody_t)
601285809Sscottl                   );
602285809Sscottl    return;
603285809Sscottl  }
604285809Sscottl
605285809Sscottl  if (agIOStatus == OSSA_IO_SUCCESS && agIOInfoLen == 0)
606285809Sscottl  {
607285809Sscottl    TI_DBG1(("itdssQueryTaskCompleted: agIOInfoLen is zero, wrong\n"));
608285809Sscottl    /* free up allocated memory */
609285809Sscottl    ostiFreeMemory(
610285809Sscottl                   tiRoot,
611285809Sscottl                   tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
612285809Sscottl                   sizeof(tdIORequestBody_t)
613285809Sscottl                   );
614285809Sscottl   return;
615285809Sscottl  }
616285809Sscottl  /* this is query task itself */
617285809Sscottl  agSASRequestBody = &(tdIORequestBody->transport.SAS.agSASRequestBody);
618285809Sscottl  agSSPTaskMgntRequest = &(agSASRequestBody->sspTaskMgntReq);
619285809Sscottl  if (agSSPTaskMgntRequest->taskMgntFunction == AGSA_QUERY_TASK)
620285809Sscottl  {
621285809Sscottl    /*
622285809Sscottl      process response for query task
623285809Sscottl      For query task, response code must be either
624285809Sscottl      TASK MANAGEMENT FUNCTION COMPLETE or TASK MANAGEMENT FUNCTION SUCCEEDED by
625285809Sscottl      SAM
626285809Sscottl
627285809Sscottl      1. If TASK MANAGEMENT FUNCTION SUCCEEDE, do nothing
628285809Sscottl
629285809Sscottl      2. If TASK MANAGEMENT FUNCTION COMPLETE and IO is not completed,
630285809Sscottl      retry by saSSPAbort()
631285809Sscottl    */
632285809Sscottl    if (respData[3] == AGSA_TASK_MANAGEMENT_FUNCTION_SUCCEEDED)
633285809Sscottl    {
634285809Sscottl      /* OK; IO is being process at the target; do nothing */
635285809Sscottl    }
636285809Sscottl    else if (respData[3] == AGSA_TASK_MANAGEMENT_FUNCTION_COMPLETE)
637285809Sscottl    {
638285809Sscottl      tiDeviceHandle = TMtdIORequestBody->tiDevHandle;
639285809Sscottl      if (tiDeviceHandle == agNULL)
640285809Sscottl      {
641285809Sscottl        TI_DBG1(("itdssQueryTaskCompleted: wrong, tiDeviceHandle is NULL\n"));
642285809Sscottl        /* free up allocated memory */
643285809Sscottl        ostiFreeMemory(
644285809Sscottl                       tiRoot,
645285809Sscottl                       tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
646285809Sscottl                       sizeof(tdIORequestBody_t)
647285809Sscottl                       );
648285809Sscottl        return;
649285809Sscottl      }
650285809Sscottl      oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
651285809Sscottl      if (oneDeviceData == agNULL)
652285809Sscottl      {
653285809Sscottl        TI_DBG1(("itdssQueryTaskCompleted: wrong, oneDeviceData is NULL\n"));
654285809Sscottl        /* free up allocated memory */
655285809Sscottl        ostiFreeMemory(
656285809Sscottl                       tiRoot,
657285809Sscottl                       tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
658285809Sscottl                       sizeof(tdIORequestBody_t)
659285809Sscottl                       );
660285809Sscottl
661285809Sscottl        return;
662285809Sscottl      }
663285809Sscottl      agDevHandle = oneDeviceData->agDevHandle;
664285809Sscottl      if (agDevHandle == agNULL)
665285809Sscottl      {
666285809Sscottl        TI_DBG1(("itdssQueryTaskCompleted: wrong, agDevHandle is NULL\n"));
667285809Sscottl      }
668285809Sscottl      /* if IO is not completed, retry IO by saSSPAbort() */
669285809Sscottl      if (TMtdIORequestBody->ioCompleted != agTRUE)
670285809Sscottl      {
671285809Sscottl        /* allocating agIORequest for abort itself */
672285809Sscottl        memAllocStatus = ostiAllocMemory(
673285809Sscottl                                         tiRoot,
674285809Sscottl                                         &osMemHandle,
675285809Sscottl                                         (void **)&tdAbortIORequestBody,
676285809Sscottl                                         &PhysUpper32,
677285809Sscottl                                         &PhysLower32,
678285809Sscottl                                         8,
679285809Sscottl                                         sizeof(tdIORequestBody_t),
680285809Sscottl                                         agTRUE
681285809Sscottl                                         );
682285809Sscottl        if (memAllocStatus != tiSuccess)
683285809Sscottl        {
684285809Sscottl          /* let os process IO */
685285809Sscottl          TI_DBG1(("itdssQueryTaskCompleted: ostiAllocMemory failed...\n"));
686285809Sscottl          /* free up allocated memory */
687285809Sscottl          ostiFreeMemory(
688285809Sscottl                         tiRoot,
689285809Sscottl                         tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
690285809Sscottl                         sizeof(tdIORequestBody_t)
691285809Sscottl                         );
692285809Sscottl
693285809Sscottl          return;
694285809Sscottl        }
695285809Sscottl        if (tdAbortIORequestBody == agNULL)
696285809Sscottl        {
697285809Sscottl          /* let os process IO */
698285809Sscottl          TI_DBG1(("itdssQueryTaskCompleted: ostiAllocMemory returned NULL tdAbortIORequestBody\n"));
699285809Sscottl          /* free up allocated memory */
700285809Sscottl          ostiFreeMemory(
701285809Sscottl                         tiRoot,
702285809Sscottl                         tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
703285809Sscottl                         sizeof(tdIORequestBody_t)
704285809Sscottl                         );
705285809Sscottl
706285809Sscottl          return;
707285809Sscottl        }
708285809Sscottl
709285809Sscottl        /* setup task management structure */
710285809Sscottl        tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle = osMemHandle;
711285809Sscottl        tdAbortIORequestBody->tiDevHandle = tdIORequestBody->tiDevHandle;
712285809Sscottl        tdAbortIORequestBody->tiIOToBeAbortedRequest = agNULL;
713285809Sscottl
714285809Sscottl        /* setting callback */
715285809Sscottl        tdAbortIORequestBody->IOCompletionFunc = itdssIOAbortedHandler;
716285809Sscottl
717285809Sscottl        /* initialize agIORequest */
718285809Sscottl        agAbortIORequest = &(tdAbortIORequestBody->agIORequest);
719285809Sscottl        agAbortIORequest->osData = (void *) tdAbortIORequestBody;
720285809Sscottl        agAbortIORequest->sdkData = agNULL; /* LL takes care of this */
721285809Sscottl
722285809Sscottl        TI_DBG2(("itdssQueryTaskCompleted: issuing saSSPAbort()\n"));
723285809Sscottl        status = saSSPAbort(agRoot, agAbortIORequest, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, 0, agTaskedIORequest, agNULL);
724285809Sscottl        if (status != AGSA_RC_SUCCESS)
725285809Sscottl        {
726285809Sscottl          TI_DBG1(("itdssQueryTaskCompleted: saSSPAbort failed agIOInfoLen is zero, wrong\n"));
727285809Sscottl          ostiFreeMemory(
728285809Sscottl                         tiRoot,
729285809Sscottl                         tdAbortIORequestBody->IOType.InitiatorTMIO.osMemHandle,
730285809Sscottl                         sizeof(tdIORequestBody_t)
731285809Sscottl                         );
732285809Sscottl        }
733285809Sscottl      }
734285809Sscottl    }
735285809Sscottl    else
736285809Sscottl    {
737285809Sscottl      TI_DBG1(("itdssQueryTaskComplted: not expected response 0x%x\n",respData[3]));
738285809Sscottl    }
739285809Sscottl  }
740285809Sscottl  else
741285809Sscottl  {
742285809Sscottl    TI_DBG1(("itdssQueryTaskCompleted: not expected task management fn %d\n",agSSPTaskMgntRequest->taskMgntFunction));
743285809Sscottl  }
744285809Sscottl
745285809Sscottl  /* free up allocated memory */
746285809Sscottl  ostiFreeMemory(
747285809Sscottl                 tiRoot,
748285809Sscottl                 tdIORequestBody->IOType.InitiatorTMIO.osMemHandle,
749285809Sscottl                 sizeof(tdIORequestBody_t)
750285809Sscottl                 );
751285809Sscottl  return;
752285809Sscottl}
753285809Sscottl#endif
754285809Sscottl
755285809Sscottl/*****************************************************************************
756285809Sscottl*!  \brief  itssdosIOCompleted
757285809Sscottl*
758285809Sscottl*  Purpose: This routine is called to complete an I/O request previously
759285809Sscottl*           issued to the LL Layer in saSSPStart().
760285809Sscottl*
761285809Sscottl*   \param  agRoot:       Pointer to driver Instance.
762285809Sscottl*   \param  agIORequest:  Pointer to the I/O Request data structure for
763285809Sscottl*                         this I/O.
764285809Sscottl*   \param  agIOStatus:   Status of I/O just completed.
765285809Sscottl*   \param  agIOInfoLen:  Length of the I/O information associated with this
766285809Sscottl*                         I/O request
767285809Sscottl*   \param   agParam      A Handle used to refer to the response frame or handle
768285809Sscottl*                         of abort request
769285809Sscottl*  \param  agOtherInfo    Residual count
770285809Sscottl*   \return:              None
771285809Sscottl*
772285809Sscottl*   \note - This is a initiator specific function called by the jump table.
773285809Sscottl*
774285809Sscottl*****************************************************************************/
775285809SscottlFORCEINLINE void
776285809SscottlitdssIOCompleted(
777285809Sscottl                 agsaRoot_t             *agRoot,
778285809Sscottl                 agsaIORequest_t        *agIORequest,
779285809Sscottl                 bit32                   agIOStatus,
780285809Sscottl                 bit32                   agIOInfoLen,
781285809Sscottl                 void                   *agParam,
782285809Sscottl                 bit32                   agOtherInfo
783285809Sscottl                 )
784285809Sscottl{
785285809Sscottl  tdsaRootOsData_t          *osData = (tdsaRootOsData_t *)agRoot->osData;
786285809Sscottl  tiRoot_t                  *tiRoot = (tiRoot_t *)osData->tiRoot;
787285809Sscottl  itdsaIni_t                *Initiator = (itdsaIni_t *)osData->itdsaIni;
788285809Sscottl  tdIORequestBody_t         *tdIORequestBody  = agNULL;
789285809Sscottl  agsaSASRequestBody_t      *agSASRequestBody = agNULL;
790285809Sscottl  agsaSSPInitiatorRequest_t *agSSPInitiatorRequest = agNULL;
791285809Sscottl  agsaSSPResponseInfoUnit_t  agSSPRespIU;
792285809Sscottl
793285809Sscottl  bit32 scsi_status = 0;
794285809Sscottl
795285809Sscottl  tiDeviceHandle_t          *tiDeviceHandle = agNULL;
796285809Sscottl  tdsaDeviceData_t          *oneDeviceData  = agNULL;
797285809Sscottl
798285809Sscottl  TI_DBG6(("itdssIOCompleted: start\n"));
799285809Sscottl  TI_DBG6(("itdssIOCompleted: agIOInfoLen %d\n", agIOInfoLen));
800285809Sscottl
801285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
802285809Sscottl  TD_ASSERT((NULL != tdIORequestBody), "itdssIOCompleted:tdIORequestBody NULL");
803285809Sscottl  if ( NULL == tdIORequestBody )  // handle windows assert case
804285809Sscottl  {
805285809Sscottl    return;
806285809Sscottl  }
807285809Sscottl  Initiator->NumIOsActive--;
808285809Sscottl
809285809Sscottl#ifdef DBG
810285809Sscottl  if (tdIORequestBody->ioCompleted == agTRUE)
811285809Sscottl  {
812285809Sscottl#ifdef  TD_DEBUG_ENABLE
813285809Sscottl    tiDeviceHandle = tdIORequestBody->tiDevHandle;
814285809Sscottl    oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
815285809Sscottl#endif /*TD_DEBUG_ENABLE*/
816285809Sscottl    TI_DBG1(("itdssIOCompleted: Error!!!!!! double completion\n"));
817285809Sscottl#ifdef  TD_DEBUG_ENABLE
818285809Sscottl    TI_DBG1(("itdssIOCompleted: did %d \n", oneDeviceData->id));
819285809Sscottl#endif /*TD_DEBUG_ENABLE*/
820285809Sscottl  }
821285809Sscottl
822285809Sscottl  if (Initiator->NumIOsActive == 0)
823285809Sscottl  {
824285809Sscottl    /* so far, no timer assocaicated here */
825285809Sscottl    TI_DBG6(("itdssIOCompleted: no acitve IO's. Kill timers\n"));
826285809Sscottl  }
827285809Sscottl
828285809Sscottl  if (tdIORequestBody->tiIORequest->osData == agNULL)
829285809Sscottl  {
830285809Sscottl    TI_DBG1( ("itdssIOCompleted: pos 1; "
831285809Sscottl              "tdIORequestBody->tiIORequest->osData is null, wrong\n") );
832285809Sscottl  }
833285809Sscottl#endif /*DBG*/
834285809Sscottl
835285809Sscottl  tdIORequestBody->ioCompleted = agTRUE;
836285809Sscottl  tdIORequestBody->ioStarted = agFALSE;
837285809Sscottl
838285809Sscottl  /* Process completion for debugging, printing cbd */
839285809Sscottl  agSASRequestBody = &(tdIORequestBody->transport.SAS.agSASRequestBody);
840285809Sscottl  agSSPInitiatorRequest = &(agSASRequestBody->sspInitiatorReq);
841285809Sscottl
842285809Sscottl  TI_DBG6( ("itdssIOCompleted: CDB 0x%x\n",
843285809Sscottl            agSSPInitiatorRequest->sspCmdIU.cdb[0]) );
844285809Sscottl
845285809Sscottl  /* no respsonse or sense data; data has been processed */
846285809Sscottl  if((agIOStatus == OSSA_IO_SUCCESS) && (agIOInfoLen == 0))
847285809Sscottl  {
848285809Sscottl    // if this is a standard Inquiry command, notify Stoport to set the
849285809Sscottl    // device queue depth to maximize oustanding IO
850285809Sscottl    if ( (agSSPInitiatorRequest->sspCmdIU.cdb[0] == SCSIOPC_INQUIRY) &&
851285809Sscottl         ((agSSPInitiatorRequest->sspCmdIU.cdb[1] & 0x01) == 0))
852285809Sscottl    {
853285809Sscottl      bit32 qdepth = 32;
854285809Sscottl      tiDeviceHandle = tdIORequestBody->tiDevHandle;
855285809Sscottl      if( tiDeviceHandle )
856285809Sscottl      {
857285809Sscottl        oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
858285809Sscottl        if( oneDeviceData->DeviceType == TD_SAS_DEVICE )
859285809Sscottl        {
860285809Sscottl          qdepth = MAX_OUTSTANDING_IO_PER_LUN;
861285809Sscottl        }
862285809Sscottl        if( oneDeviceData->DeviceType == TD_SATA_DEVICE )
863285809Sscottl        {
864285809Sscottl          qdepth = 63;
865285809Sscottl        }
866285809Sscottl      }
867285809Sscottl
868285809Sscottl      if ( ostiSetDeviceQueueDepth( tiRoot,
869285809Sscottl                                    tdIORequestBody->tiIORequest,
870285809Sscottl                                    MAX_OUTSTANDING_IO_PER_LUN ) == agFALSE )
871285809Sscottl      {
872285809Sscottl        TI_DBG1( ( "itdssIOCompleted: failed to call "
873285809Sscottl                   "ostiSetDeviceQueueDepth() Q=%d !!!\n", qdepth ) );
874285809Sscottl      }
875285809Sscottl      else
876285809Sscottl      {
877285809Sscottl        TI_DBG2(("itdssIOCompleted: set ostiSetDeviceQueueDepth() Q=%d\n",qdepth));
878285809Sscottl      }
879285809Sscottl    }
880285809Sscottl    // SCSI command was completed OK, this is the normal path. Now call the
881285809Sscottl    // OS Specific module about this completion.
882285809Sscottl    ostiInitiatorIOCompleted(
883285809Sscottl                             tiRoot,
884285809Sscottl                             tdIORequestBody->tiIORequest,
885285809Sscottl                             tiIOSuccess,
886285809Sscottl                             SCSI_STAT_GOOD,
887285809Sscottl                             agNULL,
888285809Sscottl                             agTRUE /* intContext; is not being used */
889285809Sscottl                             );
890285809Sscottl    return;
891285809Sscottl  }
892285809Sscottl
893285809Sscottl  else
894285809Sscottl  {
895285809Sscottl    TI_DBG6(("itdssIOCompleted: SUCCESS but data returned \n"));
896285809Sscottl    TI_DBG6( ("itdssIOCompleted: agIOStatus SUCCESS but data returned 0x%x\n",
897285809Sscottl              agIOStatus) );
898285809Sscottl    if(tdIORequestBody)
899285809Sscottl    {
900285809Sscottl      tiDeviceHandle = tdIORequestBody->tiDevHandle;
901285809Sscottl      if(tiDeviceHandle)
902285809Sscottl      {
903285809Sscottl        oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
904285809Sscottl      }
905285809Sscottl    }
906285809Sscottl
907285809Sscottl    osti_memset(&agSSPRespIU, 0, sizeof(agsaSSPResponseInfoUnit_t));
908285809Sscottl
909285809Sscottl    saFrameReadBlock( agRoot,
910285809Sscottl                      agParam,
911285809Sscottl                      0,
912285809Sscottl                      &agSSPRespIU,
913285809Sscottl                      sizeof(agsaSSPResponseInfoUnit_t) );
914285809Sscottl    scsi_status = agSSPRespIU.status;
915285809Sscottl
916285809Sscottl    switch (scsi_status)
917285809Sscottl    {
918285809Sscottl      case SCSI_STAT_GOOD:
919285809Sscottl        TI_DBG2( ("itdssIOCompleted: SCSI_STAT_GOOD %d\n",
920285809Sscottl                  Initiator->ScsiStatusCounts.GoodStatus) );
921285809Sscottl        Initiator->ScsiStatusCounts.GoodStatus++;
922285809Sscottl        break;
923285809Sscottl       case SCSI_STAT_CHECK_CONDITION:
924285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_CHECK_CONDITION %d\n",
925285809Sscottl                  Initiator->ScsiStatusCounts.CheckCondition) );
926285809Sscottl        Initiator->ScsiStatusCounts.CheckCondition++;
927285809Sscottl        break;
928285809Sscottl      case SCSI_STAT_BUSY:
929285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_BUSY %d\n",
930285809Sscottl                  Initiator->ScsiStatusCounts.BusyStatus) );
931285809Sscottl        Initiator->ScsiStatusCounts.BusyStatus++;
932285809Sscottl        break;
933285809Sscottl      case SCSI_STAT_RESV_CONFLICT:
934285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_RESV_CONFLICT %d\n",
935285809Sscottl                  Initiator->ScsiStatusCounts.ResvConflict) );
936285809Sscottl        Initiator->ScsiStatusCounts.ResvConflict++;
937285809Sscottl        break;
938285809Sscottl      case SCSI_STAT_TASK_SET_FULL:
939285809Sscottl        Initiator->ScsiStatusCounts.TaskSetFull++;
940285809Sscottl        //agIOStatus =  OSSA_IO_FAILED;
941285809Sscottl        //agOtherInfo = tiDetailBusy;
942285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_TASK_SET_FULL %d\n",
943285809Sscottl                  Initiator->ScsiStatusCounts.TaskSetFull) );
944285809Sscottl        break;
945285809Sscottl      case SCSI_STAT_ACA_ACTIVE:
946285809Sscottl        Initiator->ScsiStatusCounts.AcaActive++;
947285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_ACA_ACTIVE %d\n",
948285809Sscottl                  Initiator->ScsiStatusCounts.AcaActive) );
949285809Sscottl        break;
950285809Sscottl      case SCSI_STAT_TASK_ABORTED:
951285809Sscottl        Initiator->ScsiStatusCounts.TaskAborted++;
952285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_TASK_ABORTED %d\n",
953285809Sscottl                  Initiator->ScsiStatusCounts.TaskAborted) );
954285809Sscottl        break;
955285809Sscottl      case SCSI_STAT_CONDITION_MET:
956285809Sscottl        Initiator->ScsiStatusCounts.ConditionMet++;
957285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_CONDITION_MET %d\n",
958285809Sscottl                  Initiator->ScsiStatusCounts.ConditionMet) );
959285809Sscottl        break;
960285809Sscottl      case SCSI_STAT_INTERMEDIATE:
961285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_INTERMEDIATE %d\n",
962285809Sscottl                  Initiator->ScsiStatusCounts.ObsoleteStatus) );
963285809Sscottl        Initiator->ScsiStatusCounts.ObsoleteStatus++;
964285809Sscottl        break;
965285809Sscottl      case SCSI_STAT_INTER_CONDIT_MET:
966285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_INTER_CONDIT_MET %d\n",
967285809Sscottl                  Initiator->ScsiStatusCounts.ObsoleteStatus) );
968285809Sscottl        Initiator->ScsiStatusCounts.ObsoleteStatus++;
969285809Sscottl        break;
970285809Sscottl      case SCSI_STAT_COMMANDTERMINATED:
971285809Sscottl        TI_DBG1( ("itdssIOCompleted: SCSI_STAT_COMMANDTERMINATED %d\n",
972285809Sscottl                  Initiator->ScsiStatusCounts.ObsoleteStatus) );
973285809Sscottl        Initiator->ScsiStatusCounts.ObsoleteStatus++;
974285809Sscottl        break;
975285809Sscottl      default:
976285809Sscottl        Initiator->ScsiStatusCounts.ObsoleteStatus++;
977285809Sscottl        TI_DBG1( ("itdssIOCompleted: Unknown scsi_status %d 0x%x\n",
978285809Sscottl                  scsi_status,Initiator->ScsiStatusCounts.ObsoleteStatus) );
979285809Sscottl    }
980285809Sscottl
981285809Sscottl    switch (agIOStatus)
982285809Sscottl    {
983285809Sscottl    case OSSA_IO_SUCCESS:
984285809Sscottl      itdssIOSuccessHandler( agRoot,
985285809Sscottl                             agIORequest,
986285809Sscottl                             agIOStatus,
987285809Sscottl                             agIOInfoLen,
988285809Sscottl                             agParam,
989285809Sscottl                             agOtherInfo );
990285809Sscottl      break;
991285809Sscottl    case OSSA_IO_ABORTED:
992285809Sscottl      itdssIOAbortedHandler( agRoot,
993285809Sscottl                             agIORequest,
994285809Sscottl                             agIOStatus,
995285809Sscottl                             agIOInfoLen,
996285809Sscottl                             agParam,
997285809Sscottl                             agOtherInfo );
998285809Sscottl      break;
999285809Sscottl    case OSSA_IO_UNDERFLOW:
1000285809Sscottl      itdssIOUnderFlowHandler( agRoot,
1001285809Sscottl                               agIORequest,
1002285809Sscottl                               agIOStatus,
1003285809Sscottl                               agIOInfoLen,
1004285809Sscottl                               agParam,
1005285809Sscottl                               agOtherInfo );
1006285809Sscottl      break;
1007285809Sscottl    case OSSA_IO_FAILED:
1008285809Sscottl      itdssIOFailedHandler( agRoot,
1009285809Sscottl                            agIORequest,
1010285809Sscottl                            agIOStatus,
1011285809Sscottl                            agIOInfoLen,
1012285809Sscottl                            agParam,
1013285809Sscottl                            agOtherInfo );
1014285809Sscottl      break;
1015285809Sscottl    case OSSA_IO_ABORT_RESET:
1016285809Sscottl      itdssIOAbortResetHandler( agRoot,
1017285809Sscottl                                agIORequest,
1018285809Sscottl                                agIOStatus,
1019285809Sscottl                                agIOInfoLen,
1020285809Sscottl                                agParam,
1021285809Sscottl                                agOtherInfo );
1022285809Sscottl      break;
1023285809Sscottl    case OSSA_IO_NO_DEVICE:
1024285809Sscottl      itdssIONoDeviceHandler( agRoot,
1025285809Sscottl                              agIORequest,
1026285809Sscottl                              agIOStatus,
1027285809Sscottl                              agIOInfoLen,
1028285809Sscottl                              agParam,
1029285809Sscottl                              agOtherInfo );
1030285809Sscottl      break;
1031285809Sscottl    case OSSA_IO_XFER_ERROR_BREAK:
1032285809Sscottl      itdssXferErrorBreakHandler( agRoot,
1033285809Sscottl                                  agIORequest,
1034285809Sscottl                                  agIOStatus,
1035285809Sscottl                                  agIOInfoLen,
1036285809Sscottl                                  agParam,
1037285809Sscottl                                  agOtherInfo );
1038285809Sscottl      break;
1039285809Sscottl    case OSSA_IO_XFER_ERROR_PHY_NOT_READY:
1040285809Sscottl      itdssXferErrorPhyNotReadyHandler( agRoot,
1041285809Sscottl                                        agIORequest,
1042285809Sscottl                                        agIOStatus,
1043285809Sscottl                                        agIOInfoLen,
1044285809Sscottl                                        agParam,
1045285809Sscottl                                        agOtherInfo );
1046285809Sscottl      break;
1047285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED:
1048285809Sscottl      itdssOpenCnxErrorProtocolNotSupprotedHandler( agRoot,
1049285809Sscottl                                                    agIORequest,
1050285809Sscottl                                                    agIOStatus,
1051285809Sscottl                                                    agIOInfoLen,
1052285809Sscottl                                                    agParam,
1053285809Sscottl                                                    agOtherInfo );
1054285809Sscottl      break;
1055285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION:
1056285809Sscottl      itdssOpenCnxErrorZoneViolationHandler( agRoot,
1057285809Sscottl                                             agIORequest,
1058285809Sscottl                                             agIOStatus,
1059285809Sscottl                                             agIOInfoLen,
1060285809Sscottl                                             agParam,
1061285809Sscottl                                             agOtherInfo );
1062285809Sscottl      break;
1063285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_BREAK:
1064285809Sscottl      itdssOpenCnxErrorBreakHandler( agRoot,
1065285809Sscottl                                     agIORequest,
1066285809Sscottl                                     agIOStatus,
1067285809Sscottl                                     agIOInfoLen,
1068285809Sscottl                                     agParam,
1069285809Sscottl                                     agOtherInfo );
1070285809Sscottl      break;
1071285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS:
1072285809Sscottl      itdssOpenCnxErrorITNexusLossHandler( agRoot,
1073285809Sscottl                                           agIORequest,
1074285809Sscottl                                           agIOStatus,
1075285809Sscottl                                           agIOInfoLen,
1076285809Sscottl                                           agParam,
1077285809Sscottl                                           agOtherInfo );
1078285809Sscottl      break;
1079285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION:
1080285809Sscottl      itdssOpenCnxErrorBadDestinationHandler( agRoot,
1081285809Sscottl                                              agIORequest,
1082285809Sscottl                                              agIOStatus,
1083285809Sscottl                                              agIOInfoLen,
1084285809Sscottl                                              agParam,
1085285809Sscottl                                              agOtherInfo );
1086285809Sscottl      break;
1087285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED:
1088285809Sscottl      itdssOpenCnxErrorConnectionRateNotSupportedHandler( agRoot,
1089285809Sscottl                                                          agIORequest,
1090285809Sscottl                                                          agIOStatus,
1091285809Sscottl                                                          agIOInfoLen,
1092285809Sscottl                                                          agParam,
1093285809Sscottl                                                          agOtherInfo );
1094285809Sscottl      break;
1095285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION:
1096285809Sscottl      itdssOpenCnxErrorWrongDestinationHandler( agRoot,
1097285809Sscottl                                                agIORequest,
1098285809Sscottl                                                agIOStatus,
1099285809Sscottl                                                agIOInfoLen,
1100285809Sscottl                                                agParam,
1101285809Sscottl                                                agOtherInfo );
1102285809Sscottl      break;
1103285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR:
1104285809Sscottl      itdssOpenCnxErrorUnknownErrorHandler( agRoot,
1105285809Sscottl                                            agIORequest,
1106285809Sscottl                                            agIOStatus,
1107285809Sscottl                                            agIOInfoLen,
1108285809Sscottl                                            agParam,
1109285809Sscottl                                            agOtherInfo );
1110285809Sscottl      break;
1111285809Sscottl    case OSSA_IO_XFER_ERROR_NAK_RECEIVED:
1112285809Sscottl      itdssXferErrorNAKReceivedHandler( agRoot,
1113285809Sscottl                                        agIORequest,
1114285809Sscottl                                        agIOStatus,
1115285809Sscottl                                        agIOInfoLen,
1116285809Sscottl                                        agParam,
1117285809Sscottl                                        agOtherInfo );
1118285809Sscottl      break;
1119285809Sscottl    case OSSA_IO_XFER_ERROR_ACK_NAK_TIMEOUT:
1120285809Sscottl      itdssXferErrorACKNAKTimeoutHandler( agRoot,
1121285809Sscottl                                          agIORequest,
1122285809Sscottl                                          agIOStatus,
1123285809Sscottl                                          agIOInfoLen,
1124285809Sscottl                                          agParam,
1125285809Sscottl                                          agOtherInfo );
1126285809Sscottl      break;
1127285809Sscottl    case OSSA_IO_XFER_ERROR_DMA:
1128285809Sscottl      itdssXferErrorDMAHandler( agRoot,
1129285809Sscottl                                agIORequest,
1130285809Sscottl                                agIOStatus,
1131285809Sscottl                                agIOInfoLen,
1132285809Sscottl                                agParam,
1133285809Sscottl                                agOtherInfo );
1134285809Sscottl      break;
1135285809Sscottl    case OSSA_IO_XFER_ERROR_OFFSET_MISMATCH:
1136285809Sscottl      itdssXferErrorOffsetMismatchHandler( agRoot,
1137285809Sscottl                                           agIORequest,
1138285809Sscottl                                           agIOStatus,
1139285809Sscottl                                           agIOInfoLen,
1140285809Sscottl                                           agParam,
1141285809Sscottl                                           agOtherInfo );
1142285809Sscottl      break;
1143285809Sscottl    case OSSA_IO_XFER_OPEN_RETRY_TIMEOUT:
1144285809Sscottl      itdssXferOpenRetryTimeoutHandler( agRoot,
1145285809Sscottl                                        agIORequest,
1146285809Sscottl                                        agIOStatus,
1147285809Sscottl                                        agIOInfoLen,
1148285809Sscottl                                        agParam,
1149285809Sscottl                                        agOtherInfo );
1150285809Sscottl      break;
1151285809Sscottl    case OSSA_IO_PORT_IN_RESET:
1152285809Sscottl      itdssPortInResetHandler( agRoot,
1153285809Sscottl                               agIORequest,
1154285809Sscottl                               agIOStatus,
1155285809Sscottl                               agIOInfoLen,
1156285809Sscottl                               agParam,
1157285809Sscottl                               agOtherInfo );
1158285809Sscottl      break;
1159285809Sscottl    case OSSA_IO_DS_NON_OPERATIONAL:
1160285809Sscottl      itdssDsNonOperationalHandler( agRoot,
1161285809Sscottl                                    agIORequest,
1162285809Sscottl                                    agIOStatus,
1163285809Sscottl                                    agIOInfoLen,
1164285809Sscottl                                    agParam,
1165285809Sscottl                                    agOtherInfo );
1166285809Sscottl      break;
1167285809Sscottl    case OSSA_IO_DS_IN_RECOVERY:
1168285809Sscottl      itdssDsInRecoveryHandler( agRoot,
1169285809Sscottl                                agIORequest,
1170285809Sscottl                                agIOStatus,
1171285809Sscottl                                agIOInfoLen,
1172285809Sscottl                                agParam,
1173285809Sscottl                                agOtherInfo );
1174285809Sscottl      break;
1175285809Sscottl    case OSSA_IO_TM_TAG_NOT_FOUND:
1176285809Sscottl      itdssTmTagNotFoundHandler( agRoot,
1177285809Sscottl                                 agIORequest,
1178285809Sscottl                                 agIOStatus,
1179285809Sscottl                                 agIOInfoLen,
1180285809Sscottl                                 agParam,
1181285809Sscottl                                 agOtherInfo );
1182285809Sscottl      break;
1183285809Sscottl    case OSSA_IO_SSP_EXT_IU_ZERO_LEN_ERROR:
1184285809Sscottl      itdssSSPExtIUZeroLenHandler( agRoot,
1185285809Sscottl                                   agIORequest,
1186285809Sscottl                                   agIOStatus,
1187285809Sscottl                                   agIOInfoLen,
1188285809Sscottl                                   agParam,
1189285809Sscottl                                   agOtherInfo );
1190285809Sscottl      break;
1191285809Sscottl    case OSSA_IO_XFER_ERROR_UNEXPECTED_PHASE:
1192285809Sscottl      itdssXferErrorUnexpectedPhaseHandler( agRoot,
1193285809Sscottl                                            agIORequest,
1194285809Sscottl                                            agIOStatus,
1195285809Sscottl                                            agIOInfoLen,
1196285809Sscottl                                            agParam,
1197285809Sscottl                                            agOtherInfo );
1198285809Sscottl      break;
1199285809Sscottl//new
1200285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED:
1201285809Sscottl      itdssXferOpenRetryBackoffThresholdReachedHandler( agRoot,
1202285809Sscottl                                                        agIORequest,
1203285809Sscottl                                                        agIOStatus,
1204285809Sscottl                                                        agIOInfoLen,
1205285809Sscottl                                                        agParam,
1206285809Sscottl                                                        agOtherInfo );
1207285809Sscottl      break;
1208285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO:
1209285809Sscottl      itdssOpenCnxErrorItNexusLossOpenTmoHandler( agRoot,
1210285809Sscottl                                                  agIORequest,
1211285809Sscottl                                                  agIOStatus,
1212285809Sscottl                                                  agIOInfoLen,
1213285809Sscottl                                                  agParam,
1214285809Sscottl                                                  agOtherInfo );
1215285809Sscottl      break;
1216285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST:
1217285809Sscottl      itdssOpenCnxErrorItNexusLossNoDestHandler( agRoot,
1218285809Sscottl                                                 agIORequest,
1219285809Sscottl                                                 agIOStatus,
1220285809Sscottl                                                 agIOInfoLen,
1221285809Sscottl                                                 agParam,
1222285809Sscottl                                                 agOtherInfo );
1223285809Sscottl      break;
1224285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE:
1225285809Sscottl      itdssOpenCnxErrorItNexusLossOpenCollideHandler( agRoot,
1226285809Sscottl                                                      agIORequest,
1227285809Sscottl                                                      agIOStatus,
1228285809Sscottl                                                      agIOInfoLen,
1229285809Sscottl                                                      agParam,
1230285809Sscottl                                                      agOtherInfo );
1231285809Sscottl      break;
1232285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED:
1233285809Sscottl      itdssOpenCnxErrorItNexusLossOpenPathwayBlockedHandler( agRoot,
1234285809Sscottl                                                             agIORequest,
1235285809Sscottl                                                             agIOStatus,
1236285809Sscottl                                                             agIOInfoLen,
1237285809Sscottl                                                             agParam,
1238285809Sscottl                                                             agOtherInfo );
1239285809Sscottl      break;
1240285809Sscottl      // encryption IO error handling
1241285809Sscottl    case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS:
1242285809Sscottl    case OSSA_IO_XFR_ERROR_DEK_KEY_TAG_MISMATCH:
1243285809Sscottl    case OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID:
1244285809Sscottl    case OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH:
1245285809Sscottl    case OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR:
1246285809Sscottl    case OSSA_IO_XFR_ERROR_INTERNAL_RAM:
1247285809Sscottl    case OSSA_IO_XFR_ERROR_DEK_INDEX_OUT_OF_BOUNDS:
1248285809Sscottl      itdssEncryptionHandler( agRoot,
1249285809Sscottl                              agIORequest,
1250285809Sscottl                              agIOStatus,
1251285809Sscottl                              agIOInfoLen,
1252285809Sscottl                              agParam,
1253285809Sscottl                              agOtherInfo );
1254285809Sscottl      break;
1255285809Sscottl
1256285809Sscottl    /* DIF IO error handling */
1257285809Sscottl    case OSSA_IO_XFR_ERROR_DIF_MISMATCH:
1258285809Sscottl    case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH:
1259285809Sscottl    case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH:
1260285809Sscottl    case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH:
1261285809Sscottl      itdssDifHandler( agRoot,
1262285809Sscottl                       agIORequest,
1263285809Sscottl                       agIOStatus,
1264285809Sscottl                       agIOInfoLen,
1265285809Sscottl                       agParam,
1266285809Sscottl                       agOtherInfo );
1267285809Sscottl      break;
1268285809Sscottl    case OSSA_MPI_ERR_IO_RESOURCE_UNAVAILABLE:
1269285809Sscottl      itdssIOResourceUnavailableHandler( agRoot,
1270285809Sscottl                                         agIORequest,
1271285809Sscottl                                         agIOStatus,
1272285809Sscottl                                         agIOInfoLen,
1273285809Sscottl                                         agParam,
1274285809Sscottl                                         agOtherInfo );
1275285809Sscottl      break;
1276285809Sscottl    case OSSA_MPI_IO_RQE_BUSY_FULL:
1277285809Sscottl      itdssIORQEBusyFullHandler( agRoot,
1278285809Sscottl                                 agIORequest,
1279285809Sscottl                                 agIOStatus,
1280285809Sscottl                                 agIOInfoLen,
1281285809Sscottl                                 agParam,
1282285809Sscottl                                 agOtherInfo );
1283285809Sscottl      break;
1284285809Sscottl    case OSSA_IO_XFR_ERROR_INVALID_SSP_RSP_FRAME:
1285285809Sscottl      itdssXferErrorInvalidSSPRspFrameHandler( agRoot,
1286285809Sscottl                                               agIORequest,
1287285809Sscottl                                               agIOStatus,
1288285809Sscottl                                               agIOInfoLen,
1289285809Sscottl                                               agParam,
1290285809Sscottl                                               agOtherInfo );
1291285809Sscottl      break;
1292285809Sscottl    case OSSA_IO_XFER_ERR_EOB_DATA_OVERRUN:
1293285809Sscottl      itdssXferErrorEOBDataOverrunHandler( agRoot,
1294285809Sscottl                                           agIORequest,
1295285809Sscottl                                           agIOStatus,
1296285809Sscottl                                           agIOInfoLen,
1297285809Sscottl                                           agParam,
1298285809Sscottl                                           agOtherInfo );
1299285809Sscottl      break;
1300285809Sscottl    case OSSA_IO_OPEN_CNX_ERROR_OPEN_PREEMPTED:
1301285809Sscottl      itdssOpenCnxErrorOpenPreemptedHandler( agRoot,
1302285809Sscottl                                             agIORequest,
1303285809Sscottl                                             agIOStatus,
1304285809Sscottl                                             agIOInfoLen,
1305285809Sscottl                                             agParam,
1306285809Sscottl                                             agOtherInfo );
1307285809Sscottl      break;
1308285809Sscottl    default:
1309285809Sscottl      TI_DBG1( ("itdssIOCompleted: Unknown agIOStatus 0x%x\n",agIOStatus) );
1310285809Sscottl      itdssIODefaultHandler( agRoot,
1311285809Sscottl                             agIORequest,
1312285809Sscottl                             agIOStatus,
1313285809Sscottl                             agIOInfoLen,
1314285809Sscottl                             agParam,
1315285809Sscottl                             agOtherInfo );
1316285809Sscottl      break;
1317285809Sscottl    }
1318285809Sscottl  }
1319285809Sscottl  return;
1320285809Sscottl}
1321285809Sscottl
1322285809Sscottl#ifdef TD_DISCOVER
1323285809Sscottl/*****************************************************************************
1324285809Sscottl*!  \brief  itdssSMPCompleted
1325285809Sscottl*
1326285809Sscottl*  Purpose: This routine is called to complete an SMP request previously
1327285809Sscottl*           issued to the LL Layer in saSMPStart().
1328285809Sscottl*
1329285809Sscottl*   \param  agRoot:         Pointer to driver Instance.
1330285809Sscottl*   \param  agIORequest:    Pointer to the I/O Request data structure for
1331285809Sscottl*                           this I/O.
1332285809Sscottl*   \param  agIOStatus:     Status of I/O just completed.
1333285809Sscottl*   \param  agIOInfoLen:    Length of the I/O information associated with this
1334285809Sscottl*                           I/O request
1335285809Sscottl*   \param   agFrameHandle  A Handle used to refer to the response frame
1336285809Sscottl*
1337285809Sscottl*   \return:                None
1338285809Sscottl*
1339285809Sscottl*   \note - This is a initiator specific function called by the jump table.
1340285809Sscottl*
1341285809Sscottl*****************************************************************************/
1342285809SscottlosGLOBAL void
1343285809SscottlitdssSMPCompleted (
1344285809Sscottl                   agsaRoot_t            *agRoot,
1345285809Sscottl                   agsaIORequest_t       *agIORequest,
1346285809Sscottl                   bit32                 agIOStatus,
1347285809Sscottl                   bit32                 agIOInfoLen,
1348285809Sscottl                   agsaFrameHandle_t     agFrameHandle
1349285809Sscottl                   )
1350285809Sscottl{
1351285809Sscottl  tdsaRootOsData_t          *osData = (tdsaRootOsData_t *)agRoot->osData;
1352285809Sscottl  tiRoot_t                  *tiRoot = (tiRoot_t *)osData->tiRoot;
1353285809Sscottl#ifdef REMOVED
1354285809Sscottl  tdsaRoot_t                *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
1355285809Sscottl  tdsaContext_t             *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
1356285809Sscottl#endif
1357285809Sscottl  tdssSMPRequestBody_t      *tdSMPRequestBody;
1358285809Sscottl  agsaSASRequestBody_t      *agSASRequestBody;
1359285809Sscottl  agsaSMPFrame_t            *agSMPFrame;
1360285809Sscottl  tdsaDeviceData_t          *oneDeviceData;
1361285809Sscottl  tiIORequest_t             *CurrentTaskTag;
1362285809Sscottl  tdsaPortContext_t         *onePortContext;
1363285809Sscottl  tdsaPortContext_t         *oldonePortContext;
1364285809Sscottl  smpReqPhyControl_t        *smpPhyControlReq;
1365285809Sscottl  bit8                      smpHeader[4];
1366285809Sscottl  tdssSMPFrameHeader_t      *tdSMPFrameHeader;
1367285809Sscottl  bit8                      *tdSMPPayload;
1368285809Sscottl  agsaDevHandle_t           *agDevHandle;
1369285809Sscottl  bit32                     status;
1370285809Sscottl#ifndef DIRECT_SMP
1371285809Sscottl  tdssSMPFrameHeader_t      *tdRequestSMPFrameHeader;
1372285809Sscottl  bit8                      smpRequestHeader[4];
1373285809Sscottl#endif
1374285809Sscottl  bit8                      SMPRequestFunction;
1375285809Sscottl
1376285809Sscottl  TI_DBG3(("itdssSMPCompleted: start\n"));
1377285809Sscottl
1378285809Sscottl
1379285809Sscottl  tdSMPRequestBody = (tdssSMPRequestBody_t *)agIORequest->osData;
1380285809Sscottl  CurrentTaskTag  = tdSMPRequestBody->CurrentTaskTag;
1381285809Sscottl
1382285809Sscottl  oneDeviceData = tdSMPRequestBody->tdDevice;
1383285809Sscottl  onePortContext = oneDeviceData->tdPortContext;
1384285809Sscottl  agDevHandle = oneDeviceData->agDevHandle;
1385285809Sscottl
1386285809Sscottl
1387285809Sscottl  agSASRequestBody = &(tdSMPRequestBody->agSASRequestBody);
1388285809Sscottl  agSMPFrame = &(agSASRequestBody->smpFrame);
1389285809Sscottl
1390285809Sscottl#ifdef DIRECT_SMP
1391285809Sscottl  SMPRequestFunction = tdSMPRequestBody->smpPayload[1];
1392285809Sscottl#else
1393285809Sscottl  saFrameReadBlock(agRoot, tdSMPRequestBody->IndirectSMPResp, 0, smpRequestHeader, 4);
1394285809Sscottl  tdRequestSMPFrameHeader = (tdssSMPFrameHeader_t *)smpRequestHeader;
1395285809Sscottl  SMPRequestFunction = tdRequestSMPFrameHeader->smpFunction;
1396285809Sscottl#endif
1397285809Sscottl
1398285809Sscottl  TI_DBG3(("itdssSMPCompleted: agIORequest %p\n", agIORequest));
1399285809Sscottl  TI_DBG3(("itdssSMPCompleted: SMPRequestbody %p\n", tdSMPRequestBody));
1400285809Sscottl
1401285809Sscottl  if (onePortContext != agNULL)
1402285809Sscottl  {
1403285809Sscottl    TI_DBG3(("itdssSMPCompleted: pid %d\n", onePortContext->id));
1404285809Sscottl  }
1405285809Sscottl  else
1406285809Sscottl  {
1407285809Sscottl    TI_DBG1(("itdssSMPCompleted: Wrong!!! onePortContext is NULL\n"));
1408285809Sscottl    ostiFreeMemory(
1409285809Sscottl                 tiRoot,
1410285809Sscottl                 tdSMPRequestBody->osMemHandle,
1411285809Sscottl                 sizeof(tdssSMPRequestBody_t)
1412285809Sscottl                 );
1413285809Sscottl#ifndef DIRECT_SMP
1414285809Sscottl    ostiFreeMemory(
1415285809Sscottl                 tiRoot,
1416285809Sscottl                 tdSMPRequestBody->IndirectSMPReqosMemHandle,
1417285809Sscottl                 tdSMPRequestBody->IndirectSMPReqLen
1418285809Sscottl                 );
1419285809Sscottl    ostiFreeMemory(
1420285809Sscottl                 tiRoot,
1421285809Sscottl                 tdSMPRequestBody->IndirectSMPResposMemHandle,
1422285809Sscottl                 tdSMPRequestBody->IndirectSMPRespLen
1423285809Sscottl                 );
1424285809Sscottl#endif
1425285809Sscottl    return;
1426285809Sscottl  }
1427285809Sscottl
1428285809Sscottl  oldonePortContext = tdSMPRequestBody->tdPortContext;
1429285809Sscottl  if (oldonePortContext != agNULL)
1430285809Sscottl  {
1431285809Sscottl    TI_DBG3(("itdssSMPCompleted: old pid %d\n", oldonePortContext->id));
1432285809Sscottl  }
1433285809Sscottl  else
1434285809Sscottl  {
1435285809Sscottl    TI_DBG1(("itdssSMPCompleted: Wrong!!! oldonePortContext is NULL\n"));
1436285809Sscottl    ostiFreeMemory(
1437285809Sscottl                 tiRoot,
1438285809Sscottl                 tdSMPRequestBody->osMemHandle,
1439285809Sscottl                 sizeof(tdssSMPRequestBody_t)
1440285809Sscottl                 );
1441285809Sscottl#ifndef DIRECT_SMP
1442285809Sscottl    ostiFreeMemory(
1443285809Sscottl                 tiRoot,
1444285809Sscottl                 tdSMPRequestBody->IndirectSMPReqosMemHandle,
1445285809Sscottl                 tdSMPRequestBody->IndirectSMPReqLen
1446285809Sscottl                 );
1447285809Sscottl    ostiFreeMemory(
1448285809Sscottl                 tiRoot,
1449285809Sscottl                 tdSMPRequestBody->IndirectSMPResposMemHandle,
1450285809Sscottl                 tdSMPRequestBody->IndirectSMPRespLen
1451285809Sscottl                 );
1452285809Sscottl#endif
1453285809Sscottl    return;
1454285809Sscottl  }
1455285809Sscottl
1456285809Sscottl
1457285809Sscottl  /* decrement the number of pending SMP */
1458285809Sscottl  onePortContext->discovery.pendingSMP--;
1459285809Sscottl
1460285809Sscottl  /* for port invalid case;
1461285809Sscottl     full discovery -> full discovery; incremental discovery -> full discovery
1462285809Sscottl   */
1463285809Sscottl  if (onePortContext != oldonePortContext)
1464285809Sscottl  {
1465285809Sscottl    TI_DBG1(("itdssSMPCompleted: portcontext has changed!!!\n"));
1466285809Sscottl    if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
1467285809Sscottl        SMPRequestFunction == SMP_REPORT_PHY_SATA ||
1468285809Sscottl        SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION )
1469285809Sscottl    {
1470285809Sscottl      /* stop SMP timer */
1471285809Sscottl      if (onePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
1472285809Sscottl      {
1473285809Sscottl        tdsaKillTimer(
1474285809Sscottl                      tiRoot,
1475285809Sscottl                      &(onePortContext->discovery.DiscoverySMPTimer)
1476285809Sscottl                     );
1477285809Sscottl      }
1478285809Sscottl      if (oldonePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
1479285809Sscottl      {
1480285809Sscottl        tdsaKillTimer(
1481285809Sscottl                      tiRoot,
1482285809Sscottl                      &(oldonePortContext->discovery.DiscoverySMPTimer)
1483285809Sscottl                     );
1484285809Sscottl      }
1485285809Sscottl    }
1486285809Sscottl
1487285809Sscottl    /* clean up expanders data strucures; move to free exp when device is cleaned */
1488285809Sscottl    tdsaCleanAllExp(tiRoot, oldonePortContext);
1489285809Sscottl    /* remove devices */
1490285809Sscottl    tdssInternalRemovals(oldonePortContext->agRoot,
1491285809Sscottl                         oldonePortContext
1492285809Sscottl                         );
1493285809Sscottl
1494285809Sscottl    ostiFreeMemory(
1495285809Sscottl                 tiRoot,
1496285809Sscottl                 tdSMPRequestBody->osMemHandle,
1497285809Sscottl                 sizeof(tdssSMPRequestBody_t)
1498285809Sscottl                 );
1499285809Sscottl#ifndef DIRECT_SMP
1500285809Sscottl    ostiFreeMemory(
1501285809Sscottl                 tiRoot,
1502285809Sscottl                 tdSMPRequestBody->IndirectSMPReqosMemHandle,
1503285809Sscottl                 tdSMPRequestBody->IndirectSMPReqLen
1504285809Sscottl                 );
1505285809Sscottl    ostiFreeMemory(
1506285809Sscottl                 tiRoot,
1507285809Sscottl                 tdSMPRequestBody->IndirectSMPResposMemHandle,
1508285809Sscottl                 tdSMPRequestBody->IndirectSMPRespLen
1509285809Sscottl                 );
1510285809Sscottl#endif
1511285809Sscottl    return;
1512285809Sscottl  }
1513285809Sscottl
1514285809Sscottl  if (onePortContext->valid == agFALSE)
1515285809Sscottl  {
1516285809Sscottl    if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
1517285809Sscottl        SMPRequestFunction == SMP_REPORT_PHY_SATA ||
1518285809Sscottl        SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION )
1519285809Sscottl    {
1520285809Sscottl      /* stop SMP timer */
1521285809Sscottl      if (onePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
1522285809Sscottl      {
1523285809Sscottl        tdsaKillTimer(
1524285809Sscottl                      tiRoot,
1525285809Sscottl                      &(onePortContext->discovery.DiscoverySMPTimer)
1526285809Sscottl                      );
1527285809Sscottl      }
1528285809Sscottl      if (oldonePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
1529285809Sscottl      {
1530285809Sscottl        tdsaKillTimer(
1531285809Sscottl                      tiRoot,
1532285809Sscottl                      &(oldonePortContext->discovery.DiscoverySMPTimer)
1533285809Sscottl                      );
1534285809Sscottl      }
1535285809Sscottl    }
1536285809Sscottl
1537285809Sscottl    if (onePortContext->discovery.pendingSMP == 0)
1538285809Sscottl    {
1539285809Sscottl      TI_DBG1(("itdssSMPCompleted: aborting discovery\n"));
1540285809Sscottl      tdsaSASDiscoverAbort(tiRoot, onePortContext);
1541285809Sscottl    }
1542285809Sscottl    else
1543285809Sscottl    {
1544285809Sscottl      TI_DBG1(("itdssSMPCompleted: not yet abort; non zero pendingSMP %d\n", onePortContext->discovery.pendingSMP));
1545285809Sscottl    }
1546285809Sscottl    ostiFreeMemory(
1547285809Sscottl                 tiRoot,
1548285809Sscottl                 tdSMPRequestBody->osMemHandle,
1549285809Sscottl                 sizeof(tdssSMPRequestBody_t)
1550285809Sscottl                 );
1551285809Sscottl#ifndef DIRECT_SMP
1552285809Sscottl    ostiFreeMemory(
1553285809Sscottl                 tiRoot,
1554285809Sscottl                 tdSMPRequestBody->IndirectSMPReqosMemHandle,
1555285809Sscottl                 tdSMPRequestBody->IndirectSMPReqLen
1556285809Sscottl                 );
1557285809Sscottl    ostiFreeMemory(
1558285809Sscottl                 tiRoot,
1559285809Sscottl                 tdSMPRequestBody->IndirectSMPResposMemHandle,
1560285809Sscottl                 tdSMPRequestBody->IndirectSMPRespLen
1561285809Sscottl                 );
1562285809Sscottl#endif
1563285809Sscottl    return;
1564285809Sscottl  }
1565285809Sscottl
1566285809Sscottl
1567285809Sscottl  if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
1568285809Sscottl      SMPRequestFunction == SMP_REPORT_PHY_SATA ||
1569285809Sscottl      SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION )
1570285809Sscottl  {
1571285809Sscottl    /* stop SMP timer */
1572285809Sscottl    if (onePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
1573285809Sscottl    {
1574285809Sscottl      tdsaKillTimer(
1575285809Sscottl                    tiRoot,
1576285809Sscottl                    &(onePortContext->discovery.DiscoverySMPTimer)
1577285809Sscottl                    );
1578285809Sscottl    }
1579285809Sscottl    if (oldonePortContext->discovery.DiscoverySMPTimer.timerRunning == agTRUE)
1580285809Sscottl    {
1581285809Sscottl      tdsaKillTimer(
1582285809Sscottl                    tiRoot,
1583285809Sscottl                    &(oldonePortContext->discovery.DiscoverySMPTimer)
1584285809Sscottl                    );
1585285809Sscottl    }
1586285809Sscottl  }
1587285809Sscottl
1588285809Sscottl  /* the host as of 4/16/08 does not use indirect SMP. So, check only OSSA_IO_SUCCESS status*/
1589285809Sscottl  if (agIOStatus == OSSA_IO_SUCCESS)
1590285809Sscottl  {
1591285809Sscottl    //tdhexdump("itdssSMPCompleted", (bit8*)agFrameHandle, agIOInfoLen);
1592285809Sscottl    /* parsing SMP payload */
1593285809Sscottl#ifdef DIRECT_SMP
1594285809Sscottl    saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
1595285809Sscottl#else
1596285809Sscottl    saFrameReadBlock(agRoot, tdSMPRequestBody->IndirectSMPResp, 0, smpHeader, 4);
1597285809Sscottl#endif
1598285809Sscottl    tdSMPFrameHeader = (tdssSMPFrameHeader_t *)smpHeader;
1599285809Sscottl
1600285809Sscottl    /* SMP function dependent payload */
1601285809Sscottl    switch (tdSMPFrameHeader->smpFunction)
1602285809Sscottl    {
1603285809Sscottl    case SMP_REPORT_GENERAL:
1604285809Sscottl      TI_DBG3(("itdssSMPCompleted: report general\n"));
1605285809Sscottl      if (agIOInfoLen != sizeof(smpRespReportGeneral_t) + 4 &&
1606285809Sscottl          tdSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
1607285809Sscottl      {
1608285809Sscottl        TI_DBG1(("itdssSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (unsigned int)sizeof(smpRespReportGeneral_t) + 4));
1609285809Sscottl        tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1610285809Sscottl        ostiFreeMemory(
1611285809Sscottl                       tiRoot,
1612285809Sscottl                       tdSMPRequestBody->osMemHandle,
1613285809Sscottl                       sizeof(tdssSMPRequestBody_t)
1614285809Sscottl                      );
1615285809Sscottl#ifndef DIRECT_SMP
1616285809Sscottl        ostiFreeMemory(
1617285809Sscottl                       tiRoot,
1618285809Sscottl                       tdSMPRequestBody->IndirectSMPReqosMemHandle,
1619285809Sscottl                       tdSMPRequestBody->IndirectSMPReqLen
1620285809Sscottl                      );
1621285809Sscottl        ostiFreeMemory(
1622285809Sscottl                       tiRoot,
1623285809Sscottl                       tdSMPRequestBody->IndirectSMPResposMemHandle,
1624285809Sscottl                       tdSMPRequestBody->IndirectSMPRespLen
1625285809Sscottl                      );
1626285809Sscottl#endif
1627285809Sscottl        return;
1628285809Sscottl      }
1629285809Sscottl      tdsaReportGeneralRespRcvd(
1630285809Sscottl                                tiRoot,
1631285809Sscottl                                agRoot,
1632285809Sscottl                                agIORequest,
1633285809Sscottl                                oneDeviceData,
1634285809Sscottl                                tdSMPFrameHeader,
1635285809Sscottl                                agFrameHandle
1636285809Sscottl                                );
1637285809Sscottl
1638285809Sscottl      break;
1639285809Sscottl    case SMP_DISCOVER:
1640285809Sscottl      TI_DBG3(("itdssSMPCompleted: discover\n"));
1641285809Sscottl      if (agIOInfoLen != sizeof(smpRespDiscover_t) + 4 &&
1642285809Sscottl          tdSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
1643285809Sscottl      {
1644285809Sscottl        TI_DBG1(("itdssSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (unsigned int)sizeof(smpRespDiscover_t) + 4));
1645285809Sscottl        tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1646285809Sscottl        ostiFreeMemory(
1647285809Sscottl                       tiRoot,
1648285809Sscottl                       tdSMPRequestBody->osMemHandle,
1649285809Sscottl                       sizeof(tdssSMPRequestBody_t)
1650285809Sscottl                      );
1651285809Sscottl#ifndef DIRECT_SMP
1652285809Sscottl        ostiFreeMemory(
1653285809Sscottl                       tiRoot,
1654285809Sscottl                       tdSMPRequestBody->IndirectSMPReqosMemHandle,
1655285809Sscottl                       tdSMPRequestBody->IndirectSMPReqLen
1656285809Sscottl                      );
1657285809Sscottl        ostiFreeMemory(
1658285809Sscottl                       tiRoot,
1659285809Sscottl                       tdSMPRequestBody->IndirectSMPResposMemHandle,
1660285809Sscottl                       tdSMPRequestBody->IndirectSMPRespLen
1661285809Sscottl                      );
1662285809Sscottl#endif
1663285809Sscottl        return;
1664285809Sscottl      }
1665285809Sscottl      tdsaDiscoverRespRcvd(
1666285809Sscottl                           tiRoot,
1667285809Sscottl                           agRoot,
1668285809Sscottl                           agIORequest,
1669285809Sscottl                           oneDeviceData,
1670285809Sscottl                           tdSMPFrameHeader,
1671285809Sscottl                           agFrameHandle
1672285809Sscottl                           );
1673285809Sscottl      break;
1674285809Sscottl    case SMP_REPORT_PHY_SATA:
1675285809Sscottl      TI_DBG3(("itdssSMPCompleted: report phy sata\n"));
1676285809Sscottl      if (agIOInfoLen != sizeof(smpRespReportPhySata_t) + 4 &&
1677285809Sscottl          tdSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
1678285809Sscottl      {
1679285809Sscottl        TI_DBG1(("itdssSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, (unsigned int)sizeof(smpRespReportPhySata_t) + 4));
1680285809Sscottl        tdsaSATADiscoverDone(tiRoot, onePortContext, tiError);
1681285809Sscottl        ostiFreeMemory(
1682285809Sscottl                       tiRoot,
1683285809Sscottl                       tdSMPRequestBody->osMemHandle,
1684285809Sscottl                       sizeof(tdssSMPRequestBody_t)
1685285809Sscottl                      );
1686285809Sscottl#ifndef DIRECT_SMP
1687285809Sscottl        ostiFreeMemory(
1688285809Sscottl                       tiRoot,
1689285809Sscottl                       tdSMPRequestBody->IndirectSMPReqosMemHandle,
1690285809Sscottl                       tdSMPRequestBody->IndirectSMPReqLen
1691285809Sscottl                      );
1692285809Sscottl        ostiFreeMemory(
1693285809Sscottl                       tiRoot,
1694285809Sscottl                       tdSMPRequestBody->IndirectSMPResposMemHandle,
1695285809Sscottl                       tdSMPRequestBody->IndirectSMPRespLen
1696285809Sscottl                      );
1697285809Sscottl#endif
1698285809Sscottl        return;
1699285809Sscottl      }
1700285809Sscottl      tdsaReportPhySataRcvd(
1701285809Sscottl                            tiRoot,
1702285809Sscottl                            agRoot,
1703285809Sscottl                            agIORequest,
1704285809Sscottl                            oneDeviceData,
1705285809Sscottl                            tdSMPFrameHeader,
1706285809Sscottl                            agFrameHandle
1707285809Sscottl                            );
1708285809Sscottl      break;
1709285809Sscottl    case SMP_CONFIGURE_ROUTING_INFORMATION:
1710285809Sscottl      TI_DBG1(("itdssSMPCompleted: configure routing information\n"));
1711285809Sscottl      if (agIOInfoLen != 4 &&
1712285809Sscottl          tdSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED)
1713285809Sscottl      {
1714285809Sscottl        TI_DBG1(("itdssSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, 4));
1715285809Sscottl        tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1716285809Sscottl        ostiFreeMemory(
1717285809Sscottl                       tiRoot,
1718285809Sscottl                       tdSMPRequestBody->osMemHandle,
1719285809Sscottl                       sizeof(tdssSMPRequestBody_t)
1720285809Sscottl                      );
1721285809Sscottl#ifndef DIRECT_SMP
1722285809Sscottl        ostiFreeMemory(
1723285809Sscottl                       tiRoot,
1724285809Sscottl                       tdSMPRequestBody->IndirectSMPReqosMemHandle,
1725285809Sscottl                       tdSMPRequestBody->IndirectSMPReqLen
1726285809Sscottl                      );
1727285809Sscottl        ostiFreeMemory(
1728285809Sscottl                       tiRoot,
1729285809Sscottl                       tdSMPRequestBody->IndirectSMPResposMemHandle,
1730285809Sscottl                       tdSMPRequestBody->IndirectSMPRespLen
1731285809Sscottl                      );
1732285809Sscottl#endif
1733285809Sscottl        return;
1734285809Sscottl      }
1735285809Sscottl      tdsaConfigRoutingInfoRespRcvd(
1736285809Sscottl                                    tiRoot,
1737285809Sscottl                                    agRoot,
1738285809Sscottl                                    agIORequest,
1739285809Sscottl                                    oneDeviceData,
1740285809Sscottl                                    tdSMPFrameHeader,
1741285809Sscottl                                    agFrameHandle
1742285809Sscottl                                    );
1743285809Sscottl
1744285809Sscottl      break;
1745285809Sscottl    case SMP_PHY_CONTROL:
1746285809Sscottl      TI_DBG3(("itdssSMPCompleted: phy control\n"));
1747285809Sscottl      if (agIOInfoLen != 4 &&
1748285809Sscottl          tdSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED) /*zero length is expected */
1749285809Sscottl      {
1750285809Sscottl        TI_DBG1(("itdssSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, 4));
1751285809Sscottl        tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1752285809Sscottl        ostiFreeMemory(
1753285809Sscottl                       tiRoot,
1754285809Sscottl                       tdSMPRequestBody->osMemHandle,
1755285809Sscottl                       sizeof(tdssSMPRequestBody_t)
1756285809Sscottl                      );
1757285809Sscottl#ifndef DIRECT_SMP
1758285809Sscottl        ostiFreeMemory(
1759285809Sscottl                       tiRoot,
1760285809Sscottl                       tdSMPRequestBody->IndirectSMPReqosMemHandle,
1761285809Sscottl                       tdSMPRequestBody->IndirectSMPReqLen
1762285809Sscottl                      );
1763285809Sscottl        ostiFreeMemory(
1764285809Sscottl                       tiRoot,
1765285809Sscottl                       tdSMPRequestBody->IndirectSMPResposMemHandle,
1766285809Sscottl                       tdSMPRequestBody->IndirectSMPRespLen
1767285809Sscottl                      );
1768285809Sscottl#endif
1769285809Sscottl        return;
1770285809Sscottl      }
1771285809Sscottl      tdsaPhyControlRespRcvd(
1772285809Sscottl                             tiRoot,
1773285809Sscottl                             agRoot,
1774285809Sscottl                             agIORequest,
1775285809Sscottl                             oneDeviceData,
1776285809Sscottl                             tdSMPFrameHeader,
1777285809Sscottl                             agFrameHandle,
1778285809Sscottl                             CurrentTaskTag
1779285809Sscottl                             );
1780285809Sscottl
1781285809Sscottl      break;
1782285809Sscottl#ifdef REMOVED
1783285809Sscottl//temp for testing
1784285809Sscottl     case SMP_REPORT_MANUFACTURE_INFORMATION:
1785285809Sscottl      TI_DBG1(("itdssSMPCompleted: REPORT_MANUFACTURE_INFORMATION\n"));
1786285809Sscottl      if (agIOInfoLen != sizeof(smpRespReportManufactureInfo_t) + 4 &&
1787285809Sscottl          tdSMPFrameHeader->smpFunctionResult == SMP_FUNCTION_ACCEPTED) /*zero length is expected */
1788285809Sscottl      {
1789285809Sscottl        TI_DBG1(("itdssSMPCompleted: mismatch len agIOInfoLen 0x%x 0x%x\n", agIOInfoLen, 4));
1790285809Sscottl        tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1791285809Sscottl        ostiFreeMemory(
1792285809Sscottl                       tiRoot,
1793285809Sscottl                       tdSMPRequestBody->osMemHandle,
1794285809Sscottl                       sizeof(tdssSMPRequestBody_t)
1795285809Sscottl                      );
1796285809Sscottl#ifndef DIRECT_SMP
1797285809Sscottl        ostiFreeMemory(
1798285809Sscottl                       tiRoot,
1799285809Sscottl                       tdSMPRequestBody->IndirectSMPReqosMemHandle,
1800285809Sscottl                       tdSMPRequestBody->IndirectSMPReqLen
1801285809Sscottl                      );
1802285809Sscottl        ostiFreeMemory(
1803285809Sscottl                       tiRoot,
1804285809Sscottl                       tdSMPRequestBody->IndirectSMPResposMemHandle,
1805285809Sscottl                       tdSMPRequestBody->IndirectSMPRespLen
1806285809Sscottl                      );
1807285809Sscottl#endif
1808285809Sscottl        return;
1809285809Sscottl      }
1810285809Sscottl      tdsaReportManInfoRespRcvd(
1811285809Sscottl                                tiRoot,
1812285809Sscottl                                agRoot,
1813285809Sscottl                                oneDeviceData,
1814285809Sscottl                                tdSMPFrameHeader,
1815285809Sscottl                                agFrameHandle
1816285809Sscottl                                );
1817285809Sscottl
1818285809Sscottl       break;
1819285809Sscottl//end temp for testing
1820285809Sscottl#endif
1821285809Sscottl    case SMP_REPORT_ROUTING_INFORMATION:
1822285809Sscottl    case SMP_REPORT_PHY_ERROR_LOG:
1823285809Sscottl    case SMP_PHY_TEST_FUNCTION:
1824285809Sscottl    case SMP_REPORT_MANUFACTURE_INFORMATION:
1825285809Sscottl    case SMP_READ_GPIO_REGISTER:
1826285809Sscottl    case SMP_WRITE_GPIO_REGISTER:
1827285809Sscottl    default:
1828285809Sscottl      TI_DBG1(("itdssSMPCompleted: wrong SMP function 0x%x\n", tdSMPFrameHeader->smpFunction));
1829285809Sscottl      TI_DBG1(("itdssSMPCompleted: smpFrameType 0x%x\n", tdSMPFrameHeader->smpFrameType));
1830285809Sscottl      TI_DBG1(("itdssSMPCompleted: smpFunctionResult 0x%x\n", tdSMPFrameHeader->smpFunctionResult));
1831285809Sscottl      TI_DBG1(("itdssSMPCompleted: smpReserved 0x%x\n", tdSMPFrameHeader->smpReserved));
1832285809Sscottl      tdhexdump("itdssSMPCompleted: SMP payload", (bit8 *)agFrameHandle, agIOInfoLen);
1833285809Sscottl      break;
1834285809Sscottl    }
1835285809Sscottl  }
1836285809Sscottl  else if (agIOStatus == OSSA_IO_ABORTED || agIOStatus == OSSA_IO_INVALID_LENGTH)
1837285809Sscottl  {
1838285809Sscottl    /* no retry this case */
1839285809Sscottl    TI_DBG1(("itdssSMPCompleted: OSSA_IO_ABORTED\n"));
1840285809Sscottl  }
1841285809Sscottl  else if (agIOStatus == OSSA_IO_ERROR_INTERNAL_SMP_RESOURCE)
1842285809Sscottl  {
1843285809Sscottl    TI_DBG1(("itdssSMPCompleted: OSSA_IO_ERROR_INTERNAL_SMP_RESOURCE\n"));
1844285809Sscottl    saFrameReadBlock(agRoot, agFrameHandle, 0, smpHeader, 4);
1845285809Sscottl    tdSMPFrameHeader = (tdssSMPFrameHeader_t *)smpHeader;
1846285809Sscottl
1847285809Sscottl    status = saSMPStart(
1848285809Sscottl               agRoot,
1849285809Sscottl               agIORequest,
1850285809Sscottl               tdSMPRequestBody->queueNumber, //tdsaAllShared->SMPQNum, //tdsaRotateQnumber(tiRoot, oneDeviceData),
1851285809Sscottl               agDevHandle,
1852285809Sscottl               AGSA_SMP_INIT_REQ,
1853285809Sscottl               agSASRequestBody,
1854285809Sscottl               &ossaSMPCompleted
1855285809Sscottl               );
1856285809Sscottl
1857285809Sscottl    if (status == AGSA_RC_SUCCESS)
1858285809Sscottl    {
1859285809Sscottl      /* increment the number of pending SMP */
1860285809Sscottl      onePortContext->discovery.pendingSMP++;
1861285809Sscottl      if (SMPRequestFunction == SMP_REPORT_GENERAL || SMPRequestFunction == SMP_DISCOVER ||
1862285809Sscottl          SMPRequestFunction == SMP_REPORT_PHY_SATA ||
1863285809Sscottl          SMPRequestFunction == SMP_CONFIGURE_ROUTING_INFORMATION )
1864285809Sscottl      {
1865285809Sscottl        /* start discovery-related SMP timer */
1866285809Sscottl        tdsaDiscoverySMPTimer(tiRoot, onePortContext, (bit32)(tdSMPFrameHeader->smpFunction), tdSMPRequestBody);
1867285809Sscottl      }
1868285809Sscottl      return;
1869285809Sscottl    }
1870285809Sscottl    else if (status == AGSA_RC_BUSY)
1871285809Sscottl    {
1872285809Sscottl      if (tdSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
1873285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_DISCOVER ||
1874285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
1875285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION )
1876285809Sscottl      {
1877285809Sscottl        tdsaSMPBusyTimer(tiRoot, onePortContext, oneDeviceData, tdSMPRequestBody);
1878285809Sscottl      }
1879285809Sscottl      else if (tdSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
1880285809Sscottl      {
1881285809Sscottl        /* For taskmanagement SMP, let's fail task management failure */
1882285809Sscottl        tdsaPhyControlFailureRespRcvd(
1883285809Sscottl                                      tiRoot,
1884285809Sscottl                                      agRoot,
1885285809Sscottl                                      oneDeviceData,
1886285809Sscottl                                      tdSMPFrameHeader,
1887285809Sscottl                                      agFrameHandle,
1888285809Sscottl                                      CurrentTaskTag
1889285809Sscottl                                      );
1890285809Sscottl      }
1891285809Sscottl      else
1892285809Sscottl      {
1893285809Sscottl      }
1894285809Sscottl    }
1895285809Sscottl    else /* AGSA_RC_FAILURE */
1896285809Sscottl    {
1897285809Sscottl      if (tdSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
1898285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_DISCOVER ||
1899285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
1900285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION )
1901285809Sscottl      {
1902285809Sscottl        tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1903285809Sscottl      }
1904285809Sscottl      else if (tdSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
1905285809Sscottl      {
1906285809Sscottl        /* task management failure */
1907285809Sscottl        tdsaPhyControlFailureRespRcvd(
1908285809Sscottl                                      tiRoot,
1909285809Sscottl                                      agRoot,
1910285809Sscottl                                      oneDeviceData,
1911285809Sscottl                                      tdSMPFrameHeader,
1912285809Sscottl                                      agFrameHandle,
1913285809Sscottl                                      CurrentTaskTag
1914285809Sscottl                                      );
1915285809Sscottl      }
1916285809Sscottl      else
1917285809Sscottl      {
1918285809Sscottl      }
1919285809Sscottl    }
1920285809Sscottl  }
1921285809Sscottl  else
1922285809Sscottl  {
1923285809Sscottl    if (tdSMPRequestBody->retries < SMP_RETRIES) /* 5 */
1924285809Sscottl    {
1925285809Sscottl      /* retry the SMP again */
1926285809Sscottl      TI_DBG1(("itdssSMPCompleted: failed! but retries %d agIOStatus 0x%x %d agIOInfoLen %d\n",
1927285809Sscottl               tdSMPRequestBody->retries, agIOStatus, agIOStatus, agIOInfoLen));
1928285809Sscottl      if (agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS ||
1929285809Sscottl          agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED ||
1930285809Sscottl          agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO ||
1931285809Sscottl          agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST ||
1932285809Sscottl          agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE ||
1933285809Sscottl          agIOStatus == OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED ||
1934285809Sscottl          agIOStatus == OSSA_IO_DS_NON_OPERATIONAL
1935285809Sscottl         )
1936285809Sscottl      {
1937285809Sscottl        saSetDeviceState(agRoot, agNULL, tdSMPRequestBody->queueNumber, agDevHandle, SA_DS_OPERATIONAL);
1938285809Sscottl      }
1939285809Sscottl      saSMPStart(
1940285809Sscottl                 agRoot,
1941285809Sscottl                 agIORequest,
1942285809Sscottl                 tdSMPRequestBody->queueNumber, //tdsaAllShared->SMPQNum, //tdsaRotateQnumber(tiRoot, oneDeviceData),
1943285809Sscottl                 agDevHandle,
1944285809Sscottl                 AGSA_SMP_INIT_REQ,
1945285809Sscottl                 agSASRequestBody,
1946285809Sscottl                 &ossaSMPCompleted
1947285809Sscottl                 );
1948285809Sscottl      /* increment the number of pending SMP */
1949285809Sscottl      onePortContext->discovery.pendingSMP++;
1950285809Sscottl      tdSMPRequestBody->retries++;
1951285809Sscottl      return;
1952285809Sscottl    }
1953285809Sscottl    else
1954285809Sscottl    {
1955285809Sscottl      tdSMPFrameHeader = (tdssSMPFrameHeader_t *)agSMPFrame->outFrameBuf;
1956285809Sscottl      tdSMPPayload = (bit8 *)agSMPFrame->outFrameBuf + 4;
1957285809Sscottl      TI_DBG1(("itdssSMPCompleted: failed! no more retry! agIOStatus 0x%x %d\n", agIOStatus, agIOStatus));
1958285809Sscottl      if (agIOStatus == OSSA_IO_DS_NON_OPERATIONAL)
1959285809Sscottl      {
1960285809Sscottl        TI_DBG1(("itdssSMPCompleted: failed! agIOStatus is OSSA_IO_DS_NON_OPERATIONAL\n"));
1961285809Sscottl      }
1962285809Sscottl
1963285809Sscottl      if (agIOStatus == OSSA_IO_DS_IN_RECOVERY)
1964285809Sscottl      {
1965285809Sscottl        TI_DBG1(("itdssSMPCompleted: failed! agIOStatus is OSSA_IO_DS_IN_RECOVERY\n"));
1966285809Sscottl      }
1967285809Sscottl
1968285809Sscottl      if (tdSMPFrameHeader->smpFunction == SMP_REPORT_GENERAL ||
1969285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_DISCOVER ||
1970285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_REPORT_PHY_SATA ||
1971285809Sscottl          tdSMPFrameHeader->smpFunction == SMP_CONFIGURE_ROUTING_INFORMATION
1972285809Sscottl         )
1973285809Sscottl      {
1974285809Sscottl        /* discovery failure */
1975285809Sscottl        TI_DBG1(("itdssSMPCompleted: SMP function 0x%x\n", tdSMPFrameHeader->smpFunction));
1976285809Sscottl        TI_DBG1(("itdssSMPCompleted: discover done with error\n"));
1977285809Sscottl        tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1978285809Sscottl      }
1979285809Sscottl      else if (tdSMPFrameHeader->smpFunction == SMP_PHY_CONTROL)
1980285809Sscottl      {
1981285809Sscottl        TI_DBG1(("itdssSMPCompleted: SMP_PHY_CONTROL\n"));
1982285809Sscottl        smpPhyControlReq = (smpReqPhyControl_t *)tdSMPPayload;
1983285809Sscottl        if (smpPhyControlReq->phyOperation == SMP_PHY_CONTROL_CLEAR_AFFILIATION)
1984285809Sscottl        {
1985285809Sscottl          TI_DBG1(("itdssSMPCompleted: discover done with error\n"));
1986285809Sscottl          tdsaSASDiscoverDone(tiRoot, onePortContext, tiError);
1987285809Sscottl        }
1988285809Sscottl        else if (smpPhyControlReq->phyOperation == SMP_PHY_CONTROL_HARD_RESET ||
1989285809Sscottl                 smpPhyControlReq->phyOperation == SMP_PHY_CONTROL_LINK_RESET )
1990285809Sscottl        {
1991285809Sscottl          TI_DBG1(("itdssSMPCompleted: device reset failed\n"));
1992285809Sscottl          if (CurrentTaskTag != agNULL )
1993285809Sscottl          {
1994285809Sscottl            TI_DBG1(("itdssSMPCompleted: callback to OS layer with failure\n"));
1995285809Sscottl            ostiInitiatorEvent( tiRoot,
1996285809Sscottl                                NULL,
1997285809Sscottl                                NULL,
1998285809Sscottl                                tiIntrEventTypeTaskManagement,
1999285809Sscottl                                tiTMFailed,
2000285809Sscottl                                CurrentTaskTag );
2001285809Sscottl          }
2002285809Sscottl          else
2003285809Sscottl          {
2004285809Sscottl            /* hard reset was not done with this device */
2005285809Sscottl            oneDeviceData->ResetCnt = 0;
2006285809Sscottl          }
2007285809Sscottl        }
2008285809Sscottl        else
2009285809Sscottl        {
2010285809Sscottl          TI_DBG1(("itdssSMPCompleted: unknown phy operation 0x%x\n", smpPhyControlReq->phyOperation));
2011285809Sscottl        }
2012285809Sscottl      } /* SMP_PHY_CONTROL */
2013285809Sscottl      else
2014285809Sscottl      {
2015285809Sscottl        TI_DBG1(("itdssSMPCompleted: SMP function 0x%x\n", tdSMPFrameHeader->smpFunction));
2016285809Sscottl      }
2017285809Sscottl    } /* else */
2018285809Sscottl  } /* outer else */
2019285809Sscottl
2020285809Sscottl  ostiFreeMemory(
2021285809Sscottl                 tiRoot,
2022285809Sscottl                 tdSMPRequestBody->osMemHandle,
2023285809Sscottl                 sizeof(tdssSMPRequestBody_t)
2024285809Sscottl                 );
2025285809Sscottl#ifndef DIRECT_SMP
2026285809Sscottl  ostiFreeMemory(
2027285809Sscottl                 tiRoot,
2028285809Sscottl                 tdSMPRequestBody->IndirectSMPReqosMemHandle,
2029285809Sscottl                 tdSMPRequestBody->IndirectSMPReqLen
2030285809Sscottl                 );
2031285809Sscottl  ostiFreeMemory(
2032285809Sscottl                 tiRoot,
2033285809Sscottl                 tdSMPRequestBody->IndirectSMPResposMemHandle,
2034285809Sscottl                 tdSMPRequestBody->IndirectSMPRespLen
2035285809Sscottl                 );
2036285809Sscottl#endif
2037285809Sscottl
2038285809Sscottl
2039285809Sscottl  return;
2040285809Sscottl}
2041285809Sscottl
2042285809Sscottl#else
2043285809Sscottl
2044285809SscottlosGLOBAL void
2045285809SscottlitdssSMPCompleted (
2046285809Sscottl                   agsaRoot_t            *agRoot,
2047285809Sscottl                   agsaIORequest_t       *agIORequest,
2048285809Sscottl                   bit32                 agIOStatus,
2049285809Sscottl                   bit32                 agIOInfoLen,
2050285809Sscottl                   agsaFrameHandle_t     agFrameHandle
2051285809Sscottl                   )
2052285809Sscottl{
2053285809Sscottl  /* pass the payload to OS layer */
2054285809Sscottl  TI_DBG3(("itdssSMPCompleted: start\n"));
2055285809Sscottl}
2056285809Sscottl#endif
2057285809Sscottl
2058285809Sscottl
2059285809Sscottl/*****************************************************************************
2060285809Sscottl*! \brief itdIoSuccessHandler
2061285809Sscottl*
2062285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2063285809Sscottl*            layer with agIOStatus = OSSA_IO_SUCCESS
2064285809Sscottl*
2065285809Sscottl*  \param  agRoot:            pointer to port instance
2066285809Sscottl*  \param  agIORequest:       pointer to I/O request
2067285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2068285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2069285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2070285809Sscottl*                             of abort request
2071285809Sscottl*  \param  agOtherInfo        Residual count
2072285809Sscottl*  \return: None
2073285809Sscottl*
2074285809Sscottl*
2075285809Sscottl*****************************************************************************/
2076285809SscottlosGLOBAL void
2077285809SscottlitdssIOSuccessHandler(
2078285809Sscottl                      agsaRoot_t           *agRoot,
2079285809Sscottl                      agsaIORequest_t      *agIORequest,
2080285809Sscottl                      bit32                agIOStatus,
2081285809Sscottl                      bit32                agIOInfoLen,
2082285809Sscottl                      void                 *agParam,
2083285809Sscottl                      bit32                agOtherInfo
2084285809Sscottl                      )
2085285809Sscottl{
2086285809Sscottl  tdsaRootOsData_t          *osData = (tdsaRootOsData_t *)agRoot->osData;
2087285809Sscottl  tiRoot_t                  *tiRoot = (tiRoot_t *)osData->tiRoot;
2088285809Sscottl  itdsaIni_t                *Initiator = (itdsaIni_t *)osData->itdsaIni;
2089285809Sscottl  tdIORequestBody_t         *tdIORequestBody;
2090285809Sscottl  agsaSSPResponseInfoUnit_t agSSPRespIU;
2091285809Sscottl  tiSenseData_t             senseData;
2092285809Sscottl  bit8                      senseDataPayload[256];
2093285809Sscottl  bit8                      respData[128];
2094285809Sscottl  bit32                     scsi_status;
2095285809Sscottl  bit32                     senseLen;
2096285809Sscottl  bit32                     respLen;
2097285809Sscottl  bit32                     data_status;
2098285809Sscottl  bit32                     i;
2099285809Sscottl  tiDeviceHandle_t          *tiDeviceHandle = agNULL;
2100285809Sscottl  tdsaDeviceData_t          *oneDeviceData = agNULL;
2101285809Sscottl
2102285809Sscottl  TI_DBG2(("itdssIOSuccessHandler: start\n"));
2103285809Sscottl  TI_DBG2(("itdssIOSuccessHandler: agIOInfoLen %d\n", agIOInfoLen));
2104285809Sscottl
2105285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2106285809Sscottl
2107285809Sscottl  tdIORequestBody->ioCompleted = agTRUE;
2108285809Sscottl  tdIORequestBody->ioStarted = agFALSE;
2109285809Sscottl
2110285809Sscottl  /*
2111285809Sscottl    agIOInfoLen must be >= sizeof(agsaSSPResponseInfoUnit_t), which is minimum
2112285809Sscottl    date length
2113285809Sscottl  */
2114285809Sscottl  if (agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t))
2115285809Sscottl  {
2116285809Sscottl    TI_DBG1(("itdssIOSuccessHandler: First agIOInfoLen does not match!!!\n"));
2117285809Sscottl    TI_DBG1(("itdssIOSuccessHandler: First agIOInfoLen 0x%x IU 0x%x\n", agIOInfoLen, (unsigned int)sizeof(agsaSSPResponseInfoUnit_t)));
2118285809Sscottl    ostiInitiatorIOCompleted(
2119285809Sscottl                             tiRoot,
2120285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
2121285809Sscottl                             tiIOFailed,
2122285809Sscottl                             tiDetailOtherError,
2123285809Sscottl                             agNULL,
2124285809Sscottl                             agTRUE /* intContext; is not being used */
2125285809Sscottl                             );
2126285809Sscottl    return;
2127285809Sscottl  }
2128285809Sscottl  /* reads agsaSSPResponseInfoUnit_t */
2129285809Sscottl  saFrameReadBlock(agRoot, agParam, 0, &agSSPRespIU, sizeof(agsaSSPResponseInfoUnit_t));
2130285809Sscottl
2131285809Sscottl  data_status = SA_SSPRESP_GET_DATAPRES(&agSSPRespIU);
2132285809Sscottl  scsi_status = agSSPRespIU.status;
2133285809Sscottl  /* endianess is invovled here */
2134285809Sscottl  senseLen = SA_SSPRESP_GET_SENSEDATALEN(&agSSPRespIU);
2135285809Sscottl  respLen = SA_SSPRESP_GET_RESPONSEDATALEN(&agSSPRespIU);
2136285809Sscottl
2137285809Sscottl  TI_DBG2(("itdssIOSuccessHandler: dataPres=%x\n", data_status));
2138285809Sscottl  TI_DBG2(("itdssIOSuccessHandler: scsi status=0x%x, senselen=0x%x resplen 0x%x\n", scsi_status, senseLen, respLen));
2139285809Sscottl
2140285809Sscottl  /*
2141285809Sscottl    sanity check: do not go beyond of agIOInfoLen. if happens, return error
2142285809Sscottl    agIOInfoLen >= sizeof(agsaSSPResponseInfoUnit_t) + senseLen + respLen -> OK
2143285809Sscottl    because frame must be divisible by 4, so there can be extra padding
2144285809Sscottl    agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t) + senseLen + respLen -> NOT OK
2145285809Sscottl  */
2146285809Sscottl  if (agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t) + senseLen + respLen)
2147285809Sscottl  {
2148285809Sscottl    TI_DBG1(("itdssIOSuccessHandler: Second agIOInfoLen does not match!!!\n"));
2149285809Sscottl    TI_DBG1(("itdssIOSuccessHandler: Second agIOInfoLen 0x%x IU 0x%x senselen 0x%x resplen 0x%x\n", agIOInfoLen, (unsigned int)sizeof(agsaSSPResponseInfoUnit_t), senseLen, respLen));
2150285809Sscottl
2151285809Sscottl    ostiInitiatorIOCompleted(
2152285809Sscottl                             tiRoot,
2153285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
2154285809Sscottl                             tiIOFailed,
2155285809Sscottl                             tiDetailOtherError,
2156285809Sscottl                             agNULL,
2157285809Sscottl                             agTRUE /* intContext; is not being used */
2158285809Sscottl                             );
2159285809Sscottl    return;
2160285809Sscottl  }
2161285809Sscottl
2162285809Sscottl  /* reads response data */
2163285809Sscottl  saFrameReadBlock(agRoot, agParam,
2164285809Sscottl                   sizeof(agsaSSPResponseInfoUnit_t),
2165285809Sscottl                   respData, respLen);
2166285809Sscottl  /* reads sense data */
2167285809Sscottl  saFrameReadBlock(agRoot, agParam,
2168285809Sscottl                   sizeof(agsaSSPResponseInfoUnit_t)
2169285809Sscottl                   + respLen,
2170285809Sscottl                   senseDataPayload, senseLen);
2171285809Sscottl
2172285809Sscottl  if (data_status == 0)
2173285809Sscottl  {
2174285809Sscottl    /* NO_DATA */
2175285809Sscottl    TI_DBG1(("itdssIOSuccessHandler: no data scsi_status 0x%x\n",scsi_status));
2176285809Sscottl
2177285809Sscottl    ostiInitiatorIOCompleted(
2178285809Sscottl                             tiRoot,
2179285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
2180285809Sscottl                             tiIOSuccess,
2181285809Sscottl                             scsi_status,
2182285809Sscottl                             agNULL,
2183285809Sscottl                             agTRUE /* intContext; is not being used */
2184285809Sscottl                             );
2185285809Sscottl
2186285809Sscottl    return;
2187285809Sscottl  }
2188285809Sscottl
2189285809Sscottl  if (data_status == 1)
2190285809Sscottl  {
2191285809Sscottl    /* RESPONSE_DATA */
2192285809Sscottl    TI_DBG1(("itdssIOSuccessHandler: response data \n"));
2193285809Sscottl
2194285809Sscottl    ostiInitiatorIOCompleted(
2195285809Sscottl                             tiRoot,
2196285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
2197285809Sscottl                             tiIOSuccess,
2198285809Sscottl                             0,
2199285809Sscottl                             agNULL,
2200285809Sscottl                             agTRUE /* intContext; is not being used */
2201285809Sscottl                             );
2202285809Sscottl    return;
2203285809Sscottl  }
2204285809Sscottl
2205285809Sscottl  if (data_status == 2)
2206285809Sscottl  {
2207285809Sscottl    /* SENSE_DATA */
2208285809Sscottl    TI_DBG2(("itdssIOSuccessHandler: sense data \n"));
2209285809Sscottl
2210285809Sscottl    senseData.senseData = &senseDataPayload;
2211285809Sscottl    senseData.senseLen = MIN(256, senseLen);
2212285809Sscottl    /* debugging */
2213285809Sscottl    tdhexdump("ResponseIU I", (bit8 *)&agSSPRespIU, sizeof(agsaSSPResponseInfoUnit_t));
2214285809Sscottl
2215285809Sscottl    tiDeviceHandle = tdIORequestBody->tiDevHandle;
2216285809Sscottl    oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
2217285809Sscottl    TI_DBG1(("sense data Sense Key 0x%2X ASC(Code) 0x%2X ASCQ(Qualifier) 0x%2X, did 0x%x\n",*(senseDataPayload+ 2),*(senseDataPayload + 12),*(senseDataPayload + 13),
2218285809Sscottl             oneDeviceData->id));
2219285809Sscottl    tdhexdump("sense data I", (bit8 *)senseDataPayload, senseLen);
2220285809Sscottl//    tdhexdump("sense data II", (bit8 *)senseData.senseData, senseData.senseLen);
2221285809Sscottl
2222285809Sscottl    if (senseDataPayload[2] == SCSI_SENSE_KEY_RECOVERED_ERROR)
2223285809Sscottl    {
2224285809Sscottl      Initiator->SenseKeyCounter.SoftError ++;
2225285809Sscottl    }
2226285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_NOT_READY)
2227285809Sscottl    {
2228285809Sscottl      Initiator->SenseKeyCounter.MediumNotReady++;
2229285809Sscottl    }
2230285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_MEDIUM_ERROR)
2231285809Sscottl    {
2232285809Sscottl      Initiator->SenseKeyCounter.MediumError++;
2233285809Sscottl    }
2234285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_HARDWARE_ERROR)
2235285809Sscottl    {
2236285809Sscottl      Initiator->SenseKeyCounter.HardwareError++;
2237285809Sscottl    }
2238285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_ILLEGAL_REQUEST)
2239285809Sscottl    {
2240285809Sscottl      Initiator->SenseKeyCounter.IllegalRequest++;
2241285809Sscottl    }
2242285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_UNIT_ATTENTION)
2243285809Sscottl    {
2244285809Sscottl      Initiator->SenseKeyCounter.UnitAttention++;
2245285809Sscottl    }
2246285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_ABORTED_COMMAND)
2247285809Sscottl    {
2248285809Sscottl      Initiator->SenseKeyCounter.AbortCommand++;
2249285809Sscottl    }
2250285809Sscottl    else
2251285809Sscottl    {
2252285809Sscottl      Initiator->SenseKeyCounter.OtherKeyType++;
2253285809Sscottl    }
2254285809Sscottl
2255285809Sscottl    /* when ASQ and ASCQ 0x04 0x11, does saLocalPhyControl for notify spinup */
2256285809Sscottl    if ((senseDataPayload[12] == 0x04 && senseDataPayload[13] == 0x11))
2257285809Sscottl    {
2258285809Sscottl      TI_DBG2(("itdssIOSuccessHandler: sending notfify spinup\n"));
2259285809Sscottl      tiDeviceHandle = tdIORequestBody->tiDevHandle;
2260285809Sscottl      oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
2261285809Sscottl      if (oneDeviceData->directlyAttached == agTRUE)
2262285809Sscottl      {
2263285809Sscottl        for (i=0;i<TD_MAX_NUM_NOTIFY_SPINUP;i++)
2264285809Sscottl        {
2265285809Sscottl          saLocalPhyControl(agRoot, agNULL, 0, oneDeviceData->phyID, AGSA_PHY_NOTIFY_ENABLE_SPINUP, agNULL);
2266285809Sscottl        }
2267285809Sscottl      }
2268285809Sscottl    }
2269285809Sscottl    ostiInitiatorIOCompleted(
2270285809Sscottl                             tiRoot,
2271285809Sscottl                             /* tiIORequest */
2272285809Sscottl                             tdIORequestBody->tiIORequest,
2273285809Sscottl                             tiIOSuccess,
2274285809Sscottl                             scsi_status,
2275285809Sscottl                             &senseData,
2276285809Sscottl                             agTRUE /* intContext; is not being used */
2277285809Sscottl                             );
2278285809Sscottl    return;
2279285809Sscottl  }
2280285809Sscottl  if (data_status == 3)
2281285809Sscottl  {
2282285809Sscottl    /* RESERVED */
2283285809Sscottl    TI_DBG1(("itdssIOSuccessHandler: reserved wrong!!!\n"));
2284285809Sscottl    ostiInitiatorIOCompleted(
2285285809Sscottl                             tiRoot,
2286285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
2287285809Sscottl                             tiIOFailed,
2288285809Sscottl                             scsi_status,
2289285809Sscottl                             agNULL,
2290285809Sscottl                             agTRUE /* intContext; is not being used */
2291285809Sscottl                             );
2292285809Sscottl    return;
2293285809Sscottl  }
2294285809Sscottl
2295285809Sscottl}
2296285809Sscottl
2297285809Sscottl/*****************************************************************************
2298285809Sscottl*! \brief itdssIOAbortedHandler
2299285809Sscottl*
2300285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2301285809Sscottl*            layer with agIOStatus = OSSA_IO_ABORTED
2302285809Sscottl*
2303285809Sscottl*  \param  agRoot:            pointer to port instance
2304285809Sscottl*  \param  agIORequest:       pointer to I/O request
2305285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2306285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2307285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2308285809Sscottl*                             of abort request
2309285809Sscottl*  \param  agOtherInfo        Residual count
2310285809Sscottl*  \return: None
2311285809Sscottl*
2312285809Sscottl*
2313285809Sscottl*****************************************************************************/
2314285809Sscottl/* see itdosIOCompleted() and itdinit.c and  itdIoAbortedHandler in itdio.c*/
2315285809SscottlosGLOBAL void
2316285809SscottlitdssIOAbortedHandler (
2317285809Sscottl                       agsaRoot_t              *agRoot,
2318285809Sscottl                       agsaIORequest_t         *agIORequest,
2319285809Sscottl                       bit32                   agIOStatus,
2320285809Sscottl                       bit32                   agIOInfoLen,
2321285809Sscottl                       void                    *agParam,
2322285809Sscottl                       bit32                   agOtherInfo
2323285809Sscottl                       )
2324285809Sscottl{
2325285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2326285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2327285809Sscottl  bit32                  intContext = osData->IntContext;
2328285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2329285809Sscottl  tiDeviceHandle_t       *tiDeviceHandle = agNULL;
2330285809Sscottl  tdsaDeviceData_t       *oneDeviceData = agNULL;
2331285809Sscottl
2332285809Sscottl  TI_DBG2(("itdssIOAbortedHandler: start\n"));
2333285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2334285809Sscottl
2335285809Sscottl  if (agIOStatus != OSSA_IO_ABORTED)
2336285809Sscottl  {
2337285809Sscottl    TI_DBG1(("itdssIOAbortedHandler: incorrect agIOStatus 0x%x\n", agIOStatus));
2338285809Sscottl  }
2339285809Sscottl
2340285809Sscottl  if (tdIORequestBody == agNULL)
2341285809Sscottl  {
2342285809Sscottl    TI_DBG1(("itdssIOAbortedHandler: start\n"));
2343285809Sscottl    return;
2344285809Sscottl  }
2345285809Sscottl
2346285809Sscottl  if (tdIORequestBody != agNULL)
2347285809Sscottl  {
2348285809Sscottl    tiDeviceHandle = tdIORequestBody->tiDevHandle;
2349285809Sscottl  }
2350285809Sscottl  if (tiDeviceHandle != agNULL)
2351285809Sscottl  {
2352285809Sscottl    oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
2353285809Sscottl  }
2354285809Sscottl  if (oneDeviceData != agNULL)
2355285809Sscottl  {
2356285809Sscottl    TI_DBG2(("itdssIOAbortedHandler: did %d \n", oneDeviceData->id));
2357285809Sscottl  }
2358285809Sscottl  else
2359285809Sscottl  {
2360285809Sscottl    TI_DBG1(("itdssIOAbortedHandler: oneDeviceData is NULL\n"));
2361285809Sscottl  }
2362285809Sscottl
2363285809Sscottl
2364285809Sscottl  ostiInitiatorIOCompleted (
2365285809Sscottl                            tiRoot,
2366285809Sscottl                            tdIORequestBody->tiIORequest,
2367285809Sscottl                            tiIOFailed,
2368285809Sscottl                            tiDetailAborted,
2369285809Sscottl                            agNULL,
2370285809Sscottl                            intContext
2371285809Sscottl                            );
2372285809Sscottl
2373285809Sscottl  return;
2374285809Sscottl}
2375285809Sscottl
2376285809Sscottl#ifdef REMOVED
2377285809Sscottl/*****************************************************************************
2378285809Sscottl*! \brief itdssIOOverFlowHandler
2379285809Sscottl*
2380285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2381285809Sscottl*            layer with agIOStatus = OSSA_IO_OVERFLOW
2382285809Sscottl*
2383285809Sscottl*  \param  agRoot:            pointer to port instance
2384285809Sscottl*  \param  agIORequest:       pointer to I/O request
2385285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2386285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2387285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2388285809Sscottl*                             of abort request
2389285809Sscottl*  \return: None
2390285809Sscottl*
2391285809Sscottl*
2392285809Sscottl*****************************************************************************/
2393285809SscottlosGLOBAL void
2394285809SscottlitdssIOOverFlowHandler(
2395285809Sscottl                       agsaRoot_t              *agRoot,
2396285809Sscottl                       agsaIORequest_t         *agIORequest,
2397285809Sscottl                       bit32                   agIOStatus,
2398285809Sscottl                       bit32                   agIOInfoLen,
2399285809Sscottl                       void                    *agParam
2400285809Sscottl                       )
2401285809Sscottl{
2402285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2403285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2404285809Sscottl  bit32                  intContext = osData->IntContext;
2405285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2406285809Sscottl
2407285809Sscottl  TI_DBG2(("itdssIOOverFlowHandler: start\n"));
2408285809Sscottl  TI_DBG2(("itdssIOOverFlowHandler: not transferred byte 0x%x\n", agIOInfoLen));
2409285809Sscottl
2410285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2411285809Sscottl
2412285809Sscottl  ostiInitiatorIOCompleted (
2413285809Sscottl                            tiRoot,
2414285809Sscottl                            tdIORequestBody->tiIORequest,
2415285809Sscottl                            tiIOOverRun,
2416285809Sscottl                            agIOInfoLen,
2417285809Sscottl                            agNULL,
2418285809Sscottl                            intContext
2419285809Sscottl                            );
2420285809Sscottl
2421285809Sscottl  return;
2422285809Sscottl}
2423285809Sscottl#endif
2424285809Sscottl
2425285809Sscottl
2426285809Sscottl/*****************************************************************************
2427285809Sscottl*! \brief itdssIOUnderFlowHandler
2428285809Sscottl*
2429285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2430285809Sscottl*            layer with agIOStatus = OSSA_IO_UNDERFLOW
2431285809Sscottl*
2432285809Sscottl*  \param  agRoot:            pointer to port instance
2433285809Sscottl*  \param  agIORequest:       pointer to I/O request
2434285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2435285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2436285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2437285809Sscottl*                             of abort request
2438285809Sscottl*  \param  agOtherInfo        Residual count
2439285809Sscottl*  \return: None
2440285809Sscottl*
2441285809Sscottl*
2442285809Sscottl*****************************************************************************/
2443285809SscottlosGLOBAL void
2444285809SscottlitdssIOUnderFlowHandler(
2445285809Sscottl                        agsaRoot_t              *agRoot,
2446285809Sscottl                        agsaIORequest_t         *agIORequest,
2447285809Sscottl                        bit32                   agIOStatus,
2448285809Sscottl                        bit32                   agIOInfoLen,
2449285809Sscottl                        void                    *agParam,
2450285809Sscottl                        bit32                   agOtherInfo
2451285809Sscottl                        )
2452285809Sscottl{
2453285809Sscottl  tdsaRootOsData_t          *osData = (tdsaRootOsData_t *)agRoot->osData;
2454285809Sscottl  tiRoot_t                  *tiRoot = (tiRoot_t *)osData->tiRoot;
2455285809Sscottl  bit32                     intContext = osData->IntContext;
2456285809Sscottl  tdIORequestBody_t         *tdIORequestBody;
2457285809Sscottl
2458285809Sscottl  TI_DBG6(("itdssIOUnderFlowHandler: start\n"));
2459285809Sscottl  TI_DBG6(("itdssIOUnderFlowHandler: agIOInfoLen 0x%x\n", agIOInfoLen));
2460285809Sscottl
2461285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2462285809Sscottl
2463285809Sscottl  ostiInitiatorIOCompleted (
2464285809Sscottl                            tiRoot,
2465285809Sscottl                            tdIORequestBody->tiIORequest,
2466285809Sscottl                            tiIOUnderRun,
2467285809Sscottl                            agIOInfoLen,
2468285809Sscottl                            agNULL,
2469285809Sscottl                            intContext
2470285809Sscottl                            );
2471285809Sscottl
2472285809Sscottl  return;
2473285809Sscottl}
2474285809Sscottl
2475285809Sscottl/*****************************************************************************
2476285809Sscottl*! \brief itdssIOFailedHandler
2477285809Sscottl*
2478285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2479285809Sscottl*            layer with agIOStatus = OSSA_IO_FAILED
2480285809Sscottl*
2481285809Sscottl*  \param  agRoot:            pointer to port instance
2482285809Sscottl*  \param  agIORequest:       pointer to I/O request
2483285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2484285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2485285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2486285809Sscottl*                             of abort request
2487285809Sscottl*  \param  agOtherInfo        Residual count
2488285809Sscottl*  \return: None
2489285809Sscottl*
2490285809Sscottl*
2491285809Sscottl*****************************************************************************/
2492285809SscottlosGLOBAL void
2493285809SscottlitdssIOFailedHandler(
2494285809Sscottl                     agsaRoot_t              *agRoot,
2495285809Sscottl                     agsaIORequest_t         *agIORequest,
2496285809Sscottl                     bit32                   agIOStatus,
2497285809Sscottl                     bit32                   agIOInfoLen,
2498285809Sscottl                     void                    *agParam,
2499285809Sscottl                     bit32                   agOtherInfo
2500285809Sscottl                     )
2501285809Sscottl{
2502285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2503285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2504285809Sscottl  bit32                  intContext = osData->IntContext;
2505285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2506285809Sscottl
2507285809Sscottl  TI_DBG1(("itdssIOFailedHandler: start\n"));
2508285809Sscottl
2509285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2510285809Sscottl
2511285809Sscottl  ostiInitiatorIOCompleted (
2512285809Sscottl                            tiRoot,
2513285809Sscottl                            tdIORequestBody->tiIORequest,
2514285809Sscottl                            tiIOFailed,
2515285809Sscottl                            tiDetailOtherError,
2516285809Sscottl                            agNULL,
2517285809Sscottl                            intContext
2518285809Sscottl                            );
2519285809Sscottl  return;
2520285809Sscottl}
2521285809Sscottl
2522285809Sscottl/*****************************************************************************
2523285809Sscottl*! \brief itdssIOAbortResetHandler
2524285809Sscottl*
2525285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2526285809Sscottl*            layer with agIOStatus = OSSA_IO_ABORT_RESET
2527285809Sscottl*
2528285809Sscottl*  \param  agRoot:            pointer to port instance
2529285809Sscottl*  \param  agIORequest:       pointer to I/O request
2530285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2531285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2532285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2533285809Sscottl*                             of abort request
2534285809Sscottl*  \param  agOtherInfo        Residual count
2535285809Sscottl*  \return: None
2536285809Sscottl*
2537285809Sscottl*
2538285809Sscottl*****************************************************************************/
2539285809SscottlosGLOBAL void
2540285809SscottlitdssIOAbortResetHandler(
2541285809Sscottl                         agsaRoot_t              *agRoot,
2542285809Sscottl                         agsaIORequest_t         *agIORequest,
2543285809Sscottl                         bit32                   agIOStatus,
2544285809Sscottl                         bit32                   agIOInfoLen,
2545285809Sscottl                         void                    *agParam,
2546285809Sscottl                         bit32                   agOtherInfo
2547285809Sscottl                         )
2548285809Sscottl{
2549285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2550285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2551285809Sscottl  bit32                  intContext = osData->IntContext;
2552285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2553285809Sscottl  TI_DBG2(("itdssIOAbortResetHandler: start\n"));
2554285809Sscottl
2555285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2556285809Sscottl
2557285809Sscottl  ostiInitiatorIOCompleted (
2558285809Sscottl                            tiRoot,
2559285809Sscottl                            tdIORequestBody->tiIORequest,
2560285809Sscottl                            tiIOFailed,
2561285809Sscottl                            tiDetailAbortReset,
2562285809Sscottl                            agNULL,
2563285809Sscottl                            intContext
2564285809Sscottl                            );
2565285809Sscottl
2566285809Sscottl
2567285809Sscottl  return;
2568285809Sscottl}
2569285809Sscottl
2570285809Sscottl/*****************************************************************************
2571285809Sscottl*! \brief itdssIONotValidHandler
2572285809Sscottl*
2573285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2574285809Sscottl*            layer with agIOStatus = OSSA_IO_NOT_VALID
2575285809Sscottl*
2576285809Sscottl*  \param  agRoot:            pointer to port instance
2577285809Sscottl*  \param  agIORequest:       pointer to I/O request
2578285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2579285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2580285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2581285809Sscottl*                             of abort request
2582285809Sscottl*  \param  agOtherInfo        Residual count
2583285809Sscottl*  \return: None
2584285809Sscottl*
2585285809Sscottl*
2586285809Sscottl*****************************************************************************/
2587285809SscottlosGLOBAL void
2588285809SscottlitdssIONotValidHandler(
2589285809Sscottl                       agsaRoot_t           *agRoot,
2590285809Sscottl                       agsaIORequest_t      *agIORequest,
2591285809Sscottl                       bit32                agIOStatus,
2592285809Sscottl                       bit32                agIOInfoLen,
2593285809Sscottl                       void                 *agParam,
2594285809Sscottl                       bit32                agOtherInfo
2595285809Sscottl                       )
2596285809Sscottl{
2597285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2598285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2599285809Sscottl  bit32                  intContext = osData->IntContext;
2600285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2601285809Sscottl  TI_DBG2(("itdssIONotValidHandler: start\n"));
2602285809Sscottl
2603285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2604285809Sscottl
2605285809Sscottl  ostiInitiatorIOCompleted (
2606285809Sscottl                            tiRoot,
2607285809Sscottl                            tdIORequestBody->tiIORequest,
2608285809Sscottl                            tiIOFailed,
2609285809Sscottl                            tiDetailNotValid,
2610285809Sscottl                            agNULL,
2611285809Sscottl                            intContext
2612285809Sscottl                            );
2613285809Sscottl  return;
2614285809Sscottl}
2615285809Sscottl
2616285809Sscottl/*****************************************************************************
2617285809Sscottl*! \brief itdssIONoDeviceHandler
2618285809Sscottl*
2619285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2620285809Sscottl*            layer with agIOStatus = OSSA_IO_NO_DEVICE
2621285809Sscottl*
2622285809Sscottl*  \param  agRoot:            pointer to port instance
2623285809Sscottl*  \param  agIORequest:       pointer to I/O request
2624285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2625285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2626285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2627285809Sscottl*                             of abort request
2628285809Sscottl*  \param  agOtherInfo        Residual count
2629285809Sscottl*  \return: None
2630285809Sscottl*
2631285809Sscottl*
2632285809Sscottl*****************************************************************************/
2633285809SscottlosGLOBAL void
2634285809SscottlitdssIONoDeviceHandler(
2635285809Sscottl                       agsaRoot_t           *agRoot,
2636285809Sscottl                       agsaIORequest_t      *agIORequest,
2637285809Sscottl                       bit32                agIOStatus,
2638285809Sscottl                       bit32                agIOInfoLen,
2639285809Sscottl                       void                 *agParam,
2640285809Sscottl                       bit32                agOtherInfo
2641285809Sscottl                       )
2642285809Sscottl{
2643285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2644285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2645285809Sscottl  bit32                  intContext = osData->IntContext;
2646285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2647285809Sscottl  TI_DBG2(("itdssIONoDeviceHandler: start\n"));
2648285809Sscottl
2649285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2650285809Sscottl
2651285809Sscottl  ostiInitiatorIOCompleted (
2652285809Sscottl                            tiRoot,
2653285809Sscottl                            tdIORequestBody->tiIORequest,
2654285809Sscottl                            tiIOFailed,
2655285809Sscottl                            tiDetailNoLogin,
2656285809Sscottl                            agNULL,
2657285809Sscottl                            intContext
2658285809Sscottl                            );
2659285809Sscottl  return;
2660285809Sscottl}
2661285809Sscottl
2662285809Sscottl#ifdef REMOVED /* to do: removed from spec */
2663285809Sscottl/*****************************************************************************
2664285809Sscottl*! \brief itdssIllegalParameterHandler
2665285809Sscottl*
2666285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2667285809Sscottl*            layer with agIOStatus = OSSA_IO_ILLEGAL_PARAMETER
2668285809Sscottl*
2669285809Sscottl*  \param  agRoot:            pointer to port instance
2670285809Sscottl*  \param  agIORequest:       pointer to I/O request
2671285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2672285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2673285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2674285809Sscottl*                             of abort request
2675285809Sscottl*  \return: None
2676285809Sscottl*
2677285809Sscottl*
2678285809Sscottl*****************************************************************************/
2679285809SscottlosGLOBAL void
2680285809SscottlitdssIllegalParameterHandler(
2681285809Sscottl                       agsaRoot_t           *agRoot,
2682285809Sscottl                       agsaIORequest_t      *agIORequest,
2683285809Sscottl                       bit32                agIOStatus,
2684285809Sscottl                       bit32                agIOInfoLen,
2685285809Sscottl                       void                 *agParam
2686285809Sscottl                       )
2687285809Sscottl{
2688285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2689285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2690285809Sscottl  bit32                  intContext = osData->IntContext;
2691285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2692285809Sscottl  TI_DBG2(("itdssIllegalParameterHandler: start\n"));
2693285809Sscottl
2694285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2695285809Sscottl
2696285809Sscottl  ostiInitiatorIOCompleted (
2697285809Sscottl                            tiRoot,
2698285809Sscottl                            tdIORequestBody->tiIORequest,
2699285809Sscottl                            tiIOFailed,
2700285809Sscottl                            tiDetailOtherError,
2701285809Sscottl                            agNULL,
2702285809Sscottl                            intContext
2703285809Sscottl                            );
2704285809Sscottl
2705285809Sscottl  return;
2706285809Sscottl}
2707285809Sscottl#endif
2708285809Sscottl
2709285809Sscottl/*****************************************************************************
2710285809Sscottl*! \brief itdssLinkFailureHandler
2711285809Sscottl*
2712285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2713285809Sscottl*            layer with agIOStatus = OSSA_IO_LINK_FAILURE
2714285809Sscottl*
2715285809Sscottl*  \param  agRoot:            pointer to port instance
2716285809Sscottl*  \param  agIORequest:       pointer to I/O request
2717285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2718285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2719285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2720285809Sscottl*                             of abort request
2721285809Sscottl*  \param  agOtherInfo        Residual count
2722285809Sscottl*  \return: None
2723285809Sscottl*
2724285809Sscottl*
2725285809Sscottl*****************************************************************************/
2726285809SscottlosGLOBAL void
2727285809SscottlitdssLinkFailureHandler(
2728285809Sscottl                       agsaRoot_t           *agRoot,
2729285809Sscottl                       agsaIORequest_t      *agIORequest,
2730285809Sscottl                       bit32                agIOStatus,
2731285809Sscottl                       bit32                agIOInfoLen,
2732285809Sscottl                       void                 *agParam,
2733285809Sscottl                       bit32                agOtherInfo
2734285809Sscottl                       )
2735285809Sscottl{
2736285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2737285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2738285809Sscottl  bit32                  intContext = osData->IntContext;
2739285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2740285809Sscottl  TI_DBG1(("itdssLinkFailureHandler: start\n"));
2741285809Sscottl
2742285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2743285809Sscottl
2744285809Sscottl  ostiInitiatorIOCompleted (
2745285809Sscottl                            tiRoot,
2746285809Sscottl                            tdIORequestBody->tiIORequest,
2747285809Sscottl                            tiIOFailed,
2748285809Sscottl                            tiDetailOtherError,
2749285809Sscottl                            agNULL,
2750285809Sscottl                            intContext
2751285809Sscottl                            );
2752285809Sscottl
2753285809Sscottl  return;
2754285809Sscottl}
2755285809Sscottl
2756285809Sscottl/*****************************************************************************
2757285809Sscottl*! \brief itdssProgErrorHandler
2758285809Sscottl*
2759285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2760285809Sscottl*            layer with agIOStatus = OSSA_IO_PROG_ERROR
2761285809Sscottl*
2762285809Sscottl*  \param  agRoot:            pointer to port instance
2763285809Sscottl*  \param  agIORequest:       pointer to I/O request
2764285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2765285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2766285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2767285809Sscottl*                             of abort request
2768285809Sscottl*  \param  agOtherInfo        Residual count
2769285809Sscottl*  \return: None
2770285809Sscottl*
2771285809Sscottl*
2772285809Sscottl*****************************************************************************/
2773285809SscottlosGLOBAL void
2774285809SscottlitdssProgErrorHandler(
2775285809Sscottl                       agsaRoot_t           *agRoot,
2776285809Sscottl                       agsaIORequest_t      *agIORequest,
2777285809Sscottl                       bit32                agIOStatus,
2778285809Sscottl                       bit32                agIOInfoLen,
2779285809Sscottl                       void                 *agParam,
2780285809Sscottl                       bit32                agOtherInfo
2781285809Sscottl                       )
2782285809Sscottl{
2783285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2784285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2785285809Sscottl  bit32                  intContext = osData->IntContext;
2786285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2787285809Sscottl  TI_DBG2(("itdssProgErrorHandler: start\n"));
2788285809Sscottl
2789285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2790285809Sscottl
2791285809Sscottl  ostiInitiatorIOCompleted (
2792285809Sscottl                            tiRoot,
2793285809Sscottl                            tdIORequestBody->tiIORequest,
2794285809Sscottl                            tiIOFailed,
2795285809Sscottl                            tiDetailOtherError,
2796285809Sscottl                            agNULL,
2797285809Sscottl                            intContext
2798285809Sscottl                            );
2799285809Sscottl
2800285809Sscottl  return;
2801285809Sscottl}
2802285809Sscottl
2803285809Sscottl/*****************************************************************************
2804285809Sscottl*! \brief itdssXferErrorBreakHandler
2805285809Sscottl*
2806285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2807285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_BREAK
2808285809Sscottl*
2809285809Sscottl*  \param  agRoot:            pointer to port instance
2810285809Sscottl*  \param  agIORequest:       pointer to I/O request
2811285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2812285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2813285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2814285809Sscottl*                             of abort request
2815285809Sscottl*  \param  agOtherInfo        Residual count
2816285809Sscottl*  \return: None
2817285809Sscottl*
2818285809Sscottl*
2819285809Sscottl*****************************************************************************/
2820285809SscottlosGLOBAL void
2821285809SscottlitdssXferErrorBreakHandler(
2822285809Sscottl                       agsaRoot_t           *agRoot,
2823285809Sscottl                       agsaIORequest_t      *agIORequest,
2824285809Sscottl                       bit32                agIOStatus,
2825285809Sscottl                       bit32                agIOInfoLen,
2826285809Sscottl                       void                 *agParam,
2827285809Sscottl                       bit32                agOtherInfo
2828285809Sscottl                       )
2829285809Sscottl{
2830285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2831285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2832285809Sscottl  bit32                  intContext = osData->IntContext;
2833285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2834285809Sscottl  TI_DBG1(("itdssXferErrorBreakHandler: start\n"));
2835285809Sscottl
2836285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2837285809Sscottl
2838285809Sscottl  ostiInitiatorIOCompleted (
2839285809Sscottl                            tiRoot,
2840285809Sscottl                            tdIORequestBody->tiIORequest,
2841285809Sscottl                            tiIOFailed,
2842285809Sscottl                            tiDetailOtherError,
2843285809Sscottl                            agNULL,
2844285809Sscottl                            intContext
2845285809Sscottl                            );
2846285809Sscottl
2847285809Sscottl  return;
2848285809Sscottl}
2849285809Sscottl
2850285809Sscottl/*****************************************************************************
2851285809Sscottl*! \brief itdssXferErrorPhyNotReadyHandler
2852285809Sscottl*
2853285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2854285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_PHY_NOT_READY
2855285809Sscottl*
2856285809Sscottl*  \param  agRoot:            pointer to port instance
2857285809Sscottl*  \param  agIORequest:       pointer to I/O request
2858285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2859285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2860285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2861285809Sscottl*                             of abort request
2862285809Sscottl*  \param  agOtherInfo        Residual count
2863285809Sscottl*  \return: None
2864285809Sscottl*
2865285809Sscottl*
2866285809Sscottl*****************************************************************************/
2867285809SscottlosGLOBAL void
2868285809SscottlitdssXferErrorPhyNotReadyHandler(
2869285809Sscottl                       agsaRoot_t           *agRoot,
2870285809Sscottl                       agsaIORequest_t      *agIORequest,
2871285809Sscottl                       bit32                agIOStatus,
2872285809Sscottl                       bit32                agIOInfoLen,
2873285809Sscottl                       void                 *agParam,
2874285809Sscottl                       bit32                agOtherInfo
2875285809Sscottl                       )
2876285809Sscottl{
2877285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2878285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2879285809Sscottl  bit32                  intContext = osData->IntContext;
2880285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2881285809Sscottl  TI_DBG2(("itdssXferErrorPhyNotReadyHandler: start\n"));
2882285809Sscottl
2883285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2884285809Sscottl
2885285809Sscottl  ostiInitiatorIOCompleted (
2886285809Sscottl                            tiRoot,
2887285809Sscottl                            tdIORequestBody->tiIORequest,
2888285809Sscottl                            tiIOFailed,
2889285809Sscottl                            tiDetailOtherError,
2890285809Sscottl                            agNULL,
2891285809Sscottl                            intContext
2892285809Sscottl                            );
2893285809Sscottl
2894285809Sscottl  return;
2895285809Sscottl}
2896285809Sscottl
2897285809Sscottl/*****************************************************************************
2898285809Sscottl*! \brief itdssOpenCnxErrorProtocolNotSupprotedHandler
2899285809Sscottl*
2900285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2901285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED
2902285809Sscottl*
2903285809Sscottl*  \param  agRoot:            pointer to port instance
2904285809Sscottl*  \param  agIORequest:       pointer to I/O request
2905285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2906285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2907285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2908285809Sscottl*                             of abort request
2909285809Sscottl*  \param  agOtherInfo        Residual count
2910285809Sscottl*  \return: None
2911285809Sscottl*
2912285809Sscottl*
2913285809Sscottl*****************************************************************************/
2914285809SscottlosGLOBAL void
2915285809SscottlitdssOpenCnxErrorProtocolNotSupprotedHandler(
2916285809Sscottl                       agsaRoot_t           *agRoot,
2917285809Sscottl                       agsaIORequest_t      *agIORequest,
2918285809Sscottl                       bit32                agIOStatus,
2919285809Sscottl                       bit32                agIOInfoLen,
2920285809Sscottl                       void                 *agParam,
2921285809Sscottl                       bit32                agOtherInfo
2922285809Sscottl                       )
2923285809Sscottl{
2924285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2925285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2926285809Sscottl  bit32                  intContext = osData->IntContext;
2927285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2928285809Sscottl  TI_DBG2(("itdssOpenCnxErrorProtocolNotSupprotedHandler: start\n"));
2929285809Sscottl
2930285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2931285809Sscottl
2932285809Sscottl  ostiInitiatorIOCompleted (
2933285809Sscottl                            tiRoot,
2934285809Sscottl                            tdIORequestBody->tiIORequest,
2935285809Sscottl                            tiIOFailed,
2936285809Sscottl                            tiDetailOtherError,
2937285809Sscottl                            agNULL,
2938285809Sscottl                            intContext
2939285809Sscottl                            );
2940285809Sscottl
2941285809Sscottl  return;
2942285809Sscottl}
2943285809Sscottl
2944285809Sscottl/*****************************************************************************
2945285809Sscottl*! \brief itdssOpenCnxErrorZoneViolationHandler
2946285809Sscottl*
2947285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2948285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_ZONE_VIOLATION
2949285809Sscottl*
2950285809Sscottl*  \param  agRoot:            pointer to port instance
2951285809Sscottl*  \param  agIORequest:       pointer to I/O request
2952285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
2953285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
2954285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
2955285809Sscottl*                             of abort request
2956285809Sscottl*  \param  agOtherInfo        Residual count
2957285809Sscottl*  \return: None
2958285809Sscottl*
2959285809Sscottl*
2960285809Sscottl*****************************************************************************/
2961285809SscottlosGLOBAL void
2962285809SscottlitdssOpenCnxErrorZoneViolationHandler(
2963285809Sscottl                       agsaRoot_t           *agRoot,
2964285809Sscottl                       agsaIORequest_t      *agIORequest,
2965285809Sscottl                       bit32                agIOStatus,
2966285809Sscottl                       bit32                agIOInfoLen,
2967285809Sscottl                       void                 *agParam,
2968285809Sscottl                       bit32                agOtherInfo
2969285809Sscottl                       )
2970285809Sscottl{
2971285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
2972285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
2973285809Sscottl  bit32                  intContext = osData->IntContext;
2974285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
2975285809Sscottl  TI_DBG2(("itdssOpenCnxErrorZoneViolationHandler: start\n"));
2976285809Sscottl
2977285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
2978285809Sscottl
2979285809Sscottl  ostiInitiatorIOCompleted (
2980285809Sscottl                            tiRoot,
2981285809Sscottl                            tdIORequestBody->tiIORequest,
2982285809Sscottl                            tiIOFailed,
2983285809Sscottl                            tiDetailOtherError,
2984285809Sscottl                            agNULL,
2985285809Sscottl                            intContext
2986285809Sscottl                            );
2987285809Sscottl
2988285809Sscottl  return;
2989285809Sscottl}
2990285809Sscottl
2991285809Sscottl/*****************************************************************************
2992285809Sscottl*! \brief itdssOpenCnxErrorBreakHandler
2993285809Sscottl*
2994285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
2995285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_BREAK
2996285809Sscottl*
2997285809Sscottl*  \param  agRoot:            pointer to port instance
2998285809Sscottl*  \param  agIORequest:       pointer to I/O request
2999285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3000285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3001285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3002285809Sscottl*                             of abort request
3003285809Sscottl*  \param  agOtherInfo        Residual count
3004285809Sscottl*  \return: None
3005285809Sscottl*
3006285809Sscottl*
3007285809Sscottl*****************************************************************************/
3008285809SscottlosGLOBAL void
3009285809SscottlitdssOpenCnxErrorBreakHandler(
3010285809Sscottl                       agsaRoot_t           *agRoot,
3011285809Sscottl                       agsaIORequest_t      *agIORequest,
3012285809Sscottl                       bit32                agIOStatus,
3013285809Sscottl                       bit32                agIOInfoLen,
3014285809Sscottl                       void                 *agParam,
3015285809Sscottl                       bit32                agOtherInfo
3016285809Sscottl                       )
3017285809Sscottl{
3018285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3019285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3020285809Sscottl  bit32                  intContext = osData->IntContext;
3021285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3022285809Sscottl  TI_DBG1(("itdssOpenCnxErrorBreakHandler: start\n"));
3023285809Sscottl
3024285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3025285809Sscottl
3026285809Sscottl  ostiInitiatorIOCompleted (
3027285809Sscottl                            tiRoot,
3028285809Sscottl                            tdIORequestBody->tiIORequest,
3029285809Sscottl                            tiIOFailed,
3030285809Sscottl                            tiDetailOtherError,
3031285809Sscottl                            agNULL,
3032285809Sscottl                            intContext
3033285809Sscottl                            );
3034285809Sscottl
3035285809Sscottl  return;
3036285809Sscottl}
3037285809Sscottl
3038285809Sscottl/*****************************************************************************
3039285809Sscottl*! \brief itdssOpenCnxErrorITNexusLossHandler
3040285809Sscottl*
3041285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3042285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS
3043285809Sscottl*
3044285809Sscottl*  \param  agRoot:            pointer to port instance
3045285809Sscottl*  \param  agIORequest:       pointer to I/O request
3046285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3047285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3048285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3049285809Sscottl*                             of abort request
3050285809Sscottl*  \param  agOtherInfo        Residual count
3051285809Sscottl*  \return: None
3052285809Sscottl*
3053285809Sscottl*
3054285809Sscottl*****************************************************************************/
3055285809SscottlosGLOBAL void
3056285809SscottlitdssOpenCnxErrorITNexusLossHandler(
3057285809Sscottl                       agsaRoot_t           *agRoot,
3058285809Sscottl                       agsaIORequest_t      *agIORequest,
3059285809Sscottl                       bit32                agIOStatus,
3060285809Sscottl                       bit32                agIOInfoLen,
3061285809Sscottl                       void                 *agParam,
3062285809Sscottl                       bit32                agOtherInfo
3063285809Sscottl                       )
3064285809Sscottl{
3065285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3066285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3067285809Sscottl  bit32                  intContext = osData->IntContext;
3068285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3069285809Sscottl  TI_DBG1(("itdssOpenCnxErrorITNexusLossHandler: start\n"));
3070285809Sscottl
3071285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3072285809Sscottl
3073285809Sscottl  ostiInitiatorIOCompleted (
3074285809Sscottl                            tiRoot,
3075285809Sscottl                            tdIORequestBody->tiIORequest,
3076285809Sscottl                            tiIOFailed,
3077285809Sscottl                            tiDetailOtherError,
3078285809Sscottl                            agNULL,
3079285809Sscottl                            intContext
3080285809Sscottl                            );
3081285809Sscottl
3082285809Sscottl  return;
3083285809Sscottl}
3084285809Sscottl
3085285809Sscottl/*****************************************************************************
3086285809Sscottl*! \brief itdssOpenCnxErrorBadDestinationHandler
3087285809Sscottl*
3088285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3089285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_BAD_DESTINATION
3090285809Sscottl*
3091285809Sscottl*  \param  agRoot:            pointer to port instance
3092285809Sscottl*  \param  agIORequest:       pointer to I/O request
3093285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3094285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3095285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3096285809Sscottl*                             of abort request
3097285809Sscottl*  \param  agOtherInfo        Residual count
3098285809Sscottl*  \return: None
3099285809Sscottl*
3100285809Sscottl*
3101285809Sscottl*****************************************************************************/
3102285809SscottlosGLOBAL void
3103285809SscottlitdssOpenCnxErrorBadDestinationHandler(
3104285809Sscottl                       agsaRoot_t           *agRoot,
3105285809Sscottl                       agsaIORequest_t      *agIORequest,
3106285809Sscottl                       bit32                agIOStatus,
3107285809Sscottl                       bit32                agIOInfoLen,
3108285809Sscottl                       void                 *agParam,
3109285809Sscottl                       bit32                agOtherInfo
3110285809Sscottl                       )
3111285809Sscottl{
3112285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3113285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3114285809Sscottl  bit32                  intContext = osData->IntContext;
3115285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3116285809Sscottl  TI_DBG1(("itdssOpenCnxErrorBadDestinationHandler: start\n"));
3117285809Sscottl
3118285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3119285809Sscottl
3120285809Sscottl  ostiInitiatorIOCompleted (
3121285809Sscottl                            tiRoot,
3122285809Sscottl                            tdIORequestBody->tiIORequest,
3123285809Sscottl                            tiIOFailed,
3124285809Sscottl                            tiDetailOtherError,
3125285809Sscottl                            agNULL,
3126285809Sscottl                            intContext
3127285809Sscottl                            );
3128285809Sscottl
3129285809Sscottl  return;
3130285809Sscottl}
3131285809Sscottl
3132285809Sscottl/*****************************************************************************
3133285809Sscottl*! \brief itdssOpenCnxErrorConnectionRateNotSupportedHandler
3134285809Sscottl*
3135285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3136285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED
3137285809Sscottl*
3138285809Sscottl*  \param  agRoot:            pointer to port instance
3139285809Sscottl*  \param  agIORequest:       pointer to I/O request
3140285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3141285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3142285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3143285809Sscottl*                             of abort request
3144285809Sscottl*  \param  agOtherInfo        Residual count
3145285809Sscottl*  \return: None
3146285809Sscottl*
3147285809Sscottl*
3148285809Sscottl*****************************************************************************/
3149285809SscottlosGLOBAL void
3150285809SscottlitdssOpenCnxErrorConnectionRateNotSupportedHandler(
3151285809Sscottl                       agsaRoot_t           *agRoot,
3152285809Sscottl                       agsaIORequest_t      *agIORequest,
3153285809Sscottl                       bit32                agIOStatus,
3154285809Sscottl                       bit32                agIOInfoLen,
3155285809Sscottl                       void                 *agParam,
3156285809Sscottl                       bit32                agOtherInfo
3157285809Sscottl                       )
3158285809Sscottl{
3159285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3160285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3161285809Sscottl  tdsaRoot_t             *tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
3162285809Sscottl  tdsaContext_t          *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3163285809Sscottl  bit32                  intContext = osData->IntContext;
3164285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3165285809Sscottl  agsaDevHandle_t        *agDevHandle = agNULL;
3166285809Sscottl  tiDeviceHandle_t       *tiDeviceHandle = agNULL;
3167285809Sscottl  tdsaDeviceData_t       *oneDeviceData = agNULL;
3168285809Sscottl  bit32                  ConnRate = SAS_CONNECTION_RATE_12_0G;
3169285809Sscottl  agsaContext_t          *agContext = agNULL;
3170285809Sscottl  TI_DBG1(("itdssOpenCnxErrorConnectionRateNotSupportedHandler: start\n"));
3171285809Sscottl
3172285809Sscottl  /* we retry by lowering link rate
3173285809Sscottl     retry should be in ossaSetDeviceInfoCB()
3174285809Sscottl  */
3175285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3176285809Sscottl  tiDeviceHandle = tdIORequestBody->tiDevHandle;
3177285809Sscottl  oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
3178285809Sscottl  agDevHandle = oneDeviceData->agDevHandle;
3179285809Sscottl
3180285809Sscottl  if (tdsaAllShared->RateAdjust)
3181285809Sscottl  {
3182285809Sscottl    if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE &&
3183285809Sscottl        oneDeviceData->tdPortContext != agNULL )
3184285809Sscottl    {
3185285809Sscottl      ConnRate = DEVINFO_GET_LINKRATE(&oneDeviceData->agDeviceInfo);
3186285809Sscottl      if (ConnRate == SAS_CONNECTION_RATE_1_5G)
3187285809Sscottl      {
3188285809Sscottl        /* no retry; completes IO */
3189285809Sscottl        ostiInitiatorIOCompleted(
3190285809Sscottl                                 tiRoot,
3191285809Sscottl                                 tdIORequestBody->tiIORequest,
3192285809Sscottl                                 tiIOFailed,
3193285809Sscottl                                 tiDetailOtherError,
3194285809Sscottl                                 agNULL,
3195285809Sscottl                                 intContext
3196285809Sscottl                                 );
3197285809Sscottl      }
3198285809Sscottl      else
3199285809Sscottl      {
3200285809Sscottl        ConnRate = ConnRate - 1;
3201285809Sscottl      }
3202285809Sscottl      agContext = &(tdIORequestBody->agContext);
3203285809Sscottl      agContext->osData = agIORequest;
3204285809Sscottl      saSetDeviceInfo(agRoot, agContext, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, 32, ConnRate << 28, ossaIniSetDeviceInfoCB);
3205285809Sscottl    }
3206285809Sscottl  }
3207285809Sscottl  else
3208285809Sscottl  {
3209285809Sscottl    ostiInitiatorIOCompleted(
3210285809Sscottl                             tiRoot,
3211285809Sscottl                             tdIORequestBody->tiIORequest,
3212285809Sscottl                             tiIOFailed,
3213285809Sscottl                             tiDetailOtherError,
3214285809Sscottl                             agNULL,
3215285809Sscottl                             intContext
3216285809Sscottl                             );
3217285809Sscottl  }
3218285809Sscottl
3219285809Sscottl  return;
3220285809Sscottl}
3221285809Sscottl
3222285809Sscottl/*****************************************************************************
3223285809Sscottl*! \brief itdssOpenCnxErrorSTPResourceBusyHandler
3224285809Sscottl*
3225285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3226285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY
3227285809Sscottl*
3228285809Sscottl*  \param  agRoot:            pointer to port instance
3229285809Sscottl*  \param  agIORequest:       pointer to I/O request
3230285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3231285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3232285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3233285809Sscottl*                             of abort request
3234285809Sscottl*  \param  agOtherInfo        Residual count
3235285809Sscottl*  \return: None
3236285809Sscottl*
3237285809Sscottl*
3238285809Sscottl*****************************************************************************/
3239285809SscottlosGLOBAL void
3240285809SscottlitdssOpenCnxErrorSTPResourceBusyHandler(
3241285809Sscottl                       agsaRoot_t           *agRoot,
3242285809Sscottl                       agsaIORequest_t      *agIORequest,
3243285809Sscottl                       bit32                agIOStatus,
3244285809Sscottl                       bit32                agIOInfoLen,
3245285809Sscottl                       void                 *agParam,
3246285809Sscottl                       bit32                agOtherInfo
3247285809Sscottl                       )
3248285809Sscottl{
3249285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3250285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3251285809Sscottl  bit32                  intContext = osData->IntContext;
3252285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3253285809Sscottl  TI_DBG2(("itdssOpenCnxErrorSTPResourceBusyHandler: start\n"));
3254285809Sscottl
3255285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3256285809Sscottl
3257285809Sscottl  ostiInitiatorIOCompleted (
3258285809Sscottl                            tiRoot,
3259285809Sscottl                            tdIORequestBody->tiIORequest,
3260285809Sscottl                            tiIOFailed,
3261285809Sscottl                            tiDetailOtherError,
3262285809Sscottl                            agNULL,
3263285809Sscottl                            intContext
3264285809Sscottl                            );
3265285809Sscottl
3266285809Sscottl  return;
3267285809Sscottl}
3268285809Sscottl
3269285809Sscottl/*****************************************************************************
3270285809Sscottl*! \brief itdssOpenCnxErrorWrongDestinationHandler
3271285809Sscottl*
3272285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3273285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_WRONG_DESTINATION
3274285809Sscottl*
3275285809Sscottl*  \param  agRoot:            pointer to port instance
3276285809Sscottl*  \param  agIORequest:       pointer to I/O request
3277285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3278285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3279285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3280285809Sscottl*                             of abort request
3281285809Sscottl*  \param  agOtherInfo        Residual count
3282285809Sscottl*  \return: None
3283285809Sscottl*
3284285809Sscottl*
3285285809Sscottl*****************************************************************************/
3286285809SscottlosGLOBAL void
3287285809SscottlitdssOpenCnxErrorWrongDestinationHandler(
3288285809Sscottl                       agsaRoot_t           *agRoot,
3289285809Sscottl                       agsaIORequest_t      *agIORequest,
3290285809Sscottl                       bit32                agIOStatus,
3291285809Sscottl                       bit32                agIOInfoLen,
3292285809Sscottl                       void                 *agParam,
3293285809Sscottl                       bit32                agOtherInfo
3294285809Sscottl                       )
3295285809Sscottl{
3296285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3297285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3298285809Sscottl  bit32                  intContext = osData->IntContext;
3299285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3300285809Sscottl  TI_DBG1(("itdssOpenCnxErrorWrongDestinationHandler: start\n"));
3301285809Sscottl
3302285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3303285809Sscottl
3304285809Sscottl  ostiInitiatorIOCompleted (
3305285809Sscottl                            tiRoot,
3306285809Sscottl                            tdIORequestBody->tiIORequest,
3307285809Sscottl                            tiIOFailed,
3308285809Sscottl                            tiDetailOtherError,
3309285809Sscottl                            agNULL,
3310285809Sscottl                            intContext
3311285809Sscottl                            );
3312285809Sscottl
3313285809Sscottl  return;
3314285809Sscottl}
3315285809Sscottl
3316285809Sscottl/*****************************************************************************
3317285809Sscottl*! \brief itdssOpenCnxErrorUnknownErrorHandler
3318285809Sscottl*
3319285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3320285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_UNKNOWN_ERROR
3321285809Sscottl*
3322285809Sscottl*  \param  agRoot:            pointer to port instance
3323285809Sscottl*  \param  agIORequest:       pointer to I/O request
3324285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3325285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3326285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3327285809Sscottl*                             of abort request
3328285809Sscottl*  \param  agOtherInfo        Residual count
3329285809Sscottl*  \return: None
3330285809Sscottl*
3331285809Sscottl*
3332285809Sscottl*****************************************************************************/
3333285809SscottlosGLOBAL void
3334285809SscottlitdssOpenCnxErrorUnknownErrorHandler(
3335285809Sscottl                       agsaRoot_t           *agRoot,
3336285809Sscottl                       agsaIORequest_t      *agIORequest,
3337285809Sscottl                       bit32                agIOStatus,
3338285809Sscottl                       bit32                agIOInfoLen,
3339285809Sscottl                       void                 *agParam,
3340285809Sscottl                       bit32                agOtherInfo
3341285809Sscottl                       )
3342285809Sscottl{
3343285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3344285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3345285809Sscottl  bit32                  intContext = osData->IntContext;
3346285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3347285809Sscottl  TI_DBG1(("itdssOpenCnxErrorUnknownErrorHandler: start\n"));
3348285809Sscottl
3349285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3350285809Sscottl
3351285809Sscottl  ostiInitiatorIOCompleted (
3352285809Sscottl                            tiRoot,
3353285809Sscottl                            tdIORequestBody->tiIORequest,
3354285809Sscottl                            tiIOFailed,
3355285809Sscottl                            tiDetailOtherError,
3356285809Sscottl                            agNULL,
3357285809Sscottl                            intContext
3358285809Sscottl                            );
3359285809Sscottl
3360285809Sscottl  return;
3361285809Sscottl}
3362285809Sscottl
3363285809Sscottl/*****************************************************************************
3364285809Sscottl*! \brief itdssXferErrorNAKReceivedHandler
3365285809Sscottl*
3366285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3367285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_NAK_RECEIVED
3368285809Sscottl*
3369285809Sscottl*  \param  agRoot:            pointer to port instance
3370285809Sscottl*  \param  agIORequest:       pointer to I/O request
3371285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3372285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3373285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3374285809Sscottl*                             of abort request
3375285809Sscottl*  \param  agOtherInfo        Residual count
3376285809Sscottl*  \return: None
3377285809Sscottl*
3378285809Sscottl*
3379285809Sscottl*****************************************************************************/
3380285809SscottlosGLOBAL void
3381285809SscottlitdssXferErrorNAKReceivedHandler(
3382285809Sscottl                       agsaRoot_t           *agRoot,
3383285809Sscottl                       agsaIORequest_t      *agIORequest,
3384285809Sscottl                       bit32                agIOStatus,
3385285809Sscottl                       bit32                agIOInfoLen,
3386285809Sscottl                       void                 *agParam,
3387285809Sscottl                       bit32                agOtherInfo
3388285809Sscottl                       )
3389285809Sscottl{
3390285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3391285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3392285809Sscottl  bit32                  intContext = osData->IntContext;
3393285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3394285809Sscottl  TI_DBG1(("itdssXferErrorNAKReceivedHandler: start\n"));
3395285809Sscottl
3396285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3397285809Sscottl
3398285809Sscottl  ostiInitiatorIOCompleted (
3399285809Sscottl                            tiRoot,
3400285809Sscottl                            tdIORequestBody->tiIORequest,
3401285809Sscottl                            tiIOFailed,
3402285809Sscottl                            tiDetailOtherError,
3403285809Sscottl                            agNULL,
3404285809Sscottl                            intContext
3405285809Sscottl                            );
3406285809Sscottl
3407285809Sscottl  return;
3408285809Sscottl}
3409285809Sscottl
3410285809Sscottl/*****************************************************************************
3411285809Sscottl*! \brief itdssXferErrorACKNAKTimeoutHandler
3412285809Sscottl*
3413285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3414285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_ACK_NAK_TIMEOUT
3415285809Sscottl*
3416285809Sscottl*  \param  agRoot:            pointer to port instance
3417285809Sscottl*  \param  agIORequest:       pointer to I/O request
3418285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3419285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3420285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3421285809Sscottl*                             of abort request
3422285809Sscottl*  \param  agOtherInfo        Residual count
3423285809Sscottl*  \return: None
3424285809Sscottl*
3425285809Sscottl*
3426285809Sscottl*****************************************************************************/
3427285809SscottlosGLOBAL void
3428285809SscottlitdssXferErrorACKNAKTimeoutHandler(
3429285809Sscottl                       agsaRoot_t           *agRoot,
3430285809Sscottl                       agsaIORequest_t      *agIORequest,
3431285809Sscottl                       bit32                agIOStatus,
3432285809Sscottl                       bit32                agIOInfoLen,
3433285809Sscottl                       void                 *agParam,
3434285809Sscottl                       bit32                agOtherInfo
3435285809Sscottl                       )
3436285809Sscottl{
3437285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3438285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3439285809Sscottl  bit32                  intContext = osData->IntContext;
3440285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3441285809Sscottl  TI_DBG1(("itdssXferErrorACKNAKTimeoutHandler: start\n"));
3442285809Sscottl
3443285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3444285809Sscottl
3445285809Sscottl  ostiInitiatorIOCompleted (
3446285809Sscottl                            tiRoot,
3447285809Sscottl                            tdIORequestBody->tiIORequest,
3448285809Sscottl                            tiIOFailed,
3449285809Sscottl                            tiDetailOtherError,
3450285809Sscottl                            agNULL,
3451285809Sscottl                            intContext
3452285809Sscottl                            );
3453285809Sscottl
3454285809Sscottl  return;
3455285809Sscottl}
3456285809Sscottl
3457285809Sscottl/*****************************************************************************
3458285809Sscottl*! \brief itdssXferErrorPeerAbortedHandler
3459285809Sscottl*
3460285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3461285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_PEER_ABORTED
3462285809Sscottl*
3463285809Sscottl*  \param  agRoot:            pointer to port instance
3464285809Sscottl*  \param  agIORequest:       pointer to I/O request
3465285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3466285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3467285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3468285809Sscottl*                             of abort request
3469285809Sscottl*  \param  agOtherInfo        Residual count
3470285809Sscottl*  \return: None
3471285809Sscottl*
3472285809Sscottl*
3473285809Sscottl*****************************************************************************/
3474285809SscottlosGLOBAL void
3475285809SscottlitdssXferErrorPeerAbortedHandler(
3476285809Sscottl                       agsaRoot_t           *agRoot,
3477285809Sscottl                       agsaIORequest_t      *agIORequest,
3478285809Sscottl                       bit32                agIOStatus,
3479285809Sscottl                       bit32                agIOInfoLen,
3480285809Sscottl                       void                 *agParam,
3481285809Sscottl                       bit32                agOtherInfo
3482285809Sscottl                       )
3483285809Sscottl{
3484285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3485285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3486285809Sscottl  bit32                  intContext = osData->IntContext;
3487285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3488285809Sscottl  TI_DBG2(("itdssXferErrorPeerAbortedHandler: start\n"));
3489285809Sscottl
3490285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3491285809Sscottl
3492285809Sscottl  ostiInitiatorIOCompleted (
3493285809Sscottl                            tiRoot,
3494285809Sscottl                            tdIORequestBody->tiIORequest,
3495285809Sscottl                            tiIOFailed,
3496285809Sscottl                            tiDetailOtherError,
3497285809Sscottl                            agNULL,
3498285809Sscottl                            intContext
3499285809Sscottl                            );
3500285809Sscottl
3501285809Sscottl  return;
3502285809Sscottl}
3503285809Sscottl
3504285809Sscottl/*****************************************************************************
3505285809Sscottl*! \brief itdssXferErrorRxFrameHandler
3506285809Sscottl*
3507285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3508285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_RX_FRAME
3509285809Sscottl*
3510285809Sscottl*  \param  agRoot:            pointer to port instance
3511285809Sscottl*  \param  agIORequest:       pointer to I/O request
3512285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3513285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3514285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3515285809Sscottl*                             of abort request
3516285809Sscottl*  \param  agOtherInfo        Residual count
3517285809Sscottl*  \return: None
3518285809Sscottl*
3519285809Sscottl*
3520285809Sscottl*****************************************************************************/
3521285809SscottlosGLOBAL void
3522285809SscottlitdssXferErrorRxFrameHandler(
3523285809Sscottl                       agsaRoot_t           *agRoot,
3524285809Sscottl                       agsaIORequest_t      *agIORequest,
3525285809Sscottl                       bit32                agIOStatus,
3526285809Sscottl                       bit32                agIOInfoLen,
3527285809Sscottl                       void                 *agParam,
3528285809Sscottl                       bit32                agOtherInfo
3529285809Sscottl                       )
3530285809Sscottl{
3531285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3532285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3533285809Sscottl  bit32                  intContext = osData->IntContext;
3534285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3535285809Sscottl  TI_DBG1(("itdssXferErrorRxFrameHandler: start\n"));
3536285809Sscottl
3537285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3538285809Sscottl
3539285809Sscottl  ostiInitiatorIOCompleted (
3540285809Sscottl                            tiRoot,
3541285809Sscottl                            tdIORequestBody->tiIORequest,
3542285809Sscottl                            tiIOFailed,
3543285809Sscottl                            tiDetailOtherError,
3544285809Sscottl                            agNULL,
3545285809Sscottl                            intContext
3546285809Sscottl                            );
3547285809Sscottl
3548285809Sscottl  return;
3549285809Sscottl}
3550285809Sscottl
3551285809Sscottl/*****************************************************************************
3552285809Sscottl*! \brief itdssXferErrorDMAHandler
3553285809Sscottl*
3554285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3555285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_DMA
3556285809Sscottl*
3557285809Sscottl*  \param  agRoot:            pointer to port instance
3558285809Sscottl*  \param  agIORequest:       pointer to I/O request
3559285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3560285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3561285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3562285809Sscottl*                             of abort request
3563285809Sscottl*  \param  agOtherInfo        Residual count
3564285809Sscottl*  \return: None
3565285809Sscottl*
3566285809Sscottl*
3567285809Sscottl*****************************************************************************/
3568285809SscottlosGLOBAL void
3569285809SscottlitdssXferErrorDMAHandler(
3570285809Sscottl                       agsaRoot_t           *agRoot,
3571285809Sscottl                       agsaIORequest_t      *agIORequest,
3572285809Sscottl                       bit32                agIOStatus,
3573285809Sscottl                       bit32                agIOInfoLen,
3574285809Sscottl                       void                 *agParam,
3575285809Sscottl                       bit32                agOtherInfo
3576285809Sscottl                       )
3577285809Sscottl{
3578285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3579285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3580285809Sscottl  bit32                  intContext = osData->IntContext;
3581285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3582285809Sscottl  TI_DBG1(("itdssXferErrorDMAHandler: start\n"));
3583285809Sscottl
3584285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3585285809Sscottl
3586285809Sscottl  ostiInitiatorIOCompleted (
3587285809Sscottl                            tiRoot,
3588285809Sscottl                            tdIORequestBody->tiIORequest,
3589285809Sscottl                            tiIOFailed,
3590285809Sscottl                            tiDetailOtherErrorNoRetry,
3591285809Sscottl                            agNULL,
3592285809Sscottl                            intContext
3593285809Sscottl                            );
3594285809Sscottl
3595285809Sscottl  return;
3596285809Sscottl}
3597285809Sscottl
3598285809Sscottl/*****************************************************************************
3599285809Sscottl*! \brief itdssXferErrorCreditTimeoutHandler
3600285809Sscottl*
3601285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3602285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_CREDIT_TIMEOUT
3603285809Sscottl*
3604285809Sscottl*  \param  agRoot:            pointer to port instance
3605285809Sscottl*  \param  agIORequest:       pointer to I/O request
3606285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3607285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3608285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3609285809Sscottl*                             of abort request
3610285809Sscottl*  \param  agOtherInfo        Residual count
3611285809Sscottl*  \return: None
3612285809Sscottl*
3613285809Sscottl*
3614285809Sscottl*****************************************************************************/
3615285809SscottlosGLOBAL void
3616285809SscottlitdssXferErrorCreditTimeoutHandler(
3617285809Sscottl                       agsaRoot_t           *agRoot,
3618285809Sscottl                       agsaIORequest_t      *agIORequest,
3619285809Sscottl                       bit32                agIOStatus,
3620285809Sscottl                       bit32                agIOInfoLen,
3621285809Sscottl                       void                 *agParam,
3622285809Sscottl                       bit32                agOtherInfo
3623285809Sscottl                       )
3624285809Sscottl{
3625285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3626285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3627285809Sscottl  bit32                  intContext = osData->IntContext;
3628285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3629285809Sscottl  TI_DBG1(("itdssXferErrorCreditTimeoutHandler: start\n"));
3630285809Sscottl
3631285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3632285809Sscottl
3633285809Sscottl  ostiInitiatorIOCompleted (
3634285809Sscottl                            tiRoot,
3635285809Sscottl                            tdIORequestBody->tiIORequest,
3636285809Sscottl                            tiIOFailed,
3637285809Sscottl                            tiDetailOtherError,
3638285809Sscottl                            agNULL,
3639285809Sscottl                            intContext
3640285809Sscottl                            );
3641285809Sscottl
3642285809Sscottl  return;
3643285809Sscottl}
3644285809Sscottl
3645285809Sscottl/*****************************************************************************
3646285809Sscottl*! \brief itdssXferErrorCMDIssueACKNAKTimeoutHandler
3647285809Sscottl*
3648285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3649285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT
3650285809Sscottl*
3651285809Sscottl*  \param  agRoot:            pointer to port instance
3652285809Sscottl*  \param  agIORequest:       pointer to I/O request
3653285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3654285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3655285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3656285809Sscottl*                             of abort request
3657285809Sscottl*  \param  agOtherInfo        Residual count
3658285809Sscottl*  \return: None
3659285809Sscottl*
3660285809Sscottl*
3661285809Sscottl*****************************************************************************/
3662285809SscottlosGLOBAL void
3663285809SscottlitdssXferErrorCMDIssueACKNAKTimeoutHandler(
3664285809Sscottl                       agsaRoot_t           *agRoot,
3665285809Sscottl                       agsaIORequest_t      *agIORequest,
3666285809Sscottl                       bit32                agIOStatus,
3667285809Sscottl                       bit32                agIOInfoLen,
3668285809Sscottl                       void                 *agParam,
3669285809Sscottl                       bit32                agOtherInfo
3670285809Sscottl                       )
3671285809Sscottl{
3672285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3673285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3674285809Sscottl  bit32                  intContext = osData->IntContext;
3675285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3676285809Sscottl  TI_DBG1(("itdssXferErrorCMDIssueACKNAKTimeoutHandler: start\n"));
3677285809Sscottl
3678285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3679285809Sscottl
3680285809Sscottl  ostiInitiatorIOCompleted (
3681285809Sscottl                            tiRoot,
3682285809Sscottl                            tdIORequestBody->tiIORequest,
3683285809Sscottl                            tiIOFailed,
3684285809Sscottl                            tiDetailOtherError,
3685285809Sscottl                            agNULL,
3686285809Sscottl                            intContext
3687285809Sscottl                            );
3688285809Sscottl
3689285809Sscottl  return;
3690285809Sscottl}
3691285809Sscottl
3692285809Sscottl/*****************************************************************************
3693285809Sscottl*! \brief itdssXferErrorCMDIssueBreakBeforeACKNAKHandler
3694285809Sscottl*
3695285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3696285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_CMD_ISSUE_BREAK_BEFORE_ACK_NAK
3697285809Sscottl*
3698285809Sscottl*  \param  agRoot:            pointer to port instance
3699285809Sscottl*  \param  agIORequest:       pointer to I/O request
3700285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3701285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3702285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3703285809Sscottl*                             of abort request
3704285809Sscottl*  \param  agOtherInfo        Residual count
3705285809Sscottl*  \return: None
3706285809Sscottl*
3707285809Sscottl*
3708285809Sscottl*****************************************************************************/
3709285809SscottlosGLOBAL void
3710285809SscottlitdssXferErrorCMDIssueBreakBeforeACKNAKHandler(
3711285809Sscottl                       agsaRoot_t           *agRoot,
3712285809Sscottl                       agsaIORequest_t      *agIORequest,
3713285809Sscottl                       bit32                agIOStatus,
3714285809Sscottl                       bit32                agIOInfoLen,
3715285809Sscottl                       void                 *agParam,
3716285809Sscottl                       bit32                agOtherInfo
3717285809Sscottl                       )
3718285809Sscottl{
3719285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3720285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3721285809Sscottl  bit32                  intContext = osData->IntContext;
3722285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3723285809Sscottl  TI_DBG1(("itdssXferErrorCMDIssueBreakBeforeACKNAKHandler: start\n"));
3724285809Sscottl
3725285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3726285809Sscottl
3727285809Sscottl  ostiInitiatorIOCompleted (
3728285809Sscottl                            tiRoot,
3729285809Sscottl                            tdIORequestBody->tiIORequest,
3730285809Sscottl                            tiIOFailed,
3731285809Sscottl                            tiDetailOtherError,
3732285809Sscottl                            agNULL,
3733285809Sscottl                            intContext
3734285809Sscottl                            );
3735285809Sscottl
3736285809Sscottl  return;
3737285809Sscottl}
3738285809Sscottl
3739285809Sscottl/*****************************************************************************
3740285809Sscottl*! \brief itdssXferErrorCMDIssuePhyDownBeforeACKNAKHandler
3741285809Sscottl*
3742285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3743285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_CMD_ISSUE_PHY_DOWN_BEFORE_ACK_NAK
3744285809Sscottl*
3745285809Sscottl*  \param  agRoot:            pointer to port instance
3746285809Sscottl*  \param  agIORequest:       pointer to I/O request
3747285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3748285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3749285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3750285809Sscottl*                             of abort request
3751285809Sscottl*  \param  agOtherInfo        Residual count
3752285809Sscottl*  \return: None
3753285809Sscottl*
3754285809Sscottl*
3755285809Sscottl*****************************************************************************/
3756285809SscottlosGLOBAL void
3757285809SscottlitdssXferErrorCMDIssuePhyDownBeforeACKNAKHandler(
3758285809Sscottl                       agsaRoot_t           *agRoot,
3759285809Sscottl                       agsaIORequest_t      *agIORequest,
3760285809Sscottl                       bit32                agIOStatus,
3761285809Sscottl                       bit32                agIOInfoLen,
3762285809Sscottl                       void                 *agParam,
3763285809Sscottl                       bit32                agOtherInfo
3764285809Sscottl                       )
3765285809Sscottl{
3766285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3767285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3768285809Sscottl  bit32                  intContext = osData->IntContext;
3769285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3770285809Sscottl  TI_DBG1(("itdssXferErrorCMDIssuePhyDownBeforeACKNAKHandler: start\n"));
3771285809Sscottl
3772285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3773285809Sscottl
3774285809Sscottl  ostiInitiatorIOCompleted (
3775285809Sscottl                            tiRoot,
3776285809Sscottl                            tdIORequestBody->tiIORequest,
3777285809Sscottl                            tiIOFailed,
3778285809Sscottl                            tiDetailOtherError,
3779285809Sscottl                            agNULL,
3780285809Sscottl                            intContext
3781285809Sscottl                            );
3782285809Sscottl
3783285809Sscottl  return;
3784285809Sscottl}
3785285809Sscottl
3786285809Sscottl/*****************************************************************************
3787285809Sscottl*! \brief itdssXferErrorDisruptedPhyDownHandler
3788285809Sscottl*
3789285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3790285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_DISRUPTED_PHY_DOWN
3791285809Sscottl*
3792285809Sscottl*  \param  agRoot:            pointer to port instance
3793285809Sscottl*  \param  agIORequest:       pointer to I/O request
3794285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3795285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3796285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3797285809Sscottl*                             of abort request
3798285809Sscottl*  \param  agOtherInfo        Residual count
3799285809Sscottl*  \return: None
3800285809Sscottl*
3801285809Sscottl*
3802285809Sscottl*****************************************************************************/
3803285809SscottlosGLOBAL void
3804285809SscottlitdssXferErrorDisruptedPhyDownHandler(
3805285809Sscottl                       agsaRoot_t           *agRoot,
3806285809Sscottl                       agsaIORequest_t      *agIORequest,
3807285809Sscottl                       bit32                agIOStatus,
3808285809Sscottl                       bit32                agIOInfoLen,
3809285809Sscottl                       void                 *agParam,
3810285809Sscottl                       bit32                agOtherInfo
3811285809Sscottl                       )
3812285809Sscottl{
3813285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3814285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3815285809Sscottl  bit32                  intContext = osData->IntContext;
3816285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3817285809Sscottl  TI_DBG2(("itdssXferErrorDisruptedPhyDownHandler: start\n"));
3818285809Sscottl
3819285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3820285809Sscottl
3821285809Sscottl  ostiInitiatorIOCompleted (
3822285809Sscottl                            tiRoot,
3823285809Sscottl                            tdIORequestBody->tiIORequest,
3824285809Sscottl                            tiIOFailed,
3825285809Sscottl                            tiDetailOtherError,
3826285809Sscottl                            agNULL,
3827285809Sscottl                            intContext
3828285809Sscottl                            );
3829285809Sscottl
3830285809Sscottl  return;
3831285809Sscottl}
3832285809Sscottl
3833285809Sscottl/*****************************************************************************
3834285809Sscottl*! \brief itdssXferErrorOffsetMismatchHandler
3835285809Sscottl*
3836285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3837285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_OFFSET_MISMATCH
3838285809Sscottl*
3839285809Sscottl*  \param  agRoot:            pointer to port instance
3840285809Sscottl*  \param  agIORequest:       pointer to I/O request
3841285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3842285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3843285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3844285809Sscottl*                             of abort request
3845285809Sscottl*  \param  agOtherInfo        Residual count
3846285809Sscottl*  \return: None
3847285809Sscottl*
3848285809Sscottl*
3849285809Sscottl*****************************************************************************/
3850285809SscottlosGLOBAL void
3851285809SscottlitdssXferErrorOffsetMismatchHandler(
3852285809Sscottl                       agsaRoot_t           *agRoot,
3853285809Sscottl                       agsaIORequest_t      *agIORequest,
3854285809Sscottl                       bit32                agIOStatus,
3855285809Sscottl                       bit32                agIOInfoLen,
3856285809Sscottl                       void                 *agParam,
3857285809Sscottl                       bit32                agOtherInfo
3858285809Sscottl                       )
3859285809Sscottl{
3860285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3861285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3862285809Sscottl  bit32                  intContext = osData->IntContext;
3863285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3864285809Sscottl  TI_DBG1(("itdssXferErrorOffsetMismatchHandler: start\n"));
3865285809Sscottl
3866285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3867285809Sscottl
3868285809Sscottl  ostiInitiatorIOCompleted (
3869285809Sscottl                            tiRoot,
3870285809Sscottl                            tdIORequestBody->tiIORequest,
3871285809Sscottl                            tiIOFailed,
3872285809Sscottl                            tiDetailOtherError,
3873285809Sscottl                            agNULL,
3874285809Sscottl                            intContext
3875285809Sscottl                            );
3876285809Sscottl
3877285809Sscottl  return;
3878285809Sscottl}
3879285809Sscottl
3880285809Sscottl/*****************************************************************************
3881285809Sscottl*! \brief itdssXferErrorXferZeroDataLenHandler
3882285809Sscottl*
3883285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3884285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_XFER_ZERO_DATA_LEN
3885285809Sscottl*
3886285809Sscottl*  \param  agRoot:            pointer to port instance
3887285809Sscottl*  \param  agIORequest:       pointer to I/O request
3888285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3889285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3890285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3891285809Sscottl*                             of abort request
3892285809Sscottl*  \param  agOtherInfo        Residual count
3893285809Sscottl*  \return: None
3894285809Sscottl*
3895285809Sscottl*
3896285809Sscottl*****************************************************************************/
3897285809SscottlosGLOBAL void
3898285809SscottlitdssXferErrorXferZeroDataLenHandler(
3899285809Sscottl                       agsaRoot_t           *agRoot,
3900285809Sscottl                       agsaIORequest_t      *agIORequest,
3901285809Sscottl                       bit32                agIOStatus,
3902285809Sscottl                       bit32                agIOInfoLen,
3903285809Sscottl                       void                 *agParam,
3904285809Sscottl                       bit32                agOtherInfo
3905285809Sscottl                       )
3906285809Sscottl{
3907285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3908285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3909285809Sscottl  bit32                  intContext = osData->IntContext;
3910285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3911285809Sscottl  TI_DBG2(("itdssXferErrorXferZeroDataLenHandler: start\n"));
3912285809Sscottl
3913285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3914285809Sscottl
3915285809Sscottl  ostiInitiatorIOCompleted (
3916285809Sscottl                            tiRoot,
3917285809Sscottl                            tdIORequestBody->tiIORequest,
3918285809Sscottl                            tiIOFailed,
3919285809Sscottl                            tiDetailOtherError,
3920285809Sscottl                            agNULL,
3921285809Sscottl                            intContext
3922285809Sscottl                            );
3923285809Sscottl
3924285809Sscottl  return;
3925285809Sscottl}
3926285809Sscottl
3927285809Sscottl/*****************************************************************************
3928285809Sscottl*! \brief itdssXferOpenRetryTimeoutHandler
3929285809Sscottl*
3930285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
3931285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_OPEN_RETRY_TIMEOUT
3932285809Sscottl*
3933285809Sscottl*  \param  agRoot:            pointer to port instance
3934285809Sscottl*  \param  agIORequest:       pointer to I/O request
3935285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
3936285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
3937285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
3938285809Sscottl*                             of abort request
3939285809Sscottl*  \param  agOtherInfo        Residual count
3940285809Sscottl*  \return: None
3941285809Sscottl*
3942285809Sscottl*
3943285809Sscottl*****************************************************************************/
3944285809SscottlosGLOBAL void
3945285809SscottlitdssXferOpenRetryTimeoutHandler(
3946285809Sscottl                       agsaRoot_t           *agRoot,
3947285809Sscottl                       agsaIORequest_t      *agIORequest,
3948285809Sscottl                       bit32                agIOStatus,
3949285809Sscottl                       bit32                agIOInfoLen,
3950285809Sscottl                       void                 *agParam,
3951285809Sscottl                       bit32                agOtherInfo
3952285809Sscottl                       )
3953285809Sscottl{
3954285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
3955285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
3956285809Sscottl  tdsaRoot_t             *tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
3957285809Sscottl  tdsaContext_t          *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3958285809Sscottl  itdsaIni_t             *Initiator = (itdsaIni_t *)tdsaAllShared->itdsaIni;
3959285809Sscottl  bit32                  intContext = osData->IntContext;
3960285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
3961285809Sscottl  agsaDevHandle_t        *agDevHandle = agNULL;
3962285809Sscottl  tiDeviceHandle_t       *tiDeviceHandle = agNULL;
3963285809Sscottl  tdsaDeviceData_t       *oneDeviceData = agNULL;
3964285809Sscottl  bit32                  saStatus = AGSA_RC_FAILURE;
3965285809Sscottl
3966285809Sscottl  TI_DBG2(("itdssXferOpenRetryTimeoutHandler: start\n"));
3967285809Sscottl
3968285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
3969285809Sscottl  tiDeviceHandle = tdIORequestBody->tiDevHandle;
3970285809Sscottl  oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
3971285809Sscottl  agDevHandle = oneDeviceData->agDevHandle;
3972285809Sscottl
3973285809Sscottl  if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE &&
3974285809Sscottl      oneDeviceData->tdPortContext != agNULL )
3975285809Sscottl  {
3976285809Sscottl    if (tdIORequestBody->reTries < OPEN_RETRY_RETRIES) /* 10 */
3977285809Sscottl    {
3978285809Sscottl      saStatus = saSSPStart(agRoot,
3979285809Sscottl                            agIORequest,
3980285809Sscottl                            tdsaRotateQnumber(tiRoot, oneDeviceData),
3981285809Sscottl                            agDevHandle,
3982285809Sscottl                            tdIORequestBody->agRequestType,
3983285809Sscottl                            &(tdIORequestBody->transport.SAS.agSASRequestBody),
3984285809Sscottl                            agNULL,
3985285809Sscottl                            &ossaSSPCompleted);
3986285809Sscottl
3987285809Sscottl      if (saStatus == AGSA_RC_SUCCESS)
3988285809Sscottl      {
3989285809Sscottl        TI_DBG2(("itdssXferOpenRetryTimeoutHandler: retried\n"));
3990285809Sscottl        Initiator->NumIOsActive++;
3991285809Sscottl        tdIORequestBody->ioStarted = agTRUE;
3992285809Sscottl        tdIORequestBody->ioCompleted = agFALSE;
3993285809Sscottl        tdIORequestBody->reTries++;
3994285809Sscottl        return;
3995285809Sscottl      }
3996285809Sscottl      else
3997285809Sscottl      {
3998285809Sscottl        TI_DBG1(("itdssXferOpenRetryTimeoutHandler: retry failed\n"));
3999285809Sscottl        tdIORequestBody->ioStarted = agFALSE;
4000285809Sscottl        tdIORequestBody->ioCompleted = agTRUE;
4001285809Sscottl        tdIORequestBody->reTries = 0;
4002285809Sscottl      }
4003285809Sscottl    }
4004285809Sscottl    else
4005285809Sscottl    {
4006285809Sscottl      TI_DBG1(("itdssXferOpenRetryTimeoutHandler: retry is over and fail\n"));
4007285809Sscottl      tdIORequestBody->reTries = 0;
4008285809Sscottl    }
4009285809Sscottl  }
4010285809Sscottl  else
4011285809Sscottl  {
4012285809Sscottl    TI_DBG1(("itdssXferOpenRetryTimeoutHandler: not valid deivce no retry\n"));
4013285809Sscottl    tdIORequestBody->reTries = 0;
4014285809Sscottl  }
4015285809Sscottl  ostiInitiatorIOCompleted(
4016285809Sscottl                           tiRoot,
4017285809Sscottl                           tdIORequestBody->tiIORequest,
4018285809Sscottl                           tiIOFailed,
4019285809Sscottl                           tiDetailOtherError,
4020285809Sscottl                           agNULL,
4021285809Sscottl                           intContext
4022285809Sscottl                           );
4023285809Sscottl  return;
4024285809Sscottl}
4025285809Sscottl
4026285809Sscottl/*****************************************************************************
4027285809Sscottl*! \brief itdssPortInResetHandler
4028285809Sscottl*
4029285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4030285809Sscottl*            layer with agIOStatus = OSSA_IO_PORT_IN_RESET
4031285809Sscottl*
4032285809Sscottl*  \param  agRoot:            pointer to port instance
4033285809Sscottl*  \param  agIORequest:       pointer to I/O request
4034285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4035285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4036285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4037285809Sscottl*                             of abort request
4038285809Sscottl*  \param  agOtherInfo        Residual count
4039285809Sscottl*  \return: None
4040285809Sscottl*
4041285809Sscottl*
4042285809Sscottl*****************************************************************************/
4043285809SscottlosGLOBAL void
4044285809SscottlitdssPortInResetHandler(
4045285809Sscottl                       agsaRoot_t           *agRoot,
4046285809Sscottl                       agsaIORequest_t      *agIORequest,
4047285809Sscottl                       bit32                agIOStatus,
4048285809Sscottl                       bit32                agIOInfoLen,
4049285809Sscottl                       void                 *agParam,
4050285809Sscottl                       bit32                agOtherInfo
4051285809Sscottl                       )
4052285809Sscottl{
4053285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4054285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4055285809Sscottl  bit32                  intContext = osData->IntContext;
4056285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4057285809Sscottl  TI_DBG2(("itdssPortInResetHandler: start\n"));
4058285809Sscottl
4059285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4060285809Sscottl
4061285809Sscottl  ostiInitiatorIOCompleted (
4062285809Sscottl                            tiRoot,
4063285809Sscottl                            tdIORequestBody->tiIORequest,
4064285809Sscottl                            tiIOFailed,
4065285809Sscottl                            tiDetailOtherError,
4066285809Sscottl                            agNULL,
4067285809Sscottl                            intContext
4068285809Sscottl                            );
4069285809Sscottl
4070285809Sscottl  return;
4071285809Sscottl}
4072285809Sscottl
4073285809Sscottl/*****************************************************************************
4074285809Sscottl*! \brief itdssDsNonOperationalHandler
4075285809Sscottl*
4076285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4077285809Sscottl*            layer with agIOStatus = OSSA_IO_DS_NON_OPERATIONAL
4078285809Sscottl*
4079285809Sscottl*  \param  agRoot:            pointer to port instance
4080285809Sscottl*  \param  agIORequest:       pointer to I/O request
4081285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4082285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4083285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4084285809Sscottl*                             of abort request
4085285809Sscottl*  \param  agOtherInfo        Residual count
4086285809Sscottl*  \return: None
4087285809Sscottl*
4088285809Sscottl*
4089285809Sscottl*****************************************************************************/
4090285809SscottlosGLOBAL void
4091285809SscottlitdssDsNonOperationalHandler(
4092285809Sscottl                       agsaRoot_t           *agRoot,
4093285809Sscottl                       agsaIORequest_t      *agIORequest,
4094285809Sscottl                       bit32                agIOStatus,
4095285809Sscottl                       bit32                agIOInfoLen,
4096285809Sscottl                       void                 *agParam,
4097285809Sscottl                       bit32                agOtherInfo
4098285809Sscottl                       )
4099285809Sscottl{
4100285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4101285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4102285809Sscottl  bit32                  intContext = osData->IntContext;
4103285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4104285809Sscottl  agsaDevHandle_t        *agDevHandle = agNULL;
4105285809Sscottl  tiDeviceHandle_t       *tiDeviceHandle = agNULL;
4106285809Sscottl  tdsaDeviceData_t       *oneDeviceData = agNULL;
4107285809Sscottl
4108285809Sscottl
4109285809Sscottl  TI_DBG2(("itdssDsNonOperationalHandler: start\n"));
4110285809Sscottl
4111285809Sscottl
4112285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4113285809Sscottl
4114285809Sscottl#if 1 /* TBD */
4115285809Sscottl  /* let's do it only once ????? */
4116285809Sscottl  tiDeviceHandle = tdIORequestBody->tiDevHandle;
4117285809Sscottl  oneDeviceData  = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
4118285809Sscottl  agDevHandle = oneDeviceData->agDevHandle;
4119285809Sscottl  if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE &&
4120285809Sscottl      oneDeviceData->tdPortContext != agNULL )
4121285809Sscottl  {
4122285809Sscottl    saSetDeviceState(agRoot, agNULL, tdsaRotateQnumber(tiRoot, oneDeviceData), agDevHandle, SA_DS_OPERATIONAL);
4123285809Sscottl  }
4124285809Sscottl#endif
4125285809Sscottl
4126285809Sscottl  ostiInitiatorIOCompleted (
4127285809Sscottl                            tiRoot,
4128285809Sscottl                            tdIORequestBody->tiIORequest,
4129285809Sscottl                            tiIOFailed,
4130285809Sscottl                            tiDetailOtherError,
4131285809Sscottl                            agNULL,
4132285809Sscottl                            intContext
4133285809Sscottl                            );
4134285809Sscottl
4135285809Sscottl  return;
4136285809Sscottl}
4137285809Sscottl
4138285809Sscottl/*****************************************************************************
4139285809Sscottl*! \brief itdssDsInRecoveryHandler
4140285809Sscottl*
4141285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4142285809Sscottl*            layer with agIOStatus = OSSA_IO_DS_IN_RECOVERY
4143285809Sscottl*
4144285809Sscottl*  \param  agRoot:            pointer to port instance
4145285809Sscottl*  \param  agIORequest:       pointer to I/O request
4146285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4147285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4148285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4149285809Sscottl*                             of abort request
4150285809Sscottl*  \param  agOtherInfo        Residual count
4151285809Sscottl*  \return: None
4152285809Sscottl*
4153285809Sscottl*
4154285809Sscottl*****************************************************************************/
4155285809SscottlosGLOBAL void
4156285809SscottlitdssDsInRecoveryHandler(
4157285809Sscottl                       agsaRoot_t           *agRoot,
4158285809Sscottl                       agsaIORequest_t      *agIORequest,
4159285809Sscottl                       bit32                agIOStatus,
4160285809Sscottl                       bit32                agIOInfoLen,
4161285809Sscottl                       void                 *agParam,
4162285809Sscottl                       bit32                agOtherInfo
4163285809Sscottl                       )
4164285809Sscottl{
4165285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4166285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4167285809Sscottl  bit32                  intContext = osData->IntContext;
4168285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4169285809Sscottl  TI_DBG2(("itdssDsInRecoveryHandler: start\n"));
4170285809Sscottl
4171285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4172285809Sscottl
4173285809Sscottl  ostiInitiatorIOCompleted (
4174285809Sscottl                            tiRoot,
4175285809Sscottl                            tdIORequestBody->tiIORequest,
4176285809Sscottl                            tiIOFailed,
4177285809Sscottl                            tiDetailOtherError,
4178285809Sscottl                            agNULL,
4179285809Sscottl                            intContext
4180285809Sscottl                            );
4181285809Sscottl
4182285809Sscottl  return;
4183285809Sscottl}
4184285809Sscottl
4185285809Sscottl/*****************************************************************************
4186285809Sscottl*! \brief itdssTmTagNotFoundHandler
4187285809Sscottl*
4188285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4189285809Sscottl*            layer with agIOStatus = OSSA_IO_TM_TAG_NOT_FOUND
4190285809Sscottl*
4191285809Sscottl*  \param  agRoot:            pointer to port instance
4192285809Sscottl*  \param  agIORequest:       pointer to I/O request
4193285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4194285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4195285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4196285809Sscottl*                             of abort request
4197285809Sscottl*  \param  agOtherInfo        Residual count
4198285809Sscottl*  \return: None
4199285809Sscottl*
4200285809Sscottl*
4201285809Sscottl*****************************************************************************/
4202285809SscottlosGLOBAL void
4203285809SscottlitdssTmTagNotFoundHandler(
4204285809Sscottl                       agsaRoot_t           *agRoot,
4205285809Sscottl                       agsaIORequest_t      *agIORequest,
4206285809Sscottl                       bit32                agIOStatus,
4207285809Sscottl                       bit32                agIOInfoLen,
4208285809Sscottl                       void                 *agParam,
4209285809Sscottl                       bit32                agOtherInfo
4210285809Sscottl                       )
4211285809Sscottl{
4212285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4213285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4214285809Sscottl  bit32                  intContext = osData->IntContext;
4215285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4216285809Sscottl  TI_DBG2(("itdssTmTagNotFoundHandler: start\n"));
4217285809Sscottl
4218285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4219285809Sscottl
4220285809Sscottl  ostiInitiatorIOCompleted (
4221285809Sscottl                            tiRoot,
4222285809Sscottl                            tdIORequestBody->tiIORequest,
4223285809Sscottl                            tiIOFailed,
4224285809Sscottl                            tiDetailOtherError,
4225285809Sscottl                            agNULL,
4226285809Sscottl                            intContext
4227285809Sscottl                            );
4228285809Sscottl
4229285809Sscottl  return;
4230285809Sscottl}
4231285809Sscottl
4232285809Sscottl/*****************************************************************************
4233285809Sscottl*! \brief itdssSSPExtIUZeroLenHandler
4234285809Sscottl*
4235285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4236285809Sscottl*            layer with agIOStatus = OSSA_IO_SSP_EXT_IU_ZERO_LEN_ERROR
4237285809Sscottl*
4238285809Sscottl*  \param  agRoot:            pointer to port instance
4239285809Sscottl*  \param  agIORequest:       pointer to I/O request
4240285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4241285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4242285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4243285809Sscottl*                             of abort request
4244285809Sscottl*  \param  agOtherInfo        Residual count
4245285809Sscottl*  \return: None
4246285809Sscottl*
4247285809Sscottl*
4248285809Sscottl*****************************************************************************/
4249285809SscottlosGLOBAL void
4250285809SscottlitdssSSPExtIUZeroLenHandler(
4251285809Sscottl                       agsaRoot_t           *agRoot,
4252285809Sscottl                       agsaIORequest_t      *agIORequest,
4253285809Sscottl                       bit32                agIOStatus,
4254285809Sscottl                       bit32                agIOInfoLen,
4255285809Sscottl                       void                 *agParam,
4256285809Sscottl                       bit32                agOtherInfo
4257285809Sscottl                       )
4258285809Sscottl{
4259285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4260285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4261285809Sscottl  bit32                  intContext = osData->IntContext;
4262285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4263285809Sscottl  TI_DBG2(("itdssSSPExtIUZeroLenHandler: start\n"));
4264285809Sscottl
4265285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4266285809Sscottl
4267285809Sscottl  ostiInitiatorIOCompleted (
4268285809Sscottl                            tiRoot,
4269285809Sscottl                            tdIORequestBody->tiIORequest,
4270285809Sscottl                            tiIOFailed,
4271285809Sscottl                            tiDetailOtherError,
4272285809Sscottl                            agNULL,
4273285809Sscottl                            intContext
4274285809Sscottl                            );
4275285809Sscottl
4276285809Sscottl  return;
4277285809Sscottl}
4278285809Sscottl
4279285809Sscottl/*****************************************************************************
4280285809Sscottl*! \brief itdssXferErrorUnexpectedPhaseHandler
4281285809Sscottl*
4282285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4283285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERROR_UNEXPECTED_PHASE
4284285809Sscottl*
4285285809Sscottl*  \param  agRoot:            pointer to port instance
4286285809Sscottl*  \param  agIORequest:       pointer to I/O request
4287285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4288285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4289285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4290285809Sscottl*                             of abort request
4291285809Sscottl*  \param  agOtherInfo        Residual count
4292285809Sscottl*  \return: None
4293285809Sscottl*
4294285809Sscottl*
4295285809Sscottl*****************************************************************************/
4296285809SscottlosGLOBAL void
4297285809SscottlitdssXferErrorUnexpectedPhaseHandler(
4298285809Sscottl                       agsaRoot_t           *agRoot,
4299285809Sscottl                       agsaIORequest_t      *agIORequest,
4300285809Sscottl                       bit32                agIOStatus,
4301285809Sscottl                       bit32                agIOInfoLen,
4302285809Sscottl                       void                 *agParam,
4303285809Sscottl                       bit32                agOtherInfo
4304285809Sscottl                       )
4305285809Sscottl{
4306285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4307285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4308285809Sscottl  bit32                  intContext = osData->IntContext;
4309285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4310285809Sscottl  TI_DBG2(("itdssXferErrorUnexpectedPhaseHandler: start\n"));
4311285809Sscottl
4312285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4313285809Sscottl
4314285809Sscottl  ostiInitiatorIOCompleted (
4315285809Sscottl                            tiRoot,
4316285809Sscottl                            tdIORequestBody->tiIORequest,
4317285809Sscottl                            tiIOFailed,
4318285809Sscottl                            tiDetailOtherError,
4319285809Sscottl                            agNULL,
4320285809Sscottl                            intContext
4321285809Sscottl                            );
4322285809Sscottl
4323285809Sscottl  return;
4324285809Sscottl}
4325285809Sscottl
4326285809Sscottl#ifdef REMOVED
4327285809Sscottl/*****************************************************************************
4328285809Sscottl*! \brief itdssIOUnderFlowWithChkConditionHandler
4329285809Sscottl*
4330285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4331285809Sscottl*            layer with agIOStatus = OSSA_IO_UNDERFLOW_WITH_CHK_COND
4332285809Sscottl*
4333285809Sscottl*  \param  agRoot:            pointer to port instance
4334285809Sscottl*  \param  agIORequest:       pointer to I/O request
4335285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4336285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4337285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4338285809Sscottl*                             of abort request
4339285809Sscottl*  \return: None
4340285809Sscottl*
4341285809Sscottl*
4342285809Sscottl*****************************************************************************/
4343285809Sscottl/*
4344285809Sscottl  How to report SCSI_STAT_CHECK_CONDITION and tiIOUnderRun simultaneoulsy???
4345285809Sscottl  ostiInitiatorIOCompleted(
4346285809Sscottl                             tiRoot,
4347285809Sscottl                             tdIORequestBody->tiIORequest,
4348285809Sscottl                             tiIOSuccess,
4349285809Sscottl                             SCSI_STAT_CHECK_CONDITION,
4350285809Sscottl                             &senseData,
4351285809Sscottl                             agTRUE
4352285809Sscottl                             );
4353285809Sscottl
4354285809Sscottl                 vs
4355285809Sscottl
4356285809Sscottl  ostiInitiatorIOCompleted (
4357285809Sscottl                            tiRoot,
4358285809Sscottl                            tdIORequestBody->tiIORequest,
4359285809Sscottl                            tiIOUnderRun,
4360285809Sscottl                            agIOInfoLen,
4361285809Sscottl                            agNULL,
4362285809Sscottl                            intContext
4363285809Sscottl                            );
4364285809Sscottl
4365285809Sscottl  For now, SCSI_STAT_CHECK_CONDITION is reported until TISA changes (as of 1/6/09)
4366285809Sscottl  In other words, this handler is the practically same as itdssIOSuccessHandler()
4367285809Sscottl*/
4368285809SscottlosGLOBAL void
4369285809SscottlitdssIOUnderFlowWithChkConditionHandler(
4370285809Sscottl                        agsaRoot_t              *agRoot,
4371285809Sscottl                        agsaIORequest_t         *agIORequest,
4372285809Sscottl                        bit32                   agIOStatus,
4373285809Sscottl                        bit32                   agIOInfoLen,
4374285809Sscottl                        void                    *agParam
4375285809Sscottl                        )
4376285809Sscottl{
4377285809Sscottl  tdsaRootOsData_t          *osData = (tdsaRootOsData_t *)agRoot->osData;
4378285809Sscottl  tiRoot_t                  *tiRoot = (tiRoot_t *)osData->tiRoot;
4379285809Sscottl  tdIORequestBody_t         *tdIORequestBody;
4380285809Sscottl  agsaSSPResponseInfoUnit_t agSSPRespIU;
4381285809Sscottl  tiSenseData_t             senseData;
4382285809Sscottl  bit8                      senseDataPayload[256];
4383285809Sscottl  bit8                      respData[128];
4384285809Sscottl  bit32                     scsi_status;
4385285809Sscottl  bit32                     senseLen;
4386285809Sscottl  bit32                     respLen;
4387285809Sscottl  bit32                     data_status;
4388285809Sscottl  bit32                     i;
4389285809Sscottl  tiDeviceHandle_t          *tiDeviceHandle = agNULL;
4390285809Sscottl  tdsaDeviceData_t          *oneDeviceData = agNULL;
4391285809Sscottl
4392285809Sscottl  TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: start\n"));
4393285809Sscottl  TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: agIOInfoLen 0x%x\n", agIOInfoLen));
4394285809Sscottl
4395285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4396285809Sscottl
4397285809Sscottl  tdIORequestBody->ioCompleted = agTRUE;
4398285809Sscottl  tdIORequestBody->ioStarted = agFALSE;
4399285809Sscottl
4400285809Sscottl  /*
4401285809Sscottl    agIOInfoLen must be >= sizeof(agsaSSPResponseInfoUnit_t), which is minimum
4402285809Sscottl    date length
4403285809Sscottl  */
4404285809Sscottl  if (agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t))
4405285809Sscottl  {
4406285809Sscottl    TI_DBG1(("itdssIOUnderFlowWithChkConditionHandler: First agIOInfoLen does not match!!!\n"));
4407285809Sscottl    TI_DBG1(("itdssIOUnderFlowWithChkConditionHandler: First agIOInfoLen 0x%x IU 0x%x\n", agIOInfoLen, (unsigned int)sizeof(agsaSSPResponseInfoUnit_t)));
4408285809Sscottl    ostiInitiatorIOCompleted(
4409285809Sscottl                             tiRoot,
4410285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
4411285809Sscottl                             tiIOFailed,
4412285809Sscottl                             tiDetailOtherError,
4413285809Sscottl                             agNULL,
4414285809Sscottl                             agTRUE /* intContext; is not being used */
4415285809Sscottl                             );
4416285809Sscottl    return;
4417285809Sscottl  }
4418285809Sscottl  /* reads agsaSSPResponseInfoUnit_t */
4419285809Sscottl  saFrameReadBlock(agRoot, agParam, 0, &agSSPRespIU, sizeof(agsaSSPResponseInfoUnit_t));
4420285809Sscottl
4421285809Sscottl  data_status = SA_SSPRESP_GET_DATAPRES(&agSSPRespIU);
4422285809Sscottl  scsi_status = agSSPRespIU.status;
4423285809Sscottl  /* endianess is invovled here */
4424285809Sscottl  senseLen = SA_SSPRESP_GET_SENSEDATALEN(&agSSPRespIU);
4425285809Sscottl  respLen = SA_SSPRESP_GET_RESPONSEDATALEN(&agSSPRespIU);
4426285809Sscottl
4427285809Sscottl  TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: dataPres=%x\n", data_status));
4428285809Sscottl  TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: scsi status=0x%x, senselen=0x%x resplen 0x%x\n", scsi_status, senseLen, respLen));
4429285809Sscottl
4430285809Sscottl  /*
4431285809Sscottl    sanity check: do not go beyond of agIOInfoLen. if happens, return error
4432285809Sscottl    agIOInfoLen >= sizeof(agsaSSPResponseInfoUnit_t) + senseLen + respLen -> OK
4433285809Sscottl    because frame must be divisible by 4, so there can be extra padding
4434285809Sscottl    agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t) + senseLen + respLen -> NOT OK
4435285809Sscottl  */
4436285809Sscottl  if (agIOInfoLen < sizeof(agsaSSPResponseInfoUnit_t) + senseLen + respLen)
4437285809Sscottl  {
4438285809Sscottl    TI_DBG1(("itdssIOUnderFlowWithChkConditionHandler: Second agIOInfoLen does not match!!!\n"));
4439285809Sscottl    TI_DBG1(("itdssIOUnderFlowWithChkConditionHandler: Second agIOInfoLen 0x%x IU 0x%x senselen 0x%x resplen 0x%x\n", agIOInfoLen, (unsigned int)sizeof(agsaSSPResponseInfoUnit_t), senseLen, respLen));
4440285809Sscottl
4441285809Sscottl    ostiInitiatorIOCompleted(
4442285809Sscottl                             tiRoot,
4443285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
4444285809Sscottl                             tiIOFailed,
4445285809Sscottl                             tiDetailOtherError,
4446285809Sscottl                             agNULL,
4447285809Sscottl                             agTRUE /* intContext; is not being used */
4448285809Sscottl                             );
4449285809Sscottl    return;
4450285809Sscottl  }
4451285809Sscottl
4452285809Sscottl  /* reads response data */
4453285809Sscottl  saFrameReadBlock(agRoot, agParam,
4454285809Sscottl                   sizeof(agsaSSPResponseInfoUnit_t),
4455285809Sscottl                   respData, respLen);
4456285809Sscottl  /* reads sense data */
4457285809Sscottl  saFrameReadBlock(agRoot, agParam,
4458285809Sscottl                   sizeof(agsaSSPResponseInfoUnit_t)
4459285809Sscottl                   + respLen,
4460285809Sscottl                   senseDataPayload, senseLen);
4461285809Sscottl
4462285809Sscottl  if (data_status == 0)
4463285809Sscottl  {
4464285809Sscottl    /* NO_DATA */
4465285809Sscottl    TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: no data\n"));
4466285809Sscottl
4467285809Sscottl    ostiInitiatorIOCompleted(
4468285809Sscottl                             tiRoot,
4469285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
4470285809Sscottl                             tiIOSuccess,
4471285809Sscottl                             scsi_status,
4472285809Sscottl                             agNULL,
4473285809Sscottl                             agTRUE /* intContext; is not being used */
4474285809Sscottl                             );
4475285809Sscottl
4476285809Sscottl    return;
4477285809Sscottl  }
4478285809Sscottl
4479285809Sscottl  if (data_status == 1)
4480285809Sscottl  {
4481285809Sscottl    /* RESPONSE_DATA */
4482285809Sscottl    TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: response data \n"));
4483285809Sscottl
4484285809Sscottl    ostiInitiatorIOCompleted(
4485285809Sscottl                             tiRoot,
4486285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
4487285809Sscottl                             tiIOSuccess,
4488285809Sscottl                             0,
4489285809Sscottl                             agNULL,
4490285809Sscottl                             agTRUE /* intContext; is not being used */
4491285809Sscottl                             );
4492285809Sscottl    return;
4493285809Sscottl  }
4494285809Sscottl
4495285809Sscottl  if (data_status == 2)
4496285809Sscottl  {
4497285809Sscottl    /* SENSE_DATA */
4498285809Sscottl    TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: sense data \n"));
4499285809Sscottl
4500285809Sscottl    senseData.senseData = &senseDataPayload;
4501285809Sscottl    senseData.senseLen = MIN(256, senseLen);
4502285809Sscottl    /* debugging */
4503285809Sscottl    tdhexdump("ResponseIU I", (bit8 *)&agSSPRespIU, sizeof(agsaSSPResponseInfoUnit_t));
4504285809Sscottl
4505285809Sscottl    tdhexdump("sense data I", (bit8 *)senseDataPayload, senseLen);
4506285809Sscottl    tdhexdump("sense data II", (bit8 *)senseData.senseData, senseData.senseLen);
4507285809Sscottl
4508285809Sscottl    if (senseDataPayload[2] == SCSI_SENSE_KEY_RECOVERED_ERROR)
4509285809Sscottl    {
4510285809Sscottl      Initiator->SenseKeyCounter.SoftError ++;
4511285809Sscottl    }
4512285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_NOT_READY)
4513285809Sscottl    {
4514285809Sscottl      Initiator->SenseKeyCounter.MediumNotReady++;
4515285809Sscottl    }
4516285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_MEDIUM_ERROR)
4517285809Sscottl    {
4518285809Sscottl      Initiator->SenseKeyCounter.MediumError++;
4519285809Sscottl    }
4520285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_HARDWARE_ERROR)
4521285809Sscottl    {
4522285809Sscottl      Initiator->SenseKeyCounter.HardwareError++;
4523285809Sscottl    }
4524285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_ILLEGAL_REQUEST)
4525285809Sscottl    {
4526285809Sscottl      Initiator->SenseKeyCounter.IllegalRequest++;
4527285809Sscottl    }
4528285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_UNIT_ATTENTION)
4529285809Sscottl    {
4530285809Sscottl      Initiator->SenseKeyCounter.UnitAttention++;
4531285809Sscottl    }
4532285809Sscottl    else if (senseDataPayload[2] == SCSI_SENSE_KEY_ABORTED_COMMAND)
4533285809Sscottl    {
4534285809Sscottl      Initiator->SenseKeyCounter.AbortCommand++;
4535285809Sscottl    }
4536285809Sscottl    else
4537285809Sscottl    {
4538285809Sscottl      Initiator->SenseKeyCounter.OtherKeyType++;
4539285809Sscottl    }
4540285809Sscottl
4541285809Sscottl    /* when ASQ and ASCQ 0x04 0x11, does saLocalPhyControl for notify spinup */
4542285809Sscottl    if ((senseDataPayload[12] == 0x04 && senseDataPayload[13] == 0x11))
4543285809Sscottl    {
4544285809Sscottl      TI_DBG2(("itdssIOUnderFlowWithChkConditionHandler: sending notfify spinup\n"));
4545285809Sscottl      tiDeviceHandle = tdIORequestBody->tiDevHandle;
4546285809Sscottl      oneDeviceData = (tdsaDeviceData_t *)tiDeviceHandle->tdData;
4547285809Sscottl      if (oneDeviceData->directlyAttached == agTRUE)
4548285809Sscottl      {
4549285809Sscottl        for (i=0;i<TD_MAX_NUM_NOTIFY_SPINUP;i++)
4550285809Sscottl        {
4551285809Sscottl          saLocalPhyControl(agRoot, agNULL, 0, oneDeviceData->phyID, AGSA_PHY_NOTIFY_ENABLE_SPINUP, agNULL);
4552285809Sscottl        }
4553285809Sscottl      }
4554285809Sscottl    }
4555285809Sscottl    ostiInitiatorIOCompleted(
4556285809Sscottl                             tiRoot,
4557285809Sscottl                             /* tiIORequest */
4558285809Sscottl                             tdIORequestBody->tiIORequest,
4559285809Sscottl                             tiIOSuccess,
4560285809Sscottl                             scsi_status,
4561285809Sscottl                             &senseData,
4562285809Sscottl                             agTRUE /* intContext; is not being used */
4563285809Sscottl                             );
4564285809Sscottl    return;
4565285809Sscottl  }
4566285809Sscottl  if (data_status == 3)
4567285809Sscottl  {
4568285809Sscottl    /* RESERVED */
4569285809Sscottl    TI_DBG1(("itdssIOUnderFlowWithChkConditionHandler: reserved wrong!!!\n"));
4570285809Sscottl    ostiInitiatorIOCompleted(
4571285809Sscottl                             tiRoot,
4572285809Sscottl                             tdIORequestBody->tiIORequest, /* tiIORequest */
4573285809Sscottl                             tiIOFailed,
4574285809Sscottl                             scsi_status,
4575285809Sscottl                             agNULL,
4576285809Sscottl                             agTRUE /* intContext; is not being used */
4577285809Sscottl                             );
4578285809Sscottl    return;
4579285809Sscottl  }
4580285809Sscottl
4581285809Sscottl
4582285809Sscottl  return;
4583285809Sscottl}
4584285809Sscottl#endif
4585285809Sscottl
4586285809Sscottl/*****************************************************************************
4587285809Sscottl*! \brief itdssXferOpenRetryBackoffThresholdReachedHandler
4588285809Sscottl*
4589285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4590285809Sscottl*            layer with agIOStatus =
4591285809Sscottl*            OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED
4592285809Sscottl*
4593285809Sscottl*  \param  agRoot:            pointer to port instance
4594285809Sscottl*  \param  agIORequest:       pointer to I/O request
4595285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4596285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4597285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4598285809Sscottl*                             of abort request
4599285809Sscottl*  \param  agOtherInfo        Residual count
4600285809Sscottl*  \return: None
4601285809Sscottl*
4602285809Sscottl*
4603285809Sscottl*****************************************************************************/
4604285809SscottlosGLOBAL void
4605285809SscottlitdssXferOpenRetryBackoffThresholdReachedHandler(
4606285809Sscottl                                                 agsaRoot_t           *agRoot,
4607285809Sscottl                                                 agsaIORequest_t      *agIORequest,
4608285809Sscottl                                                 bit32                agIOStatus,
4609285809Sscottl                                                 bit32                agIOInfoLen,
4610285809Sscottl                                                 void                 *agParam,
4611285809Sscottl                                                 bit32                agOtherInfo
4612285809Sscottl                                                )
4613285809Sscottl{
4614285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4615285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4616285809Sscottl  bit32                  intContext = osData->IntContext;
4617285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4618285809Sscottl  TI_DBG2(("itdssXferOpenRetryBackoffThresholdReachedHandler: start\n"));
4619285809Sscottl
4620285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4621285809Sscottl
4622285809Sscottl  ostiInitiatorIOCompleted (
4623285809Sscottl                            tiRoot,
4624285809Sscottl                            tdIORequestBody->tiIORequest,
4625285809Sscottl                            tiIOFailed,
4626285809Sscottl                            tiDetailOtherError,
4627285809Sscottl                            agNULL,
4628285809Sscottl                            intContext
4629285809Sscottl                            );
4630285809Sscottl
4631285809Sscottl  return;
4632285809Sscottl}
4633285809Sscottl
4634285809Sscottl/*****************************************************************************
4635285809Sscottl*! \brief itdssOpenCnxErrorItNexusLossOpenTmoHandler
4636285809Sscottl*
4637285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4638285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO
4639285809Sscottl*
4640285809Sscottl*  \param  agRoot:            pointer to port instance
4641285809Sscottl*  \param  agIORequest:       pointer to I/O request
4642285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4643285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4644285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4645285809Sscottl*                             of abort request
4646285809Sscottl*  \param  agOtherInfo        Residual count
4647285809Sscottl*  \return: None
4648285809Sscottl*
4649285809Sscottl*
4650285809Sscottl*****************************************************************************/
4651285809SscottlosGLOBAL void
4652285809SscottlitdssOpenCnxErrorItNexusLossOpenTmoHandler(
4653285809Sscottl                                           agsaRoot_t           *agRoot,
4654285809Sscottl                                           agsaIORequest_t      *agIORequest,
4655285809Sscottl                                           bit32                agIOStatus,
4656285809Sscottl                                           bit32                agIOInfoLen,
4657285809Sscottl                                           void                 *agParam,
4658285809Sscottl                                           bit32                agOtherInfo
4659285809Sscottl                                          )
4660285809Sscottl{
4661285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4662285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4663285809Sscottl  bit32                  intContext = osData->IntContext;
4664285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4665285809Sscottl  TI_DBG2(("itdssOpenCnxErrorItNexusLossOpenTmoHandler: start\n"));
4666285809Sscottl
4667285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4668285809Sscottl
4669285809Sscottl  ostiInitiatorIOCompleted (
4670285809Sscottl                            tiRoot,
4671285809Sscottl                            tdIORequestBody->tiIORequest,
4672285809Sscottl                            tiIOFailed,
4673285809Sscottl                            tiDetailOtherError,
4674285809Sscottl                            agNULL,
4675285809Sscottl                            intContext
4676285809Sscottl                            );
4677285809Sscottl
4678285809Sscottl  return;
4679285809Sscottl}
4680285809Sscottl
4681285809Sscottl/*****************************************************************************
4682285809Sscottl*! \brief itdssOpenCnxErrorItNexusLossNoDestHandler
4683285809Sscottl*
4684285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4685285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST
4686285809Sscottl*
4687285809Sscottl*  \param  agRoot:            pointer to port instance
4688285809Sscottl*  \param  agIORequest:       pointer to I/O request
4689285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4690285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4691285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4692285809Sscottl*                             of abort request
4693285809Sscottl*  \param  agOtherInfo        Residual count
4694285809Sscottl*  \return: None
4695285809Sscottl*
4696285809Sscottl*
4697285809Sscottl*****************************************************************************/
4698285809SscottlosGLOBAL void
4699285809SscottlitdssOpenCnxErrorItNexusLossNoDestHandler(
4700285809Sscottl                                          agsaRoot_t           *agRoot,
4701285809Sscottl                                          agsaIORequest_t      *agIORequest,
4702285809Sscottl                                          bit32                agIOStatus,
4703285809Sscottl                                          bit32                agIOInfoLen,
4704285809Sscottl                                          void                 *agParam,
4705285809Sscottl                                          bit32                agOtherInfo
4706285809Sscottl                                         )
4707285809Sscottl{
4708285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4709285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4710285809Sscottl  bit32                  intContext = osData->IntContext;
4711285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4712285809Sscottl  TI_DBG2(("itdssOpenCnxErrorItNexusLossNoDestHandler: start\n"));
4713285809Sscottl
4714285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4715285809Sscottl
4716285809Sscottl  ostiInitiatorIOCompleted (
4717285809Sscottl                            tiRoot,
4718285809Sscottl                            tdIORequestBody->tiIORequest,
4719285809Sscottl                            tiIOFailed,
4720285809Sscottl                            tiDetailOtherError,
4721285809Sscottl                            agNULL,
4722285809Sscottl                            intContext
4723285809Sscottl                            );
4724285809Sscottl
4725285809Sscottl  return;
4726285809Sscottl}
4727285809Sscottl
4728285809Sscottl/*****************************************************************************
4729285809Sscottl*! \brief itdssOpenCnxErrorItNexusLossOpenCollideHandler
4730285809Sscottl*
4731285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4732285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE
4733285809Sscottl*
4734285809Sscottl*  \param  agRoot:            pointer to port instance
4735285809Sscottl*  \param  agIORequest:       pointer to I/O request
4736285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4737285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4738285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4739285809Sscottl*                             of abort request
4740285809Sscottl*  \param  agOtherInfo        Residual count
4741285809Sscottl*  \return: None
4742285809Sscottl*
4743285809Sscottl*
4744285809Sscottl*****************************************************************************/
4745285809SscottlosGLOBAL void
4746285809SscottlitdssOpenCnxErrorItNexusLossOpenCollideHandler(
4747285809Sscottl                                               agsaRoot_t           *agRoot,
4748285809Sscottl                                               agsaIORequest_t      *agIORequest,
4749285809Sscottl                                               bit32                agIOStatus,
4750285809Sscottl                                               bit32                agIOInfoLen,
4751285809Sscottl                                               void                 *agParam,
4752285809Sscottl                                               bit32                agOtherInfo
4753285809Sscottl                                              )
4754285809Sscottl{
4755285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4756285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4757285809Sscottl  bit32                  intContext = osData->IntContext;
4758285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4759285809Sscottl  TI_DBG2(("itdssOpenCnxErrorItNexusLossOpenCollideHandler: start\n"));
4760285809Sscottl
4761285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4762285809Sscottl
4763285809Sscottl  ostiInitiatorIOCompleted (
4764285809Sscottl                            tiRoot,
4765285809Sscottl                            tdIORequestBody->tiIORequest,
4766285809Sscottl                            tiIOFailed,
4767285809Sscottl                            tiDetailOtherError,
4768285809Sscottl                            agNULL,
4769285809Sscottl                            intContext
4770285809Sscottl                            );
4771285809Sscottl
4772285809Sscottl  return;
4773285809Sscottl}
4774285809Sscottl
4775285809Sscottl/*****************************************************************************
4776285809Sscottl*! \brief itdssOpenCnxErrorItNexusLossOpenPathwayBlockedHandler
4777285809Sscottl*
4778285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4779285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED
4780285809Sscottl*
4781285809Sscottl*  \param  agRoot:            pointer to port instance
4782285809Sscottl*  \param  agIORequest:       pointer to I/O request
4783285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4784285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4785285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4786285809Sscottl*                             of abort request
4787285809Sscottl*  \param  agOtherInfo        Residual count
4788285809Sscottl*  \return: None
4789285809Sscottl*
4790285809Sscottl*
4791285809Sscottl*****************************************************************************/
4792285809SscottlosGLOBAL void
4793285809SscottlitdssOpenCnxErrorItNexusLossOpenPathwayBlockedHandler(
4794285809Sscottl                                                      agsaRoot_t           *agRoot,
4795285809Sscottl                                                      agsaIORequest_t      *agIORequest,
4796285809Sscottl                                                      bit32                agIOStatus,
4797285809Sscottl                                                      bit32                agIOInfoLen,
4798285809Sscottl                                                      void                 *agParam,
4799285809Sscottl                                                      bit32                agOtherInfo
4800285809Sscottl                                                     )
4801285809Sscottl{
4802285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4803285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4804285809Sscottl  bit32                  intContext = osData->IntContext;
4805285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4806285809Sscottl  TI_DBG2(("itdssOpenCnxErrorItNexusLossOpenPathwayBlockedHandler: start\n"));
4807285809Sscottl
4808285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4809285809Sscottl
4810285809Sscottl  ostiInitiatorIOCompleted (
4811285809Sscottl                            tiRoot,
4812285809Sscottl                            tdIORequestBody->tiIORequest,
4813285809Sscottl                            tiIOFailed,
4814285809Sscottl                            tiDetailOtherError,
4815285809Sscottl                            agNULL,
4816285809Sscottl                            intContext
4817285809Sscottl                            );
4818285809Sscottl
4819285809Sscottl  return;
4820285809Sscottl}
4821285809Sscottl
4822285809Sscottl/*****************************************************************************
4823285809Sscottl*! \brief itdssEncryptionHandler
4824285809Sscottl*
4825285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS lower
4826285809Sscottl*            layer with any encryption specific agIOStatus.
4827285809Sscottl*
4828285809Sscottl*  \param  agRoot:            pointer to port instance
4829285809Sscottl*  \param  agIORequest:       pointer to I/O request
4830285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4831285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4832285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4833285809Sscottl*                             of abort request
4834285809Sscottl*  \return: None
4835285809Sscottl*
4836285809Sscottl*
4837285809Sscottl*****************************************************************************/
4838285809SscottlosGLOBAL void
4839285809SscottlitdssEncryptionHandler (
4840285809Sscottl                       agsaRoot_t              *agRoot,
4841285809Sscottl                       agsaIORequest_t         *agIORequest,
4842285809Sscottl                       bit32                   agIOStatus,
4843285809Sscottl                       bit32                   agIOInfoLen,
4844285809Sscottl                       void                    *agParam,
4845285809Sscottl                       bit32                   agOtherInfo
4846285809Sscottl                       )
4847285809Sscottl{
4848285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4849285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4850285809Sscottl  bit32                  intContext = osData->IntContext;
4851285809Sscottl  bit32                  errorDetail = tiDetailOtherError;
4852285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4853285809Sscottl  TI_DBG1(("itdssEncryptionHandler: start\n"));
4854285809Sscottl  TI_DBG1(("itdssEncryptionHandler: agIOStatus 0x%x\n", agIOStatus));
4855285809Sscottl
4856285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4857285809Sscottl
4858285809Sscottl  switch (agIOStatus)
4859285809Sscottl  {
4860285809Sscottl  case OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS:
4861285809Sscottl      TI_DBG1(("itdssEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_KEY_CACHE_MISS\n"));
4862285809Sscottl      errorDetail = tiDetailDekKeyCacheMiss;
4863285809Sscottl      break;
4864285809Sscottl  case OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID:
4865285809Sscottl      TI_DBG1(("itdssEncryptionHandler: OSSA_IO_XFR_ERROR_CIPHER_MODE_INVALID\n"));
4866285809Sscottl      errorDetail = tiDetailCipherModeInvalid;
4867285809Sscottl      break;
4868285809Sscottl  case OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH:
4869285809Sscottl      TI_DBG1(("itdssEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_IV_MISMATCH\n"));
4870285809Sscottl      errorDetail = tiDetailDekIVMismatch;
4871285809Sscottl      break;
4872285809Sscottl  case OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR:
4873285809Sscottl      TI_DBG1(("itdssEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_RAM_INTERFACE_ERROR\n"));
4874285809Sscottl      errorDetail = tiDetailDekRamInterfaceError;
4875285809Sscottl      break;
4876285809Sscottl  case OSSA_IO_XFR_ERROR_DEK_INDEX_OUT_OF_BOUNDS:
4877285809Sscottl      TI_DBG1(("itdssEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_INDEX_OUT_OF_BOUNDS\n"));
4878285809Sscottl      errorDetail = tiDetailDekIndexOutofBounds;
4879285809Sscottl      break;
4880285809Sscottl  case OSSA_IO_XFR_ERROR_DEK_ILLEGAL_TABLE:
4881285809Sscottl      TI_DBG1(("itdssEncryptionHandler: OSSA_IO_XFR_ERROR_DEK_ILLEGAL_TABLE\n"));
4882285809Sscottl      errorDetail = tiDetailOtherError;
4883285809Sscottl      break;
4884285809Sscottl  default:
4885285809Sscottl      TI_DBG1(("itdssEncryptionHandler: other error!!! 0x%x\n", agIOStatus));
4886285809Sscottl      errorDetail = tiDetailOtherError;
4887285809Sscottl      break;
4888285809Sscottl  }
4889285809Sscottl
4890285809Sscottl  ostiInitiatorIOCompleted (
4891285809Sscottl                            tiRoot,
4892285809Sscottl                            tdIORequestBody->tiIORequest,
4893285809Sscottl                            tiIOEncryptError,
4894285809Sscottl                            errorDetail,
4895285809Sscottl                            agNULL,
4896285809Sscottl                            intContext
4897285809Sscottl                            );
4898285809Sscottl  return;
4899285809Sscottl}
4900285809Sscottl
4901285809Sscottl/*****************************************************************************
4902285809Sscottl*! \brief itdssDifHandler
4903285809Sscottl*
4904285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4905285809Sscottl*            layer with any DIF specific agIOStatus
4906285809Sscottl*
4907285809Sscottl*  \param  agRoot:            pointer to port instance
4908285809Sscottl*  \param  agIORequest:       pointer to I/O request
4909285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4910285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4911285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4912285809Sscottl*                             of abort request
4913285809Sscottl*  \param  agOtherInfo        Residual count
4914285809Sscottl*  \return: None
4915285809Sscottl*
4916285809Sscottl*
4917285809Sscottl*****************************************************************************/
4918285809SscottlosGLOBAL void
4919285809SscottlitdssDifHandler(
4920285809Sscottl                agsaRoot_t           *agRoot,
4921285809Sscottl                agsaIORequest_t      *agIORequest,
4922285809Sscottl                bit32                agIOStatus,
4923285809Sscottl                bit32                agIOInfoLen,
4924285809Sscottl                void                 *agParam,
4925285809Sscottl                bit32                agOtherInfo
4926285809Sscottl               )
4927285809Sscottl{
4928285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
4929285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
4930285809Sscottl  bit32                  intContext = osData->IntContext;
4931285809Sscottl  bit32                  errorDetail = tiDetailOtherError;
4932285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
4933285809Sscottl#ifdef  TD_DEBUG_ENABLE
4934285809Sscottl  agsaDifDetails_t       *DifDetail;
4935285809Sscottl#endif
4936285809Sscottl
4937285809Sscottl  TI_DBG1(("itdssDifHandler: start\n"));
4938285809Sscottl  TI_DBG1(("itdssDifHandler: agIOStatus 0x%x\n", agIOStatus));
4939285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
4940285809Sscottl#ifdef  TD_DEBUG_ENABLE
4941285809Sscottl  DifDetail = (agsaDifDetails_t *)agParam;
4942285809Sscottl#endif
4943285809Sscottl  switch (agIOStatus)
4944285809Sscottl  {
4945285809Sscottl  case OSSA_IO_XFR_ERROR_DIF_MISMATCH:
4946285809Sscottl      errorDetail = tiDetailDifMismatch;
4947285809Sscottl      TI_DBG1(("itdssDifHandler: OSSA_IO_XFR_ERROR_DIF_MISMATCH\n"));
4948285809Sscottl      break;
4949285809Sscottl  case OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH:
4950285809Sscottl      errorDetail = tiDetailDifAppTagMismatch;
4951285809Sscottl      TI_DBG1(("itdssDifHandler: OSSA_IO_XFR_ERROR_DIF_APPLICATION_TAG_MISMATCH\n"));
4952285809Sscottl      break;
4953285809Sscottl  case OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH:
4954285809Sscottl      errorDetail = tiDetailDifRefTagMismatch;
4955285809Sscottl      TI_DBG1(("itdssDifHandler: OSSA_IO_XFR_ERROR_DIF_REFERENCE_TAG_MISMATCH\n"));
4956285809Sscottl      break;
4957285809Sscottl  case OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH:
4958285809Sscottl      errorDetail = tiDetailDifCrcMismatch;
4959285809Sscottl      TI_DBG1(("itdssDifHandler: OSSA_IO_XFR_ERROR_DIF_CRC_MISMATCH\n"));
4960285809Sscottl      break;
4961285809Sscottl  default:
4962285809Sscottl      errorDetail = tiDetailOtherError;
4963285809Sscottl      TI_DBG1(("itdssDifHandler: other error!!! 0x%x\n", agIOStatus));
4964285809Sscottl      break;
4965285809Sscottl  }
4966285809Sscottl  TI_DBG1(("itdssDifHandler: DIF detail UpperLBA 0x%08x LowerLBA 0x%08x\n", DifDetail->UpperLBA, DifDetail->LowerLBA));
4967285809Sscottl  ostiInitiatorIOCompleted (
4968285809Sscottl                            tiRoot,
4969285809Sscottl                            tdIORequestBody->tiIORequest,
4970285809Sscottl                            tiIODifError,
4971285809Sscottl                            errorDetail,
4972285809Sscottl                            agNULL,
4973285809Sscottl                            intContext
4974285809Sscottl                            );
4975285809Sscottl  return;
4976285809Sscottl}
4977285809Sscottl
4978285809Sscottl/*****************************************************************************
4979285809Sscottl*! \brief itdssIOResourceUnavailableHandler
4980285809Sscottl*
4981285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
4982285809Sscottl*            layer with agIOStatus = OSSA_MPI_ERR_IO_RESOURCE_UNAVAILABLE
4983285809Sscottl*
4984285809Sscottl*  \param  agRoot:            pointer to port instance
4985285809Sscottl*  \param  agIORequest:       pointer to I/O request
4986285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
4987285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
4988285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
4989285809Sscottl*                             of abort request
4990285809Sscottl*  \param  agOtherInfo        Residual count
4991285809Sscottl*  \return: None
4992285809Sscottl*
4993285809Sscottl*
4994285809Sscottl*****************************************************************************/
4995285809SscottlosGLOBAL void
4996285809SscottlitdssIOResourceUnavailableHandler(
4997285809Sscottl                                  agsaRoot_t              *agRoot,
4998285809Sscottl                                  agsaIORequest_t         *agIORequest,
4999285809Sscottl                                  bit32                   agIOStatus,
5000285809Sscottl                                  bit32                   agIOInfoLen,
5001285809Sscottl                                  void                    *agParam,
5002285809Sscottl                                  bit32                   agOtherInfo
5003285809Sscottl                                 )
5004285809Sscottl{
5005285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
5006285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
5007285809Sscottl  bit32                  intContext = osData->IntContext;
5008285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
5009285809Sscottl  TI_DBG2(("itdssIOResourceUnavailableHandler: start\n"));
5010285809Sscottl  TI_DBG2(("itdssIOResourceUnavailableHandler: agIOStatus 0x%x\n", agIOStatus));
5011285809Sscottl
5012285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
5013285809Sscottl
5014285809Sscottl  ostiInitiatorIOCompleted (
5015285809Sscottl                            tiRoot,
5016285809Sscottl                            tdIORequestBody->tiIORequest,
5017285809Sscottl                            tiIOFailed,
5018285809Sscottl                            tiDetailBusy,
5019285809Sscottl                            agNULL,
5020285809Sscottl                            intContext
5021285809Sscottl                            );
5022285809Sscottl  return;
5023285809Sscottl}
5024285809Sscottl/*****************************************************************************
5025285809Sscottl*! \brief itdssIORQEBusyFullHandler
5026285809Sscottl*
5027285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
5028285809Sscottl*            layer with agIOStatus = OSSA_MPI_IO_RQE_BUSY_FULL
5029285809Sscottl*
5030285809Sscottl*  \param  agRoot:            pointer to port instance
5031285809Sscottl*  \param  agIORequest:       pointer to I/O request
5032285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5033285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5034285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5035285809Sscottl*                             of abort request
5036285809Sscottl*  \param  agOtherInfo        Residual count
5037285809Sscottl*  \return: None
5038285809Sscottl*
5039285809Sscottl*
5040285809Sscottl*****************************************************************************/
5041285809SscottlosGLOBAL void
5042285809SscottlitdssIORQEBusyFullHandler(
5043285809Sscottl                                  agsaRoot_t              *agRoot,
5044285809Sscottl                                  agsaIORequest_t         *agIORequest,
5045285809Sscottl                                  bit32                   agIOStatus,
5046285809Sscottl                                  bit32                   agIOInfoLen,
5047285809Sscottl                                  void                    *agParam,
5048285809Sscottl                                  bit32                   agOtherInfo
5049285809Sscottl                                 )
5050285809Sscottl{
5051285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
5052285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
5053285809Sscottl  bit32                  intContext = osData->IntContext;
5054285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
5055285809Sscottl  TI_DBG2(("itdssIORQEBusyFullHandler: start\n"));
5056285809Sscottl  TI_DBG2(("itdssIORQEBusyFullHandler: agIOStatus 0x%x\n", agIOStatus));
5057285809Sscottl
5058285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
5059285809Sscottl
5060285809Sscottl  ostiInitiatorIOCompleted (
5061285809Sscottl                            tiRoot,
5062285809Sscottl                            tdIORequestBody->tiIORequest,
5063285809Sscottl                            tiIOFailed,
5064285809Sscottl                            tiDetailBusy,
5065285809Sscottl                            agNULL,
5066285809Sscottl                            intContext
5067285809Sscottl                            );
5068285809Sscottl  return;
5069285809Sscottl}
5070285809Sscottl
5071285809Sscottl/*****************************************************************************
5072285809Sscottl*! \brief itdssXferErrorInvalidSSPRspFrameHandler
5073285809Sscottl*
5074285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
5075285809Sscottl*            layer with agIOStatus = OSSA_IO_XFR_ERROR_INVALID_SSP_RSP_FRAME
5076285809Sscottl*
5077285809Sscottl*  \param  agRoot:            pointer to port instance
5078285809Sscottl*  \param  agIORequest:       pointer to I/O request
5079285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5080285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5081285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5082285809Sscottl*                             of abort request
5083285809Sscottl*  \param  agOtherInfo        Residual count
5084285809Sscottl*  \return: None
5085285809Sscottl*
5086285809Sscottl*
5087285809Sscottl*****************************************************************************/
5088285809SscottlosGLOBAL void
5089285809SscottlitdssXferErrorInvalidSSPRspFrameHandler(
5090285809Sscottl                                  agsaRoot_t              *agRoot,
5091285809Sscottl                                  agsaIORequest_t         *agIORequest,
5092285809Sscottl                                  bit32                   agIOStatus,
5093285809Sscottl                                  bit32                   agIOInfoLen,
5094285809Sscottl                                  void                    *agParam,
5095285809Sscottl                                  bit32                   agOtherInfo
5096285809Sscottl                                 )
5097285809Sscottl{
5098285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
5099285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
5100285809Sscottl  bit32                  intContext = osData->IntContext;
5101285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
5102285809Sscottl  TI_DBG2(("itdssXferErrorInvalidSSPRspFrameHandler: start\n"));
5103285809Sscottl  TI_DBG2(("itdssXferErrorInvalidSSPRspFrameHandler: agIOStatus 0x%x\n", agIOStatus));
5104285809Sscottl
5105285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
5106285809Sscottl
5107285809Sscottl  ostiInitiatorIOCompleted (
5108285809Sscottl                            tiRoot,
5109285809Sscottl                            tdIORequestBody->tiIORequest,
5110285809Sscottl                            tiIOFailed,
5111285809Sscottl                            tiDetailOtherError,
5112285809Sscottl                            agNULL,
5113285809Sscottl                            intContext
5114285809Sscottl                            );
5115285809Sscottl  return;
5116285809Sscottl}
5117285809Sscottl
5118285809Sscottl/*****************************************************************************
5119285809Sscottl*! \brief itdssXferErrorEOBDataOverrunHandler
5120285809Sscottl*
5121285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
5122285809Sscottl*            layer with agIOStatus = OSSA_IO_XFER_ERR_EOB_DATA_OVERRUN
5123285809Sscottl*
5124285809Sscottl*  \param  agRoot:            pointer to port instance
5125285809Sscottl*  \param  agIORequest:       pointer to I/O request
5126285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5127285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5128285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5129285809Sscottl*                             of abort request
5130285809Sscottl*  \param  agOtherInfo        Residual count
5131285809Sscottl*  \return: None
5132285809Sscottl*
5133285809Sscottl*
5134285809Sscottl*****************************************************************************/
5135285809SscottlosGLOBAL void
5136285809SscottlitdssXferErrorEOBDataOverrunHandler(
5137285809Sscottl                                  agsaRoot_t              *agRoot,
5138285809Sscottl                                  agsaIORequest_t         *agIORequest,
5139285809Sscottl                                  bit32                   agIOStatus,
5140285809Sscottl                                  bit32                   agIOInfoLen,
5141285809Sscottl                                  void                    *agParam,
5142285809Sscottl                                  bit32                   agOtherInfo
5143285809Sscottl                                 )
5144285809Sscottl{
5145285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
5146285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
5147285809Sscottl  bit32                  intContext = osData->IntContext;
5148285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
5149285809Sscottl  TI_DBG2(("itdssXferErrorEOBDataOverrunHandler: start\n"));
5150285809Sscottl  TI_DBG2(("itdssXferErrorEOBDataOverrunHandler: agIOStatus 0x%x\n", agIOStatus));
5151285809Sscottl
5152285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
5153285809Sscottl
5154285809Sscottl  ostiInitiatorIOCompleted (
5155285809Sscottl                            tiRoot,
5156285809Sscottl                            tdIORequestBody->tiIORequest,
5157285809Sscottl                            tiIOFailed,
5158285809Sscottl                            tiDetailOtherError,
5159285809Sscottl                            agNULL,
5160285809Sscottl                            intContext
5161285809Sscottl                            );
5162285809Sscottl  return;
5163285809Sscottl}
5164285809Sscottl
5165285809Sscottl/*****************************************************************************
5166285809Sscottl*! \brief itdssOpenCnxErrorOpenPreemptedHandler
5167285809Sscottl*
5168285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
5169285809Sscottl*            layer with agIOStatus = OSSA_IO_OPEN_CNX_ERROR_OPEN_PREEMPTED
5170285809Sscottl*
5171285809Sscottl*  \param  agRoot:            pointer to port instance
5172285809Sscottl*  \param  agIORequest:       pointer to I/O request
5173285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5174285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5175285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5176285809Sscottl*                             of abort request
5177285809Sscottl*  \param  agOtherInfo        Residual count
5178285809Sscottl*  \return: None
5179285809Sscottl*
5180285809Sscottl*
5181285809Sscottl*****************************************************************************/
5182285809SscottlosGLOBAL void
5183285809SscottlitdssOpenCnxErrorOpenPreemptedHandler(
5184285809Sscottl                                  agsaRoot_t              *agRoot,
5185285809Sscottl                                  agsaIORequest_t         *agIORequest,
5186285809Sscottl                                  bit32                   agIOStatus,
5187285809Sscottl                                  bit32                   agIOInfoLen,
5188285809Sscottl                                  void                    *agParam,
5189285809Sscottl                                  bit32                   agOtherInfo
5190285809Sscottl                                 )
5191285809Sscottl{
5192285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
5193285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
5194285809Sscottl  bit32                  intContext = osData->IntContext;
5195285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
5196285809Sscottl  TI_DBG2(("itdssOpenCnxErrorOpenPreemptedHandler: start\n"));
5197285809Sscottl  TI_DBG2(("itdssOpenCnxErrorOpenPreemptedHandler: agIOStatus 0x%x\n", agIOStatus));
5198285809Sscottl
5199285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
5200285809Sscottl
5201285809Sscottl  ostiInitiatorIOCompleted (
5202285809Sscottl                            tiRoot,
5203285809Sscottl                            tdIORequestBody->tiIORequest,
5204285809Sscottl                            tiIOFailed,
5205285809Sscottl                            tiDetailOtherError,
5206285809Sscottl                            agNULL,
5207285809Sscottl                            intContext
5208285809Sscottl                            );
5209285809Sscottl  return;
5210285809Sscottl}
5211285809Sscottl
5212285809Sscottl/* default */
5213285809Sscottl/*****************************************************************************
5214285809Sscottl*! \brief itdssIODefaultHandler
5215285809Sscottl*
5216285809Sscottl*  Purpose:  This function processes I/Os completed and returned by SAS/SATA lower
5217285809Sscottl*            layer with agIOStatus = unspecified
5218285809Sscottl*
5219285809Sscottl*  \param  agRoot:            pointer to port instance
5220285809Sscottl*  \param  agIORequest:       pointer to I/O request
5221285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5222285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5223285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5224285809Sscottl*                             of abort request
5225285809Sscottl*  \param  agOtherInfo        Residual count
5226285809Sscottl*  \return: None
5227285809Sscottl*
5228285809Sscottl*
5229285809Sscottl*****************************************************************************/
5230285809SscottlosGLOBAL void
5231285809SscottlitdssIODefaultHandler (
5232285809Sscottl                       agsaRoot_t              *agRoot,
5233285809Sscottl                       agsaIORequest_t         *agIORequest,
5234285809Sscottl                       bit32                   agIOStatus,
5235285809Sscottl                       bit32                   agIOInfoLen,
5236285809Sscottl                       void                    *agParam,
5237285809Sscottl                       bit32                   agOtherInfo
5238285809Sscottl                       )
5239285809Sscottl{
5240285809Sscottl  tdsaRootOsData_t       *osData = (tdsaRootOsData_t *)agRoot->osData;
5241285809Sscottl  tiRoot_t               *tiRoot = (tiRoot_t *)osData->tiRoot;
5242285809Sscottl  bit32                  intContext = osData->IntContext;
5243285809Sscottl  tdIORequestBody_t      *tdIORequestBody;
5244285809Sscottl  TI_DBG2(("itdssIODefaultHandler: start\n"));
5245285809Sscottl  TI_DBG2(("itdssIODefaultHandler: agIOStatus 0x%x\n", agIOStatus));
5246285809Sscottl
5247285809Sscottl  tdIORequestBody = (tdIORequestBody_t *)agIORequest->osData;
5248285809Sscottl
5249285809Sscottl  ostiInitiatorIOCompleted (
5250285809Sscottl                            tiRoot,
5251285809Sscottl                            tdIORequestBody->tiIORequest,
5252285809Sscottl                            tiIOFailed,
5253285809Sscottl                            tiDetailOtherError,
5254285809Sscottl                            agNULL,
5255285809Sscottl                            intContext
5256285809Sscottl                            );
5257285809Sscottl  return;
5258285809Sscottl}
5259285809Sscottl
5260285809Sscottl/*****************************************************************************
5261285809Sscottl*! \brief itdssIOForDebugging1Completed
5262285809Sscottl*
5263285809Sscottl*  Purpose:  This function is only for debugging. This function should NOT be
5264285809Sscottl*            called.
5265285809Sscottl*
5266285809Sscottl*  \param  agRoot:            pointer to port instance
5267285809Sscottl*  \param  agIORequest:       pointer to I/O request
5268285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5269285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5270285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5271285809Sscottl*                             of abort request
5272285809Sscottl*  \param  agOtherInfo        Residual count
5273285809Sscottl*  \return: None
5274285809Sscottl*
5275285809Sscottl*
5276285809Sscottl*****************************************************************************/
5277285809SscottlosGLOBAL void
5278285809SscottlitdssIOForDebugging1Completed(
5279285809Sscottl                 agsaRoot_t             *agRoot,
5280285809Sscottl                 agsaIORequest_t        *agIORequest,
5281285809Sscottl                 bit32                  agIOStatus,
5282285809Sscottl                 bit32                  agIOInfoLen,
5283285809Sscottl                 void                   *agParam,
5284285809Sscottl                 bit32                  agOtherInfo
5285285809Sscottl                 )
5286285809Sscottl{
5287285809Sscottl  TI_DBG1(("itdssIOForDebugging1Completed: start, error!!! can't be called. \n"));
5288285809Sscottl}
5289285809Sscottl
5290285809Sscottl/*****************************************************************************
5291285809Sscottl*! \brief itdssIOForDebugging2Completed
5292285809Sscottl*
5293285809Sscottl*  Purpose:  This function is only for debugging. This function should NOT be
5294285809Sscottl*            called.
5295285809Sscottl*
5296285809Sscottl*  \param  agRoot:            pointer to port instance
5297285809Sscottl*  \param  agIORequest:       pointer to I/O request
5298285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5299285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5300285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5301285809Sscottl*                             of abort request
5302285809Sscottl*  \param  agOtherInfo        Residual count
5303285809Sscottl*  \return: None
5304285809Sscottl*
5305285809Sscottl*
5306285809Sscottl*****************************************************************************/
5307285809SscottlosGLOBAL void
5308285809SscottlitdssIOForDebugging2Completed(
5309285809Sscottl                 agsaRoot_t             *agRoot,
5310285809Sscottl                 agsaIORequest_t        *agIORequest,
5311285809Sscottl                 bit32                  agIOStatus,
5312285809Sscottl                 bit32                  agIOInfoLen,
5313285809Sscottl                 void                   *agParam,
5314285809Sscottl                 bit32                  agOtherInfo
5315285809Sscottl                 )
5316285809Sscottl{
5317285809Sscottl  TI_DBG1(("itdssIOForDebugging2Completed: start, error!!! can't be called.  \n"));
5318285809Sscottl}
5319285809Sscottl
5320285809Sscottl/*****************************************************************************
5321285809Sscottl*! \brief itdssIOForDebugging3Completed
5322285809Sscottl*
5323285809Sscottl*  Purpose:  This function is only for debugging. This function should NOT be
5324285809Sscottl*            called.
5325285809Sscottl*
5326285809Sscottl*  \param  agRoot:            pointer to port instance
5327285809Sscottl*  \param  agIORequest:       pointer to I/O request
5328285809Sscottl*  \param  agIOStatus:        I/O status given by LL layer
5329285809Sscottl*  \param  agIOInfoLen:       lenth of complete SAS RESP frame
5330285809Sscottl*  \param  agParam            A Handle used to refer to the response frame or handle
5331285809Sscottl*                             of abort request
5332285809Sscottl*  \param  agOtherInfo        Residual count
5333285809Sscottl*  \return: None
5334285809Sscottl*
5335285809Sscottl*
5336285809Sscottl*****************************************************************************/
5337285809SscottlosGLOBAL void
5338285809SscottlitdssIOForDebugging3Completed(
5339285809Sscottl                 agsaRoot_t             *agRoot,
5340285809Sscottl                 agsaIORequest_t        *agIORequest,
5341285809Sscottl                 bit32                  agIOStatus,
5342285809Sscottl                 bit32                  agIOInfoLen,
5343285809Sscottl                 void                   *agParam,
5344285809Sscottl                 bit32                  agOtherInfo
5345285809Sscottl                 )
5346285809Sscottl{
5347285809Sscottl  TI_DBG1(("itdssIOForDebugging3Completed: start, error!!! can't be called.  \n"));
5348285809Sscottl}
5349285809Sscottl
5350285809Sscottl
5351