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 #include <sys/cdefs.h>
23 #include <dev/pms/config.h>
24
25 #include <dev/pms/freebsd/driver/common/osenv.h>
26 #include <dev/pms/freebsd/driver/common/ostypes.h>
27 #include <dev/pms/freebsd/driver/common/osdebug.h>
28
29 #include <dev/pms/RefTisa/tisa/api/titypes.h>
30
31 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
32 #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
33 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
34
35 #include <dev/pms/RefTisa/sat/api/sm.h>
36 #include <dev/pms/RefTisa/sat/api/smapi.h>
37 #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
38
39 #include <dev/pms/RefTisa/sat/src/smdefs.h>
40 #include <dev/pms/RefTisa/sat/src/smproto.h>
41 #include <dev/pms/RefTisa/sat/src/smtypes.h>
42
43 /*
44 * This table is used to map LL Layer saSATAStart() status to TISA status.
45 */
46
47
48 FORCEINLINE bit32
smsataLLIOStart(smRoot_t * smRoot,smIORequest_t * smIORequest,smDeviceHandle_t * smDeviceHandle,smScsiInitiatorRequest_t * smScsiRequest,smSatIOContext_t * satIOContext)49 smsataLLIOStart(
50 smRoot_t *smRoot,
51 smIORequest_t *smIORequest,
52 smDeviceHandle_t *smDeviceHandle,
53 smScsiInitiatorRequest_t *smScsiRequest,
54 smSatIOContext_t *satIOContext
55 )
56 {
57 smDeviceData_t *oneDeviceData = (smDeviceData_t *)smDeviceHandle->smData;
58 smIntRoot_t *smIntRoot = (smIntRoot_t *) smRoot->smData;
59 smIntContext_t *smAllShared = (smIntContext_t *)&(smIntRoot->smAllShared);
60 smIORequestBody_t *smIORequestBody = (smIORequestBody_t *)satIOContext->smRequestBody;
61 smDeviceData_t *pSatDevData = satIOContext->pSatDevData;
62 smSatInternalIo_t *satIntIo = satIOContext->satIntIoContext;
63 agsaRoot_t *agRoot = smAllShared->agRoot;
64 agsaIORequest_t *agIORequest = &(smIORequestBody->agIORequest);
65 agsaDevHandle_t *agDevHandle = oneDeviceData->agDevHandle;
66 agsaSATAInitiatorRequest_t *agSATAReq = &(smIORequestBody->transport.SATA.agSATARequestBody);
67 bit32 RLERecovery = agFALSE;
68 bit32 status = SM_RC_FAILURE;
69 bit32 nQNumber = 0;
70 /*
71 * If this is a super I/O request, check for optional settings.
72 * Be careful. Use the superRequest pointer for all references
73 * in this block of code.
74 */
75 agSATAReq->option = 0;
76 if (satIOContext->superIOFlag)
77 {
78 smSuperScsiInitiatorRequest_t *superRequest = (smSuperScsiInitiatorRequest_t *) smScsiRequest;
79
80 if (superRequest->flags & SM_SCSI_INITIATOR_ENCRYPT)
81 {
82 /* Copy all of the relevant encrypt information */
83 agSATAReq->option |= AGSA_SATA_ENABLE_ENCRYPTION;
84 sm_memcpy(&agSATAReq->encrypt, &superRequest->Encrypt, sizeof(agsaEncrypt_t));
85 }
86 {
87 /* initialize expDataLength */
88 if (satIOContext->reqType == AGSA_SATA_PROTOCOL_NON_DATA ||
89 satIOContext->reqType == AGSA_SATA_PROTOCOL_SRST_ASSERT ||
90 satIOContext->reqType == AGSA_SATA_PROTOCOL_SRST_DEASSERT )
91 {
92 smIORequestBody->IOType.InitiatorRegIO.expDataLength = 0;
93 }
94 else
95 {
96 smIORequestBody->IOType.InitiatorRegIO.expDataLength = smScsiRequest->scsiCmnd.expDataLength;
97 }
98
99 agSATAReq->dataLength = smIORequestBody->IOType.InitiatorRegIO.expDataLength;
100 }
101 }
102 else
103 {
104 /* initialize expDataLength */
105 if (satIOContext->reqType == AGSA_SATA_PROTOCOL_NON_DATA ||
106 satIOContext->reqType == AGSA_SATA_PROTOCOL_SRST_ASSERT ||
107 satIOContext->reqType == AGSA_SATA_PROTOCOL_SRST_DEASSERT )
108 {
109 smIORequestBody->IOType.InitiatorRegIO.expDataLength = 0;
110 }
111 else
112 {
113 smIORequestBody->IOType.InitiatorRegIO.expDataLength = smScsiRequest->scsiCmnd.expDataLength;
114 }
115
116 agSATAReq->dataLength = smIORequestBody->IOType.InitiatorRegIO.expDataLength;
117 }
118
119 if ( (pSatDevData->satDriveState == SAT_DEV_STATE_IN_RECOVERY) &&
120 (satIOContext->pFis->h.command == SAT_READ_LOG_EXT) )
121 {
122 RLERecovery = agTRUE;
123 }
124
125 /* check max io, be sure to free */
126 if ( (pSatDevData->satDriveState != SAT_DEV_STATE_IN_RECOVERY) ||
127 (RLERecovery == agTRUE) )
128 {
129 if (RLERecovery == agFALSE) /* RLE is not checked against pending IO's */
130 {
131 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK
132 bit32 volatile satPendingNCQIO = 0;
133 bit32 volatile satPendingNONNCQIO = 0;
134 bit32 volatile satPendingIO = 0;
135
136 tdsmInterlockedExchange(smRoot, &satPendingNCQIO, pSatDevData->satPendingNCQIO);
137 tdsmInterlockedExchange(smRoot, &satPendingNONNCQIO, pSatDevData->satPendingNONNCQIO);
138 tdsmInterlockedExchange(smRoot, &satPendingIO, pSatDevData->satPendingIO);
139 #endif
140
141 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) ||
142 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) )
143 {
144 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK
145 if ( satPendingNCQIO >= pSatDevData->satNCQMaxIO ||
146 satPendingNONNCQIO != 0)
147 {
148 SM_DBG1(("smsataLLIOStart: 1st busy did %d!!!\n", pSatDevData->id));
149 SM_DBG1(("smsataLLIOStart: 1st busy NCQ. NCQ Pending 0x%x NONNCQ Pending 0x%x All Pending 0x%x!!!\n", satPendingNCQIO,
150 satPendingNONNCQIO, satPendingIO));
151 /* free resource */
152 smsatFreeIntIoResource( smRoot,
153 pSatDevData,
154 satIntIo);
155 return SM_RC_DEVICE_BUSY;
156 }
157 #else
158 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK);
159 if (pSatDevData->satPendingNCQIO >= pSatDevData->satNCQMaxIO ||
160 pSatDevData->satPendingNONNCQIO != 0)
161 {
162 SM_DBG1(("smsataLLIOStart: 1st busy did %d!!!\n", pSatDevData->id));
163 SM_DBG1(("smsataLLIOStart: 1st busy NCQ. NCQ Pending 0x%x NONNCQ Pending 0x%x All Pending 0x%x!!!\n", pSatDevData->satPendingNCQIO,
164 pSatDevData->satPendingNONNCQIO, pSatDevData->satPendingIO));
165 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
166 /* free resource */
167 smsatFreeIntIoResource( smRoot,
168 pSatDevData,
169 satIntIo);
170 return SM_RC_DEVICE_BUSY;
171 }
172 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
173 #endif
174
175 }
176 else if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_D2H_PKT) ||
177 (satIOContext->reqType == AGSA_SATA_PROTOCOL_H2D_PKT) ||
178 (satIOContext->reqType == AGSA_SATA_PROTOCOL_NON_PKT) )
179 {
180 sm_memcpy(agSATAReq->scsiCDB, smScsiRequest->scsiCmnd.cdb, 16);
181 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK
182 if ( satPendingNONNCQIO >= SAT_APAPI_CMDQ_MAX ||
183 satPendingNCQIO != 0)
184 {
185 SM_DBG1(("smsataLLIOStart: ATAPI busy did %d!!!\n", pSatDevData->id));
186 SM_DBG1(("smsataLLIOStart: ATAPI busy NON-NCQ. NCQ Pending 0x%x NON-NCQ Pending 0x%x All Pending 0x%x!!!\n", satPendingNCQIO,
187 satPendingNONNCQIO, satPendingIO));
188 /* free resource */
189 smsatFreeIntIoResource( smRoot,
190 pSatDevData,
191 satIntIo);
192 return SM_RC_DEVICE_BUSY;
193 }
194 #else
195 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK);
196 if ( pSatDevData->satPendingNONNCQIO >= SAT_APAPI_CMDQ_MAX ||
197 pSatDevData->satPendingNCQIO != 0)
198 {
199 SM_DBG1(("smsataLLIOStart: ATAPI busy did %d!!!\n", pSatDevData->id));
200 SM_DBG1(("smsataLLIOStart: ATAPI busy NON-NCQ. NCQ Pending 0x%x NON-NCQ Pending 0x%x All Pending 0x%x!!!\n", pSatDevData->satPendingNCQIO,
201 pSatDevData->satPendingNONNCQIO, pSatDevData->satPendingIO));
202 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
203 /* free resource */
204 smsatFreeIntIoResource( smRoot,
205 pSatDevData,
206 satIntIo);
207 return SM_RC_DEVICE_BUSY;
208 }
209 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
210 #endif
211
212 }
213 else
214 {
215 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK
216 if ( satPendingNONNCQIO >= SAT_NONNCQ_MAX ||
217 satPendingNCQIO != 0)
218 {
219 SM_DBG1(("smsataLLIOStart: 2nd busy did %d!!!\n", pSatDevData->id));
220 SM_DBG1(("smsataLLIOStart: 2nd busy NCQ. NCQ Pending 0x%x NONNCQ Pending 0x%x All Pending 0x%x!!!\n", satPendingNCQIO,
221 satPendingNONNCQIO, satPendingIO));
222 /* free resource */
223 smsatFreeIntIoResource( smRoot,
224 pSatDevData,
225 satIntIo);
226 return SM_RC_DEVICE_BUSY;
227 }
228 #else
229 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK);
230 if (pSatDevData->satPendingNONNCQIO >= SAT_NONNCQ_MAX ||
231 pSatDevData->satPendingNCQIO != 0)
232 {
233 SM_DBG1(("smsataLLIOStart: 2nd busy did %d!!!\n", pSatDevData->id));
234 SM_DBG1(("smsataLLIOStart: 2nd busy NCQ. NCQ Pending 0x%x NONNCQ Pending 0x%x All Pending 0x%x!!!\n", pSatDevData->satPendingNCQIO,
235 pSatDevData->satPendingNONNCQIO, pSatDevData->satPendingIO));
236 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
237 /* free resource */
238 smsatFreeIntIoResource( smRoot,
239 pSatDevData,
240 satIntIo);
241 return SM_RC_DEVICE_BUSY;
242 }
243 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
244 #endif
245 }
246 } /* RLE */
247 /* for internal SATA command only */
248 if (satIOContext->satOrgIOContext != agNULL)
249 {
250 /* Initialize tiIORequest */
251 smIORequestBody->smIORequest = smIORequest;
252 if (smIORequest == agNULL)
253 {
254 SM_DBG1(("smsataLLIOStart: 1 check!!!\n"));
255 }
256 }
257 /* Initialize tiDevhandle */
258 smIORequestBody->smDevHandle = smDeviceHandle;
259
260 /* Initializes Scatter Gather and ESGL */
261 status = smsatIOPrepareSGL( smRoot,
262 smIORequestBody,
263 &smScsiRequest->smSgl1,
264 smScsiRequest->sglVirtualAddr );
265
266 if (status != SM_RC_SUCCESS)
267 {
268 SM_DBG1(("smsataLLIOStart: can't get SGL!!!\n"));
269 /* free resource */
270 smsatFreeIntIoResource( smRoot,
271 pSatDevData,
272 satIntIo);
273 return status;
274 }
275
276 /* Initialize LL Layer agIORequest */
277 agIORequest->osData = (void *) smIORequestBody;
278 agIORequest->sdkData = agNULL; /* SA takes care of this */
279
280 smIORequestBody->ioStarted = agTRUE;
281 smIORequestBody->ioCompleted = agFALSE;
282
283 /* assign tag value for SATA */
284 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) ||
285 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) )
286 {
287 if (agFALSE == smsatTagAlloc(smRoot, pSatDevData, &satIOContext->sataTag))
288 {
289 SM_DBG1(("smsataLLIOStart: No more NCQ tag!!!\n"));
290 smIORequestBody->ioStarted = agFALSE;
291 smIORequestBody->ioCompleted = agTRUE;
292 return SM_RC_DEVICE_BUSY;
293 }
294 SM_DBG3(("smsataLLIOStart: ncq tag 0x%x\n",satIOContext->sataTag));
295 }
296 else
297 {
298 satIOContext->sataTag = 0xFF;
299 }
300 }
301 else /* AGSA_SATA_PROTOCOL_SRST_ASSERT or AGSA_SATA_PROTOCOL_SRST_DEASSERT
302 or SAT_CHECK_POWER_MODE as ABORT */
303 {
304 agsaSgl_t *agSgl;
305
306 /* for internal SATA command only */
307 if (satIOContext->satOrgIOContext != agNULL)
308 {
309 /* Initialize tiIORequest */
310 smIORequestBody->smIORequest = smIORequest;
311 if (smIORequest == agNULL)
312 {
313 SM_DBG1(("smsataLLIOStart: 2 check!!!\n"));
314 }
315 }
316 /* Initialize tiDevhandle */
317 smIORequestBody->smDevHandle = smDeviceHandle;
318
319
320 smIORequestBody->IOType.InitiatorRegIO.expDataLength = 0;
321 /* SGL for SATA request */
322 agSgl = &(smIORequestBody->transport.SATA.agSATARequestBody.agSgl);
323 agSgl->len = 0;
324
325 agSgl->sgUpper = 0;
326 agSgl->sgLower = 0;
327 agSgl->len = 0;
328 SM_CLEAR_ESGL_EXTEND(agSgl->extReserved);
329
330 /* Initialize LL Layer agIORequest */
331 agIORequest = &(smIORequestBody->agIORequest);
332 agIORequest->osData = (void *) smIORequestBody;
333 agIORequest->sdkData = agNULL; /* SA takes care of this */
334
335 smIORequestBody->ioStarted = agTRUE;
336 smIORequestBody->ioCompleted = agFALSE;
337
338 /* setting the data length */
339 agSATAReq->dataLength = 0;
340
341 }
342
343
344 smIORequestBody->reTries = 0;
345
346 #ifdef TD_INTERNAL_DEBUG
347 smhexdump("smsataLLIOStart", (bit8 *)satIOContext->pFis, sizeof(agsaFisRegHostToDevice_t));
348 smhexdump("smsataLLIOStart LL", (bit8 *)&agSATAReq->fis.fisRegHostToDev,
349 sizeof(agsaFisRegHostToDevice_t));
350 #endif
351
352 SM_DBG6(("smsataLLIOStart: agDevHandle %p\n", agDevHandle));
353
354 /* to get better IO performance, rotate the OBQ number on main IO path */
355 if (smScsiRequest == agNULL)
356 {
357 nQNumber = 0;
358 }
359 else
360 {
361 switch (smScsiRequest->scsiCmnd.cdb[0])
362 {
363 case SCSIOPC_READ_10:
364 case SCSIOPC_WRITE_10:
365 case SCSIOPC_READ_6:
366 case SCSIOPC_WRITE_6:
367 case SCSIOPC_READ_12:
368 case SCSIOPC_WRITE_12:
369 case SCSIOPC_READ_16:
370 case SCSIOPC_WRITE_16:
371 nQNumber = tdsmRotateQnumber(smRoot, smDeviceHandle);
372 break;
373
374 default:
375 nQNumber = 0;
376 break;
377 }
378 }
379
380 SM_DBG3(("sataLLIOStart: Lock in\n"));
381
382 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK
383 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) ||
384 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) )
385 {
386 tdsmInterlockedIncrement(smRoot,&pSatDevData->satPendingNCQIO);
387 }
388 else
389 {
390 tdsmInterlockedIncrement(smRoot,&pSatDevData->satPendingNONNCQIO);
391 }
392 tdsmInterlockedIncrement(smRoot,&pSatDevData->satPendingIO);
393 #else
394 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK);
395 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) ||
396 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) )
397 {
398 pSatDevData->satPendingNCQIO++;
399 }
400 else
401 {
402 pSatDevData->satPendingNONNCQIO++;
403 }
404 pSatDevData->satPendingIO++;
405
406 SMLIST_INIT_ELEMENT (&satIOContext->satIoContextLink);
407 SMLIST_ENQUEUE_AT_TAIL (&satIOContext->satIoContextLink, &pSatDevData->satIoLinkList);
408 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
409 #endif
410 /* post SATA command to low level MPI */
411 status = saSATAStart( agRoot,
412 agIORequest,
413 nQNumber,
414 agDevHandle,
415 satIOContext->reqType,
416 agSATAReq,
417 satIOContext->sataTag,
418 smllSATACompleted
419 );
420
421 if (status != AGSA_RC_SUCCESS)
422 {
423 if (status == AGSA_RC_BUSY)
424 {
425 SM_DBG1(("smsataLLIOStart: saSATAStart busy!!!\n"));
426 status = SM_RC_BUSY;
427 }
428 else
429 {
430 SM_DBG1(("smsataLLIOStart: saSATAStart failed!!!\n"));
431 status = SM_RC_FAILURE;
432 }
433
434 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) ||
435 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) )
436 {
437 smsatTagRelease(smRoot, pSatDevData, satIOContext->sataTag);
438 }
439
440 #ifdef CCFLAG_OPTIMIZE_SAT_LOCK
441 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) ||
442 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) )
443 {
444 tdsmInterlockedDecrement(smRoot,&oneDeviceData->satPendingNCQIO);
445 }
446 else
447 {
448 tdsmInterlockedDecrement(smRoot,&oneDeviceData->satPendingNONNCQIO);
449 }
450 tdsmInterlockedDecrement(smRoot,&oneDeviceData->satPendingIO);
451 #else
452 if ( (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_WRITE) ||
453 (satIOContext->reqType == AGSA_SATA_PROTOCOL_FPDMA_READ) )
454 {
455 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK);
456 oneDeviceData->satPendingNCQIO--;
457 oneDeviceData->satPendingIO--;
458 SMLIST_DEQUEUE_THIS (&satIOContext->satIoContextLink);
459 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
460 }
461 else
462 {
463 tdsmSingleThreadedEnter(smRoot, SM_EXTERNAL_IO_LOCK);
464 oneDeviceData->satPendingNONNCQIO--;
465 oneDeviceData->satPendingIO--;
466 SMLIST_DEQUEUE_THIS (&satIOContext->satIoContextLink);
467 tdsmSingleThreadedLeave(smRoot, SM_EXTERNAL_IO_LOCK);
468 }
469 #endif /* CCFLAG_OPTIMIZE_SAT_LOCK */
470
471 /* Free the ESGL pages associated with this I/O */
472 smIORequestBody->ioStarted = agFALSE;
473 smIORequestBody->ioCompleted = agTRUE;
474 return (status);
475 }
476
477 return SM_RC_SUCCESS;
478 }
479
480
481 osGLOBAL FORCEINLINE bit32
smsatIOPrepareSGL(smRoot_t * smRoot,smIORequestBody_t * smIORequestBody,smSgl_t * smSgl1,void * sglVirtualAddr)482 smsatIOPrepareSGL(
483 smRoot_t *smRoot,
484 smIORequestBody_t *smIORequestBody,
485 smSgl_t *smSgl1,
486 void *sglVirtualAddr
487 )
488 {
489 agsaSgl_t *agSgl;
490
491 /* Uppper should be zero-out */
492 SM_DBG5(("smsatIOPrepareSGL: start\n"));
493
494 SM_DBG5(("smsatIOPrepareSGL: smSgl1->upper %d smSgl1->lower %d smSgl1->len %d\n",
495 smSgl1->upper, smSgl1->lower, smSgl1->len));
496 SM_DBG5(("smsatIOPrepareSGL: smSgl1->type %d\n", smSgl1->type));
497
498 /* SGL for SATA request */
499 agSgl = &(smIORequestBody->transport.SATA.agSATARequestBody.agSgl);
500 agSgl->len = 0;
501
502 if (smSgl1 == agNULL)
503 {
504 SM_DBG1(("smsatIOPrepareSGL: Error smSgl1 is NULL!!!\n"));
505 return tiError;
506 }
507
508 if (smIORequestBody->IOType.InitiatorRegIO.expDataLength == 0)
509 {
510 SM_DBG3(("smsatIOPrepareSGL: expDataLength is 0\n"));
511 agSgl->sgUpper = 0;
512 agSgl->sgLower = 0;
513 agSgl->len = 0;
514 SM_CLEAR_ESGL_EXTEND(agSgl->extReserved);
515 return SM_RC_SUCCESS;
516 }
517
518 agSgl->sgUpper = smSgl1->upper;
519 agSgl->sgLower = smSgl1->lower;
520 agSgl->len = smSgl1->len;
521 agSgl->extReserved = smSgl1->type;
522
523 return SM_RC_SUCCESS;
524
525 }
526
527
528
529
530