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