xref: /freebsd/sys/dev/pms/RefTisa/sallsdk/spc/sasata.c (revision 193d9e768ba63fcfb187cfd17f461f7d41345048)
1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3 *
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7 *following disclaimer.
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
11 *
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20 
21 ********************************************************************************/
22 /*******************************************************************************/
23 /*! \file sasata.c
24  *  \brief The file implements the functions to SATA IO
25  *
26  */
27 /******************************************************************************/
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
30 #include <dev/pms/config.h>
31 
32 #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
33 #ifdef SA_ENABLE_TRACE_FUNCTIONS
34 #ifdef siTraceFileID
35 #undef siTraceFileID
36 #endif
37 #define siTraceFileID 'M'
38 #endif
39 
40 /******************************************************************************/
41 /*! \brief Start SATA command
42  *
43  *  Start SATA command
44  *
45  *  \param agRoot handles for this instance of SAS/SATA hardware
46  *  \param queueNum
47  *  \param agIORequest
48  *  \param agDevHandle
49  *  \param agRequestType
50  *  \param agSATAReq
51  *  \param agTag
52  *  \param agCB
53  *
54  *  \return If command is started successfully
55  *          - \e AGSA_RC_SUCCESS command is started successfully
56  *          - \e AGSA_RC_FAILURE command is not started successfully
57  */
58 /*******************************************************************************/
59 GLOBAL bit32 saSATAStart(
60   agsaRoot_t                  *agRoot,
61   agsaIORequest_t             *agIORequest,
62   bit32                       queueNum,
63   agsaDevHandle_t             *agDevHandle,
64   bit32                       agRequestType,
65   agsaSATAInitiatorRequest_t  *agSATAReq,
66   bit8                        agTag,
67   ossaSATACompletedCB_t       agCB
68   )
69 
70 {
71   agsaLLRoot_t        *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
72   mpiICQueue_t        *circularQ = agNULL;
73   agsaDeviceDesc_t    *pDevice   = agNULL;
74   agsaPort_t          *pPort     = agNULL;
75   agsaIORequestDesc_t *pRequest  = agNULL;
76   void                *pMessage  = agNULL;
77   agsaSgl_t           *pSgl      = agNULL;
78   bit32               *payload   = agNULL;
79   bit32               deviceIndex = 0;
80   bit32               ret = AGSA_RC_SUCCESS, retVal = 0;
81   bit32               AtapDir = 0;
82   bit32               encryptFlags = 0;
83   bit16               size = 0;
84   bit16               opCode = 0;
85   bit8                inq = 0, outq = 0;
86 
87   OSSA_INP_ENTER(agRoot);
88   smTraceFuncEnter(hpDBG_VERY_LOUD, "8a");
89 
90   SA_DBG3(("saSATAStart: in\n"));
91   /* sanity check */
92   SA_ASSERT((agNULL != agRoot), "(saSATAStart) agRoot is NULL");
93   SA_ASSERT((agNULL != agIORequest), "(saSATAStart) agIORequest is NULL");
94   SA_ASSERT((agNULL != agDevHandle), "(saSATAStart) agDevHandle is NULL");
95   SA_ASSERT((agNULL != agSATAReq), "(saSATAStart) agSATAReq is NULL");
96 
97   /* Assign inbound and outbound queue */
98   inq = (bit8)(queueNum & MPI_IB_NUM_MASK);
99   outq = (bit8)((queueNum & MPI_OB_NUM_MASK) >> MPI_OB_SHIFT);
100   SA_ASSERT((AGSA_MAX_INBOUND_Q > inq), "The IBQ Number is out of range.");
101 
102   /* Find the outgoing port for the device */
103   pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
104   SA_ASSERT((agNULL != pDevice), "(saSATAStart) pDevice is NULL");
105 
106   pPort = pDevice->pPort;
107   SA_ASSERT((agNULL != pPort), "(saSATAStart) pPort is NULL");
108 
109   /* SATA DIF is obsolete */
110   if (agSATAReq->option & AGSA_SATA_ENABLE_DIF)
111   {
112     return AGSA_RC_FAILURE;
113   }
114 
115   /* find deviceID for IOMB */
116   deviceIndex = pDevice->DeviceMapIndex;
117 
118   /*  Get request from free IORequests */
119   ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
120   pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeIORequests));
121   if ( agNULL != pRequest )
122   {
123     /* If free IOMB avaliable */
124     /* Remove the request from free list */
125     saLlistIORemove(&(saRoot->freeIORequests), &(pRequest->linkNode));
126 
127     /* Add the request to the pendingSTARequests list of the device */
128     pRequest->valid = agTRUE;
129     saLlistIOAdd(&(pDevice->pendingIORequests), &(pRequest->linkNode));
130     ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
131 
132     if ((agSATAReq->option & AGSA_SATA_ENABLE_ENCRYPTION) ||
133           (agSATAReq->option & AGSA_SATA_ENABLE_DIF))
134     {
135         opCode = OPC_INB_SATA_DIF_ENC_OPSTART;
136         size = IOMB_SIZE128;
137     }
138     else
139     {
140         opCode = OPC_INB_SATA_HOST_OPSTART;
141         if (agRequestType == AGSA_SATA_PROTOCOL_NON_PKT ||
142             agRequestType == AGSA_SATA_PROTOCOL_H2D_PKT ||
143             agRequestType == AGSA_SATA_PROTOCOL_D2H_PKT)
144             size = IOMB_SIZE128;
145         else
146             size = IOMB_SIZE64;
147     }
148     /* If LL IO request entry avaliable */
149     /* set up pRequest */
150     pRequest->pIORequestContext = agIORequest;
151     pRequest->pDevice = pDevice;
152     pRequest->pPort = pPort;
153     pRequest->requestType = agRequestType;
154     pRequest->startTick = saRoot->timeTick;
155     pRequest->completionCB = (ossaSSPCompletedCB_t)agCB;
156     /* Set request to the sdkData of agIORequest */
157     agIORequest->sdkData = pRequest;
158 
159     /* save tag and IOrequest pointer to IOMap */
160     saRoot->IOMap[pRequest->HTag].Tag = pRequest->HTag;
161     saRoot->IOMap[pRequest->HTag].IORequest = (void *)pRequest;
162 
163 #ifdef SA_LL_IBQ_PROTECT
164     ossaSingleThreadedEnter(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
165 #endif /* SA_LL_IBQ_PROTECT */
166 
167     /* get a free inbound queue entry */
168     circularQ = &saRoot->inboundQueue[inq];
169     retVal    = mpiMsgFreeGet(circularQ, size, &pMessage);
170 
171     if (AGSA_RC_FAILURE == retVal)
172     {
173 #ifdef SA_LL_IBQ_PROTECT
174       ossaSingleThreadedLeave(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
175 #endif /* SA_LL_IBQ_PROTECT */
176       /* if not sending return to free list rare */
177       ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
178       saLlistIORemove(&(pDevice->pendingIORequests), &(pRequest->linkNode));
179       pRequest->valid = agFALSE;
180       saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
181       ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
182 
183       SA_DBG3(("saSATAStart, error when get free IOMB\n"));
184       smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "8a");
185       ret = AGSA_RC_FAILURE;
186       goto ext;
187     }
188 
189     /* return busy if inbound queue is full */
190     if (AGSA_RC_BUSY == retVal)
191     {
192 #ifdef SA_LL_IBQ_PROTECT
193       ossaSingleThreadedLeave(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
194 #endif /* SA_LL_IBQ_PROTECT */
195       /* if not sending return to free list rare */
196       ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
197       saLlistIORemove(&(pDevice->pendingIORequests), &(pRequest->linkNode));
198       pRequest->valid = agFALSE;
199       saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
200       ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
201 
202       SA_DBG1(("saSATAStart, no more IOMB\n"));
203       smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "8a");
204       ret = AGSA_RC_BUSY;
205       goto ext;
206     }
207 
208   }
209   else   /* If no LL IO request entry available */
210   {
211     ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
212     SA_DBG1(("saSATAStart, No request from free list\n"));
213     smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "8a");
214     ret = AGSA_RC_BUSY;
215     goto ext;
216   }
217 
218   payload = (bit32 *)pMessage;
219   SA_DBG4(("saSATAStart: Payload offset 0x%X\n", (unsigned int)(payload - (bit32 *)pMessage)));
220 
221 
222   switch ( agRequestType )
223   {
224   case AGSA_SATA_PROTOCOL_FPDMA_READ:
225   case AGSA_SATA_PROTOCOL_FPDMA_WRITE:
226   case AGSA_SATA_PROTOCOL_FPDMA_READ_M:
227   case AGSA_SATA_PROTOCOL_FPDMA_WRITE_M:
228     pSgl = &(agSATAReq->agSgl);
229     AtapDir = agRequestType & (AGSA_DIR_MASK | AGSA_SATA_ATAP_MASK);
230     if (agRequestType & AGSA_MSG)
231     {
232       /* set M bit */
233       AtapDir |= AGSA_MSG_BIT;
234     }
235     break;
236   case AGSA_SATA_PROTOCOL_DMA_READ:
237   case AGSA_SATA_PROTOCOL_DMA_WRITE:
238   case AGSA_SATA_PROTOCOL_DMA_READ_M:
239   case AGSA_SATA_PROTOCOL_DMA_WRITE_M:
240   case AGSA_SATA_PROTOCOL_PIO_READ_M:
241   case AGSA_SATA_PROTOCOL_PIO_WRITE_M:
242   case AGSA_SATA_PROTOCOL_PIO_READ:
243   case AGSA_SATA_PROTOCOL_PIO_WRITE:
244   case AGSA_SATA_PROTOCOL_H2D_PKT:
245   case AGSA_SATA_PROTOCOL_D2H_PKT:
246     agTag = 0; /* agTag not valid for these requests */
247     pSgl = &(agSATAReq->agSgl);
248     AtapDir = agRequestType & (AGSA_DIR_MASK | AGSA_SATA_ATAP_MASK);
249     if (agRequestType & AGSA_MSG)
250     {
251       /* set M bit */
252       AtapDir |= AGSA_MSG_BIT;
253     }
254     break;
255 
256   case AGSA_SATA_PROTOCOL_NON_DATA:
257   case AGSA_SATA_PROTOCOL_NON_DATA_M:
258   case AGSA_SATA_PROTOCOL_NON_PKT:
259     agTag = 0; /* agTag not valid for these requests */
260     AtapDir = agRequestType & (AGSA_DIR_MASK | AGSA_SATA_ATAP_MASK);
261     if (agRequestType & AGSA_MSG)
262     {
263       /* set M bit */
264       AtapDir |= AGSA_MSG_BIT;
265     }
266     break;
267 
268   case AGSA_SATA_PROTOCOL_SRST_ASSERT:
269     agTag = 0; /* agTag not valid for these requests */
270     AtapDir = AGSA_SATA_ATAP_SRST_ASSERT;
271     break;
272 
273   case AGSA_SATA_PROTOCOL_SRST_DEASSERT:
274     agTag = 0; /* agTag not valid for these requests */
275     AtapDir = AGSA_SATA_ATAP_SRST_DEASSERT;
276     break;
277 
278   case AGSA_SATA_PROTOCOL_DEV_RESET:
279   case AGSA_SATA_PROTOCOL_DEV_RESET_M: /* TestBase */
280     agTag = 0; /* agTag not valid for these requests */
281     AtapDir = AGSA_SATA_ATAP_PKT_DEVRESET;
282     if (agRequestType & AGSA_MSG)
283     {
284       /* set M bit */
285       AtapDir |= AGSA_MSG_BIT; /* TestBase */
286     }
287     break;
288 
289   default:
290     SA_DBG1(("saSATAStart: (Unknown agRequestType) 0x%X \n",agRequestType));
291     SA_ASSERT((0), "saSATAStart: (Unknown agRequestType)");
292 
293     break;
294   }
295 
296   if ((AGSA_SATA_PROTOCOL_SRST_ASSERT == agRequestType) ||
297        (AGSA_SATA_PROTOCOL_SRST_DEASSERT == agRequestType) ||
298        (AGSA_SATA_PROTOCOL_DEV_RESET == agRequestType))
299   {
300 
301     SA_DBG3(("saSATAStart:AGSA_SATA_PROTOCOL_SRST_DEASSERT AGSA_SATA_PROTOCOL_SRST_ASSERT\n"));
302 
303     si_memset((void *)payload, 0, sizeof(agsaSATAStartCmd_t));
304     /* build IOMB DW 1 */
305     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t, tag), pRequest->HTag);
306     /* DWORD 2 */
307     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,deviceId ), deviceIndex);
308     /* DWORD 3 */
309     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,dataLen ), 0 );
310     /* DWORD 4 */
311     OSSA_WRITE_LE_32(agRoot,
312                     payload,
313                     OSSA_OFFSET_OF(agsaSATAStartCmd_t,optNCQTagataProt ),
314                     (((agSATAReq->option & SATA_FIS_MASK) << SHIFT24)    |
315                     (agTag << SHIFT16)                                   |
316                     AtapDir));
317 
318    si_memcpy((void *)(payload+4), (void *)&agSATAReq->fis.fisRegHostToDev, sizeof(agsaFisRegHostToDevice_t));
319   }
320   else
321   {
322     /* build IOMB DW 1 */
323     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t, tag), pRequest->HTag);
324     /* DWORD 2 */
325     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,deviceId ), deviceIndex);
326     /* DWORD 3 */
327     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,dataLen ),  agSATAReq->dataLength );
328 
329      /* Since we are writing the payload in order, check for any special modes now. */
330     if (agSATAReq->option & AGSA_SATA_ENABLE_ENCRYPTION)
331     {
332         SA_ASSERT((opCode == OPC_INB_SATA_DIF_ENC_OPSTART), "opcode");
333         SA_DBG4(("saSATAStart: 1 Payload offset 0x%X\n", (unsigned int)(payload - (bit32 *)pMessage)));
334         AtapDir |= AGSA_ENCRYPT_BIT;
335     }
336 
337     if (agSATAReq->option & AGSA_SATA_ENABLE_DIF)
338     {
339         SA_ASSERT((opCode == OPC_INB_SATA_DIF_ENC_OPSTART), "opcode");
340         AtapDir |= AGSA_DIF_BIT;
341     }
342 #ifdef CCBUILD_TEST_EPL
343     if(agSATAReq->encrypt.enableEncryptionPerLA)
344         AtapDir |= (1 << SHIFT4);        // enable EPL
345 #endif
346     /* DWORD 4 */
347     OSSA_WRITE_LE_32(agRoot,
348                     payload,
349                     OSSA_OFFSET_OF(agsaSATAStartCmd_t,optNCQTagataProt ),
350                   (((agSATAReq->option & SATA_FIS_MASK) << SHIFT24) |
351                     (agTag << SHIFT16)                              |
352                     AtapDir));
353 
354     /* DWORD 5 6 7 8 9 */
355     si_memcpy((void *)(payload+4), (void *)&agSATAReq->fis.fisRegHostToDev, sizeof(agsaFisRegHostToDevice_t));
356     /* DWORD 10 reserved */
357     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,reserved1 ),  0 );
358 
359     /* DWORD 11 reserved */
360     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,reserved2 ),  0 );
361 
362     SA_DBG4(("saSATAStart: 2 Payload offset 0x%X\n", (unsigned int)(payload - (bit32 *)pMessage)));
363   }
364   if (agSATAReq->option & AGSA_SATA_ENABLE_ENCRYPTION)
365   {
366     /* Write 10 dwords of zeroes as payload, skipping all DIF fields */
367     SA_DBG4(("saSATAStart: 2a Payload offset 0x%X\n", (unsigned int)(payload - (bit32 *)pMessage)));
368     if (opCode == OPC_INB_SATA_DIF_ENC_OPSTART)
369     {
370       /* DW 11 */
371       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,Res_EPL_DESCL ),0 );
372       /* DW 12 */
373       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,resSKIPBYTES ),0 );
374        /* DW 13 */
375       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,Res_DPL_DESCL_NDPLR ),0 );
376       /* DW 14 */
377       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,Res_EDPL_DESCH ),0 );
378       /* DW 15 */
379       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,DIF_flags ),0 );
380       /* DW 16 */
381       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,udt ),0 );
382       /* DW 17 */
383       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,udtReplacementLo ),0 );
384       /* DW 18 */
385       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,udtReplacementHi ),0 );
386       /* DW 19 */
387       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,DIF_seed ),0 );
388     }
389 
390     if (agSATAReq->option & AGSA_SATA_ENABLE_ENCRYPTION)
391     {
392         SA_ASSERT((opCode == OPC_INB_SATA_DIF_ENC_OPSTART), "opcode");
393 
394         SA_DBG4(("saSATAStart: 3 Payload offset 0x%X\n", (unsigned int)(payload - (bit32 *)pMessage)));
395         /* Configure DWORD 20 */
396         encryptFlags = 0;
397 
398         if (agSATAReq->encrypt.keyTagCheck == agTRUE)
399         {
400           encryptFlags |= AGSA_ENCRYPT_KEY_TAG_BIT;
401         }
402 
403         if( agSATAReq->encrypt.cipherMode == agsaEncryptCipherModeXTS )
404         {
405           encryptFlags |= AGSA_ENCRYPT_XTS_Mode << SHIFT4;
406         }
407 
408         encryptFlags |= agSATAReq->encrypt.dekInfo.dekTable << SHIFT2;
409 
410         encryptFlags |= (agSATAReq->encrypt.dekInfo.dekIndex & 0xFFFFFF) << SHIFT8;
411         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,encryptFlagsLo ),encryptFlags );
412 
413         /* Configure DWORD 21*/
414         /* This information is available in the sectorSizeIndex */
415         encryptFlags = agSATAReq->encrypt.sectorSizeIndex;
416         /*
417          * Set Region0 sectors count
418          */
419         if(agSATAReq->encrypt.enableEncryptionPerLA)
420         {
421             encryptFlags |= (agSATAReq->encrypt.EncryptionPerLRegion0SecCount << SHIFT16);
422         }
423 
424         encryptFlags |= (agSATAReq->encrypt.kekIndex) << SHIFT5;
425         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,encryptFlagsHi ),encryptFlags );
426 
427         /* Configure DWORD 22*/
428         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,keyTagLo ),  agSATAReq->encrypt.keyTag_W0 );
429         /* Configure DWORD 23 */
430         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,keyTagHi ),  agSATAReq->encrypt.keyTag_W1 );
431         /* Configure DWORD 24 */
432         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W0 ), agSATAReq->encrypt.tweakVal_W0  );
433         /* Configure DWORD 25 */
434         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W1 ), agSATAReq->encrypt.tweakVal_W1  );
435         /* Configure DWORD 26 */
436         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W2 ), agSATAReq->encrypt.tweakVal_W2  );
437         /* Configure DWORD 27 */
438         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W3 ), agSATAReq->encrypt.tweakVal_W3  );
439     }
440     else
441     {
442       /* Write 8 dwords of zeros as payload, skipping all encryption fields */
443       if (opCode == OPC_INB_SATA_DIF_ENC_OPSTART)
444       {
445         /* Configure DWORD 22*/
446         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,keyTagLo ), 0 );
447         /* Configure DWORD 23 */
448         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,keyTagHi ), 0 );
449         /* Configure DWORD 24 */
450         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W0 ), 0  );
451         /* Configure DWORD 25 */
452         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W1 ), 0  );
453         /* Configure DWORD 26 */
454         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W2 ), 0  );
455         /* Configure DWORD 27 */
456         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,tweakVal_W3 ), 0  );
457       }
458     }
459 
460     SA_DBG4(("saSATAStart: 4 Payload offset 0x%X\n", (unsigned int)(payload - (bit32 *)pMessage)));
461 
462     /* DWORD 11 13 14*/
463     if(agSATAReq->encrypt.enableEncryptionPerLA)
464     {
465       /* DWORD 11 */
466       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t, Res_EPL_DESCL),
467                          agSATAReq->encrypt.EncryptionPerLAAddrLo);
468       /* DWORD 13 */
469       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t, Res_DPL_DESCL_NDPLR), 0);
470       /* DWORD 14 */
471       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t, Res_EDPL_DESCH),
472                       agSATAReq->encrypt.EncryptionPerLAAddrHi);
473     }
474     else
475     {
476       /* DWORD 11 */
477       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t, Res_EPL_DESCL),0);
478       /* DW 13 */
479       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t, Res_DPL_DESCL_NDPLR), 0);
480       /* DWORD 14 */
481       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,Res_EDPL_DESCH ),0 );
482     }
483 
484     /* Configure DWORD 28 for encryption*/
485     if (pSgl)
486     {
487       /* Configure DWORD 28 */
488       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,AddrLow0 ),  pSgl->sgLower );
489       /* Configure DWORD 29 */
490       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,AddrHi0 ), pSgl->sgUpper  );
491       /* Configure DWORD 30 */
492       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,Len0 ),  pSgl->len );
493       /* Configure DWORD 31 */
494       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,E0 ), pSgl->extReserved  );
495     }
496     else
497     {
498       /* Configure DWORD 28 */
499       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,AddrLow0 ),  0 );
500       /* Configure DWORD 29 */
501       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,AddrHi0 ),  0 );
502       /* Configure DWORD 30 */
503       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,Len0 ),  0 );
504       /* Configure DWORD 31 */
505       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAEncryptStartCmd_t,E0 ),  0 );
506     }
507 
508   }
509   else
510   {
511     SA_ASSERT((opCode == OPC_INB_SATA_HOST_OPSTART), "opcode");
512     if (pSgl)
513     {
514       /* Configure DWORD 12 */
515       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,AddrLow0 ),  pSgl->sgLower );
516       /* Configure DWORD 13 */
517       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,AddrHi0 ), pSgl->sgUpper  );
518       /* Configure DWORD 14 */
519       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,Len0 ),  pSgl->len );
520       /* Configure DWORD 15 */
521       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,E0 ), pSgl->extReserved  );
522     }
523     else
524     {
525       /* Configure DWORD 12 */
526       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,AddrLow0 ),  0 );
527       /* Configure DWORD 13 */
528       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,AddrHi0 ),  0 );
529       /* Configure DWORD 14 */
530       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,Len0 ),  0 );
531       /* Configure DWORD 15 */
532       OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,E0 ),  0 );
533     }
534     /* support ATAPI packet command */
535     if ((agRequestType == AGSA_SATA_PROTOCOL_NON_PKT ||
536         agRequestType == AGSA_SATA_PROTOCOL_H2D_PKT ||
537         agRequestType == AGSA_SATA_PROTOCOL_D2H_PKT))
538      {
539          /*DWORD 16 - 19 as SCSI CDB for support ATAPI Packet command*/
540         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,ATAPICDB ),
541                         (bit32)(agSATAReq->scsiCDB[0]|(agSATAReq->scsiCDB[1]<<8)|(agSATAReq->scsiCDB[2]<<16)|(agSATAReq->scsiCDB[3]<<24)));
542         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,ATAPICDB )+ 4,
543                         (bit32)(agSATAReq->scsiCDB[4]|(agSATAReq->scsiCDB[5]<<8)|(agSATAReq->scsiCDB[6]<<16)|(agSATAReq->scsiCDB[7]<<24)));
544         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,ATAPICDB )+ 8,
545                         (bit32)(agSATAReq->scsiCDB[8]|(agSATAReq->scsiCDB[9]<<8)|(agSATAReq->scsiCDB[10]<<16)|(agSATAReq->scsiCDB[11]<<24)));
546         OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAStartCmd_t,ATAPICDB )+ 12,
547                         (bit32)(agSATAReq->scsiCDB[12]|(agSATAReq->scsiCDB[13]<<8)|(agSATAReq->scsiCDB[14]<<16)|(agSATAReq->scsiCDB[15]<<24)));
548      }
549   }
550 
551   /* send IOMB to SPC */
552   ret = mpiMsgProduce(circularQ,
553                       (void *)pMessage,
554                       MPI_CATEGORY_SAS_SATA,
555                       opCode,
556                       outq,
557                       (bit8)circularQ->priority);
558 
559 #ifdef SA_LL_IBQ_PROTECT
560   ossaSingleThreadedLeave(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
561 #endif /* SA_LL_IBQ_PROTECT */
562 
563 #ifdef SALL_API_TEST
564   if (AGSA_RC_FAILURE != ret)
565   {
566     saRoot->LLCounters.IOCounter.numSataStarted++;
567   }
568 #endif
569 
570   smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "8a");
571 
572 ext:
573   OSSA_INP_LEAVE(agRoot);
574   return ret;
575 }
576 
577 /******************************************************************************/
578 /*! \brief Abort SATA command
579  *
580  *  Abort SATA command
581  *
582  *  \param agRoot      handles for this instance of SAS/SATA hardware
583  *  \param queueNum    inbound/outbound queue number
584  *  \param agIORequest the IO Request descriptor
585  *  \param agIOtoBeAborted
586  *
587  *  \return If command is aborted successfully
588  *          - \e AGSA_RC_SUCCESS command is aborted successfully
589  *          - \e AGSA_RC_FAILURE command is not aborted successfully
590  */
591 /*******************************************************************************/
592 GLOBAL bit32 saSATAAbort(
593   agsaRoot_t      *agRoot,
594   agsaIORequest_t *agIORequest,
595   bit32           queueNum,
596   agsaDevHandle_t *agDevHandle,
597   bit32           flag,
598   void            *abortParam,
599   ossaGenericAbortCB_t   agCB
600   )
601 {
602   bit32 ret = AGSA_RC_SUCCESS, retVal;
603   agsaLLRoot_t        *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
604   agsaIORequestDesc_t *pRequest;
605   agsaIORequestDesc_t *pRequestABT = agNULL;
606   agsaDeviceDesc_t    *pDevice = agNULL;
607   agsaDeviceDesc_t    *pDeviceABT = NULL;
608   agsaPort_t          *pPort = agNULL;
609   mpiICQueue_t        *circularQ;
610   void                *pMessage;
611   agsaSATAAbortCmd_t  *payload;
612   agsaIORequest_t     *agIOToBeAborted;
613   bit8                inq, outq;
614   bit32               flag_copy = flag;
615 
616 
617   smTraceFuncEnter(hpDBG_VERY_LOUD,"8b");
618 
619   /* sanity check */
620   SA_ASSERT((agNULL != agRoot), "");
621   SA_ASSERT((agNULL != agIORequest), "");
622 
623   SA_DBG3(("saSATAAbort: Aborting request %p ITtoBeAborted %p\n", agIORequest, abortParam));
624 
625   /* Assign inbound and outbound Ring Buffer */
626   inq = (bit8)(queueNum & MPI_IB_NUM_MASK);
627   outq = (bit8)((queueNum & MPI_OB_NUM_MASK) >> MPI_OB_SHIFT);
628   SA_ASSERT((AGSA_MAX_INBOUND_Q > inq), "The IBQ Number is out of range.");
629 
630   if( ABORT_SINGLE == (flag & ABORT_MASK) )
631   {
632     agIOToBeAborted = (agsaIORequest_t *)abortParam;
633     /* Get LL IORequest entry for saSATAAbort() */
634     pRequest = (agsaIORequestDesc_t *) (agIOToBeAborted->sdkData);
635     if (agNULL == pRequest)
636     {
637       /* no pRequest found - can not Abort */
638       SA_DBG1(("saSATAAbort: pRequest AGSA_RC_FAILURE\n"));
639       smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "8b");
640       return AGSA_RC_FAILURE;
641     }
642     /* Find the device the request sent to */
643     pDevice = pRequest->pDevice;
644     /* Get LL IORequest entry */
645     pRequestABT = (agsaIORequestDesc_t *) (agIOToBeAborted->sdkData);
646     /* Find the device the request sent to */
647     if (agNULL == pRequestABT)
648     {
649       /* no pRequestABT - can not find pDeviceABT */
650       SA_DBG1(("saSATAAbort: pRequestABT AGSA_RC_FAILURE\n"));
651       smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "8b");
652       return AGSA_RC_FAILURE;
653     }
654     pDeviceABT = pRequestABT->pDevice;
655 
656     if (agNULL == pDeviceABT)
657     {
658       /* no deviceID - can not build IOMB */
659       SA_DBG1(("saSATAAbort: pDeviceABT AGSA_RC_FAILURE\n"));
660 
661       smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "8b");
662       return AGSA_RC_FAILURE;
663     }
664 
665     if (agNULL != pDevice)
666     {
667       /* Find the port the request was sent to */
668       pPort = pDevice->pPort;
669     }
670 
671     /* Get request from free IORequests */
672     ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
673     pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeIORequests));
674   }
675   else
676   {
677     if (ABORT_ALL == (flag & ABORT_MASK))
678     {
679       /* abort all */
680       /* Find the outgoing port for the device */
681       pDevice = (agsaDeviceDesc_t *) (agDevHandle->sdkData);
682       pPort = pDevice->pPort;
683       ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
684       pRequest = (agsaIORequestDesc_t *)saLlistIOGetHead(&(saRoot->freeIORequests));
685     }
686     else
687     {
688       /* only support 00 and 01 for flag */
689       SA_DBG1(("saSATAAbort: flag AGSA_RC_FAILURE\n"));
690       smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "8b");
691       return AGSA_RC_FAILURE;
692     }
693   }
694 
695   /* If no LL IO request entry avalable */
696   if ( agNULL == pRequest )
697   {
698     ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
699     SA_DBG1(("saSATAAbort, No request from free list\n" ));
700     smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "8b");
701     return AGSA_RC_BUSY;
702   }
703 
704   /* If free IOMB avaliable */
705   /* Remove the request from free list */
706   saLlistIORemove(&(saRoot->freeIORequests), &(pRequest->linkNode));
707 
708   SA_ASSERT((!pRequest->valid), "The pRequest is in use");
709   /* Add the request to the pendingIORequests list of the device */
710   pRequest->valid = agTRUE;
711   saLlistIOAdd(&(pDevice->pendingIORequests), &(pRequest->linkNode));
712   /* set up pRequest */
713 
714   ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
715 
716   pRequest->pIORequestContext = agIORequest;
717   pRequest->requestType = AGSA_SATA_REQTYPE;
718   pRequest->pDevice = pDevice;
719   pRequest->pPort = pPort;
720   pRequest->completionCB = (void*)agCB;
721 /* pRequest->abortCompletionCB = agCB; */
722   pRequest->startTick = saRoot->timeTick;
723 
724   /* Set request to the sdkData of agIORequest */
725   agIORequest->sdkData = pRequest;
726 
727   /* save tag and IOrequest pointer to IOMap */
728   saRoot->IOMap[pRequest->HTag].Tag = pRequest->HTag;
729   saRoot->IOMap[pRequest->HTag].IORequest = (void *)pRequest;
730 
731 #ifdef SA_LL_IBQ_PROTECT
732   ossaSingleThreadedEnter(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
733 #endif /* SA_LL_IBQ_PROTECT */
734 
735   /* If LL IO request entry avaliable */
736   /* Get a free inbound queue entry */
737   circularQ = &saRoot->inboundQueue[inq];
738   retVal    = mpiMsgFreeGet(circularQ, IOMB_SIZE64, &pMessage);
739 
740   /* if message size is too large return failure */
741   if (AGSA_RC_FAILURE == retVal)
742   {
743 #ifdef SA_LL_IBQ_PROTECT
744     ossaSingleThreadedLeave(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
745 #endif /* SA_LL_IBQ_PROTECT */
746 
747     ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
748     saLlistIORemove(&(pDevice->pendingIORequests), &(pRequest->linkNode));
749     pRequest->valid = agFALSE;
750     saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
751     ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
752 
753     SA_DBG1(("saSATAAbort, error when get free IOMB\n"));
754     smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "8b");
755     return AGSA_RC_FAILURE;
756   }
757 
758   /* return busy if inbound queue is full */
759   if (AGSA_RC_BUSY == retVal)
760   {
761 #ifdef SA_LL_IBQ_PROTECT
762     ossaSingleThreadedLeave(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
763 #endif /* SA_LL_IBQ_PROTECT */
764 
765     ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
766     saLlistIORemove(&(pDevice->pendingIORequests), &(pRequest->linkNode));
767     pRequest->valid = agFALSE;
768     saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
769     ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
770 
771     SA_DBG1(("saSATASAbort, no more IOMB\n"));
772     smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "8b");
773     return AGSA_RC_BUSY;
774   }
775 
776 
777   /* setup payload */
778   payload = (agsaSATAAbortCmd_t*)pMessage;
779   OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAAbortCmd_t, tag), pRequest->HTag);
780 
781   if( ABORT_SINGLE == (flag & ABORT_MASK) )
782   {
783     /* If no device  */
784     if ( agNULL == pDeviceABT )
785     {
786       #ifdef SA_LL_IBQ_PROTECT
787       ossaSingleThreadedLeave(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
788       #endif /* SA_LL_IBQ_PROTECT */
789 
790       ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
791       saLlistIORemove(&(pDevice->pendingIORequests), &(pRequest->linkNode));
792       pRequest->valid = agFALSE;
793       saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
794       ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
795 
796       SA_DBG1(("saSATAAbort,no device\n" ));
797       smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "8b");
798       return AGSA_RC_FAILURE;
799     }
800     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAAbortCmd_t, deviceId), pDeviceABT->DeviceMapIndex);
801     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAAbortCmd_t, HTagAbort), pRequestABT->HTag);
802   }
803   else
804   {
805     /* abort all */
806     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAAbortCmd_t, deviceId), pDevice->DeviceMapIndex);
807     OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAAbortCmd_t, HTagAbort), 0);
808   }
809 
810   if(flag & ABORT_TSDK_QUARANTINE)
811   {
812     if(smIS_SPCV(agRoot))
813     {
814       flag_copy &= ABORT_SCOPE;
815       flag_copy |= ABORT_QUARANTINE_SPCV;
816     }
817   }
818   OSSA_WRITE_LE_32(agRoot, payload, OSSA_OFFSET_OF(agsaSATAAbortCmd_t, abortAll), flag_copy);
819 
820 
821 
822   SA_DBG1(("saSATAAbort, HTag 0x%x HTagABT 0x%x deviceId 0x%x\n", payload->tag, payload->HTagAbort, payload->deviceId));
823 
824   /* post the IOMB to SPC */
825   ret = mpiMsgProduce(circularQ, (void *)pMessage, MPI_CATEGORY_SAS_SATA, OPC_INB_SATA_ABORT, outq, (bit8)circularQ->priority);
826 
827 #ifdef SA_LL_IBQ_PROTECT
828   ossaSingleThreadedLeave(agRoot, LL_IOREQ_IBQ0_LOCK + inq);
829 #endif /* SA_LL_IBQ_PROTECT */
830 
831 #ifdef SALL_API_TEST
832   if (AGSA_RC_FAILURE != ret)
833   {
834     saRoot->LLCounters.IOCounter.numSataAborted++;
835   }
836 #endif
837 
838   siCountActiveIORequestsOnDevice( agRoot,   payload->deviceId );
839 
840   smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "8b");
841 
842   return ret;
843 }
844 
845 /******************************************************************************/
846 /*! \brief Routine to handle for received SATA with data payload event
847  *
848  *  The handle for received SATA with data payload event
849  *
850  *  \param agRoot       handles for this instance of SAS/SATA hardware
851  *  \param pRequest     the IO request descriptor
852  *  \param agFirstDword pointer to the first Dword
853  *  \param pResp        pointer to the rest of SATA response
854  *  \param lengthResp   total length of SATA Response frame
855  *
856  *  \return -void-
857  */
858 /*******************************************************************************/
859 GLOBAL void siEventSATAResponseWtDataRcvd(
860   agsaRoot_t              *agRoot,
861   agsaIORequestDesc_t     *pRequest,
862   bit32                   *agFirstDword,
863   bit32                   *pResp,
864   bit32                   lengthResp
865   )
866 {
867   agsaLLRoot_t        *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
868   agsaDeviceDesc_t    *pDevice;
869 #if defined(SALLSDK_DEBUG)
870   agsaFrameHandle_t   frameHandle;
871   /* get frame handle */
872   frameHandle = (agsaFrameHandle_t)(pResp);
873 #endif  /* SALLSDK_DEBUG */
874 
875   smTraceFuncEnter(hpDBG_VERY_LOUD,"8c");
876 
877   /* If the request is still valid */
878   if ( agTRUE == pRequest->valid )
879   {
880     /* get device */
881     pDevice = pRequest->pDevice;
882     ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
883 
884     /* Delete the request from the pendingIORequests */
885     saLlistIORemove(&(pDevice->pendingIORequests), &(pRequest->linkNode));
886     ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
887 
888     (*(ossaSATACompletedCB_t)(pRequest->completionCB))(agRoot,
889                                                        pRequest->pIORequestContext,
890                                                        OSSA_IO_SUCCESS,
891                                                        agFirstDword,
892                                                        lengthResp,
893                                                        (void *)pResp);
894 
895     ossaSingleThreadedEnter(agRoot, LL_IOREQ_LOCKEQ_LOCK);
896     pRequest->valid = agFALSE;
897     /* return the request to free pool */
898     saLlistIOAdd(&(saRoot->freeIORequests), &(pRequest->linkNode));
899     ossaSingleThreadedLeave(agRoot, LL_IOREQ_LOCKEQ_LOCK);
900   }
901 
902   smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "8c");
903 
904   return;
905 }
906 
907 /******************************************************************************/
908 /*! \brief copy a SATA signature to another
909  *
910  *  copy a SATA signature to another
911  *
912  *  \param pDstSignature pointer to the destination signature
913  *  \param pSrcSignature pointer to the source signature
914  *
915  *  \return If they match
916  *          - \e agTRUE match
917  *          - \e agFALSE  doesn't match
918  */
919 /*******************************************************************************/
920 GLOBAL void siSATASignatureCpy(
921   bit8  *pDstSignature,
922   bit8  *pSrcSignature
923   )
924 {
925   bit32   i;
926 
927   for ( i = 0; i < 5; i ++ )
928   {
929     pDstSignature[i] = pSrcSignature[i];
930   }
931 
932   return;
933 }
934 
935 
936 
937