1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
22 ********************************************************************************/
23 /*******************************************************************************/
26 * This file contains the SAS/SATA TD layer initialization functions
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31 #include <dev/pms/config.h>
33 #include <dev/pms/freebsd/driver/common/osenv.h>
34 #include <dev/pms/freebsd/driver/common/ostypes.h>
35 #include <dev/pms/freebsd/driver/common/osdebug.h>
37 #include <dev/pms/RefTisa/sallsdk/api/sa.h>
38 #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
39 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
41 #include <dev/pms/RefTisa/tisa/api/titypes.h>
42 #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
43 #include <dev/pms/RefTisa/tisa/api/tiapi.h>
44 #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
47 #include <dev/pms/RefTisa/sat/api/sm.h>
48 #include <dev/pms/RefTisa/sat/api/smapi.h>
49 #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
53 #include <dev/pms/RefTisa/discovery/api/dm.h>
54 #include <dev/pms/RefTisa/discovery/api/dmapi.h>
55 #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
58 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
59 #include <dev/pms/freebsd/driver/common/osstring.h>
60 #include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
62 #ifdef INITIATOR_DRIVER
63 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
64 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
65 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
69 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
70 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
71 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
74 #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
75 #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
77 LOCAL bit32 tdsaGetCardID(tiRoot_t * tiRoot);
80 bit32 tdCardIDList[TD_MAX_CARD_NUM] = {
81 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
82 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
83 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
84 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
85 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
86 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
87 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
88 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
89 TD_CARD_ID_FREE , TD_CARD_ID_FREE ,
90 TD_CARD_ID_FREE , TD_CARD_ID_FREE
93 /*****************************************************************************
101 * tiRoot: Pointer to driver/port instance.
104 * tiSuccess : CardIDString was successfully read
105 * tiError : CardIDString reading failed
107 *****************************************************************************/
108 bit32 tdsaGetCardID(tiRoot_t * tiRoot)
111 bit32 RetVal = 0xFFFFFFFF;
113 for (i = 0 ; i < TD_MAX_CARD_NUM ; i++)
115 if (tdCardIDList[i] == TD_CARD_ID_FREE)
117 tdCardIDList[i] = TD_CARD_ID_ALLOC;
125 } /* tdsaGetCardID() */
127 /*****************************************************************************
135 * tiRoot: Pointer to driver/port instance.
138 * tiSuccess : CardIDString was successfully read
139 * tiError : CardIDString reading failed
141 *****************************************************************************/
143 tdsaFreeCardID(tiRoot_t *tiRoot, bit32 CardID)
145 OS_ASSERT(CardID < TD_MAX_CARD_NUM, "Invalid CardID\n");
147 tdCardIDList[CardID] = TD_CARD_ID_FREE;
151 } /* tdFreeCardID() */
153 /*****************************************************************************
155 * tdsaGetCardIDString
161 * tiRoot: Pointer to driver/port instance.
164 * tiSuccess : CardIDString was successfully read
165 * tiError : CardIDString reading failed
167 *****************************************************************************/
168 bit32 tdsaGetCardIDString(tiRoot_t *tiRoot)
170 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
171 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
173 bit32 thisCardID = tdsaGetCardID(tiRoot);
176 TI_DBG3(("tdsaGetCardIDString: start\n"));
178 TI_DBG3(("tdsaGetCardIDString: thisCardID 0x%x\n", thisCardID));
181 if (thisCardID == 0xFFFFFFFF)
183 TI_DBG1(("tdGetCardIDString: No more CardIDs available\n"));
188 tdsaAllShared->CardID = thisCardID;
189 osti_sprintf(CardNum,"CardNum%d", thisCardID);
190 TI_DBG3(("tdsaGetCardIDString: CardNum is %s\n", CardNum));
191 osti_strcpy(tdsaAllShared->CardIDString, CardNum);
192 TI_DBG3(("tdsaGetCardIDString: tdsaAllShared->CardIDString is %s\n", tdsaAllShared->CardIDString));
198 /*****************************************************************************
199 *! \brief tiCOMGetResource
201 * Purpose: This function is called to determine the Transport
202 * Dependent Layer internal resource requirement.
203 * This function will internally call the initiator specific,
204 * target specific and shared TD resource requirement calls.
206 * \param tiRoot: Pointer to driver/port instance.
207 * \param loResource: Pointer to low level TSDK resource requirement.
208 * \param initiatorResource: Pointer to initiator functionality memory and
209 * option requirement.
210 * \param targetResource: Pointer to target functionality memory and
211 * option requirement.
212 * \param tdSharedMem: Pointer to cached memory required by the
213 * target/initiator shared functionality.
217 * \note - This function only return the memory requirement in the tiMem_t
218 * structure in loResource, initiatorResource, targetResource
219 * and tdSharedMem. It does not allocate memory, so the address
220 * fields in tiMem_t are not used.
222 *****************************************************************************/
226 tiLoLevelResource_t *loResource,
227 tiInitiatorResource_t *initiatorResource,
228 tiTargetResource_t *targetResource,
229 tiTdSharedMem_t *tdSharedMem
232 TI_DBG6(("tiCOMGetResource start\n"));
233 TI_DBG6(("tiCOMGetResource: loResource %p\n", loResource));
235 if(loResource != agNULL)
237 tdsaLoLevelGetResource(tiRoot, loResource);
239 if(tdSharedMem != agNULL)
241 tdsaSharedMemCalculate(tiRoot, loResource, tdSharedMem);
244 #ifdef INITIATOR_DRIVER
246 if(initiatorResource != agNULL)
248 itdssGetResource(tiRoot, initiatorResource);
250 * for the time being set the initiator usecsPerTick
251 * same as lolevel usecsPerTick
253 if (loResource == agNULL)
255 TI_DBG1(("tiCOMGetResource: loResource is NULL, wrong\n"));
263 if(targetResource != agNULL)
265 ttdssGetResource(tiRoot, targetResource);
273 /*****************************************************************************
276 * Purpose: This function is called to initialize Transport Dependent Layer.
277 * This function will internally call the initiator specific,
278 * target specific and shared TD initialization calls.
280 * \param tiRoot: Pointer to target driver/port instance.
281 * \param loResource: Pointer to low level TSDK resource requirement.
282 * \param initiatorResource: Pointer to initiator functionality memory and
283 * option requirement.
284 * \param targetResource: Pointer to target functionality memory and
285 * option requirement.
286 * \param tdSharedMem: Pointer to cached memory required by the
287 * target/initiator shared functionality.
289 * \return: tiSuccess - if successful
290 * tiError - if failed
292 *****************************************************************************/
296 tiLoLevelResource_t *loResource,
297 tiInitiatorResource_t *initiatorResource,
298 tiTargetResource_t *targetResource,
299 tiTdSharedMem_t *tdSharedMem )
301 tdsaRoot_t *tdsaRoot;
302 tdsaPortContext_t *tdsaPortContext;
303 tdsaDeviceData_t *tdsaDeviceData;
305 #ifdef TD_INT_COALESCE
306 tdsaIntCoalesceContext_t *tdsaIntCoalCxt;
310 tdsaExpander_t *tdsaExpander;
313 bit32 status = tiSuccess;
314 void *IniAddr = agNULL;
315 void *TgtAddr = agNULL;
316 tdsaContext_t *tdsaAllShared;
317 #if defined(TD_INT_COALESCE) || defined(TD_DISCOVER) || defined(TD_INTERNAL_DEBUG)
320 #ifdef TD_INTERNAL_DEBUG /* for debugging only */
321 tdsaEsglAllInfo_t *pEsglAllInfo;
322 tdList_t *tdlist_to_fill;
323 tdsaEsglPageInfo_t *page_to_fill;
327 dmSwConfig_t dmSwConfig;
328 static dmMemoryRequirement_t dmMemRequirement;
329 bit32 dmUsecsPerTick = 0;
330 bit32 dmMaxNumLocks = 0;
333 smSwConfig_t smSwConfig;
334 static smMemoryRequirement_t smMemRequirement;
335 bit32 smUsecsPerTick = 0;
336 bit32 smMaxNumLocks = 0;
340 /* for memory analysis */
341 TI_DBG6(("ticominit: tdsaroot\n"));
342 TI_DBG6(("ticominit: tdsaRoot_t %d\n", (int)sizeof(tdsaRoot_t)));
343 TI_DBG6(("ticominit: tdsaEsglAllInfo_t %d\n", (int)sizeof(tdsaEsglAllInfo_t)));
344 TI_DBG6(("ticominit: portcontext\n"));
345 TI_DBG6(("ticominit: tdsaPortContext_t %d\n", (int)sizeof(tdsaPortContext_t)));
346 TI_DBG6(("ticominit: device data\n"));
347 TI_DBG6(("ticominit: tdsaDeviceData_t %d\n", (int)sizeof(tdsaDeviceData_t)));
348 TI_DBG6(("ticominit: agsaSASDeviceInfo_t %d\n", (int)sizeof(agsaSASDeviceInfo_t)));
349 TI_DBG6(("ticominit: satDeviceData_t %d\n", (int)sizeof(satDeviceData_t)));
350 TI_DBG6(("ticominit: agsaSATAIdentifyData_t %d\n", (int)sizeof(agsaSATAIdentifyData_t)));
352 TI_DBG6(("ticominit: IO request body\n"));
353 TI_DBG6(("ticominit: tdIORequestBody_t %d\n", (int)sizeof(tdIORequestBody_t)));
354 TI_DBG6(("ticominit: tdssIOCompleted_t %d\n", (int)sizeof(tdssIOCompleted_t)));
355 TI_DBG6(("ticominit: agsaIORequest_t %d\n", (int)sizeof(agsaIORequest_t)));
357 TI_DBG6(("ticominit: FOR SAS\n"));
358 TI_DBG6(("ticominit: agsaSASRequestBody_t %d\n", (int)sizeof(agsaSASRequestBody_t)));
359 TI_DBG6(("ticominit: FOR SATA\n"));
360 TI_DBG6(("ticominit: agsaSATAInitiatorRequest_t %d\n", (int)sizeof(agsaSATAInitiatorRequest_t)));
361 TI_DBG6(("ticominit: scsiRspSense_t %d\n", (int)sizeof(scsiRspSense_t)));
362 TI_DBG6(("ticominit: tiSenseData_t %d\n", (int)sizeof(tiSenseData_t)));
363 TI_DBG6(("ticominit: satIOContext_t %d\n", (int)sizeof(satIOContext_t)));
364 TI_DBG6(("ticominit: satInternalIo_t %d\n", (int)sizeof(satInternalIo_t)));
367 /*************************************************************************
369 *************************************************************************/
371 TI_DBG6(("ticominit: start\n"));
374 #if defined(TD_INT_COALESCE) && defined(TD_DISCOVER)
376 /* Let's start from the tdsaRoot */
377 tdsaRoot = tdSharedMem->tdSharedCachedMem1.virtPtr;
378 tdsaPortContext = (tdsaPortContext_t *)((bitptr)tdSharedMem->tdSharedCachedMem1.virtPtr + sizeof(tdsaRoot_t));
379 tdsaDeviceData = (tdsaDeviceData_t *)((bitptr)tdsaPortContext + (sizeof(tdsaPortContext_t) * TD_MAX_PORT_CONTEXT));
381 /* the following fn fills in MaxTargets */
382 tdssGetMaxTargetsParams(tiRoot, &MaxTargets);
383 TI_DBG6(("tiCOMInit: MaxTargets %d\n", MaxTargets));
386 (tdsaIntCoalesceContext_t *)((bitptr)tdsaDeviceData
387 + (sizeof(tdsaDeviceData_t) * MaxTargets));
390 (tdsaExpander_t *)((bitptr)tdsaIntCoalCxt
391 + (sizeof(tdsaIntCoalesceContext_t) * TD_MAX_INT_COALESCE));
394 #elif defined(TD_INT_COALESCE)
398 /* Let's start from the tdsaRoot */
399 tdsaRoot = tdSharedMem->tdSharedCachedMem1.virtPtr;
400 tdsaPortContext = (tdsaPortContext_t *)((bitptr)tdSharedMem->tdSharedCachedMem1.virtPtr + sizeof(tdsaRoot_t));
401 tdsaDeviceData = (tdsaDeviceData_t *)((bitptr)tdsaPortContext + (sizeof(tdsaPortContext_t) * TD_MAX_PORT_CONTEXT));
403 /* the following fn fills in MaxTargets */
404 tdssGetMaxTargetsParams(tiRoot, &MaxTargets);
405 TI_DBG6(("tiCOMInit: MaxTargets %d\n", MaxTargets));
408 (tdsaIntCoalesceContext_t *)((bitptr)tdsaDeviceData
409 + (sizeof(tdsaDeviceData_t) * MaxTargets));
412 #elif defined(TD_DISCOVER)
415 /* Let's start from the tdsaRoot */
416 tdsaRoot = tdSharedMem->tdSharedCachedMem1.virtPtr;
417 tdsaPortContext = (tdsaPortContext_t *)((bitptr)tdSharedMem->tdSharedCachedMem1.virtPtr + sizeof(tdsaRoot_t));
418 tdsaDeviceData = (tdsaDeviceData_t *)((bitptr)tdsaPortContext + (sizeof(tdsaPortContext_t) * TD_MAX_PORT_CONTEXT));
420 /* the following fn fills in MaxTargets */
421 tdssGetMaxTargetsParams(tiRoot, &MaxTargets);
422 TI_DBG6(("tiCOMInit: MaxTargets %d\n", MaxTargets));
425 (tdsaExpander_t *)((bitptr)tdsaDeviceData
426 + (sizeof(tdsaDeviceData_t) * MaxTargets));
432 /* Let's start from the tdsaRoot */
433 tdsaRoot = tdSharedMem->tdSharedCachedMem1.virtPtr;
434 tdsaPortContext = (tdsaPortContext_t *)((bitptr)tdSharedMem->tdSharedCachedMem1.virtPtr + sizeof(tdsaRoot_t));
435 tdsaDeviceData = (tdsaDeviceData_t *)((bitptr)tdsaPortContext + (sizeof(tdsaPortContext_t) * TD_MAX_PORT_CONTEXT));
439 TI_DBG6(("tiCOMInit: ******* tdsaRoot %p tdsaPortContext %p tdsaDeviceData %p\n", tdsaRoot, tdsaPortContext, tdsaDeviceData));
442 tiRoot->tdData = tdsaRoot;
443 tdsaAllShared = &(tdsaRoot->tdsaAllShared);
446 #ifdef INITIATOR_DRIVER
447 /**< Initialize initiator; itdssIni_t itself */
448 if(initiatorResource)
450 IniAddr = initiatorResource->initiatorMem.tdCachedMem[0].virtPtr;
451 tdsaRoot->itdsaIni = IniAddr;
452 tdsaRoot->itdsaIni->tdsaAllShared = tdsaAllShared;
453 tdsaAllShared->itdsaIni = tdsaRoot->itdsaIni;
458 /**< Initialize target; ttdssTgt_t itself */
461 TgtAddr = targetResource->targetMem.tdMem[0].virtPtr;
462 tdsaRoot->ttdsaTgt = TgtAddr;
463 tdsaRoot->ttdsaTgt->tdsaAllShared = tdsaAllShared;
464 tdsaAllShared->ttdsaTgt = tdsaRoot->ttdsaTgt;
466 #endif /* target driver */
468 TI_DBG5(("tiCOMInit: IniAddr %p TgtAddr %p\n", IniAddr, TgtAddr));
470 TI_DBG3(("tiCOMInit: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
472 /**< Initialize the OS data part of the interrupt context agRoot */
473 tdsaAllShared->agRootOsDataForInt.tiRoot = tiRoot;
474 tdsaAllShared->agRootOsDataForInt.tdsaAllShared = (void *) tdsaAllShared;
475 tdsaAllShared->agRootOsDataForInt.itdsaIni = (void *) IniAddr;
476 tdsaAllShared->agRootOsDataForInt.ttdsaTgt = (void *) TgtAddr;
478 tdsaAllShared->agRootOsDataForInt.tdstHost = agNULL;
479 tdsaAllShared->agRootOsDataForInt.tdstDevice = agNULL;
481 /* tiInterruptContext is an enum value */
482 tdsaAllShared->agRootOsDataForInt.IntContext = tiInterruptContext;
483 /* queueId or lockid in TD layer; LL maxlock + 1 since TD uses only one lock */
486 tdsaAllShared->agRootInt.osData =
487 (void *) &(tdsaAllShared->agRootOsDataForInt);
488 tdsaAllShared->agRootInt.sdkData = agNULL;
490 /**< Initialize the OS data part of the non-interrupt context agRoot */
491 tdsaAllShared->agRootOsDataForNonInt.tiRoot = tiRoot;
492 tdsaAllShared->agRootOsDataForNonInt.tdsaAllShared = (void *) tdsaAllShared;
493 tdsaAllShared->agRootOsDataForNonInt.itdsaIni = (void *) IniAddr;
494 tdsaAllShared->agRootOsDataForNonInt.ttdsaTgt = (void *) TgtAddr;
496 tdsaAllShared->agRootOsDataForNonInt.tdstHost = agNULL;
497 tdsaAllShared->agRootOsDataForNonInt.tdstDevice = agNULL;
499 tdsaAllShared->agRootOsDataForNonInt.IntContext = tiNonInterruptContext;
500 /* queueId or lockid in TD layer; LL maxlock + 1 since TD uses only one lock */
503 tdsaAllShared->agRootNonInt.osData =
504 (void *) &(tdsaAllShared->agRootOsDataForNonInt);
505 tdsaAllShared->agRootNonInt.sdkData = agNULL;
507 tdsaAllShared->loResource = *loResource;
509 tdsaAllShared->PortContextMem = tdsaPortContext;
510 tdsaAllShared->DeviceMem = tdsaDeviceData;
512 tdsaAllShared->IBQnumber = 0;
513 tdsaAllShared->OBQnumber = 0;
515 #ifdef TD_INT_COALESCE
516 tdsaAllShared->IntCoalesce = tdsaIntCoalCxt;
520 tdsaAllShared->ExpanderHead = tdsaExpander;
523 tdsaAllShared->MaxNumLocks = loResource->loLevelOption.numOfQueuesPerPort;
525 tdsaAllShared->MaxNumOSLocks = loResource->loLevelOption.maxNumOSLocks;
527 #if defined(FDS_DM) && defined(FDS_SM)
528 dmGetRequirements(agNULL,
535 tdsaAllShared->MaxNumDMLocks = dmMaxNumLocks;
536 TI_DBG2(("tiCOMInit: DM MaxNumDMLocks 0x%x\n", tdsaAllShared->MaxNumDMLocks));
538 smGetRequirements(agNULL,
545 tdsaAllShared->MaxNumSMLocks = smMaxNumLocks;
546 TI_DBG2(("tiCOMInit: SM MaxNumSMLocks 0x%x\n", tdsaAllShared->MaxNumSMLocks));
548 tdsaAllShared->MaxNumLLLocks = tdsaAllShared->MaxNumLocks - TD_MAX_LOCKS - tdsaAllShared->MaxNumDMLocks - tdsaAllShared->MaxNumSMLocks;
549 TI_DBG2(("tiCOMInit: LL MaxNumLLLocks 0x%x\n", tdsaAllShared->MaxNumLLLocks));
551 #elif defined(FDS_DM)
552 dmGetRequirements(agNULL,
559 tdsaAllShared->MaxNumDMLocks = dmMaxNumLocks;
560 TI_DBG2(("tiCOMInit: DM MaxNumDMLocks 0x%x\n", tdsaAllShared->MaxNumDMLocks));
562 tdsaAllShared->MaxNumLLLocks = tdsaAllShared->MaxNumLocks - TD_MAX_LOCKS - tdsaAllShared->MaxNumDMLocks;
563 TI_DBG2(("tiCOMInit: LL MaxNumLLLocks 0x%x\n", tdsaAllShared->MaxNumLLLocks));
564 #elif defined(FDS_SM)
565 smGetRequirements(agNULL,
572 tdsaAllShared->MaxNumSMLocks = smMaxNumLocks;
573 TI_DBG2(("tiCOMInit: SM MaxNumSMLocks 0x%x\n", tdsaAllShared->MaxNumSMLocks));
575 tdsaAllShared->MaxNumLLLocks = tdsaAllShared->MaxNumLocks - TD_MAX_LOCKS - tdsaAllShared->MaxNumSMLocks;
576 TI_DBG2(("tiCOMInit: LL MaxNumLLLocks 0x%x\n", tdsaAllShared->MaxNumLLLocks));
578 tdsaAllShared->MaxNumLLLocks = tdsaAllShared->MaxNumLocks - TD_MAX_LOCKS;
579 TI_DBG2(("tiCOMInit: LL MaxNumLLLocks 0x%x\n", tdsaAllShared->MaxNumLLLocks));
583 tdsaAllShared->MaxNumLLLocks = loResource->loLevelOption.numOfQueuesPerPort - TD_MAX_LOCKS;
586 tdsaAllShared->resetCount = 0;
588 /* used for saHwEventAck() and ossaDeregisterDeviceHandleCB() */
589 // tdsaAllShared->EventValid = agFALSE;
590 for(i=0; i<TD_MAX_NUM_PHYS; i++)
592 tdsaAllShared->eventSource[i].EventValid = agFALSE;
593 tdsaAllShared->eventSource[i].Source.agPortContext = agNULL;
594 tdsaAllShared->eventSource[i].Source.event = 0;
596 tdsaAllShared->eventSource[i].Source.param = 0xFF;
600 #ifdef TD_INTERNAL_DEBUG /* for debugging only */
601 pEsglAllInfo = (tdsaEsglAllInfo_t *)&(tdsaAllShared->EsglAllInfo);
604 /* initialize CardIDString */
605 osti_strcpy(tdsaAllShared->CardIDString,"");
609 tdsaAllShared->dmRoot.tdData = tdsaRoot;
613 tdsaAllShared->smRoot.tdData = tdsaRoot;
617 if (tdsaGetCardIDString(tiRoot) == tiError)
619 TI_DBG1(("tdsaGetCardIDString() failed\n"));
623 /**< initializes jumptable */
624 tdsaJumpTableInit(tiRoot);
626 /**< initializes tdsaPortStartInfo_s including flags */
627 tdssInitSASPortStartInfo(tiRoot);
629 /* resets all the relevant flags */
630 tdsaResetComMemFlags(tiRoot);
632 /**< initializes timers */
633 tdsaInitTimers(tiRoot);
635 TI_DBG6(("ticominit: ******* before tdsaRoot %p tdsaPortContext %p tdsaDeviceData %p\n", tdsaRoot, tdsaPortContext, tdsaDeviceData));
638 /**< initializes tdsaPortContext_t */
639 tdsaPortContextInit(tiRoot);
641 /**< initializes devicelist in tdsaPortContext_t */
642 tdsaDeviceDataInit(tiRoot);
644 #ifdef TD_INT_COALESCE
645 tdsaIntCoalCxtInit(tiRoot);
649 tdsaExpanderInit(tiRoot);
652 tdsaQueueConfigInit(tiRoot);
654 #ifdef TD_INTERNAL_DEBUG /* for debugging only */
655 TI_DBG6(("ticominit: temp 1\n"));
656 TDLIST_DEQUEUE_FROM_HEAD(&tdlist_to_fill, &pEsglAllInfo->freelist);
657 /* get the pointer to the page from list pointer */
658 page_to_fill = TDLIST_OBJECT_BASE(tdsaEsglPageInfo_t, tdlist, tdlist_to_fill);
659 TI_DBG6(("ticominit: pageinfo ID %d\n", page_to_fill->id));
660 /* this does not work */
661 TDLIST_ENQUEUE_AT_HEAD(tdlist_to_fill, &pEsglAllInfo->freelist);
663 TI_DBG6(("ticominit: devide\n"));
664 TDLIST_DEQUEUE_FROM_HEAD(&tdlist_to_fill, &pEsglAllInfo->freelist);
665 /* get the pointer to the page from list pointer */
666 page_to_fill = TDLIST_OBJECT_BASE(tdsaEsglPageInfo_t, tdlist, tdlist_to_fill);
667 TDINIT_PRINT("ticominit: second pageinfo ID %d\n", page_to_fill->id);
669 TDLIST_ENQUEUE_AT_HEAD(tdlist_to_fill, &pEsglAllInfo->freelist);
674 #ifdef INITIATOR_DRIVER
675 if(initiatorResource != agNULL)
677 tdsaAllShared->currentOperation |= TD_OPERATION_INITIATOR;
678 TI_DBG5(("tiCOMInit: calling itdssInit\n"));
679 status = itdssInit(tiRoot, initiatorResource, tdSharedMem);
681 if(status != tiSuccess)
683 TI_DBG1(("tiCOMInit: itdInit FAILED\n"));
690 if(targetResource != agNULL)
692 tdsaAllShared->currentOperation |= TD_OPERATION_TARGET;
693 TI_DBG5 (("tiCOMInit: calling ttdssInit\n"));
694 status = ttdssInit(tiRoot, targetResource, tdSharedMem);
696 if(status != tiSuccess)
698 TI_DBG1(("tiCOMInit: ttdInit FAILED\n"));
707 /*****************************************************************************
708 *! \brief tdsaLoLevelGetResource
710 * Purpose: This function is called to determine the Transport
711 * Dependent Layer internal resource requirement used by the
714 * \param tiRoot: Pointer to driver/port instance.
715 * \param loResource: Pointer to low level TSDK resource requirement.
719 * \note - currenlty mem[0] - mem[18] are being used
721 *****************************************************************************/
723 this calls ostiGetTransportParam which parses the configuration file to get
727 tdsaLoLevelGetResource(
729 tiLoLevelResource_t * loResource)
732 bit32 usecsPerTick = 0;
733 agsaSwConfig_t SwConfig;
734 static agsaQueueConfig_t QueueConfig;
735 static agsaMemoryRequirement_t memRequirement;
736 bit32 maxQueueSets = 0;
737 bit32 maxNumOSLocks = 0;
743 char *pLastUsedChar = agNULL;
744 char globalStr[] = "Global";
745 char iniParmsStr[] = "InitiatorParms";
746 char SwParmsStr[] = "SWParms";
747 char OBQueueProps[] = "OBQueueProps";
748 char IBQueueProps[] = "IBQueueProps";
750 static char IBQueueSize[30];
751 static char OBQueueSize[30];
752 static char IBQueueEleSize[30];
753 static char OBQueueEleSize[30];
755 static char OBQueueInterruptCount[30];
756 static char OBQueueInterruptDelay[30];
757 static char OBQueueInterruptEnable[30];
758 static char IBQueuePriority[30];
761 static char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
762 static bit32 InboundQueueSize[AGSA_MAX_OUTBOUND_Q];
763 static bit32 OutboundQueueSize[AGSA_MAX_OUTBOUND_Q];
764 static bit32 InboundQueueEleSize[AGSA_MAX_OUTBOUND_Q];
765 static bit32 OutboundQueueEleSize[AGSA_MAX_OUTBOUND_Q];
766 static bit32 InboundQueuePriority[AGSA_MAX_INBOUND_Q];
767 static bit32 OutboundQueueInterruptDelay[AGSA_MAX_OUTBOUND_Q];
768 static bit32 OutboundQueueInterruptCount[AGSA_MAX_OUTBOUND_Q];
769 static bit32 OutboundQueueInterruptEnable[AGSA_MAX_OUTBOUND_Q];
770 static bit32 cardID = 0;
775 dmSwConfig_t dmSwConfig;
776 static dmMemoryRequirement_t dmMemRequirement;
777 bit32 dmUsecsPerTick = 0;
778 bit32 dmMaxNumLocks = 0;
783 smSwConfig_t smSwConfig;
784 static smMemoryRequirement_t smMemRequirement;
785 bit32 smUsecsPerTick = 0;
786 bit32 smMaxNumLocks = 0;
789 TI_DBG1(("tdsaLoLevelGetResource: start \n"));
790 TI_DBG6(("tdsaLoLevelGetResource: loResource %p\n", loResource));
792 osti_memset(&agRoot, 0, sizeof(agsaRoot_t));
793 osti_memset(&QueueConfig, 0, sizeof(QueueConfig));
794 osti_memset(&memRequirement, 0, sizeof(memRequirement));
795 osti_memset(InboundQueueSize, 0, sizeof(InboundQueueSize));
796 osti_memset(OutboundQueueSize, 0, sizeof(OutboundQueueSize));
797 osti_memset(InboundQueueEleSize, 0, sizeof(InboundQueueEleSize));
798 osti_memset(OutboundQueueEleSize, 0, sizeof(OutboundQueueEleSize));
800 memRequirement.count = 0;
802 /* default values which are overwritten later */
803 /* The followings are default values */
804 SwConfig.maxActiveIOs = DEFAULT_MAX_ACTIVE_IOS;
805 SwConfig.numDevHandles = DEFAULT_MAX_DEV;
806 SwConfig.smpReqTimeout = DEFAULT_SMP_TIMEOUT; /* DEFAULT_VALUE; */
807 SwConfig.numberOfEventRegClients = DEFAULT_NUM_REG_CLIENTS;
808 SwConfig.sizefEventLog1 = HOST_EVENT_LOG_SIZE; /* in KBytes */
809 SwConfig.sizefEventLog2 = HOST_EVENT_LOG_SIZE; /* in KBytes */
810 SwConfig.eventLog1Option = DEFAULT_EVENT_LOG_OPTION;
811 SwConfig.eventLog2Option = DEFAULT_EVENT_LOG_OPTION;
812 SwConfig.fatalErrorInterruptEnable = 1;
813 SwConfig.fatalErrorInterruptVector = 0; /* Was 1 */
814 SwConfig.hostDirectAccessSupport = 0;
815 SwConfig.hostDirectAccessMode = 0;
816 SwConfig.FWConfig = 0;
817 SwConfig.enableDIF = agFALSE;
818 SwConfig.enableEncryption = agFALSE;
820 #ifdef SA_CONFIG_MDFD_REGISTRY
821 SwConfig.disableMDF = agFALSE;
822 #endif /*SA_CONFIG_MDFD_REGISTRY*/
824 #if defined(SALLSDK_DEBUG)
825 SwConfig.sallDebugLevel = 1; /* DEFAULT_VALUE; */
829 #ifdef SA_ENABLE_PCI_TRIGGER
830 SwConfig.PCI_trigger = 0; /* DEFAULT_VALUE; */
831 #endif /* SA_ENABLE_PCI_TRIGGER */
835 dmMemRequirement.count = 0;
836 dmSwConfig.numDevHandles = DEFAULT_MAX_DEV;
838 dmSwConfig.DMDebugLevel = 1;
844 smMemRequirement.count = 0;
845 smSwConfig.maxActiveIOs = DEFAULT_MAX_ACTIVE_IOS;
846 smSwConfig.numDevHandles = DEFAULT_MAX_DEV;
848 smSwConfig.SMDebugLevel = 1;
853 buffLen = sizeof(tmpBuffer);
855 /* param3 points to QueueConfig; tdsaAllShared does not exit at this point yet */
856 SwConfig.param3 = (void *)&QueueConfig;
858 osti_memset(buffer, 0, buffLen);
861 if ((ostiGetTransportParam(
873 ) == tiSuccess) && (lenRecv != 0))
875 if (osti_strncmp(buffer, "0x", 2) == 0)
877 SwConfig.numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 0);
881 SwConfig.numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 10);
883 TI_DBG2(("tdsaLoLevelGetResource: MaxTargets %d\n", SwConfig.numDevHandles));
888 * read the NumInboundQueue parameter
890 osti_memset(buffer, 0, buffLen);
893 QueueConfig.numInboundQueues = DEFAULT_NUM_INBOUND_QUEUE; /* default 1 Inbound queue */
895 if ((ostiGetTransportParam(
898 SwParmsStr, /* subkey1 */
899 agNULL, /* subkey2 */
902 agNULL, /* subkey5 */
903 "NumInboundQueues", /* valueName */
907 ) == tiSuccess) && (lenRecv != 0))
909 if (osti_strncmp(buffer, "0x", 2) == 0)
911 QueueConfig.numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
915 QueueConfig.numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
918 if (QueueConfig.numInboundQueues > AGSA_MAX_INBOUND_Q)
920 QueueConfig.numInboundQueues = AGSA_MAX_INBOUND_Q;
925 * read the NumOutboundQueue parameter
927 osti_memset(buffer, 0, buffLen);
930 QueueConfig.numOutboundQueues = DEFAULT_NUM_OUTBOUND_QUEUE; /* default 1 Outbound queue */
932 if ((ostiGetTransportParam(
935 SwParmsStr, /* subkey1 */
936 agNULL, /* subkey2 */
939 agNULL, /* subkey5 */
940 "NumOutboundQueues", /* valueName */
944 ) == tiSuccess) && (lenRecv != 0))
946 if (osti_strncmp(buffer, "0x", 2) == 0)
948 QueueConfig.numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
952 QueueConfig.numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
955 if (QueueConfig.numOutboundQueues > AGSA_MAX_OUTBOUND_Q)
957 QueueConfig.numOutboundQueues = AGSA_MAX_OUTBOUND_Q;
962 * read the MaxActiveIO parameter
964 osti_memset(buffer, 0, buffLen);
968 if ((ostiGetTransportParam(
971 SwParmsStr, /* subkey1 */
972 agNULL, /* subkey2 */
975 agNULL, /* subkey5 */
976 "MaxActiveIO", /* valueName */
980 ) == tiSuccess) && (lenRecv != 0))
982 if (osti_strncmp(buffer, "0x", 2) == 0)
984 SwConfig.maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 0);
988 SwConfig.maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 10);
995 * read the SMPTO parameter (SMP Timeout)
997 osti_memset(buffer, 0, buffLen);
1000 if ((ostiGetTransportParam(
1002 globalStr, /* key */
1003 SwParmsStr, /* subkey1 */
1004 agNULL, /* subkey2 */
1007 agNULL, /* subkey5 */
1008 "SMPTO", /* valueName */
1012 ) == tiSuccess) && (lenRecv != 0))
1014 if (osti_strncmp(buffer, "0x", 2) == 0)
1016 SwConfig.smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
1020 SwConfig.smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
1025 * read the NumRegClients parameter
1027 osti_memset(buffer, 0, buffLen);
1030 if ((ostiGetTransportParam(
1032 globalStr, /* key */
1033 SwParmsStr, /* subkey1 */
1034 agNULL, /* subkey2 */
1037 agNULL, /* subkey5 */
1038 "NumRegClients", /* valueName */
1042 ) == tiSuccess) && (lenRecv != 0))
1044 if (osti_strncmp(buffer, "0x", 2) == 0)
1046 SwConfig.numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 0);
1050 SwConfig.numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 10);
1054 #if defined(SALLSDK_DEBUG)
1055 osti_memset(buffer, 0, buffLen);
1058 if ((ostiGetTransportParam(
1060 globalStr, /* key */
1061 SwParmsStr, /* subkey1 */
1062 agNULL, /* subkey2 */
1065 agNULL, /* subkey5 */
1066 "LLDebugLevel", /* valueName */
1070 ) == tiSuccess) && (lenRecv != 0))
1072 if (osti_strncmp(buffer, "0x", 2) == 0)
1074 SwConfig.sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
1078 SwConfig.sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
1084 #if defined(DM_DEBUG)
1085 osti_memset(buffer, 0, buffLen);
1088 if ((ostiGetTransportParam(
1090 globalStr, /* key */
1091 SwParmsStr, /* subkey1 */
1092 agNULL, /* subkey2 */
1095 agNULL, /* subkey5 */
1096 "DMDebugLevel", /* valueName */
1100 ) == tiSuccess) && (lenRecv != 0))
1102 if (osti_strncmp(buffer, "0x", 2) == 0)
1104 dmSwConfig.DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
1108 dmSwConfig.DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
1113 #if defined(SM_DEBUG)
1114 osti_memset(buffer, 0, buffLen);
1117 if ((ostiGetTransportParam(
1119 globalStr, /* key */
1120 SwParmsStr, /* subkey1 */
1121 agNULL, /* subkey2 */
1124 agNULL, /* subkey5 */
1125 "SMDebugLevel", /* valueName */
1129 ) == tiSuccess) && (lenRecv != 0))
1131 if (osti_strncmp(buffer, "0x", 2) == 0)
1133 smSwConfig.SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
1137 smSwConfig.SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
1142 osti_memset(buffer, 0, buffLen);
1145 for (i=0;i<QueueConfig.numInboundQueues;i++)
1147 osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
1148 osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
1149 osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
1154 * read the IBQueueSize
1156 osti_memset(buffer, 0, buffLen);
1159 InboundQueueSize[i] = DEFAULT_INBOUND_QUEUE_SIZE; /* default 256 Inbound queue size */
1161 if ((ostiGetTransportParam(
1163 globalStr, /* key */
1164 SwParmsStr, /* subkey1 */
1165 IBQueueProps, /* subkey2 */
1168 agNULL, /* subkey5 */
1169 IBQueueSize, /* valueName */
1173 ) == tiSuccess) && (lenRecv != 0))
1175 if (osti_strncmp(buffer, "0x", 2) == 0)
1177 InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1181 InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1182 TI_DBG6(("tdsaLoLevelGetResource: queue number %d IB queue size %d\n", i, InboundQueueSize[i]));
1188 * read the IBQueueEleSize
1190 osti_memset(buffer, 0, buffLen);
1193 InboundQueueEleSize[i] = DEFAULT_INBOUND_QUEUE_ELE_SIZE; /* default 128 Inbound queue element */
1195 if ((ostiGetTransportParam(
1197 globalStr, /* key */
1198 SwParmsStr, /* subkey1 */
1199 IBQueueProps, /* subkey2 */
1202 agNULL, /* subkey5 */
1203 IBQueueEleSize, /* valueName */
1207 ) == tiSuccess) && (lenRecv != 0))
1209 if (osti_strncmp(buffer, "0x", 2) == 0)
1211 InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1215 InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1216 TI_DBG6(("tdsaLoLevelGetResource: queue number %d IB queue ele size %d\n", i, InboundQueueEleSize[i]));
1221 * read the IBQueuePriority
1224 osti_memset(buffer, 0, buffLen);
1227 InboundQueuePriority[i] = DEFAULT_INBOUND_QUEUE_PRIORITY; /* default 0 Inbound queue priority */
1229 if ((ostiGetTransportParam(
1231 globalStr, /* key */
1232 SwParmsStr, /* subkey1 */
1233 IBQueueProps,/* subkey2 */
1236 agNULL, /* subkey5 */
1237 IBQueuePriority, /* valueName */
1241 ) == tiSuccess) && (lenRecv != 0))
1243 if (osti_strncmp(buffer, "0x", 2) == 0)
1245 InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1249 InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1250 TI_DBG6(("tdsaLoLevelGetResource: queue number %d priority %d\n", i, InboundQueuePriority[i]));
1254 /**********************************************/
1255 osti_memset(buffer, 0, buffLen);
1260 osti_memset(buffer, 0, buffLen);
1263 for (i=0;i<QueueConfig.numOutboundQueues;i++)
1265 osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
1266 osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
1267 osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
1268 osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
1269 osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
1272 * read the OBQueueSize
1274 osti_memset(buffer, 0, buffLen);
1277 OutboundQueueSize[i] = DEFAULT_OUTBOUND_QUEUE_SIZE; /* default 256 Outbound queue size */
1279 if ((ostiGetTransportParam(
1281 globalStr, /* key */
1282 SwParmsStr, /* subkey1 */
1283 OBQueueProps, /* subkey2 */
1286 agNULL, /* subkey5 */
1287 OBQueueSize, /* valueName */
1291 ) == tiSuccess) && (lenRecv != 0))
1293 if (osti_strncmp(buffer, "0x", 2) == 0)
1295 OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1299 OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1300 TI_DBG6(("tdsaLoLevelGetResource: queue number %d OB queue size %d\n", i, OutboundQueueSize[i]));
1306 * read the OBQueueEleSize
1308 osti_memset(buffer, 0, buffLen);
1311 OutboundQueueEleSize[i] = DEFAULT_OUTBOUND_QUEUE_ELE_SIZE; /* default 128 Outbound queue element */
1313 if ((ostiGetTransportParam(
1315 globalStr, /* key */
1316 SwParmsStr, /* subkey1 */
1317 OBQueueProps, /* subkey2 */
1320 agNULL, /* subkey5 */
1321 OBQueueEleSize, /* valueName */
1325 ) == tiSuccess) && (lenRecv != 0))
1327 if (osti_strncmp(buffer, "0x", 2) == 0)
1329 OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1333 OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1334 TI_DBG6(("tdsaLoLevelGetResource: queue number %d OB queue ele size %d\n", i, OutboundQueueEleSize[i]));
1339 * read the OBQueueInterruptDelay
1341 osti_memset(buffer, 0, buffLen);
1344 OutboundQueueInterruptDelay[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_DELAY; /* default 1 Outbound interrupt delay */
1346 if ((ostiGetTransportParam(
1348 globalStr, /* key */
1349 SwParmsStr, /* subkey1 */
1350 OBQueueProps, /* subkey2 */
1353 agNULL, /* subkey5 */
1354 OBQueueInterruptDelay, /* valueName */
1358 ) == tiSuccess) && (lenRecv != 0))
1360 if (osti_strncmp(buffer, "0x", 2) == 0)
1362 OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1366 OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1367 TI_DBG6(("tdsaLoLevelGetResource: queue number %d interrupt delay %d\n", i, OutboundQueueInterruptDelay[i]));
1372 * read the OBQueueInterruptCount
1375 osti_memset(buffer, 0, buffLen);
1378 OutboundQueueInterruptCount[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_COUNT; /* default 1 Outbound interrupt count */
1380 if ((ostiGetTransportParam(
1382 globalStr, /* key */
1383 SwParmsStr, /* subkey1 */
1384 OBQueueProps, /* subkey2 */
1387 agNULL, /* subkey5 */
1388 OBQueueInterruptCount, /* valueName */
1392 ) == tiSuccess) && (lenRecv != 0))
1394 if (osti_strncmp(buffer, "0x", 2) == 0)
1396 OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1400 OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1401 TI_DBG6(("tdsaLoLevelGetResource: queue number %d interrupt count %d\n", i, OutboundQueueInterruptCount[i]));
1406 * read the OBQueueInterruptEnable
1409 osti_memset(buffer, 0, buffLen);
1412 OutboundQueueInterruptEnable[i] = DEFAULT_OUTBOUND_INTERRUPT_ENABLE; /* default 1 Outbound interrupt is enabled */
1414 if ((ostiGetTransportParam(
1416 globalStr, /* key */
1417 SwParmsStr, /* subkey1 */
1418 OBQueueProps, /* subkey2 */
1421 agNULL, /* subkey5 */
1422 OBQueueInterruptEnable, /* valueName */
1426 ) == tiSuccess) && (lenRecv != 0))
1428 if (osti_strncmp(buffer, "0x", 2) == 0)
1430 OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1431 #ifdef SPC_POLLINGMODE
1432 OutboundQueueInterruptEnable[i] = 0;
1433 #endif /* SPC_POLLINGMODE */
1438 OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1439 #ifdef SPC_POLLINGMODE
1440 OutboundQueueInterruptEnable[i] = 0;
1441 #endif /* SPC_POLLINGMODE */
1443 TI_DBG2(("tdsaLoLevelGetResource: queue number %d interrupt enable %d\n", i, OutboundQueueInterruptEnable[i]));
1446 /**********************************************/
1447 osti_memset(buffer, 0, buffLen);
1454 /************************************************************
1455 * READ CARD Specific
1457 osti_memset(buffer, 0, buffLen);
1460 for (i=0;i<QueueConfig.numInboundQueues;i++)
1462 osti_sprintf(CardNum,"CardNum%d", cardID);
1463 osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
1464 osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
1465 osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
1468 * read the IBQueueSize
1470 osti_memset(buffer, 0, buffLen);
1473 if ((ostiGetTransportParam(
1476 SwParmsStr, /* subkey1 */
1477 IBQueueProps, /* subkey2 */
1480 agNULL, /* subkey5 */
1481 IBQueueSize, /* valueName */
1485 ) == tiSuccess) && (lenRecv != 0))
1487 if (osti_strncmp(buffer, "0x", 2) == 0)
1489 InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1493 InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1494 TI_DBG6(("tdsaLoLevelGetResource: queue number %d IB queue size %d\n", i, InboundQueueSize[i]));
1500 * read the IBQueueEleSize
1502 osti_memset(buffer, 0, buffLen);
1505 if ((ostiGetTransportParam(
1508 SwParmsStr, /* subkey1 */
1509 IBQueueProps, /* subkey2 */
1512 agNULL, /* subkey5 */
1513 IBQueueEleSize, /* valueName */
1517 ) == tiSuccess) && (lenRecv != 0))
1519 if (osti_strncmp(buffer, "0x", 2) == 0)
1521 InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1525 InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1526 TI_DBG6(("tdsaLoLevelGetResource: queue number %d IB queue size %d\n", i, InboundQueueEleSize[i]));
1531 * read the IBQueuePriority
1534 osti_memset(buffer, 0, buffLen);
1536 if ((ostiGetTransportParam(
1539 SwParmsStr, /* subkey1 */
1540 IBQueueProps,/* subkey2 */
1543 agNULL, /* subkey5 */
1544 IBQueuePriority, /* valueName */
1548 ) == tiSuccess) && (lenRecv != 0))
1550 if (osti_strncmp(buffer, "0x", 2) == 0)
1552 InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1556 InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1557 TI_DBG6(("tdsaLoLevelGetResource: card number %d queue number %d priority %d\n", cardID, i, InboundQueuePriority[i]));
1561 /**********************************************/
1562 osti_memset(buffer, 0, buffLen);
1568 osti_memset(buffer, 0, buffLen);
1571 for (i=0;i<QueueConfig.numOutboundQueues;i++)
1573 osti_sprintf(CardNum,"CardNum%d", cardID);
1574 osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
1575 osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
1576 osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
1577 osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
1578 osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
1581 * read the OBQueueSize
1583 osti_memset(buffer, 0, buffLen);
1586 if ((ostiGetTransportParam(
1589 SwParmsStr, /* subkey1 */
1590 OBQueueProps, /* subkey2 */
1593 agNULL, /* subkey5 */
1594 OBQueueSize, /* valueName */
1598 ) == tiSuccess) && (lenRecv != 0))
1600 if (osti_strncmp(buffer, "0x", 2) == 0)
1602 OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1606 OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1607 TI_DBG6(("tdsaLoLevelGetResource: queue number %d OB queue size %d\n", i, OutboundQueueSize[i]));
1613 * read the OBQueueEleSize
1615 osti_memset(buffer, 0, buffLen);
1618 if ((ostiGetTransportParam(
1621 SwParmsStr, /* subkey1 */
1622 OBQueueProps, /* subkey2 */
1625 agNULL, /* subkey5 */
1626 OBQueueEleSize, /* valueName */
1630 ) == tiSuccess) && (lenRecv != 0))
1632 if (osti_strncmp(buffer, "0x", 2) == 0)
1634 OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1638 OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1639 TI_DBG6(("tdsaLoLevelGetResource: queue number %d OB queue ele size %d\n", i, OutboundQueueEleSize[i]));
1644 * read the OBQueueInterruptDelay
1646 osti_memset(buffer, 0, buffLen);
1649 if ((ostiGetTransportParam(
1652 SwParmsStr, /* subkey1 */
1653 OBQueueProps, /* subkey2 */
1656 agNULL, /* subkey5 */
1657 OBQueueInterruptDelay, /* valueName */
1661 ) == tiSuccess) && (lenRecv != 0))
1663 if (osti_strncmp(buffer, "0x", 2) == 0)
1665 OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1669 OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1670 TI_DBG6(("tdsaLoLevelGetResource: card number %d queue number %d interrupt delay %d\n", cardID, i, OutboundQueueInterruptDelay[i]));
1675 * read the OBQueueInterruptCount
1678 osti_memset(buffer, 0, buffLen);
1680 if ((ostiGetTransportParam(
1683 SwParmsStr, /* subkey1 */
1684 OBQueueProps, /* subkey2 */
1687 agNULL, /* subkey5 */
1688 OBQueueInterruptCount, /* valueName */
1692 ) == tiSuccess) && (lenRecv != 0))
1694 if (osti_strncmp(buffer, "0x", 2) == 0)
1696 OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1700 OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1701 TI_DBG6(("tdsaLoLevelGetResource: card number %d queue number %d interrupt count %d\n", cardID, i, OutboundQueueInterruptCount[i]));
1706 * read the OBQueueInterruptEnable
1709 osti_memset(buffer, 0, buffLen);
1711 if ((ostiGetTransportParam(
1714 SwParmsStr, /* subkey1 */
1715 OBQueueProps, /* subkey2 */
1718 agNULL, /* subkey5 */
1719 OBQueueInterruptEnable, /* valueName */
1723 ) == tiSuccess) && (lenRecv != 0))
1725 if (osti_strncmp(buffer, "0x", 2) == 0)
1727 OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1728 #ifdef SPC_POLLINGMODE
1729 OutboundQueueInterruptEnable[i] = 0;
1730 #endif /* SPC_POLLINGMODE */
1735 OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1736 #ifdef SPC_POLLINGMODE
1737 OutboundQueueInterruptEnable[i] = 0;
1738 #endif /* SPC_POLLINGMODE */
1740 TI_DBG2(("tdsaLoLevelGetResource: card number %d queue number %d interrupt count %d\n", cardID, i, OutboundQueueInterruptEnable[i]));
1744 /**********************************************/
1745 osti_memset(buffer, 0, buffLen);
1751 TI_DBG6(("tdsaLoLevelGetResource: \n"));
1752 tdsaPrintSwConfig(&SwConfig);
1754 /* fills in queue related parameters */
1755 for (i=0;i<QueueConfig.numInboundQueues;i++)
1757 QueueConfig.inboundQueues[i].elementCount = InboundQueueSize[i];
1758 QueueConfig.inboundQueues[i].elementSize = InboundQueueEleSize[i];
1759 QueueConfig.inboundQueues[i].priority = InboundQueuePriority[i];
1761 for (i=0;i<QueueConfig.numOutboundQueues;i++)
1763 QueueConfig.outboundQueues[i].elementCount = OutboundQueueSize[i];
1764 QueueConfig.outboundQueues[i].elementSize = OutboundQueueEleSize[i];
1765 QueueConfig.outboundQueues[i].interruptDelay = OutboundQueueInterruptDelay[i];
1766 QueueConfig.outboundQueues[i].interruptCount = OutboundQueueInterruptCount[i];
1767 QueueConfig.outboundQueues[i].interruptEnable = OutboundQueueInterruptEnable[i];
1771 /* process event log related parameters */
1772 osti_memset(buffer, 0, buffLen);
1776 if ((ostiGetTransportParam(
1778 globalStr, /* key */
1779 SwParmsStr, /* subkey1 */
1780 agNULL, /* subkey2 */
1783 agNULL, /* subkey5 */
1784 "EventLogSize1", /* valueName */
1788 ) == tiSuccess) && (lenRecv != 0))
1790 if (osti_strncmp(buffer, "0x", 2) == 0)
1792 SwConfig.sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 0);
1796 SwConfig.sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 10);
1800 osti_memset(buffer, 0, buffLen);
1804 if ((ostiGetTransportParam(
1806 globalStr, /* key */
1807 SwParmsStr, /* subkey1 */
1808 agNULL, /* subkey2 */
1811 agNULL, /* subkey5 */
1812 "EventLogOption1", /* valueName */
1816 ) == tiSuccess) && (lenRecv != 0))
1818 if (osti_strncmp(buffer, "0x", 2) == 0)
1820 SwConfig.eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1824 SwConfig.eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1828 osti_memset(buffer, 0, buffLen);
1832 if ((ostiGetTransportParam(
1834 globalStr, /* key */
1835 SwParmsStr, /* subkey1 */
1836 agNULL, /* subkey2 */
1839 agNULL, /* subkey5 */
1840 "EventLogSize2", /* valueName */ /* size in K Dwords */
1844 ) == tiSuccess) && (lenRecv != 0))
1846 if (osti_strncmp(buffer, "0x", 2) == 0)
1848 SwConfig.sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 0);
1852 SwConfig.sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 10);
1856 osti_memset(buffer, 0, buffLen);
1860 if ((ostiGetTransportParam(
1862 globalStr, /* key */
1863 SwParmsStr, /* subkey1 */
1864 agNULL, /* subkey2 */
1867 agNULL, /* subkey5 */
1868 "EventLogOption2", /* valueName */
1872 ) == tiSuccess) && (lenRecv != 0))
1874 if (osti_strncmp(buffer, "0x", 2) == 0)
1876 SwConfig.eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1880 SwConfig.eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1883 /* end of event log related parameters */
1888 osti_memset(buffer, 0, buffLen);
1892 if ((ostiGetTransportParam(
1894 globalStr, /* key */
1895 SwParmsStr, /* subkey1 */
1896 agNULL, /* subkey2 */
1899 agNULL, /* subkey5 */
1900 "HDASupport", /* valueName */
1904 ) == tiSuccess) && (lenRecv != 0))
1906 if (osti_strncmp(buffer, "0x", 2) == 0)
1908 SwConfig.hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 0);
1912 SwConfig.hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 10);
1915 /***********************************************************************/
1916 osti_memset(buffer, 0, buffLen);
1920 if ((ostiGetTransportParam(
1922 globalStr, /* key */
1923 SwParmsStr, /* subkey1 */
1924 agNULL, /* subkey2 */
1927 agNULL, /* subkey5 */
1928 "HDAMode", /* valueName */
1932 ) == tiSuccess) && (lenRecv != 0))
1934 if (osti_strncmp(buffer, "0x", 2) == 0)
1936 SwConfig.hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 0);
1940 SwConfig.hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 10);
1943 /***********************************************************************/
1944 /* the end of HDA parameters */
1947 /* FW configuration */
1948 osti_memset(buffer, 0, buffLen);
1952 if ((ostiGetTransportParam(
1954 globalStr, /* key */
1955 SwParmsStr, /* subkey1 */
1956 agNULL, /* subkey2 */
1959 agNULL, /* subkey5 */
1960 "FWConfig", /* valueName */
1964 ) == tiSuccess) && (lenRecv != 0))
1966 if (osti_strncmp(buffer, "0x", 2) == 0)
1968 SwConfig.FWConfig = osti_strtoul (buffer, &pLastUsedChar, 0);
1972 SwConfig.FWConfig = osti_strtoul (buffer, &pLastUsedChar, 10);
1975 /* The end of FW configuration */
1979 #ifdef SA_ENABLE_TRACE_FUNCTIONS
1981 TI_DBG2(("tdsaLoLevelGetResource: SA_ENABLE_TRACE_FUNCTIONS\n"));
1985 buffLen = sizeof(tmpBuffer);
1987 osti_memset(buffer, 0, buffLen);
1991 SwConfig.TraceBufferSize = 0;
1992 if ((ostiGetTransportParam(
1994 globalStr, /* key */
1995 SwParmsStr, /* subkey1 */
1996 agNULL, /* subkey2 */
1999 agNULL, /* subkey5 */
2000 "TraceBufferSize", /* valueName */
2004 ) == tiSuccess) && (lenRecv != 0))
2006 if (osti_strncmp(buffer, "0x", 2) == 0)
2008 SwConfig.TraceBufferSize = osti_strtoul (buffer, &pLastUsedChar, 0);
2012 SwConfig.TraceBufferSize = osti_strtoul (buffer, &pLastUsedChar, 10);
2014 TI_DBG2(("tdsaLoLevelGetResource: SwConfig.TraceBufferSize %d\n",SwConfig.TraceBufferSize));
2017 #endif /*# SA_ENABLE_TRACE_FUNCTIONS */
2019 SwConfig.mpiContextTable = agNULL;
2020 SwConfig.mpiContextTablelen = 0;
2025 QueueConfig.sasHwEventQueue[i] = 0;
2026 QueueConfig.sataNCQErrorEventQueue[i] = 0;
2029 #ifdef TARGET_DRIVER
2032 QueueConfig.tgtITNexusEventQueue[i] = 0;
2033 QueueConfig.tgtSSPEventQueue[i] = 0;
2034 QueueConfig.tgtSMPEventQueue[i] = 0;
2038 QueueConfig.iqNormalPriorityProcessingDepth = 0;
2039 QueueConfig.iqHighPriorityProcessingDepth = 0;
2040 QueueConfig.generalEventQueue = 0;
2043 * can agRoot be agNULL below? Yes.
2044 * saGetRequirements(agRoot, IN, OUT, OUT, OUT);
2046 saGetRequirements(&agRoot,
2053 dmGetRequirements(&dmRoot,
2074 /* initialization */
2075 maxNumOSLocks = loResource->loLevelOption.maxNumOSLocks;
2077 MAX_LL_LAYER_MEM_DESCRIPTORS is 24. see tidefs.h and tiLoLevelMem_t
2080 #if defined (FDS_DM) && defined (FDS_SM)
2082 TI_DBG1(("tdsaLoLevelGetResource:MAX_LL_LAYER_MEM_DESCRIPTORS %d\n", MAX_LL_LAYER_MEM_DESCRIPTORS));
2083 for(i=0;i<MAX_LL_LAYER_MEM_DESCRIPTORS;i++)
2085 loResource->loLevelMem.mem[i].numElements = 0;
2086 loResource->loLevelMem.mem[i].totalLength = 0;
2087 loResource->loLevelMem.mem[i].singleElementLength = 0;
2088 loResource->loLevelMem.mem[i].alignment = 0;
2089 loResource->loLevelMem.mem[i].type = 0;
2090 loResource->loLevelMem.mem[i].reserved = 0;
2091 loResource->loLevelMem.mem[i].virtPtr = agNULL;
2092 loResource->loLevelMem.mem[i].osHandle = agNULL;
2093 loResource->loLevelMem.mem[i].physAddrUpper = 0;
2094 loResource->loLevelMem.mem[i].physAddrLower = 0;
2097 TI_DBG1(("tdsaLoLevelGetResource:memRequirement.count %d\n", memRequirement.count));
2098 /* using the returned value from saGetRequirements */
2099 for (i=0;i< memRequirement.count;i++)
2101 /* hardcoded values for now */
2102 loResource->loLevelMem.mem[i].numElements = memRequirement.agMemory[i].numElements;
2103 loResource->loLevelMem.mem[i].totalLength = memRequirement.agMemory[i].totalLength;
2104 loResource->loLevelMem.mem[i].singleElementLength = memRequirement.agMemory[i].singleElementLength;
2105 loResource->loLevelMem.mem[i].alignment = memRequirement.agMemory[i].alignment;
2106 TI_DBG2(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2107 if ( AGSA_DMA_MEM == memRequirement.agMemory[i].type )
2109 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2110 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2113 else if ( AGSA_CACHED_MEM == memRequirement.agMemory[i].type )
2115 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2116 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2118 else if ( AGSA_CACHED_DMA_MEM == memRequirement.agMemory[i].type )
2120 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2121 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2126 TI_DBG1(("tdsaLoLevelGetResource:dmMemRequirement.count %d\n", dmMemRequirement.count));
2127 /* using the returned value from dmGetRequirements */
2128 for (i=memRequirement.count;i< (memRequirement.count + dmMemRequirement.count);i++)
2130 /* hardcoded values for now */
2131 loResource->loLevelMem.mem[i].numElements = dmMemRequirement.dmMemory[i-memRequirement.count].numElements;
2132 loResource->loLevelMem.mem[i].totalLength = dmMemRequirement.dmMemory[i-memRequirement.count].totalLength;
2133 loResource->loLevelMem.mem[i].singleElementLength = dmMemRequirement.dmMemory[i-memRequirement.count].singleElementLength;
2134 loResource->loLevelMem.mem[i].alignment = dmMemRequirement.dmMemory[i-memRequirement.count].alignment;
2135 TI_DBG2(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2136 if ( AGSA_DMA_MEM == dmMemRequirement.dmMemory[i-memRequirement.count].type )
2138 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2139 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2142 else if ( AGSA_CACHED_MEM == dmMemRequirement.dmMemory[i-memRequirement.count].type )
2144 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2145 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2147 else if ( AGSA_CACHED_DMA_MEM == dmMemRequirement.dmMemory[i-memRequirement.count].type )
2149 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2150 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2155 TI_DBG1(("tdsaLoLevelGetResource:smMemRequirement.count %d\n", smMemRequirement.count));
2156 /* using the returned value from dmGetRequirements */
2157 for (i=(memRequirement.count + dmMemRequirement.count);i< (memRequirement.count + dmMemRequirement.count + smMemRequirement.count);i++)
2159 /* hardcoded values for now */
2160 loResource->loLevelMem.mem[i].numElements = smMemRequirement.smMemory[i-memRequirement.count-dmMemRequirement.count].numElements;
2161 loResource->loLevelMem.mem[i].totalLength = smMemRequirement.smMemory[i-memRequirement.count-dmMemRequirement.count].totalLength;
2162 loResource->loLevelMem.mem[i].singleElementLength = smMemRequirement.smMemory[i-memRequirement.count-dmMemRequirement.count].singleElementLength;
2163 loResource->loLevelMem.mem[i].alignment = smMemRequirement.smMemory[i-memRequirement.count-dmMemRequirement.count].alignment;
2164 TI_DBG2(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2165 if ( AGSA_DMA_MEM == smMemRequirement.smMemory[i-memRequirement.count-dmMemRequirement.count].type )
2167 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2168 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2171 else if ( AGSA_CACHED_MEM == smMemRequirement.smMemory[i-memRequirement.count-dmMemRequirement.count].type )
2173 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2174 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2176 else if ( AGSA_CACHED_DMA_MEM == smMemRequirement.smMemory[i-memRequirement.count-dmMemRequirement.count].type )
2178 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2179 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2183 /* sets the low level options */
2184 loResource->loLevelOption.usecsPerTick = MIN(MIN(usecsPerTick, dmUsecsPerTick), smUsecsPerTick);
2185 loResource->loLevelOption.numOfQueuesPerPort = maxQueueSets + dmMaxNumLocks + smMaxNumLocks + TD_MAX_LOCKS + maxNumOSLocks;
2186 loResource->loLevelOption.mutexLockUsage = tiOneMutexLockPerQueue;
2188 loResource->loLevelMem.count = memRequirement.count + dmMemRequirement.count + smMemRequirement.count;
2189 /* setting interrupt requirements */
2190 loResource->loLevelOption.maxInterruptVectors = SwConfig.max_MSIX_InterruptVectors;
2191 loResource->loLevelOption.max_MSI_InterruptVectors = SwConfig.max_MSI_InterruptVectors;
2192 loResource->loLevelOption.flag = SwConfig.legacyInt_X;
2193 TI_DBG2(("tdsaLoLevelGetResource: asking maxInterruptVectors(MSIX) %d \n", loResource->loLevelOption.maxInterruptVectors));
2194 TI_DBG2(("tdsaLoLevelGetResource: asking max_MSI_InterruptVectors %d \n", loResource->loLevelOption.max_MSI_InterruptVectors));
2195 TI_DBG2(("tdsaLoLevelGetResource: asking flag - legacyInt_X %d \n", loResource->loLevelOption.flag));
2197 // TI_DBG6(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n",memRequirement.count, loResource->loLevelMem.mem[memRequirement.count].numElements,loResource->loLevelMem.mem[memRequirement.count].totalLength, loResource->loLevelMem.mem[memRequirement.count].singleElementLength,loResource->loLevelMem.mem[memRequirement.count].alignment ));
2198 TI_DBG6(("tdsaLoLevelGetResource: total memRequirement count %d TI_DMA_MEM\n", loResource->loLevelMem.count));
2200 #elif defined(FDS_DM)
2201 TI_DBG1(("tdsaLoLevelGetResource:MAX_LL_LAYER_MEM_DESCRIPTORS %d\n", MAX_LL_LAYER_MEM_DESCRIPTORS));
2202 for(i=0;i<MAX_LL_LAYER_MEM_DESCRIPTORS;i++)
2204 loResource->loLevelMem.mem[i].numElements = 0;
2205 loResource->loLevelMem.mem[i].totalLength = 0;
2206 loResource->loLevelMem.mem[i].singleElementLength = 0;
2207 loResource->loLevelMem.mem[i].alignment = 0;
2208 loResource->loLevelMem.mem[i].type = 0;
2209 loResource->loLevelMem.mem[i].reserved = 0;
2210 loResource->loLevelMem.mem[i].virtPtr = agNULL;
2211 loResource->loLevelMem.mem[i].osHandle = agNULL;
2212 loResource->loLevelMem.mem[i].physAddrUpper = 0;
2213 loResource->loLevelMem.mem[i].physAddrLower = 0;
2216 TI_DBG1(("tdsaLoLevelGetResource:memRequirement.count %d\n", memRequirement.count));
2217 /* using the returned value from saGetRequirements */
2218 for (i=0;i< memRequirement.count;i++)
2220 /* hardcoded values for now */
2221 loResource->loLevelMem.mem[i].numElements = memRequirement.agMemory[i].numElements;
2222 loResource->loLevelMem.mem[i].totalLength = memRequirement.agMemory[i].totalLength;
2223 loResource->loLevelMem.mem[i].singleElementLength = memRequirement.agMemory[i].singleElementLength;
2224 loResource->loLevelMem.mem[i].alignment = memRequirement.agMemory[i].alignment;
2225 TI_DBG2(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2226 if ( AGSA_DMA_MEM == memRequirement.agMemory[i].type )
2228 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2229 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2232 else if ( AGSA_CACHED_MEM == memRequirement.agMemory[i].type )
2234 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2235 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2237 else if ( AGSA_CACHED_DMA_MEM == memRequirement.agMemory[i].type )
2239 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2240 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2244 TI_DBG1(("tdsaLoLevelGetResource:dmMemRequirement.count %d\n", dmMemRequirement.count));
2245 /* using the returned value from dmGetRequirements */
2246 for (i=memRequirement.count;i< (memRequirement.count + dmMemRequirement.count);i++)
2248 /* hardcoded values for now */
2249 loResource->loLevelMem.mem[i].numElements = dmMemRequirement.dmMemory[i-memRequirement.count].numElements;
2250 loResource->loLevelMem.mem[i].totalLength = dmMemRequirement.dmMemory[i-memRequirement.count].totalLength;
2251 loResource->loLevelMem.mem[i].singleElementLength = dmMemRequirement.dmMemory[i-memRequirement.count].singleElementLength;
2252 loResource->loLevelMem.mem[i].alignment = dmMemRequirement.dmMemory[i-memRequirement.count].alignment;
2253 TI_DBG2(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2254 if ( AGSA_DMA_MEM == dmMemRequirement.dmMemory[i-memRequirement.count].type )
2256 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2257 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2260 else if ( AGSA_CACHED_MEM == dmMemRequirement.dmMemory[i-memRequirement.count].type )
2262 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2263 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2265 else if ( AGSA_CACHED_DMA_MEM == dmMemRequirement.dmMemory[i-memRequirement.count].type )
2267 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2268 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2274 /* sets the low level options */
2275 loResource->loLevelOption.usecsPerTick = MIN(usecsPerTick, dmUsecsPerTick);
2276 loResource->loLevelOption.numOfQueuesPerPort = maxQueueSets + dmMaxNumLocks + TD_MAX_LOCKS + maxNumOSLocks;
2277 loResource->loLevelOption.mutexLockUsage = tiOneMutexLockPerQueue;
2279 loResource->loLevelMem.count = memRequirement.count + dmMemRequirement.count;
2280 /* setting interrupt requirements */
2281 loResource->loLevelOption.maxInterruptVectors = SwConfig.max_MSIX_InterruptVectors;
2282 loResource->loLevelOption.max_MSI_InterruptVectors = SwConfig.max_MSI_InterruptVectors;
2283 loResource->loLevelOption.flag = SwConfig.legacyInt_X;
2284 TI_DBG2(("tdsaLoLevelGetResource: asking maxInterruptVectors(MSIX) %d \n", loResource->loLevelOption.maxInterruptVectors));
2285 TI_DBG2(("tdsaLoLevelGetResource: asking max_MSI_InterruptVectors %d \n", loResource->loLevelOption.max_MSI_InterruptVectors));
2286 TI_DBG2(("tdsaLoLevelGetResource: asking flag - legacyInt_X %d \n", loResource->loLevelOption.flag));
2288 // TI_DBG6(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n",memRequirement.count, loResource->loLevelMem.mem[memRequirement.count].numElements,loResource->loLevelMem.mem[memRequirement.count].totalLength, loResource->loLevelMem.mem[memRequirement.count].singleElementLength,loResource->loLevelMem.mem[memRequirement.count].alignment ));
2289 TI_DBG6(("tdsaLoLevelGetResource: total memRequirement count %d TI_DMA_MEM\n", loResource->loLevelMem.count));
2291 #elif defined(FDS_SM)
2292 TI_DBG1(("tdsaLoLevelGetResource:MAX_LL_LAYER_MEM_DESCRIPTORS %d\n", MAX_LL_LAYER_MEM_DESCRIPTORS));
2293 for(i=0;i<MAX_LL_LAYER_MEM_DESCRIPTORS;i++)
2295 loResource->loLevelMem.mem[i].numElements = 0;
2296 loResource->loLevelMem.mem[i].totalLength = 0;
2297 loResource->loLevelMem.mem[i].singleElementLength = 0;
2298 loResource->loLevelMem.mem[i].alignment = 0;
2299 loResource->loLevelMem.mem[i].type = 0;
2300 loResource->loLevelMem.mem[i].reserved = 0;
2301 loResource->loLevelMem.mem[i].virtPtr = agNULL;
2302 loResource->loLevelMem.mem[i].osHandle = agNULL;
2303 loResource->loLevelMem.mem[i].physAddrUpper = 0;
2304 loResource->loLevelMem.mem[i].physAddrLower = 0;
2307 TI_DBG1(("tdsaLoLevelGetResource:memRequirement.count %d\n", memRequirement.count));
2308 /* using the returned value from saGetRequirements */
2309 for (i=0;i< memRequirement.count;i++)
2311 /* hardcoded values for now */
2312 loResource->loLevelMem.mem[i].numElements = memRequirement.agMemory[i].numElements;
2313 loResource->loLevelMem.mem[i].totalLength = memRequirement.agMemory[i].totalLength;
2314 loResource->loLevelMem.mem[i].singleElementLength = memRequirement.agMemory[i].singleElementLength;
2315 loResource->loLevelMem.mem[i].alignment = memRequirement.agMemory[i].alignment;
2316 TI_DBG6(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2317 if ( AGSA_DMA_MEM == memRequirement.agMemory[i].type )
2319 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2320 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2323 else if ( AGSA_CACHED_MEM == memRequirement.agMemory[i].type )
2325 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2326 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2328 else if ( AGSA_CACHED_DMA_MEM == memRequirement.agMemory[i].type )
2330 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2331 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2335 TI_DBG1(("tdsaLoLevelGetResource:smMemRequirement.count %d\n", smMemRequirement.count));
2336 /* using the returned value from smGetRequirements */
2337 for (i=memRequirement.count;i< (memRequirement.count + smMemRequirement.count);i++)
2339 /* hardcoded values for now */
2340 loResource->loLevelMem.mem[i].numElements = smMemRequirement.smMemory[i-memRequirement.count].numElements;
2341 loResource->loLevelMem.mem[i].totalLength = smMemRequirement.smMemory[i-memRequirement.count].totalLength;
2342 loResource->loLevelMem.mem[i].singleElementLength = smMemRequirement.smMemory[i-memRequirement.count].singleElementLength;
2343 loResource->loLevelMem.mem[i].alignment = smMemRequirement.smMemory[i-memRequirement.count].alignment;
2344 TI_DBG6(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2345 if ( AGSA_DMA_MEM == smMemRequirement.smMemory[i-memRequirement.count].type )
2347 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2348 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2351 else if ( AGSA_CACHED_MEM == smMemRequirement.smMemory[i-memRequirement.count].type )
2353 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2354 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2356 else if ( AGSA_CACHED_DMA_MEM == smMemRequirement.smMemory[i-memRequirement.count].type )
2358 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2359 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2365 /* sets the low level options */
2366 loResource->loLevelOption.usecsPerTick = MIN(usecsPerTick, smUsecsPerTick);
2367 loResource->loLevelOption.numOfQueuesPerPort = maxQueueSets + smMaxNumLocks + TD_MAX_LOCKS + maxNumOSLocks;
2368 loResource->loLevelOption.mutexLockUsage = tiOneMutexLockPerQueue;
2370 loResource->loLevelMem.count = memRequirement.count + smMemRequirement.count;
2371 /* setting interrupt requirements */
2372 loResource->loLevelOption.maxInterruptVectors = SwConfig.max_MSIX_InterruptVectors;
2373 loResource->loLevelOption.max_MSI_InterruptVectors = SwConfig.max_MSI_InterruptVectors;
2374 loResource->loLevelOption.flag = SwConfig.legacyInt_X;
2375 TI_DBG2(("tdsaLoLevelGetResource: asking maxInterruptVectors(MSIX) %d \n", loResource->loLevelOption.maxInterruptVectors));
2376 TI_DBG2(("tdsaLoLevelGetResource: asking max_MSI_InterruptVectors %d \n", loResource->loLevelOption.max_MSI_InterruptVectors));
2377 TI_DBG2(("tdsaLoLevelGetResource: asking flag - legacyInt_X %d \n", loResource->loLevelOption.flag));
2379 // TI_DBG6(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n",memRequirement.count, loResource->loLevelMem.mem[memRequirement.count].numElements,loResource->loLevelMem.mem[memRequirement.count].totalLength, loResource->loLevelMem.mem[memRequirement.count].singleElementLength,loResource->loLevelMem.mem[memRequirement.count].alignment ));
2380 TI_DBG6(("tdsaLoLevelGetResource: total memRequirement count %d TI_DMA_MEM\n", loResource->loLevelMem.count));
2384 TI_DBG6(("tdsaLoLevelGetResource:MAX_LL_LAYER_MEM_DESCRIPTORS %d\n", MAX_LL_LAYER_MEM_DESCRIPTORS));
2385 for(i=0;i<MAX_LL_LAYER_MEM_DESCRIPTORS;i++)
2387 loResource->loLevelMem.mem[i].numElements = 0;
2388 loResource->loLevelMem.mem[i].totalLength = 0;
2389 loResource->loLevelMem.mem[i].singleElementLength = 0;
2390 loResource->loLevelMem.mem[i].alignment = 0;
2391 loResource->loLevelMem.mem[i].type = 0;
2392 loResource->loLevelMem.mem[i].reserved = 0;
2393 loResource->loLevelMem.mem[i].virtPtr = agNULL;
2394 loResource->loLevelMem.mem[i].osHandle = agNULL;
2395 loResource->loLevelMem.mem[i].physAddrUpper = 0;
2396 loResource->loLevelMem.mem[i].physAddrLower = 0;
2399 /* using the returned value from saGetRequirements */
2400 for (i=0;i< memRequirement.count;i++)
2402 /* hardcoded values for now */
2403 loResource->loLevelMem.mem[i].numElements = memRequirement.agMemory[i].numElements;
2404 loResource->loLevelMem.mem[i].totalLength = memRequirement.agMemory[i].totalLength;
2405 loResource->loLevelMem.mem[i].singleElementLength = memRequirement.agMemory[i].singleElementLength;
2406 loResource->loLevelMem.mem[i].alignment = memRequirement.agMemory[i].alignment;
2407 TI_DBG6(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].numElements, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].singleElementLength,loResource->loLevelMem.mem[i].alignment ));
2408 if ( AGSA_DMA_MEM == memRequirement.agMemory[i].type )
2410 loResource->loLevelMem.mem[i].type = TI_DMA_MEM;
2411 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_DMA_MEM\n", i));
2414 else if ( AGSA_CACHED_MEM == memRequirement.agMemory[i].type )
2416 loResource->loLevelMem.mem[i].type = TI_CACHED_MEM;
2417 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_MEM\n", i));
2419 else if ( AGSA_CACHED_DMA_MEM == memRequirement.agMemory[i].type )
2421 loResource->loLevelMem.mem[i].type = TI_CACHED_DMA_MEM;
2422 TI_DBG6(("tdsaLoLevelGetResource: index %d TI_CACHED_DMA_MEM\n", i));
2428 /* sets the low level options */
2429 loResource->loLevelOption.usecsPerTick = usecsPerTick;
2430 loResource->loLevelOption.numOfQueuesPerPort = maxQueueSets + TD_MAX_LOCKS + maxNumOSLocks;
2431 loResource->loLevelOption.mutexLockUsage = tiOneMutexLockPerQueue;
2433 loResource->loLevelMem.count = memRequirement.count;
2434 /* setting interrupt requirements */
2435 loResource->loLevelOption.maxInterruptVectors = SwConfig.max_MSIX_InterruptVectors;
2436 loResource->loLevelOption.max_MSI_InterruptVectors = SwConfig.max_MSI_InterruptVectors;
2437 loResource->loLevelOption.flag = SwConfig.legacyInt_X;
2438 TI_DBG2(("tdsaLoLevelGetResource: asking maxInterruptVectors(MSIX) %d \n", loResource->loLevelOption.maxInterruptVectors));
2439 TI_DBG2(("tdsaLoLevelGetResource: asking max_MSI_InterruptVectors %d \n", loResource->loLevelOption.max_MSI_InterruptVectors));
2440 TI_DBG2(("tdsaLoLevelGetResource: asking flag - legacyInt_X %d \n", loResource->loLevelOption.flag));
2442 TI_DBG6(("tdsaLoLevelGetResource: index %d numElements %d totalLength %d singleElementLength %d alignment %d\n",memRequirement.count, loResource->loLevelMem.mem[memRequirement.count].numElements,loResource->loLevelMem.mem[memRequirement.count].totalLength, loResource->loLevelMem.mem[memRequirement.count].singleElementLength,loResource->loLevelMem.mem[memRequirement.count].alignment ));
2443 TI_DBG6(("tdsaLoLevelGetResource: memRequirement.count %d TI_DMA_MEM\n", memRequirement.count));
2451 /*****************************************************************************
2452 *! \brief tdsaSharedMemCalculate
2454 * Purpose: This function is called to determine the Transport
2455 * Dependent Layer internal resource requirement
2456 * for shared memory between target and initiator
2459 * \param tiRoot: Pointer to driver/port instance.
2460 * \param tdSharedMem: Pointer to shared memory structure
2464 * \note - The shared memory is composed of like the followings
2465 * sizeof(tdsaRoot_t)
2466 * + sizeof(tdsaPortContext_t) * TD_MAX_PORT_CONTEXT
2467 * + sizeof(tdsaDeviceData_t) * MaxTargets
2468 * + sizeof(tdsaEsglPageInfo_t) * NumEsglPages
2470 *****************************************************************************/
2472 tdsaSharedMemCalculate(
2474 tiLoLevelResource_t * loResource,
2475 tiTdSharedMem_t * tdSharedMem
2480 /* the following fn fills in MaxTargets */
2481 tdssGetMaxTargetsParams(tiRoot, &MaxTargets);
2482 TI_DBG6(("tdsaSharedMemCalculate: MaxTargets %d\n", MaxTargets));
2485 * Cached mem for the shared TD Layer functionality
2487 tdSharedMem->tdSharedCachedMem1.singleElementLength =
2488 sizeof(tdsaRoot_t) + (sizeof(tdsaPortContext_t) * TD_MAX_PORT_CONTEXT) +
2489 (sizeof(tdsaDeviceData_t) * MaxTargets);
2491 #ifdef TD_INT_COALESCE
2492 /* adding TD interrupt coalesce data structure to the shared TD layer */
2493 /* TD_MAX_INT_COALESCE is defined to be 512 */
2494 tdSharedMem->tdSharedCachedMem1.singleElementLength +=
2495 sizeof(tdsaIntCoalesceContext_t) * TD_MAX_INT_COALESCE;
2499 /* adding expander data strutures */
2500 tdSharedMem->tdSharedCachedMem1.singleElementLength +=
2501 sizeof(tdsaExpander_t) * MaxTargets;
2504 tdSharedMem->tdSharedCachedMem1.numElements = 1;
2506 tdSharedMem->tdSharedCachedMem1.totalLength =
2507 tdSharedMem->tdSharedCachedMem1.singleElementLength *
2508 tdSharedMem->tdSharedCachedMem1.numElements;
2510 tdSharedMem->tdSharedCachedMem1.alignment = 8;
2512 tdSharedMem->tdSharedCachedMem1.type = TI_CACHED_MEM;
2514 tdSharedMem->tdSharedCachedMem1.virtPtr = agNULL;
2515 tdSharedMem->tdSharedCachedMem1.osHandle = agNULL;
2516 tdSharedMem->tdSharedCachedMem1.physAddrUpper = 0;
2517 tdSharedMem->tdSharedCachedMem1.physAddrLower = 0;
2518 tdSharedMem->tdSharedCachedMem1.reserved = 0;
2524 /*****************************************************************************
2525 *! \biref tdResetComMemFlags
2527 * Purpose: This function is called to reset all the flags for the port
2529 * \param tiRoot: Pointer to driver/port instance.
2534 *****************************************************************************/
2536 tdsaResetComMemFlags(
2540 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2541 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2542 #ifdef TD_DEBUG_ENABLE
2543 tdsaPortContext_t *tdsaPortContext = (tdsaPortContext_t *)tdsaAllShared->PortContextMem;
2544 TI_DBG6(("tdsaResetComMemFlags: start\n"));
2545 TI_DBG6(("tdsaResetComMemFlag:: ******* tdsaRoot %p \n", tdsaRoot));
2546 TI_DBG6(("tdsaResetComMemFlag:: ******* tdsaPortContext %p \n",tdsaPortContext));
2549 tdsaAllShared->flags.sysIntsActive = agFALSE;
2550 tdsaAllShared->flags.resetInProgress = agFALSE;
2555 /*****************************************************************************
2556 *! \biref tdssInitSASPortStartInfo
2558 * Purpose: This function sets information related to staring a port
2560 * \param tiRoot: Pointer to driver/port instance.
2565 *****************************************************************************/
2567 tdssInitSASPortStartInfo(
2571 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2572 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2574 #ifdef TD_DEBUG_ENABLE
2575 tdsaPortContext_t *tdsaPortContext = (tdsaPortContext_t *)tdsaAllShared->PortContextMem;
2576 TI_DBG6(("tdssInitSASPortStartInfo: start\n"));
2578 TI_DBG6(("tdssInitSASPortStartInfo: ******* tdsaRoot %p \n", tdsaRoot));
2579 TI_DBG6(("tdssInitSASPortStartInfo: ******* tdsaPortContext %p \n",tdsaPortContext));
2582 for(i=0;i<TD_MAX_NUM_PHYS;i++)
2584 tdsaAllShared->Ports[i].tiPortalContext = agNULL;
2585 tdsaAllShared->Ports[i].portContext = agNULL;
2586 tdsaAllShared->Ports[i].SASID.sasAddressHi[0] = 0;
2587 tdsaAllShared->Ports[i].SASID.sasAddressHi[1] = 0;
2588 tdsaAllShared->Ports[i].SASID.sasAddressHi[2] = 0;
2589 tdsaAllShared->Ports[i].SASID.sasAddressHi[3] = 0;
2590 tdsaAllShared->Ports[i].SASID.sasAddressLo[0] = 0;
2591 tdsaAllShared->Ports[i].SASID.sasAddressLo[1] = 0;
2592 tdsaAllShared->Ports[i].SASID.sasAddressLo[2] = 0;
2593 tdsaAllShared->Ports[i].SASID.sasAddressLo[3] = 0;
2594 tdsaAllShared->Ports[i].SASID.phyIdentifier = (bit8) i;
2597 tdsaAllShared->Ports[i].flags.portStarted = agFALSE;
2598 tdsaAllShared->Ports[i].flags.portInitialized = agFALSE;
2599 tdsaAllShared->Ports[i].flags.portReadyForDiscoverySent = agFALSE;
2600 tdsaAllShared->Ports[i].flags.portStoppedByOSLayer = agFALSE;
2601 tdsaAllShared->Ports[i].flags.failPortInit = agFALSE;
2608 /*****************************************************************************
2609 *! \brief tdsaInitTimers
2611 * Purpose: This function is called to initialize the timers
2614 * \param tiRoot: pointer to the driver instance
2620 *****************************************************************************/
2627 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2628 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2629 #ifdef TD_DEBUG_ENABLE
2630 tdsaPortContext_t *tdsaPortContext = (tdsaPortContext_t *)tdsaAllShared->PortContextMem;
2632 TI_DBG6(("tdsaInitTimers: start \n"));
2633 TI_DBG6(("tdsaInitTimers: ******* tdsaRoot %p \n", tdsaRoot));
2634 TI_DBG6(("tdsaInitTimers: ******* tdsaPortContext %p \n",tdsaPortContext));
2637 /* initialize the timerlist */
2638 TDLIST_INIT_HDR(&(tdsaAllShared->timerlist));
2644 /*****************************************************************************
2645 *! \brief tdsaJumpTableInit
2647 * Purpose: This function initializes SAS related callback functions
2649 * \param tiRoot: pointer to the driver instance
2655 *****************************************************************************/
2662 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2663 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2664 #ifdef TD_DEBUG_ENABLE
2665 tdsaPortContext_t *tdsaPortContext = (tdsaPortContext_t *)tdsaAllShared->PortContextMem;
2667 TI_DBG6(("tdsaJumpTableInit: start \n"));
2668 TI_DBG6(("tdsaJumpTableInit:: ******* tdsaRoot %p \n", tdsaRoot));
2669 TI_DBG6(("tdsaJumpTableInit:: ******* tdsaPortContext %p \n",tdsaPortContext));
2675 pSSPIOCompleted, pSMPCompleted; use callback
2676 pSSPReqReceive, pSMPReqReceived; use jumptable
2679 #ifdef INITIATOR_DRIVER
2680 tdsaAllShared->tdJumpTable.pSSPIOCompleted = agNULL; /* initiator */
2681 tdsaAllShared->tdJumpTable.pSMPCompleted =agNULL; /* initiator */
2683 #ifdef TARGET_DRIVER
2684 tdsaAllShared->tdJumpTable.pSSPIOCompleted = agNULL;
2685 tdsaAllShared->tdJumpTable.pSSPReqReceived = &ttdsaSSPReqReceived;
2686 tdsaAllShared->tdJumpTable.pSMPReqReceived = &ttdsaSMPReqReceived;
2687 tdsaAllShared->tdJumpTable.pSMPCompleted =agNULL;
2689 tdsaAllShared->tdJumpTable.pGetSGLChunk = agNULL;
2695 /*****************************************************************************
2696 *! \brief tdsaPortContextInit
2698 * Purpose: This function initializes port contexts.
2700 * \param tiRoot: pointer to the driver instance
2706 *****************************************************************************/
2708 tdsaPortContextInit(
2712 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2713 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2714 tdsaPortContext_t *tdsaPortContext = (tdsaPortContext_t *)tdsaAllShared->PortContextMem;
2718 TI_DBG6(("tdsaPortContextInit: start\n"));
2719 TI_DBG6(("tdsaPortContextInit: ******* sizeof(tdsaPortContext) %d %x\n", (int)sizeof(tdsaPortContext_t), (unsigned int)sizeof(tdsaPortContext_t)));
2720 TI_DBG6(("tdsaPortContextInit: ******* tdsaRoot %p \n", tdsaRoot));
2721 TI_DBG6(("tdsaPortContextInit: ******* tdsaPortContext %p \n",tdsaPortContext));
2722 TI_DBG6(("tdsaPortContextInit: ******* tdsaPortContext+1 %p \n",tdsaPortContext + 1));
2723 TI_DBG6(("tdsaPortContextInit: ******* &tdsaPortContext[0] %p &tdsaPortContext[1] %p\n", &(tdsaPortContext[0]), &(tdsaPortContext[1])));
2725 TDLIST_INIT_HDR(&(tdsaAllShared->MainPortContextList));
2726 TDLIST_INIT_HDR(&(tdsaAllShared->FreePortContextList));
2728 for(i=0;i<TD_MAX_PORT_CONTEXT;i++)
2730 TDLIST_INIT_ELEMENT(&(tdsaPortContext[i].FreeLink));
2731 TDLIST_INIT_ELEMENT(&(tdsaPortContext[i].MainLink));
2734 TDLIST_INIT_HDR(&(tdsaPortContext[i].discovery.discoveringExpanderList));
2735 TDLIST_INIT_HDR(&(tdsaPortContext[i].discovery.UpdiscoveringExpanderList));
2736 tdsaPortContext[i].discovery.type = TDSA_DISCOVERY_OPTION_FULL_START;
2737 tdsaInitTimerRequest(tiRoot, &(tdsaPortContext[i].discovery.discoveryTimer));
2738 tdsaInitTimerRequest(tiRoot, &(tdsaPortContext[i].discovery.configureRouteTimer));
2739 tdsaInitTimerRequest(tiRoot, &(tdsaPortContext[i].discovery.deviceRegistrationTimer));
2740 tdsaInitTimerRequest(tiRoot, &(tdsaPortContext[i].discovery.SMPBusyTimer));
2741 tdsaInitTimerRequest(tiRoot, &(tdsaPortContext[i].discovery.BCTimer));
2742 tdsaInitTimerRequest(tiRoot, &(tdsaPortContext[i].discovery.DiscoverySMPTimer));
2743 tdsaPortContext[i].discovery.retries = 0;
2744 tdsaPortContext[i].discovery.configureRouteRetries = 0;
2745 tdsaPortContext[i].discovery.deviceRetistrationRetries = 0;
2746 tdsaPortContext[i].discovery.pendingSMP = 0;
2747 tdsaPortContext[i].discovery.SeenBC = agFALSE;
2748 tdsaPortContext[i].discovery.forcedOK = agFALSE;
2749 tdsaPortContext[i].discovery.SMPRetries = 0;
2750 // tdsaPortContext[i].discovery.doIncremental = agFALSE;
2751 tdsaPortContext[i].discovery.ResetTriggerred = agFALSE;
2755 #ifdef INITIATOR_DRIVER
2756 tdsaPortContext[i].DiscoveryState = ITD_DSTATE_NOT_STARTED;
2757 tdsaPortContext[i].nativeSATAMode = agFALSE;
2758 tdsaPortContext[i].directAttatchedSAS = agFALSE;
2759 tdsaPortContext[i].DiscoveryRdyGiven = agFALSE;
2760 tdsaPortContext[i].SeenLinkUp = agFALSE;
2763 tdsaPortContext[i].id = i;
2764 tdsaPortContext[i].agPortContext = agNULL;
2765 tdsaPortContext[i].LinkRate = 0;
2766 tdsaPortContext[i].Count = 0;
2767 tdsaPortContext[i].valid = agFALSE;
2768 for (j=0;j<TD_MAX_NUM_PHYS;j++)
2770 tdsaPortContext[i].PhyIDList[j] = agFALSE;
2772 tdsaPortContext[i].RegisteredDevNums = 0;
2773 tdsaPortContext[i].eventPhyID = 0xFF;
2774 tdsaPortContext[i].Transient = agFALSE;
2775 tdsaPortContext[i].PortRecoverPhyID = 0xFF;
2776 tdsaPortContext[i].DiscFailNSeenBC = agFALSE;
2778 tdsaPortContext[i].dmPortContext.tdData = &(tdsaPortContext[i]);
2779 tdsaPortContext[i].DMDiscoveryState = dmDiscCompleted;
2780 tdsaPortContext[i].UseDM = agFALSE;
2781 tdsaPortContext[i].UpdateMCN = agFALSE;
2783 /* add more variables later */
2784 TDLIST_ENQUEUE_AT_TAIL(&(tdsaPortContext[i].FreeLink), &(tdsaAllShared->FreePortContextList));
2787 #ifdef TD_INTERNAL_DEBUG /* for debugging only */
2788 for(i=0;i<TD_MAX_PORT_CONTEXT;i++)
2790 TI_DBG6(("tdsaPortContextInit: index %d &tdsaPortContext[] %p\n", i, &(tdsaPortContext[i])));
2792 TI_DBG6(("tdsaPortContextInit: sizeof(tdsaPortContext_t) %d 0x%x\n", sizeof(tdsaPortContext_t), sizeof(tdsaPortContext_t)));
2797 /*****************************************************************************
2798 *! \brief tdsaPortContextReInit
2800 * Purpose: This function re-initializes port contexts for reuse.
2802 * \param tiRoot: pointer to the driver instance
2803 * \param onePortContext: pointer to the portcontext
2809 *****************************************************************************/
2811 tdsaPortContextReInit(
2813 tdsaPortContext_t *onePortContext
2818 tdsaDiscovery_t *discovery;
2821 TI_DBG3(("tdsaPortContextReInit: start\n"));
2824 discovery = &(onePortContext->discovery);
2826 onePortContext->discovery.type = TDSA_DISCOVERY_OPTION_FULL_START;
2827 onePortContext->discovery.retries = 0;
2828 onePortContext->discovery.configureRouteRetries = 0;
2829 onePortContext->discovery.deviceRetistrationRetries = 0;
2830 onePortContext->discovery.pendingSMP = 0;
2831 onePortContext->discovery.SeenBC = agFALSE;
2832 onePortContext->discovery.forcedOK = agFALSE;
2833 onePortContext->discovery.SMPRetries = 0;
2834 onePortContext->discovery.ResetTriggerred = agFALSE;
2835 /* free expander lists */
2836 tdsaFreeAllExp(tiRoot, onePortContext);
2837 /* kill the discovery-related timers if they are running */
2838 if (discovery->discoveryTimer.timerRunning == agTRUE)
2842 &discovery->discoveryTimer
2845 if (discovery->configureRouteTimer.timerRunning == agTRUE)
2849 &discovery->configureRouteTimer
2852 if (discovery->deviceRegistrationTimer.timerRunning == agTRUE)
2856 &discovery->deviceRegistrationTimer
2859 if (discovery->BCTimer.timerRunning == agTRUE)
2866 if (discovery->SMPBusyTimer.timerRunning == agTRUE)
2870 &discovery->SMPBusyTimer
2873 if (discovery->DiscoverySMPTimer.timerRunning == agTRUE)
2877 &discovery->DiscoverySMPTimer
2882 #ifdef INITIATOR_DRIVER
2883 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED;
2884 onePortContext->nativeSATAMode = agFALSE;
2885 onePortContext->directAttatchedSAS = agFALSE;
2886 onePortContext->DiscoveryRdyGiven = agFALSE;
2887 onePortContext->SeenLinkUp = agFALSE;
2889 onePortContext->agPortContext->osData = agNULL;
2890 onePortContext->agPortContext = agNULL;
2891 onePortContext->tiPortalContext = agNULL;
2892 onePortContext->agRoot = agNULL;
2893 onePortContext->LinkRate = 0;
2894 onePortContext->Count = 0;
2895 onePortContext->valid = agFALSE;
2896 for (j=0;j<TD_MAX_NUM_PHYS;j++)
2898 onePortContext->PhyIDList[j] = agFALSE;
2900 onePortContext->RegisteredDevNums = 0;
2901 onePortContext->eventPhyID = 0xFF;
2902 onePortContext->Transient = agFALSE;
2903 onePortContext->PortRecoverPhyID = 0xFF;
2904 onePortContext->DiscFailNSeenBC = agFALSE;
2907 onePortContext->dmPortContext.tdData = onePortContext;
2908 onePortContext->DMDiscoveryState = dmDiscCompleted;
2909 onePortContext->UseDM = agFALSE;
2910 onePortContext->UpdateMCN = agFALSE;
2915 /*****************************************************************************
2916 *! \brief tdsaDeviceDataInit
2918 * Purpose: This function initializes devices
2920 * \param tiRoot: pointer to the driver instance
2926 *****************************************************************************/
2932 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2933 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
2934 #ifdef TD_DEBUG_ENABLE
2935 tdsaPortContext_t *tdsaPortContext = (tdsaPortContext_t *)tdsaAllShared->PortContextMem;
2937 tdsaDeviceData_t *tdsaDeviceData =
2938 (tdsaDeviceData_t *)tdsaAllShared->DeviceMem;
2942 satInternalIo_t *satIntIO;
2946 TI_DBG6(("tdsaDeviceDataInit: start\n"));
2947 TI_DBG6(("tdsaDeviceDataInit: ******* tdsaPortContext %p \n",tdsaPortContext));
2948 TI_DBG6(("tdsaDeviceDataInit: ******* tdsaDeviceData %p\n", tdsaDeviceData));
2949 TI_DBG6(("tdsaDeviceDataInit: ******* tdsaDeviceData+1 %p\n", tdsaDeviceData+1));
2950 TI_DBG6(("tdsaDeviceDataInit: ******* &tdsaDeviceData[0] %p &tdsaDeviceData[1] %p\n", &(tdsaDeviceData[0]), &(tdsaDeviceData[1])));
2952 /* the following fn fills in MaxTargets */
2953 tdssGetMaxTargetsParams(tiRoot, &MaxTargets);
2954 TI_DBG6(("tdsaDeviceDataInit: MaxTargets %d\n", MaxTargets));
2956 TDLIST_INIT_HDR(&(tdsaAllShared->MainDeviceList));
2957 TDLIST_INIT_HDR(&(tdsaAllShared->FreeDeviceList));
2959 for(i=0;i<(int)MaxTargets;i++)
2961 TDLIST_INIT_ELEMENT(&(tdsaDeviceData[i].FreeLink));
2962 TDLIST_INIT_ELEMENT(&(tdsaDeviceData[i].MainLink));
2963 TDLIST_INIT_ELEMENT(&(tdsaDeviceData[i].IncDisLink));
2964 tdsaDeviceData[i].id = i;
2965 tdsaDeviceData[i].InQID = 0;
2966 tdsaDeviceData[i].OutQID = 0;
2967 tdsaDeviceData[i].DeviceType = TD_DEFAULT_DEVICE;
2968 tdsaDeviceData[i].agRoot = agNULL;
2969 tdsaDeviceData[i].agDevHandle = agNULL;
2971 tdsaDeviceData[i].pJumpTable = &(tdsaAllShared->tdJumpTable);
2972 tdsaDeviceData[i].tiDeviceHandle.osData = agNULL;
2973 tdsaDeviceData[i].tiDeviceHandle.tdData = &(tdsaDeviceData[i]);
2974 tdsaDeviceData[i].tdPortContext = agNULL;
2975 tdsaDeviceData[i].tdExpander = agNULL;
2976 tdsaDeviceData[i].ExpDevice = agNULL;
2977 tdsaDeviceData[i].phyID = 0xFF;
2978 tdsaDeviceData[i].SASAddressID.sasAddressHi = 0;
2979 tdsaDeviceData[i].SASAddressID.sasAddressLo = 0;
2980 tdsaDeviceData[i].valid = agFALSE;
2981 tdsaDeviceData[i].valid2 = agFALSE;
2982 tdsaDeviceData[i].processed = agFALSE;
2983 tdsaDeviceData[i].initiator_ssp_stp_smp = 0;
2984 tdsaDeviceData[i].target_ssp_stp_smp = 0;
2985 tdsaDeviceData[i].numOfPhys = 0;
2986 tdsaDeviceData[i].registered = agFALSE;
2987 tdsaDeviceData[i].directlyAttached = agFALSE;
2988 tdsaDeviceData[i].SASSpecDeviceType = 0xFF;
2989 tdsaDeviceData[i].IOStart = 0;
2990 tdsaDeviceData[i].IOResponse = 0;
2991 tdsaDeviceData[i].agDeviceResetContext.osData = agNULL;
2992 tdsaDeviceData[i].agDeviceResetContext.sdkData = agNULL;
2993 tdsaDeviceData[i].TRflag = agFALSE;
2994 tdsaDeviceData[i].ResetCnt = 0;
2995 tdsaDeviceData[i].OSAbortAll = agFALSE;
2998 tdsaDeviceData[i].devMCN = 1;
2999 tdsaDeviceData[i].finalMCN = 1;
3003 tdsaDeviceData[i].SMNumOfFCA = 0;
3004 tdsaDeviceData[i].SMNumOfID = 0;
3008 TDLIST_INIT_HDR(&(tdsaDeviceData[i].satDevData.satIoLinkList));
3009 TDLIST_INIT_HDR(&(tdsaDeviceData[i].satDevData.satFreeIntIoLinkList));
3010 TDLIST_INIT_HDR(&(tdsaDeviceData[i].satDevData.satActiveIntIoLinkList));
3013 tdsaDeviceData[i].satDevData.satDriveState = SAT_DEV_STATE_NORMAL;
3014 tdsaDeviceData[i].satDevData.satNCQMaxIO =SAT_NCQ_MAX;
3015 tdsaDeviceData[i].satDevData.satPendingIO = 0;
3016 tdsaDeviceData[i].satDevData.satPendingNCQIO = 0;
3017 tdsaDeviceData[i].satDevData.satPendingNONNCQIO = 0;
3018 tdsaDeviceData[i].satDevData.IDDeviceValid = agFALSE;
3019 tdsaDeviceData[i].satDevData.freeSATAFDMATagBitmap = 0;
3020 tdsaDeviceData[i].satDevData.NumOfFCA = 0;
3021 tdsaDeviceData[i].satDevData.NumOfIDRetries = 0;
3022 tdsaDeviceData[i].satDevData.ID_Retries = 0;
3023 tdsaDeviceData[i].satDevData.IDPending = agFALSE;
3024 tdsaInitTimerRequest(tiRoot, &(tdsaDeviceData[i].SATAIDDeviceTimer));
3026 tdsaInitTimerRequest(tiRoot, &(tdsaDeviceData[i].tdIDTimer));
3028 osti_memset(tdsaDeviceData[i].satDevData.satMaxLBA, 0, sizeof(tdsaDeviceData[i].satDevData.satMaxLBA));
3030 tdsaDeviceData[i].satDevData.satSaDeviceData = &tdsaDeviceData[i];
3031 satIntIO = &tdsaDeviceData[i].satDevData.satIntIo[0];
3032 for (j = 0; j < SAT_MAX_INT_IO; j++)
3034 TDLIST_INIT_ELEMENT (&satIntIO->satIntIoLink);
3035 TDLIST_ENQUEUE_AT_TAIL (&satIntIO->satIntIoLink,
3036 &tdsaDeviceData[i].satDevData.satFreeIntIoLinkList);
3037 satIntIO->satOrgTiIORequest = agNULL;
3039 satIntIO = satIntIO + 1;
3042 /* some other variables */
3043 TDLIST_ENQUEUE_AT_TAIL(&(tdsaDeviceData[i].FreeLink), &(tdsaAllShared->FreeDeviceList));
3046 #ifdef TD_INTERNAL_DEBUG /* for debugging only */
3047 for(i=0;i<MaxTargets;i++)
3049 TI_DBG6(("tdsaDeviceDataInit: index %d &tdsaDeviceData[] %p\n", i, &(tdsaDeviceData[i])));
3052 TI_DBG6(("tdsaDeviceDataInit: sizeof(tdsaDeviceData_t) %d 0x%x\n", sizeof(tdsaDeviceData_t), sizeof(tdsaDeviceData_t)));
3057 /*****************************************************************************
3058 *! \brief tdsaDeviceDataReInit
3060 * Purpose: This function re-initializes device data for reuse.
3062 * \param tiRoot: pointer to the driver instance
3063 * \param onePortContext: pointer to the device data
3069 *****************************************************************************/
3071 tdsaDeviceDataReInit(
3073 tdsaDeviceData_t *oneDeviceData
3076 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3077 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3080 satInternalIo_t *satIntIO;
3083 TI_DBG3(("tdsaDeviceDataReInit: start\n"));
3085 oneDeviceData->InQID = 0;
3086 oneDeviceData->OutQID = 0;
3087 oneDeviceData->DeviceType = TD_DEFAULT_DEVICE;
3088 oneDeviceData->agDevHandle = agNULL;
3090 oneDeviceData->pJumpTable = &(tdsaAllShared->tdJumpTable);
3091 oneDeviceData->tiDeviceHandle.osData = agNULL;
3092 oneDeviceData->tiDeviceHandle.tdData = oneDeviceData;
3093 oneDeviceData->tdPortContext = agNULL;
3094 oneDeviceData->tdExpander = agNULL;
3095 oneDeviceData->ExpDevice = agNULL;
3096 oneDeviceData->phyID = 0xFF;
3097 oneDeviceData->SASAddressID.sasAddressHi = 0;
3098 oneDeviceData->SASAddressID.sasAddressLo = 0;
3099 oneDeviceData->valid = agFALSE;
3100 oneDeviceData->valid2 = agFALSE;
3101 oneDeviceData->processed = agFALSE;
3102 oneDeviceData->initiator_ssp_stp_smp = 0;
3103 oneDeviceData->target_ssp_stp_smp = 0;
3104 oneDeviceData->numOfPhys = 0;
3105 oneDeviceData->registered = agFALSE;
3106 oneDeviceData->directlyAttached = agFALSE;
3107 oneDeviceData->SASSpecDeviceType = 0xFF;
3108 oneDeviceData->IOStart = 0;
3109 oneDeviceData->IOResponse = 0;
3110 oneDeviceData->agDeviceResetContext.osData = agNULL;
3111 oneDeviceData->agDeviceResetContext.sdkData = agNULL;
3112 oneDeviceData->TRflag = agFALSE;
3113 oneDeviceData->ResetCnt = 0;
3114 oneDeviceData->OSAbortAll = agFALSE;
3117 oneDeviceData->devMCN = 1;
3118 oneDeviceData->finalMCN = 1;
3122 oneDeviceData->SMNumOfFCA = 0;
3123 oneDeviceData->SMNumOfID = 0;
3124 if (oneDeviceData->tdIDTimer.timerRunning == agTRUE)
3128 &oneDeviceData->tdIDTimer
3135 oneDeviceData->satDevData.satDriveState = SAT_DEV_STATE_NORMAL;
3136 oneDeviceData->satDevData.satNCQMaxIO =SAT_NCQ_MAX;
3137 oneDeviceData->satDevData.satPendingIO = 0;
3138 oneDeviceData->satDevData.satPendingNCQIO = 0;
3139 oneDeviceData->satDevData.satPendingNONNCQIO = 0;
3140 oneDeviceData->satDevData.IDDeviceValid = agFALSE;
3141 oneDeviceData->satDevData.freeSATAFDMATagBitmap = 0;
3142 oneDeviceData->satDevData.NumOfFCA = 0;
3143 oneDeviceData->satDevData.NumOfIDRetries = 0;
3144 oneDeviceData->satDevData.ID_Retries = 0;
3145 oneDeviceData->satDevData.IDPending = agFALSE;
3147 osti_memset(oneDeviceData->satDevData.satMaxLBA, 0, sizeof(oneDeviceData->satDevData.satMaxLBA));
3148 osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t));
3150 oneDeviceData->satDevData.satSaDeviceData = oneDeviceData;
3152 satIntIO = (satInternalIo_t *)&(oneDeviceData->satDevData.satIntIo[0]);
3153 for (j = 0; j < SAT_MAX_INT_IO; j++)
3155 TI_DBG3(("tdsaDeviceDataReInit: in loop of internal io free, id %d\n", satIntIO->id));
3156 satFreeIntIoResource(tiRoot, &(oneDeviceData->satDevData), satIntIO);
3157 satIntIO = satIntIO + 1;
3163 #ifdef TD_INT_COALESCE
3164 /*****************************************************************************
3165 *! \brief tdsaIntCoalCxtInit(
3167 * Purpose: This function initializes interrupt coalesce contexts.
3169 * \param tiRoot: pointer to the driver instance
3175 *****************************************************************************/
3181 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3182 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3183 tdsaPortContext_t *tdsaPortContext = (tdsaPortContext_t *)tdsaAllShared->PortContext;
3184 tdsaDeviceData_t *tdsaDeviceData = (tdsaDeviceData_t *)tdsaAllShared->DeviceDataHead;
3185 tdsaIntCoalesceContext_t *tdsaIntCoalCxt = (tdsaIntCoalesceContext_t *)tdsaAllShared->IntCoalesce;
3190 TI_DBG2(("tdsaIntCoalCxtInit: start\n"));
3191 TI_DBG6(("tdsaIntCoalCxtInit: ******* sizeof(tdsaPortContext) %d 0x%x\n", sizeof(tdsaPortContext_t), sizeof(tdsaPortContext_t)));
3192 TI_DBG6(("tdsaIntCoalCxtInit: ******* sizeof(tdsaIntCoalCxt) %d 0x%x\n", sizeof(tdsaDeviceData_t), sizeof(tdsaDeviceData_t)));
3193 TI_DBG6(("tdsaIntCoalCxtInit: ******* sizeof(tdsaIntCoalCxt) %d 0x%x\n", sizeof(tdsaIntCoalesceContext_t), sizeof(tdsaIntCoalesceContext_t)));
3194 TI_DBG6(("tdsaIntCoalCxtInit: ******* tdsaRoot %p \n", tdsaRoot));
3195 TI_DBG6(("tdsaIntCoalCxtInit: ******* tdsaPortContext %p \n",tdsaPortContext));
3196 TI_DBG6(("tdsaDeviceDataInit: ******* tdsaDeviceData %p\n", tdsaDeviceData));
3197 TI_DBG6(("tdsaIntCoalCxtInit: ******* tdsaIntCoalCxt+1 %p \n", tdsaIntCoalCxt + 1));
3198 TI_DBG6(("tdsaIntCoalCxtInit: ******* &tdsaIntCoalCxt[0] %p &tdsaIntCoalCxt[1] %p\n", &(tdsaIntCoalCxt[0]), &(tdsaIntCoalCxt[1])));
3201 TI_DBG6(("tdsaIntCoalCxtInit: TD_MAX_PORT_CONTEXT %d\n", TD_MAX_PORT_CONTEXT));
3202 /* the following fn fills in MaxTargets */
3203 tdssGetMaxTargetsParams(tiRoot, &MaxTargets);
3204 TI_DBG6(("tdsaIntCoalCxtInit: MaxTargets %d\n", MaxTargets));
3206 TI_DBG6(("tdsaIntCoalCxtInit: portcontext in sum 0x%x\n", sizeof(tdsaPortContext_t) * TD_MAX_PORT_CONTEXT));
3207 TI_DBG6(("tdsaIntCoalCxtInit: devicedata in sum 0x%x\n", sizeof(tdsaDeviceData_t) * MaxTargets));
3210 tdsaIntCoalCx[0] is just head, not an element
3212 TDLIST_INIT_HDR(&(tdsaIntCoalCxt[0].MainLink));
3213 TDLIST_INIT_HDR(&(tdsaIntCoalCxt[0].FreeLink));
3215 tdsaIntCoalCxt[0].tdsaAllShared = tdsaAllShared;
3216 tdsaIntCoalCxt[0].tiIntCoalesceCxt = agNULL;
3217 tdsaIntCoalCxt[0].id = 0;
3220 for(i=1;i<TD_MAX_INT_COALESCE;i++)
3222 TDLIST_INIT_ELEMENT(&(tdsaIntCoalCxt[i].FreeLink));
3223 TDLIST_INIT_ELEMENT(&(tdsaIntCoalCxt[i].MainLink));
3225 tdsaIntCoalCxt[i].tdsaAllShared = tdsaAllShared;
3226 tdsaIntCoalCxt[i].tiIntCoalesceCxt = agNULL;
3227 tdsaIntCoalCxt[i].id = i;
3230 TDLIST_ENQUEUE_AT_TAIL(&(tdsaIntCoalCxt[i].FreeLink), &(tdsaIntCoalCxt[0].FreeLink));
3234 #endif /* TD_INT_COALESCE */
3242 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3243 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3245 tdsaExpander_t *tdsaExpander =
3246 (tdsaExpander_t *)tdsaAllShared->ExpanderHead;
3252 TI_DBG6(("tdsaExpanderInit: start\n"));
3253 tdssGetMaxTargetsParams(tiRoot, &MaxTargets);
3254 TI_DBG6(("tdsaExpanderInit: MaxTargets %d\n", MaxTargets));
3256 // TDLIST_INIT_HDR(&(tdsaAllShared->discoveringExpanderList));
3257 TDLIST_INIT_HDR(&(tdsaAllShared->freeExpanderList));
3259 for(i=0;i<(int)MaxTargets;i++)
3261 TDLIST_INIT_ELEMENT(&(tdsaExpander[i].linkNode));
3262 TDLIST_INIT_ELEMENT(&(tdsaExpander[i].upNode));
3263 /* initialize expander fields */
3264 tdsaExpander[i].tdDevice = agNULL;
3265 tdsaExpander[i].tdUpStreamExpander = agNULL;
3266 tdsaExpander[i].tdDeviceToProcess = agNULL;
3267 tdsaExpander[i].tdCurrentDownStreamExpander = agNULL;
3268 tdsaExpander[i].hasUpStreamDevice = agFALSE;
3269 tdsaExpander[i].numOfUpStreamPhys = 0;
3270 tdsaExpander[i].currentUpStreamPhyIndex = 0;
3271 tdsaExpander[i].numOfDownStreamPhys = 0;
3272 tdsaExpander[i].currentDownStreamPhyIndex = 0;
3273 tdsaExpander[i].discoveringPhyId = 0;
3274 tdsaExpander[i].underDiscovering = agFALSE;
3275 tdsaExpander[i].id = i;
3276 tdsaExpander[i].tdReturnginExpander = agNULL;
3277 tdsaExpander[i].discoverSMPAllowed = agTRUE;
3278 osti_memset( &(tdsaExpander[i].currentIndex), 0, sizeof(tdsaExpander[i].currentIndex));
3279 osti_memset( &(tdsaExpander[i].upStreamPhys), 0, sizeof(tdsaExpander[i].upStreamPhys));
3280 osti_memset( &(tdsaExpander[i].downStreamPhys), 0, sizeof(tdsaExpander[i].downStreamPhys));
3281 osti_memset( &(tdsaExpander[i].routingAttribute), 0, sizeof(tdsaExpander[i].routingAttribute));
3282 tdsaExpander[i].configSASAddrTableIndex = 0;
3283 osti_memset( &(tdsaExpander[i].configSASAddressHiTable), 0, sizeof(tdsaExpander[i].configSASAddressHiTable));
3284 osti_memset( &(tdsaExpander[i].configSASAddressLoTable), 0, sizeof(tdsaExpander[i].configSASAddressLoTable));
3287 TDLIST_ENQUEUE_AT_TAIL(&(tdsaExpander[i].linkNode), &(tdsaAllShared->freeExpanderList));
3293 tdsaQueueConfigInit(
3297 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
3298 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
3300 /* for memory index requirement */
3301 agsaQueueConfig_t *QueueConfig;
3304 TI_DBG2(("tdsaQueueConfigInit: start\n"));
3305 tdsaGetSwConfigParams(tiRoot);
3306 QueueConfig = &tdsaAllShared->QueueConfig;
3308 for(i=0;i<QueueConfig->numInboundQueues;i++)
3310 QueueConfig->inboundQueues[i].elementCount = tdsaAllShared->InboundQueueSize[i];
3311 QueueConfig->inboundQueues[i].elementSize = tdsaAllShared->InboundQueueEleSize[i];
3312 QueueConfig->inboundQueues[i].priority = tdsaAllShared->InboundQueuePriority[i];
3313 QueueConfig->inboundQueues[i].reserved = 0;
3315 for(i=0;i<QueueConfig->numOutboundQueues;i++)
3317 QueueConfig->outboundQueues[i].elementCount = tdsaAllShared->OutboundQueueSize[i];
3318 QueueConfig->outboundQueues[i].elementSize = tdsaAllShared->OutboundQueueEleSize[i];
3319 QueueConfig->outboundQueues[i].interruptDelay = tdsaAllShared->OutboundQueueInterruptDelay[i]; /* default 0; no interrupt delay */
3320 QueueConfig->outboundQueues[i].interruptCount = tdsaAllShared->OutboundQueueInterruptCount[i]; /* default 1*/
3321 QueueConfig->outboundQueues[i].interruptEnable = tdsaAllShared->OutboundQueueInterruptEnable[i]; /* default 1*/
3322 QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
3327 QueueConfig->sasHwEventQueue[i] = 0;
3328 QueueConfig->sataNCQErrorEventQueue[i] = 0;
3331 #ifdef TARGET_DRIVER
3334 QueueConfig->tgtITNexusEventQueue[i] = 0;
3335 QueueConfig->tgtSSPEventQueue[i] = 0;
3336 QueueConfig->tgtSMPEventQueue[i] = 0;
3339 QueueConfig->iqNormalPriorityProcessingDepth = 0;
3340 QueueConfig->iqHighPriorityProcessingDepth = 0;
3341 QueueConfig->generalEventQueue = 0;
3346 /*****************************************************************************
3347 *! \brief tdssGetMaxTargetsParams
3349 * Purpose: This function is called to get default parameters from the
3350 * OS Specific area. This function is called in the context of
3351 * tiCOMGetResource() and tiCOMInit().
3354 * \param tiRoot: Pointer to initiator driver/port instance.
3355 * \param option: Pointer to bit32 where the max target number is saved
3361 *****************************************************************************/
3363 tdssGetMaxTargetsParams(
3369 char *subkey1 = agNULL;
3370 char *subkey2 = agNULL;
3374 char *pLastUsedChar = agNULL;
3375 char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3376 char globalStr[] = "Global";
3377 char iniParmsStr[] = "InitiatorParms";
3380 TI_DBG6(("tdssGetMaxTargetsParams: start\n"));
3382 *pMaxTargets = DEFAULT_MAX_DEV;
3384 /* to remove compiler warnings */
3385 pLastUsedChar = pLastUsedChar;
3390 buffer = &tmpBuffer[0];
3391 buffLen = sizeof (tmpBuffer);
3393 osti_memset(buffer, 0, buffLen);
3395 /* defaults are overwritten in the following */
3396 /* Get MaxTargets */
3397 if ((ostiGetTransportParam(
3409 ) == tiSuccess) && (lenRecv != 0))
3411 if (osti_strncmp(buffer, "0x", 2) == 0)
3413 MaxTargets = osti_strtoul (buffer, &pLastUsedChar, 0);
3417 MaxTargets = osti_strtoul (buffer, &pLastUsedChar, 10);
3419 *pMaxTargets = MaxTargets;
3420 TI_DBG2(("tdssGetMaxTargetsParams: MaxTargets %d\n", MaxTargets ));
3423 osti_memset(buffer, 0, buffLen);
3429 /* temporary to distinguish SAS and SATA mode */
3431 tdssGetSATAOnlyModeParams(
3433 bit32 *pSATAOnlyMode
3437 char *subkey1 = agNULL;
3438 char *subkey2 = agNULL;
3442 char *pLastUsedChar = agNULL;
3443 char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3444 char globalStr[] = "Global";
3445 char iniParmsStr[] = "InitiatorParms";
3448 TI_DBG6(("tdssGetSATAOnlyModeParams: start\n"));
3450 *pSATAOnlyMode = agFALSE; /* default SAS and SATA */
3452 /* to remove compiler warnings */
3453 pLastUsedChar = pLastUsedChar;
3458 buffer = &tmpBuffer[0];
3459 buffLen = sizeof (tmpBuffer);
3461 osti_memset(buffer, 0, buffLen);
3463 /* defaults are overwritten in the following */
3464 /* Get SATAOnlyMode */
3465 if ((ostiGetTransportParam(
3477 ) == tiSuccess) && (lenRecv != 0))
3479 if (osti_strncmp(buffer, "0x", 2) == 0)
3481 SATAOnlyMode = osti_strtoul (buffer, &pLastUsedChar, 0);
3485 SATAOnlyMode = osti_strtoul (buffer, &pLastUsedChar, 10);
3487 *pSATAOnlyMode = SATAOnlyMode;
3490 osti_memset(buffer, 0, buffLen);