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
21 ********************************************************************************/
22 /*******************************************************************************/
26 * This file contains port realted functions such as tiCOMPortStart()
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/spc/sadefs.h>
40 #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
42 #include <dev/pms/RefTisa/tisa/api/titypes.h>
43 #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
44 #include <dev/pms/RefTisa/tisa/api/tiapi.h>
45 #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
48 #include <dev/pms/RefTisa/sat/api/sm.h>
49 #include <dev/pms/RefTisa/sat/api/smapi.h>
50 #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
54 #include <dev/pms/RefTisa/discovery/api/dm.h>
55 #include <dev/pms/RefTisa/discovery/api/dmapi.h>
56 #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
59 #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
60 #include <dev/pms/freebsd/driver/common/osstring.h>
61 #include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
63 #ifdef INITIATOR_DRIVER
64 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
65 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
66 #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
70 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
71 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
72 #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
75 #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
76 #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
79 #include <dev/pms/RefTisa/sallsdk/hda/64k/aap1img.h> /* SPC HDA */
80 #include <dev/pms/RefTisa/sallsdk/hda/64k/ilaimg.h>
81 #include <dev/pms/RefTisa/sallsdk/hda/64k/iopimg.h>
82 #include <dev/pms/RefTisa/sallsdk/hda/64k/istrimg.h>
84 #include <dev/pms/RefTisa/sallsdk/hda/64k/aap18008.h> /* SPCv HDA */
85 #include <dev/pms/RefTisa/sallsdk/hda/64k/iop8008.h>
87 #include <dev/pms/RefTisa/sallsdk/hda/64k/ila8008.h> /* Ila common to SPCv SPCvp versions */
89 #include <dev/pms/RefTisa/sallsdk/hda/64k/raae8070.h> /* SPCv 12g HDA */
90 #include <dev/pms/RefTisa/sallsdk/hda/64k/iop8070.h>
91 #include <dev/pms/RefTisa/sallsdk/hda/64k/ila8070.h> /* Ila 12g SPCv SPCvp versions */
93 #endif /* TURN_OFF_HDA */
96 bit32 gSSC_Disable = 0;
97 bit32 volatile sgpioResponseSet = 0;
100 /* temporary to test saEchoCommand() */
103 bit32 tiCOMConfigureSgpio(
109 /*****************************************************************************
110 *! \brief tdsaGetSwConfigParams
112 * Purpose: This function reads software configuration parameters from the
115 * \param tiRoot: Pointer to driver/port instance.
121 *****************************************************************************/
123 tdsaGetSwConfigParams(
127 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
128 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
129 agsaSwConfig_t *SwConfig;
130 agsaQueueConfig_t *QueueConfig;
134 char *pLastUsedChar = agNULL;
135 char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
136 char globalStr[] = "Global";
137 char iniParmsStr[] = "InitiatorParms";
138 char SwParmsStr[] = "SWParms";
139 char OBQueueProps[] = "OBQueueProps";
140 char IBQueueProps[] = "IBQueueProps";
141 char IBQueueSize[40];
142 char OBQueueSize[40];
143 char IBQueueEleSize[40];
144 char OBQueueEleSize[40];
145 char OBQueueInterruptCount[40];
146 char OBQueueInterruptDelay[40];
147 char OBQueueInterruptEnable[40];
148 char IBQueuePriority[40];
149 char *cardNum = tdsaAllShared->CardIDString;
152 bit32 enableEncryption;
153 #ifdef SA_CONFIG_MDFD_REGISTRY
158 dmSwConfig_t *dmSwConfig;
161 smSwConfig_t *smSwConfig;
164 TI_DBG6(("tdsaGetSwConfigParams: start\n"));
165 TI_DBG6(("tdsaGetSwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
168 buffLen = sizeof(tmpBuffer);
170 osti_memset(buffer, 0, buffLen);
172 /* the followings are the default values */
173 SwConfig = (agsaSwConfig_t *)&(tdsaAllShared->SwConfig);
174 QueueConfig = (agsaQueueConfig_t *)&(tdsaAllShared->QueueConfig);
177 dmSwConfig = (dmSwConfig_t *)&(tdsaAllShared->dmSwConfig);
180 smSwConfig = (smSwConfig_t *)&(tdsaAllShared->smSwConfig);
185 and are overwritten later by the configuration file contents
187 SwConfig->numDevHandles = DEFAULT_MAX_DEV;
189 SwConfig->maxActiveIOs = DEFAULT_MAX_ACTIVE_IOS;
190 SwConfig->smpReqTimeout = DEFAULT_SMP_TIMEOUT; /* DEFAULT_VALUE; */
191 SwConfig->numberOfEventRegClients = DEFAULT_NUM_REG_CLIENTS;
192 SwConfig->sizefEventLog1 = HOST_EVENT_LOG_SIZE;
193 SwConfig->sizefEventLog2 = HOST_EVENT_LOG_SIZE;
194 SwConfig->eventLog1Option = DEFAULT_EVENT_LOG_OPTION;
195 SwConfig->eventLog2Option = DEFAULT_EVENT_LOG_OPTION;
196 SwConfig->fatalErrorInterruptEnable = 1;
197 SwConfig->fatalErrorInterruptVector = 0; /* Was 1 */
198 SwConfig->hostDirectAccessSupport = 0;
199 SwConfig->hostDirectAccessMode = 0;
200 SwConfig->FWConfig = 0;
201 SwConfig->enableDIF = agFALSE;
202 SwConfig->enableEncryption = agFALSE;
204 #ifdef SA_CONFIG_MDFD_REGISTRY
205 SwConfig->disableMDF = agFALSE;
208 SwConfig->param1 = tdsaAllShared->tdDeviceIdVendId;
209 SwConfig->param2 = tdsaAllShared->tdSubVendorId;
212 #if defined(SALLSDK_DEBUG)
213 SwConfig->sallDebugLevel = 1; /* DEFAULT_VALUE; */
215 #if defined(DM_DEBUG)
216 dmSwConfig->DMDebugLevel = 1; /* DEFAULT_VALUE; */
218 #if defined(SM_DEBUG)
219 smSwConfig->SMDebugLevel = 1; /* DEFAULT_VALUE; */
222 tdsaAllShared->portTMO = PORT_RECOVERY_TIMEOUT; /* default 5 sec */
223 tdsaAllShared->stp_idle_time = STP_IDLE_TIME; /* default 5 us */
224 tdsaAllShared->itNexusTimeout = IT_NEXUS_TIMEOUT; /* default 2000 ms */
226 osti_memset(buffer, 0, buffLen);
229 if ((ostiGetTransportParam(
241 ) == tiSuccess) && (lenRecv != 0))
243 if (osti_strncmp(buffer, "0x", 2) == 0)
245 SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 0);
249 SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 10);
251 TI_DBG2(("tdsaGetSwConfigParams: MaxTargets %d\n",SwConfig->numDevHandles ));
255 * read the NumInboundQueue parameter
257 osti_memset(buffer, 0, buffLen);
260 QueueConfig->numInboundQueues = DEFAULT_NUM_INBOUND_QUEUE; /* default 1 Inbound queue */
262 if ((ostiGetTransportParam(
265 SwParmsStr, /* subkey1 */
266 agNULL, /* subkey2 */
269 agNULL, /* subkey5 */
270 "NumInboundQueues", /* valueName */
274 ) == tiSuccess) && (lenRecv != 0))
276 if (osti_strncmp(buffer, "0x", 2) == 0)
278 QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
282 QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
285 if (QueueConfig->numInboundQueues > AGSA_MAX_INBOUND_Q)
287 QueueConfig->numInboundQueues = AGSA_MAX_INBOUND_Q;
292 * read the NumOutboundQueue parameter
294 osti_memset(buffer, 0, buffLen);
297 QueueConfig->numOutboundQueues = DEFAULT_NUM_OUTBOUND_QUEUE; /* default 1 Outbound queue */
299 if ((ostiGetTransportParam(
302 SwParmsStr, /* subkey1 */
303 agNULL, /* subkey2 */
306 agNULL, /* subkey5 */
307 "NumOutboundQueues", /* valueName */
311 ) == tiSuccess) && (lenRecv != 0))
313 if (osti_strncmp(buffer, "0x", 2) == 0)
315 QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
319 QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
322 if (QueueConfig->numOutboundQueues > AGSA_MAX_OUTBOUND_Q)
324 QueueConfig->numOutboundQueues = AGSA_MAX_OUTBOUND_Q;
329 * read the outbound queue option
332 osti_memset(buffer, 0, buffLen);
335 tdsaAllShared->QueueOption = DEFAULT_QUEUE_OPTION; /* default 0 Outbound queue element */
337 if ((ostiGetTransportParam(
340 SwParmsStr, /* subkey1 */
341 agNULL, /* subkey2 */
344 agNULL, /* subkey5 */
345 "QueueOption", /* valueName */
349 ) == tiSuccess) && (lenRecv != 0))
351 if (osti_strncmp(buffer, "0x", 2) == 0)
353 tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
357 tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
362 * read the MaxActiveIO parameter
365 osti_memset(buffer, 0, buffLen);
368 if ((ostiGetTransportParam(
371 SwParmsStr, /* subkey1 */
372 agNULL, /* subkey2 */
375 agNULL, /* subkey5 */
376 "MaxActiveIO", /* valueName */
380 ) == tiSuccess) && (lenRecv != 0))
382 if (osti_strncmp(buffer, "0x", 2) == 0)
384 SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 0);
385 TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 1 !!!\n"));
389 SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 10);
390 TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 2 !!!\n"));
392 TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 3 !!!\n"));
398 * read the SMPTO parameter (SMP Timeout)
400 osti_memset(buffer, 0, buffLen);
403 if ((ostiGetTransportParam(
406 SwParmsStr, /* subkey1 */
407 agNULL, /* subkey2 */
410 agNULL, /* subkey5 */
411 "SMPTO", /* valueName */
415 ) == tiSuccess) && (lenRecv != 0))
417 if (osti_strncmp(buffer, "0x", 2) == 0)
419 SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
423 SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
429 * read the NumRegClients parameter (SMP Timeout)
431 osti_memset(buffer, 0, buffLen);
434 if ((ostiGetTransportParam(
437 SwParmsStr, /* subkey1 */
438 agNULL, /* subkey2 */
441 agNULL, /* subkey5 */
442 "NumRegClients", /* valueName */
446 ) == tiSuccess) && (lenRecv != 0))
448 if (osti_strncmp(buffer, "0x", 2) == 0)
450 SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 0);
454 SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 10);
458 #if defined(SALLSDK_DEBUG)
459 osti_memset(buffer, 0, buffLen);
462 if ((ostiGetTransportParam(
465 SwParmsStr, /* subkey1 */
466 agNULL, /* subkey2 */
469 agNULL, /* subkey5 */
470 "LLDebugLevel", /* valueName */
474 ) == tiSuccess) && (lenRecv != 0))
476 if (osti_strncmp(buffer, "0x", 2) == 0)
478 SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
482 SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
487 #if defined(DM_DEBUG)
488 osti_memset(buffer, 0, buffLen);
491 if ((ostiGetTransportParam(
494 SwParmsStr, /* subkey1 */
495 agNULL, /* subkey2 */
498 agNULL, /* subkey5 */
499 "DMDebugLevel", /* valueName */
503 ) == tiSuccess) && (lenRecv != 0))
505 if (osti_strncmp(buffer, "0x", 2) == 0)
507 dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
511 dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
516 #if defined(SM_DEBUG)
517 osti_memset(buffer, 0, buffLen);
520 if ((ostiGetTransportParam(
523 SwParmsStr, /* subkey1 */
524 agNULL, /* subkey2 */
527 agNULL, /* subkey5 */
528 "SMDebugLevel", /* valueName */
532 ) == tiSuccess) && (lenRecv != 0))
534 if (osti_strncmp(buffer, "0x", 2) == 0)
536 smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
540 smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
545 osti_memset(buffer, 0, buffLen);
548 for (i=0;i<QueueConfig->numInboundQueues;i++)
550 osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
551 osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
552 osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
555 * read the IBQueueSize
558 osti_memset(buffer, 0, buffLen);
561 tdsaAllShared->InboundQueueSize[i] = DEFAULT_INBOUND_QUEUE_SIZE; /* default 256 Inbound queue size */
563 if ((ostiGetTransportParam(
566 SwParmsStr, /* subkey1 */
567 IBQueueProps,/* subkey2 */
570 agNULL, /* subkey5 */
571 IBQueueSize, /* valueName */
575 ) == tiSuccess) && (lenRecv != 0))
577 if (osti_strncmp(buffer, "0x", 2) == 0)
579 tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
583 tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
584 TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
590 * read the IBQueueEleSize
593 osti_memset(buffer, 0, buffLen);
596 tdsaAllShared->InboundQueueEleSize[i] = DEFAULT_INBOUND_QUEUE_ELE_SIZE; /* default 128 Inbound queue element */
598 if ((ostiGetTransportParam(
601 SwParmsStr, /* subkey1 */
602 IBQueueProps,/* subkey2 */
605 agNULL, /* subkey5 */
606 IBQueueEleSize, /* valueName */
610 ) == tiSuccess) && (lenRecv != 0))
612 if (osti_strncmp(buffer, "0x", 2) == 0)
614 tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
618 tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
619 TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
624 * read the IBQueuePriority
627 osti_memset(buffer, 0, buffLen);
630 tdsaAllShared->InboundQueuePriority[i] = DEFAULT_INBOUND_QUEUE_PRIORITY; /* default 0 Inbound queue priority */
632 if ((ostiGetTransportParam(
635 SwParmsStr, /* subkey1 */
636 IBQueueProps,/* subkey2 */
639 agNULL, /* subkey5 */
640 IBQueuePriority, /* valueName */
644 ) == tiSuccess) && (lenRecv != 0))
646 if (osti_strncmp(buffer, "0x", 2) == 0)
648 tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
652 tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
653 TI_DBG6(("tdsaGetSwConfigParams: queue number %d priority %d\n", i, tdsaAllShared->InboundQueuePriority[i]));
657 /**********************************************/
658 osti_memset(buffer, 0, buffLen);
664 osti_memset(buffer, 0, buffLen);
667 for (i=0;i<QueueConfig->numOutboundQueues;i++)
669 osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
670 osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
671 osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
672 osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
673 osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
676 * read the OBQueueSize
678 osti_memset(buffer, 0, buffLen);
682 tdsaAllShared->OutboundQueueSize[i] = DEFAULT_OUTBOUND_QUEUE_SIZE; /* default 256 Outbound queue size */
684 if ((ostiGetTransportParam(
687 SwParmsStr, /* subkey1 */
688 OBQueueProps, /* subkey2 */
691 agNULL, /* subkey5 */
692 OBQueueSize, /* valueName */
696 ) == tiSuccess) && (lenRecv != 0))
698 if (osti_strncmp(buffer, "0x", 2) == 0)
700 tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
704 tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
705 TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
712 * read the OBQueueEleSize
714 osti_memset(buffer, 0, buffLen);
718 tdsaAllShared->OutboundQueueEleSize[i] = DEFAULT_OUTBOUND_QUEUE_ELE_SIZE; /* default 128 Outbound queue element */
720 if ((ostiGetTransportParam(
723 SwParmsStr, /* subkey1 */
724 OBQueueProps, /* subkey2 */
727 agNULL, /* subkey5 */
728 OBQueueEleSize, /* valueName */
732 ) == tiSuccess) && (lenRecv != 0))
734 if (osti_strncmp(buffer, "0x", 2) == 0)
736 tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
740 tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
741 TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
748 * read the OBQueueInterruptDelay
750 osti_memset(buffer, 0, buffLen);
754 tdsaAllShared->OutboundQueueInterruptDelay[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_DELAY; /* default 1 Outbound interrupt delay */
756 if ((ostiGetTransportParam(
759 SwParmsStr, /* subkey1 */
760 OBQueueProps, /* subkey2 */
763 agNULL, /* subkey5 */
764 OBQueueInterruptDelay, /* valueName */
768 ) == tiSuccess) && (lenRecv != 0))
770 if (osti_strncmp(buffer, "0x", 2) == 0)
772 tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
776 tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
777 TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt delay %d\n", i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
783 * read the OBQueueInterruptCount
786 osti_memset(buffer, 0, buffLen);
789 tdsaAllShared->OutboundQueueInterruptCount[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_COUNT; /* default 1 Outbound interrupt count */
791 if ((ostiGetTransportParam(
794 SwParmsStr, /* subkey1 */
795 OBQueueProps, /* subkey2 */
798 agNULL, /* subkey5 */
799 OBQueueInterruptCount, /* valueName */
803 ) == tiSuccess) && (lenRecv != 0))
805 if (osti_strncmp(buffer, "0x", 2) == 0)
807 tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
811 tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
812 TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt count %d\n", i, tdsaAllShared->OutboundQueueInterruptCount[i]));
818 * read the OBQueueInterruptEnable
821 osti_memset(buffer, 0, buffLen);
824 tdsaAllShared->OutboundQueueInterruptEnable[i] = DEFAULT_OUTBOUND_INTERRUPT_ENABLE; /* default 1 Outbound interrupt is enabled */
826 if ((ostiGetTransportParam(
829 SwParmsStr, /* subkey1 */
830 OBQueueProps, /* subkey2 */
833 agNULL, /* subkey5 */
834 OBQueueInterruptEnable, /* valueName */
838 ) == tiSuccess) && (lenRecv != 0))
840 if (osti_strncmp(buffer, "0x", 2) == 0)
842 tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
846 tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
847 TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt enable %d\n", i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
851 /**********************************************/
852 osti_memset(buffer, 0, buffLen);
859 /********************READ CARD SPECIFIC *******************************************************/
861 osti_memset(buffer, 0, buffLen);
864 for (i=0;i<QueueConfig->numInboundQueues;i++)
866 osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
867 osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
868 osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
871 * read the IBQueueSize
874 osti_memset(buffer, 0, buffLen);
877 if ((ostiGetTransportParam(
880 SwParmsStr, /* subkey1 */
881 IBQueueProps,/* subkey2 */
884 agNULL, /* subkey5 */
885 IBQueueSize, /* valueName */
889 ) == tiSuccess) && (lenRecv != 0))
891 if (osti_strncmp(buffer, "0x", 2) == 0)
893 tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
897 tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
898 TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
903 * read the IBQueueEleSize
906 osti_memset(buffer, 0, buffLen);
909 if ((ostiGetTransportParam(
912 SwParmsStr, /* subkey1 */
913 IBQueueProps,/* subkey2 */
916 agNULL, /* subkey5 */
917 IBQueueEleSize, /* valueName */
921 ) == tiSuccess) && (lenRecv != 0))
923 if (osti_strncmp(buffer, "0x", 2) == 0)
925 tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
929 tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
930 TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
935 * read the IBQueuePriority
938 osti_memset(buffer, 0, buffLen);
941 if ((ostiGetTransportParam(
944 SwParmsStr, /* subkey1 */
945 IBQueueProps,/* subkey2 */
948 agNULL, /* subkey5 */
949 IBQueuePriority, /* valueName */
953 ) == tiSuccess) && (lenRecv != 0))
955 if (osti_strncmp(buffer, "0x", 2) == 0)
957 tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
961 tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
962 TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d priority %d\n", cardNum, i, tdsaAllShared->InboundQueuePriority[i]));
966 /**********************************************/
967 osti_memset(buffer, 0, buffLen);
973 osti_memset(buffer, 0, buffLen);
976 for (i=0;i<QueueConfig->numOutboundQueues;i++)
978 osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
979 osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
980 osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
981 osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
982 osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
985 * read the OBQueueSize
987 osti_memset(buffer, 0, buffLen);
990 if ((ostiGetTransportParam(
993 SwParmsStr, /* subkey1 */
994 OBQueueProps, /* subkey2 */
997 agNULL, /* subkey5 */
998 OBQueueSize, /* valueName */
1002 ) == tiSuccess) && (lenRecv != 0))
1004 if (osti_strncmp(buffer, "0x", 2) == 0)
1006 tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1010 tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1011 TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
1017 * read the OBQueueEleSize
1019 osti_memset(buffer, 0, buffLen);
1023 if ((ostiGetTransportParam(
1026 SwParmsStr, /* subkey1 */
1027 OBQueueProps, /* subkey2 */
1030 agNULL, /* subkey5 */
1031 OBQueueEleSize, /* valueName */
1035 ) == tiSuccess) && (lenRecv != 0))
1037 if (osti_strncmp(buffer, "0x", 2) == 0)
1039 tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1043 tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1044 TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
1050 * read the OBQueueInterruptDelay
1052 osti_memset(buffer, 0, buffLen);
1056 if ((ostiGetTransportParam(
1059 SwParmsStr, /* subkey1 */
1060 OBQueueProps, /* subkey2 */
1063 agNULL, /* subkey5 */
1064 OBQueueInterruptDelay, /* valueName */
1068 ) == tiSuccess) && (lenRecv != 0))
1070 if (osti_strncmp(buffer, "0x", 2) == 0)
1072 tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1076 tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1077 TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt delay %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
1083 * read the OBQueueInterruptCount
1086 osti_memset(buffer, 0, buffLen);
1089 if ((ostiGetTransportParam(
1092 SwParmsStr, /* subkey1 */
1093 OBQueueProps, /* subkey2 */
1096 agNULL, /* subkey5 */
1097 OBQueueInterruptCount, /* valueName */
1101 ) == tiSuccess) && (lenRecv != 0))
1103 if (osti_strncmp(buffer, "0x", 2) == 0)
1105 tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1109 tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1110 TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt count %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptCount[i]));
1116 * read the OBQueueInterruptEnable
1119 osti_memset(buffer, 0, buffLen);
1122 if ((ostiGetTransportParam(
1125 SwParmsStr, /* subkey1 */
1126 OBQueueProps, /* subkey2 */
1129 agNULL, /* subkey5 */
1130 OBQueueInterruptEnable, /* valueName */
1134 ) == tiSuccess) && (lenRecv != 0))
1136 if (osti_strncmp(buffer, "0x", 2) == 0)
1138 tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1142 tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1143 TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt enable %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
1148 /**********************************************/
1149 osti_memset(buffer, 0, buffLen);
1154 /* process event log related parameters */
1155 osti_memset(buffer, 0, buffLen);
1158 if ((ostiGetTransportParam(
1160 globalStr, /* key */
1161 SwParmsStr, /* subkey1 */
1162 agNULL, /* subkey2 */
1165 agNULL, /* subkey5 */
1166 "EventLogSize1", /* valueName */
1170 ) == tiSuccess) && (lenRecv != 0))
1172 if (osti_strncmp(buffer, "0x", 2) == 0)
1174 SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 0);
1178 SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 10);
1182 osti_memset(buffer, 0, buffLen);
1185 if ((ostiGetTransportParam(
1187 globalStr, /* key */
1188 SwParmsStr, /* subkey1 */
1189 agNULL, /* subkey2 */
1192 agNULL, /* subkey5 */
1193 "EventLogOption1", /* valueName */
1197 ) == tiSuccess) && (lenRecv != 0))
1199 if (osti_strncmp(buffer, "0x", 2) == 0)
1201 SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1205 SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1209 osti_memset(buffer, 0, buffLen);
1212 if ((ostiGetTransportParam(
1214 globalStr, /* key */
1215 SwParmsStr, /* subkey1 */
1216 agNULL, /* subkey2 */
1219 agNULL, /* subkey5 */
1220 "EventLogSize2", /* valueName *//* IOP size in K dWords */
1224 ) == tiSuccess) && (lenRecv != 0))
1226 if (osti_strncmp(buffer, "0x", 2) == 0)
1228 SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 0);
1232 SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 10);
1236 osti_memset(buffer, 0, buffLen);
1239 if ((ostiGetTransportParam(
1241 globalStr, /* key */
1242 SwParmsStr, /* subkey1 */
1243 agNULL, /* subkey2 */
1246 agNULL, /* subkey5 */
1247 "EventLogOption2", /* valueName */
1251 ) == tiSuccess) && (lenRecv != 0))
1253 if (osti_strncmp(buffer, "0x", 2) == 0)
1255 SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1259 SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1262 /* end of event log related parameters */
1267 osti_memset(buffer, 0, buffLen);
1270 if ((ostiGetTransportParam(
1272 globalStr, /* key */
1273 SwParmsStr, /* subkey1 */
1274 agNULL, /* subkey2 */
1277 agNULL, /* subkey5 */
1278 "HDASupport", /* valueName */
1282 ) == tiSuccess) && (lenRecv != 0))
1284 if (osti_strncmp(buffer, "0x", 2) == 0)
1286 SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 0);
1290 SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 10);
1294 osti_memset(buffer, 0, buffLen);
1297 if ((ostiGetTransportParam(
1299 globalStr, /* key */
1300 SwParmsStr, /* subkey1 */
1301 agNULL, /* subkey2 */
1304 agNULL, /* subkey5 */
1305 "HDAMode", /* valueName */
1309 ) == tiSuccess) && (lenRecv != 0))
1311 if (osti_strncmp(buffer, "0x", 2) == 0)
1313 SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 0);
1317 SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 10);
1320 /* the end of HDA parameters */
1322 /* FW configuration */
1323 osti_memset(buffer, 0, buffLen);
1326 if ((ostiGetTransportParam(
1328 globalStr, /* key */
1329 SwParmsStr, /* subkey1 */
1330 agNULL, /* subkey2 */
1333 agNULL, /* subkey5 */
1334 "FWConfig", /* valueName */
1338 ) == tiSuccess) && (lenRecv != 0))
1340 if (osti_strncmp(buffer, "0x", 2) == 0)
1342 SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 0);
1346 SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 10);
1349 /* The end of FW configuration */
1351 /* IQ Normal priority and High priority */
1352 osti_memset(buffer, 0, buffLen);
1355 if ((ostiGetTransportParam(
1357 globalStr, /* key */
1358 SwParmsStr, /* subkey1 */
1359 IBQueueProps,/* subkey2 */
1362 agNULL, /* subkey5 */
1363 "IQNQDepth", /* valueName */
1367 ) == tiSuccess) && (lenRecv != 0))
1369 if (osti_strncmp(buffer, "0x", 2) == 0)
1371 QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
1375 QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
1379 osti_memset(buffer, 0, buffLen);
1382 if ((ostiGetTransportParam(
1384 globalStr, /* key */
1385 SwParmsStr, /* subkey1 */
1386 IBQueueProps,/* subkey2 */
1389 agNULL, /* subkey5 */
1390 "IQHQDepth", /* valueName */
1394 ) == tiSuccess) && (lenRecv != 0))
1396 if (osti_strncmp(buffer, "0x", 2) == 0)
1398 QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
1402 QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
1405 /* End IQ Normal priority and High priority */
1407 /* Start port timeout value */
1408 osti_memset(buffer, 0, buffLen);
1411 if ((ostiGetTransportParam(
1413 globalStr, /* key */
1414 SwParmsStr, /* subkey1 */
1415 agNULL,/* subkey2 */
1418 agNULL, /* subkey5 */
1419 "PortTMO", /* valueName */
1423 ) == tiSuccess) && (lenRecv != 0))
1425 if (osti_strncmp(buffer, "0x", 2) == 0)
1427 tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1431 tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1434 /* End port timeout value */
1436 #ifdef SA_ENABLE_TRACE_FUNCTIONS
1437 osti_memset(buffer, 0, buffLen);
1439 if ((ostiGetTransportParam(
1441 globalStr, /* key */
1442 SwParmsStr, /* subkey1 */
1443 agNULL, /* subkey2 */
1446 agNULL, /* subkey5 */
1447 "TraceDestination", /* valueName */
1451 ) == tiSuccess) && (lenRecv != 0))
1453 if (osti_strncmp(buffer, "0x", 2) == 0)
1455 SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 0);
1459 SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 10);
1461 TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceDestination %d\n",SwConfig->TraceDestination));
1464 osti_memset(buffer, 0, buffLen);
1466 if ((ostiGetTransportParam(
1468 globalStr, /* key */
1469 SwParmsStr, /* subkey1 */
1470 agNULL, /* subkey2 */
1473 agNULL, /* subkey5 */
1474 "TraceMask", /* valueName */
1478 ) == tiSuccess) && (lenRecv != 0))
1480 if (osti_strncmp(buffer, "0x", 2) == 0)
1482 SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 0);
1486 SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 10);
1488 TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceMask %d %X\n",SwConfig->TraceMask,SwConfig->TraceMask));
1490 #endif /*# SA_ENABLE_TRACE_FUNCTIONS */
1494 * read the SAS Connection Time Limit parameter
1496 osti_memset(buffer, 0, buffLen);
1498 tdsaAllShared->SASConnectTimeLimit = 0;
1500 if ((ostiGetTransportParam(
1502 globalStr, /* key */
1503 SwParmsStr, /* subkey1 */
1504 agNULL, /* subkey2 */
1507 agNULL, /* subkey5 */
1508 "SASCTL", /* valueName */
1512 ) == tiSuccess) && (lenRecv != 0))
1514 if (osti_strncmp(buffer, "0x", 2) == 0)
1515 tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 0);
1517 tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 10);
1521 /* Start FCA value */
1522 osti_memset(buffer, 0, buffLen);
1525 tdsaAllShared->FCA = 1; /* No FCA by default */
1527 if ((ostiGetTransportParam(
1529 globalStr, /* key */
1530 "InitiatorParms", /* subkey1 */
1531 agNULL,/* subkey2 */
1534 agNULL, /* subkey5 */
1535 "FCA", /* valueName */
1539 ) == tiSuccess) && (lenRecv != 0))
1541 if (osti_strncmp(buffer, "0x", 2) == 0)
1543 tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 0);
1547 tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 10);
1552 /* Start ResetInDiscovery value */
1553 osti_memset(buffer, 0, buffLen);
1556 tdsaAllShared->ResetInDiscovery = 0; /* No ResetInDiscovery by default */
1558 if ((ostiGetTransportParam(
1560 globalStr, /* key */
1561 "InitiatorParms", /* subkey1 */
1562 agNULL,/* subkey2 */
1565 agNULL, /* subkey5 */
1566 "ResetInDiscovery", /* valueName */
1570 ) == tiSuccess) && (lenRecv != 0))
1572 if (osti_strncmp(buffer, "0x", 2) == 0)
1574 tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 0);
1578 tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 10);
1581 /* End ResetInDiscovery value */
1583 /* Start MCN value */
1584 osti_memset(buffer, 0, buffLen);
1587 tdsaAllShared->MCN = 1; /* default MCN */
1589 if ((ostiGetTransportParam(
1591 globalStr, /* key */
1592 SwParmsStr, /* subkey1 */
1593 agNULL,/* subkey2 */
1596 agNULL, /* subkey5 */
1597 "MCN", /* valueName */
1601 ) == tiSuccess) && (lenRecv != 0))
1603 if (osti_strncmp(buffer, "0x", 2) == 0)
1605 tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 0);
1609 tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 10);
1611 TI_DBG6(("tdsaGetSwConfigParams: MCN %d\n", tdsaAllShared->MCN));
1615 /* Start sflag value */
1616 osti_memset(buffer, 0, buffLen);
1619 tdsaAllShared->sflag = 0; /* default sflag */
1621 if ((ostiGetTransportParam(
1623 globalStr, /* key */
1624 SwParmsStr, /* subkey1 */
1625 agNULL, /* subkey2 */
1628 agNULL, /* subkey5 */
1629 "Sflag", /* valueName */
1633 ) == tiSuccess) && (lenRecv != 0))
1635 if (osti_strncmp(buffer, "0x", 2) == 0)
1637 tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 0);
1641 tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 10);
1643 TI_DBG1(("tdsaGetSwConfigParams: sflag %d\n", tdsaAllShared->sflag));
1645 /* End sflag value */
1647 /* Start enable DIF */
1648 osti_memset(buffer, 0, buffLen);
1651 if ((ostiGetTransportParam(
1653 globalStr, /* key */
1654 SwParmsStr, /* subkey1 */
1655 agNULL,/* subkey2 */
1658 agNULL, /* subkey5 */
1659 "enableDIF", /* valueName */
1663 ) == tiSuccess) && (lenRecv != 0))
1665 if (osti_strncmp(buffer, "0x", 2) == 0)
1667 enableDIF = osti_strtoul (buffer, &pLastUsedChar, 0);
1671 enableDIF = osti_strtoul (buffer, &pLastUsedChar, 10);
1673 TI_DBG6(("tdsaGetSwConfigParams: enableDIF %d\n", enableDIF));
1676 SwConfig->enableDIF = agTRUE;
1680 SwConfig->enableDIF = agFALSE;
1682 TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableDIF %d\n", SwConfig->enableDIF));
1684 /* End enable DIF */
1687 /* Start enable Encryption */
1688 osti_memset(buffer, 0, buffLen);
1691 if ((ostiGetTransportParam(
1693 globalStr, /* key */
1694 SwParmsStr, /* subkey1 */
1695 agNULL,/* subkey2 */
1698 agNULL, /* subkey5 */
1699 "enableEncryption", /* valueName */
1703 ) == tiSuccess) && (lenRecv != 0))
1705 if (osti_strncmp(buffer, "0x", 2) == 0)
1707 enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 0);
1711 enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 10);
1713 TI_DBG6(("tdsaGetSwConfigParams: enableEncryption %d\n", enableEncryption));
1714 if (enableEncryption)
1716 SwConfig->enableEncryption = agTRUE;
1720 SwConfig->enableEncryption = agFALSE;
1722 TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableEncryption %d\n", SwConfig->enableEncryption));
1724 /* End enable Encryption */
1726 /* Start allow connection rate change */
1727 osti_memset(buffer, 0, buffLen);
1729 tdsaAllShared->RateAdjust = 0; /* No rate adjust by default */
1730 if ((ostiGetTransportParam(
1732 globalStr, /* key */
1733 SwParmsStr, /* subkey1 */
1734 agNULL,/* subkey2 */
1737 agNULL, /* subkey5 */
1738 "RateAdjust", /* valueName */
1742 ) == tiSuccess) && (lenRecv != 0))
1744 if (osti_strncmp(buffer, "0x", 2) == 0)
1746 tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 0);
1750 tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 10);
1752 TI_DBG6(("tdsaGetSwConfigParams: tdsaAllShared->RateAdjust %d\n", tdsaAllShared->RateAdjust));
1754 /* End allow connection rate change */
1757 #ifdef SA_CONFIG_MDFD_REGISTRY
1758 /* Start disable MDF */
1759 osti_memset(buffer, 0, buffLen);
1762 if ((ostiGetTransportParam(
1764 globalStr, /* key */
1765 SwParmsStr, /* subkey1 */
1766 agNULL,/* subkey2 */
1769 agNULL, /* subkey5 */
1770 "disableMDF", /* valueName */
1774 ) == tiSuccess) && (lenRecv != 0))
1776 if (osti_strncmp(buffer, "0x", 2) == 0)
1778 disableMDF = osti_strtoul (buffer, &pLastUsedChar, 0);
1782 disableMDF = osti_strtoul (buffer, &pLastUsedChar, 10);
1784 TI_DBG6(("tdsaGetSwConfigParams: disableMDF %d\n", disableMDF));
1787 SwConfig->disableMDF = agTRUE;
1791 SwConfig->disableMDF = agFALSE;
1793 TI_DBG6(("tdsaGetSwConfigParams: SwConfig->disableMDF %d\n", SwConfig->disableMDF));
1795 /* End disable MDF */
1796 #endif /*SA_CONFIG_MDFD_REGISTRY*/
1798 /* Start IT_NEXUS_TIMEOUT */
1799 osti_memset(buffer, 0, buffLen);
1802 if ((ostiGetTransportParam(
1804 globalStr, /* key */
1805 SwParmsStr, /* subkey1 */
1806 agNULL,/* subkey2 */
1809 agNULL, /* subkey5 */
1810 "IT_NEXUS_TIMEOUT", /* valueName */
1814 ) == tiSuccess) && (lenRecv != 0))
1816 if (osti_strncmp(buffer, "0x", 2) == 0)
1818 tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
1822 tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
1824 TI_DBG1(("tdsaGetSwConfigParams: tdsaAllShared->itNexusTimeout %d\n", tdsaAllShared->itNexusTimeout));
1826 /* End IT_NEXUS_TIMEOUT */
1828 /* Start stp idle time */
1829 osti_memset(buffer, 0, buffLen);
1832 if ((ostiGetTransportParam(
1834 globalStr, /* key */
1835 SwParmsStr, /* subkey1 */
1836 agNULL,/* subkey2 */
1839 agNULL, /* subkey5 */
1840 "STPIdleTime", /* valueName */
1844 ) == tiSuccess) && (lenRecv != 0))
1846 if (osti_strncmp(buffer, "0x", 2) == 0)
1848 tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 0);
1852 tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 10);
1854 TI_DBG2(("tdsaGetSwConfigParams: STPIdleTime %d\n", tdsaAllShared->stp_idle_time));
1856 /* End stp idle time */
1858 /* Start STP_MCT_TMO */
1859 osti_memset(buffer, 0, buffLen);
1862 tdsaAllShared->STP_MCT_TMO = 32;
1863 if ((ostiGetTransportParam(
1865 globalStr, /* key */
1866 SwParmsStr, /* subkey1 */
1867 agNULL,/* subkey2 */
1870 agNULL, /* subkey5 */
1871 "SAS_STP_MCT_TMO", /* valueName */
1875 ) == tiSuccess) && (lenRecv != 0))
1877 if (osti_strncmp(buffer, "0x", 2) == 0)
1879 tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1883 tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1885 TI_DBG2(("tdsaGetSwConfigParams: STP_MCT_TMO %d\n", tdsaAllShared->STP_MCT_TMO));
1887 /* End STP_MCT_TMO */
1889 /* Start SSP_MCT_TMO */
1890 osti_memset(buffer, 0, buffLen);
1892 tdsaAllShared->SSP_MCT_TMO = 32;
1893 if ((ostiGetTransportParam(
1895 globalStr, /* key */
1896 SwParmsStr, /* subkey1 */
1897 agNULL,/* subkey2 */
1900 agNULL, /* subkey5 */
1901 "SAS_SSP_MCT_TMO", /* valueName */
1905 ) == tiSuccess) && (lenRecv != 0))
1907 if (osti_strncmp(buffer, "0x", 2) == 0)
1909 tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1913 tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1915 TI_DBG2(("tdsaGetSwConfigParams: SSP_MCT_TMO %d\n", tdsaAllShared->SSP_MCT_TMO));
1917 /* End SSP_MCT_TMO */
1920 /* Start MAX_OPEN_TIME */
1921 osti_memset(buffer, 0, buffLen);
1923 tdsaAllShared->MAX_OPEN_TIME = 5;
1924 if ((ostiGetTransportParam(
1926 globalStr, /* key */
1927 SwParmsStr, /* subkey1 */
1928 agNULL,/* subkey2 */
1931 agNULL, /* subkey5 */
1932 "SAS_MAX_OPEN_TIME", /* valueName */
1936 ) == tiSuccess) && (lenRecv != 0))
1938 if (osti_strncmp(buffer, "0x", 2) == 0)
1940 tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 0);
1944 tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 10);
1946 TI_DBG2(("tdsaGetSwConfigParams: MAX_OPEN_TIME %d\n", tdsaAllShared->MAX_OPEN_TIME));
1948 /* End MAX_OPEN_TIME */
1951 /* Start SMP_MAX_CONN_TIMER */
1952 osti_memset(buffer, 0, buffLen);
1954 tdsaAllShared->SMP_MAX_CONN_TIMER = 0xFF;
1955 if ((ostiGetTransportParam(
1957 globalStr, /* key */
1958 SwParmsStr, /* subkey1 */
1959 agNULL,/* subkey2 */
1962 agNULL, /* subkey5 */
1963 "SAS_SMP_MAX_CONN_TIMER", /* valueName */
1967 ) == tiSuccess) && (lenRecv != 0))
1969 if (osti_strncmp(buffer, "0x", 2) == 0)
1971 tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 0);
1975 tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 10);
1977 TI_DBG2(("tdsaGetSwConfigParams: SMP_MAX_CONN_TIMER %d\n", tdsaAllShared->SMP_MAX_CONN_TIMER));
1979 /* End SMP_MAX_CONN_TIMER */
1981 /* Start STP_FRM_TMO */
1982 osti_memset(buffer, 0, buffLen);
1984 tdsaAllShared->STP_FRM_TMO = 0;
1985 if ((ostiGetTransportParam(
1987 globalStr, /* key */
1988 SwParmsStr, /* subkey1 */
1989 agNULL,/* subkey2 */
1992 agNULL, /* subkey5 */
1993 "SAS_STP_FRM_TMO", /* valueName */
1997 ) == tiSuccess) && (lenRecv != 0))
1999 if (osti_strncmp(buffer, "0x", 2) == 0)
2001 tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2005 tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2007 TI_DBG2(("tdsaGetSwConfigParams: STP_FRM_TMO %d\n", tdsaAllShared->STP_FRM_TMO));
2009 /* End STP_FRM_TMO */
2011 /* Start MFD_OPNRJT_RTRY_INTVL */
2012 osti_memset(buffer, 0, buffLen);
2014 tdsaAllShared->MFD = 1; /* disabled by default */
2015 if ((ostiGetTransportParam(
2017 globalStr, /* key */
2018 SwParmsStr, /* subkey1 */
2019 agNULL,/* subkey2 */
2022 agNULL, /* subkey5 */
2023 "SAS_MFD", /* valueName */
2027 ) == tiSuccess) && (lenRecv != 0))
2029 if (osti_strncmp(buffer, "0x", 2) == 0)
2031 tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 0);
2035 tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 10);
2037 TI_DBG2(("tdsaGetSwConfigParams: MFD %d\n", tdsaAllShared->MFD));
2039 /* End MFD_OPNRJT_RTRY_INTVL */
2041 /* Start MFD_OPNRJT_RTRY_INTVL */
2042 osti_memset(buffer, 0, buffLen);
2044 tdsaAllShared->OPNRJT_RTRY_INTVL = 2;
2045 if ((ostiGetTransportParam(
2047 globalStr, /* key */
2048 SwParmsStr, /* subkey1 */
2049 agNULL,/* subkey2 */
2052 agNULL, /* subkey5 */
2053 "SAS_OPNRJT_RTRY_INTVL", /* valueName */
2057 ) == tiSuccess) && (lenRecv != 0))
2059 if (osti_strncmp(buffer, "0x", 2) == 0)
2061 tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 0);
2065 tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 10);
2067 TI_DBG2(("tdsaGetSwConfigParams: OPNRJT_RTRY_INTVL %d\n", tdsaAllShared->OPNRJT_RTRY_INTVL));
2069 /* End MFD_OPNRJT_RTRY_INTVL */
2071 /* Start DOPNRJT_RTRY_TMO */
2072 osti_memset(buffer, 0, buffLen);
2074 tdsaAllShared->DOPNRJT_RTRY_TMO = 128;
2075 if ((ostiGetTransportParam(
2077 globalStr, /* key */
2078 SwParmsStr, /* subkey1 */
2079 agNULL,/* subkey2 */
2082 agNULL, /* subkey5 */
2083 "SAS_DOPNRJT_RTRY_TMO", /* valueName */
2087 ) == tiSuccess) && (lenRecv != 0))
2089 if (osti_strncmp(buffer, "0x", 2) == 0)
2091 tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2095 tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2097 TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_TMO %d\n", tdsaAllShared->DOPNRJT_RTRY_TMO));
2099 /* End DOPNRJT_RTRY_TMO */
2101 /* Start COPNRJT_RTRY_TMO */
2102 osti_memset(buffer, 0, buffLen);
2104 // tdsaAllShared->COPNRJT_RTRY_TMO = 32;
2105 tdsaAllShared->COPNRJT_RTRY_TMO = 128;
2106 if ((ostiGetTransportParam(
2108 globalStr, /* key */
2109 SwParmsStr, /* subkey1 */
2110 agNULL,/* subkey2 */
2113 agNULL, /* subkey5 */
2114 "SAS_COPNRJT_RTRY_TMO", /* valueName */
2118 ) == tiSuccess) && (lenRecv != 0))
2120 if (osti_strncmp(buffer, "0x", 2) == 0)
2122 tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2126 tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2128 TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_TMO %d\n", tdsaAllShared->COPNRJT_RTRY_TMO));
2130 /* End COPNRJT_RTRY_TMO */
2132 /* Start DOPNRJT_RTRY_THR */
2133 osti_memset(buffer, 0, buffLen);
2135 // tdsaAllShared->DOPNRJT_RTRY_THR = 16; /* FW default */
2137 Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second.
2138 Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128 is tdsaAllShared->DOPNRJT_RTRY_TMO
2140 tdsaAllShared->DOPNRJT_RTRY_THR = 23438;
2141 if ((ostiGetTransportParam(
2143 globalStr, /* key */
2144 SwParmsStr, /* subkey1 */
2145 agNULL,/* subkey2 */
2148 agNULL, /* subkey5 */
2149 "SAS_DOPNRJT_RTRY_THR", /* valueName */
2153 ) == tiSuccess) && (lenRecv != 0))
2155 if (osti_strncmp(buffer, "0x", 2) == 0)
2157 tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
2161 tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
2163 TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_THR %d\n", tdsaAllShared->DOPNRJT_RTRY_THR));
2165 /* End DOPNRJT_RTRY_THR */
2167 /* Start COPNRJT_RTRY_THR */
2168 osti_memset(buffer, 0, buffLen);
2170 // tdsaAllShared->COPNRJT_RTRY_THR = 1024; /* FW default */
2172 Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second.
2173 Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128 is tdsaAllShared->COPNRJT_RTRY_TMO
2175 tdsaAllShared->COPNRJT_RTRY_THR = 23438;
2176 if ((ostiGetTransportParam(
2178 globalStr, /* key */
2179 SwParmsStr, /* subkey1 */
2180 agNULL,/* subkey2 */
2183 agNULL, /* subkey5 */
2184 "SAS_COPNRJT_RTRY_THR", /* valueName */
2188 ) == tiSuccess) && (lenRecv != 0))
2190 if (osti_strncmp(buffer, "0x", 2) == 0)
2192 tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
2196 tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
2198 TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_THR %d\n", tdsaAllShared->COPNRJT_RTRY_THR));
2200 /* End COPNRJT_RTRY_THR */
2203 osti_memset(buffer, 0, buffLen);
2205 tdsaAllShared->MAX_AIP = 0x200000;
2206 if ((ostiGetTransportParam(
2208 globalStr, /* key */
2209 SwParmsStr, /* subkey1 */
2210 agNULL,/* subkey2 */
2213 agNULL, /* subkey5 */
2214 "SAS_MAX_AIP", /* valueName */
2218 ) == tiSuccess) && (lenRecv != 0))
2220 if (osti_strncmp(buffer, "0x", 2) == 0)
2222 tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 0);
2226 tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 10);
2228 TI_DBG2(("tdsaGetSwConfigParams: MAX_AIP %d\n", tdsaAllShared->MAX_AIP));
2232 /***********************************************************************/
2233 osti_memset(buffer, 0, buffLen);
2238 typedef struct agsaMPIContext_s
2247 bit32 MpiContextvalue = 0;
2248 SwConfig->mpiContextTable = agNULL;
2249 SwConfig->mpiContextTablelen = 0;
2251 if ((ostiGetTransportParam(
2253 globalStr, /* key */
2254 SwParmsStr, /* subkey1 */
2255 agNULL, /* subkey2 */
2258 agNULL, /* subkey5 */
2259 "MpiContext", /* valueName */
2263 ) == tiSuccess) && (lenRecv != 0))
2266 if (osti_strncmp(buffer, "0x", 2) == 0)
2268 MpiContextvalue = osti_strtoul (buffer, &pLastUsedChar, 0);
2272 MpiContextvalue = osti_strtoul (buffer, &pLastUsedChar, 10);
2276 if (MpiContextvalue == 0)
2278 SwConfig->mpiContextTable = agNULL;
2279 SwConfig->mpiContextTablelen = 0;
2283 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2284 if(agNULL != tdsaRoot)
2286 tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = 0xFF;
2287 tdsaRoot->tdsaAllShared.MpiOverride.offset = 0;
2288 tdsaRoot->tdsaAllShared.MpiOverride.value = 0;
2290 SwConfig->mpiContextTable = &(tdsaRoot->tdsaAllShared.MpiOverride);
2291 SwConfig->mpiContextTablelen = sizeof(agsaMPIContext_t);
2294 TI_DBG1(("tdsaGetSwConfigParams: MpiContext %p Len %d\n", SwConfig->mpiContextTable, SwConfig->mpiContextTablelen));
2299 if(SwConfig->mpiContextTable != agNULL )
2301 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2302 if(agNULL != tdsaRoot)
2304 if ((ostiGetTransportParam(
2306 globalStr, /* key */
2307 SwParmsStr, /* subkey1 */
2308 agNULL, /* subkey2 */
2311 agNULL, /* subkey5 */
2312 "MpiTableType", /* valueName */
2316 ) == tiSuccess) && (lenRecv != 0))
2318 if (osti_strncmp(buffer, "0x", 2) == 0)
2320 tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = osti_strtoul (buffer, &pLastUsedChar, 0);
2324 tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = osti_strtoul (buffer, &pLastUsedChar, 10);
2326 TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.MPITableType 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.MPITableType ));
2329 if ((ostiGetTransportParam(
2331 globalStr, /* key */
2332 SwParmsStr, /* subkey1 */
2333 agNULL, /* subkey2 */
2336 agNULL, /* subkey5 */
2337 "MpiTableOffset", /* valueName */
2341 ) == tiSuccess) && (lenRecv != 0))
2343 if (osti_strncmp(buffer, "0x", 2) == 0)
2345 tdsaRoot->tdsaAllShared.MpiOverride.offset = osti_strtoul (buffer, &pLastUsedChar, 0);
2349 tdsaRoot->tdsaAllShared.MpiOverride.offset = osti_strtoul (buffer, &pLastUsedChar, 10);
2352 TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.offset 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.offset ));
2355 if ((ostiGetTransportParam(
2357 globalStr, /* key */
2358 SwParmsStr, /* subkey1 */
2359 agNULL, /* subkey2 */
2362 agNULL, /* subkey5 */
2363 "MpiTableValue", /* valueName */
2367 ) == tiSuccess) && (lenRecv != 0))
2369 if (osti_strncmp(buffer, "0x", 2) == 0)
2371 tdsaRoot->tdsaAllShared.MpiOverride.value = osti_strtoul (buffer, &pLastUsedChar, 0);
2375 tdsaRoot->tdsaAllShared.MpiOverride.value = osti_strtoul (buffer, &pLastUsedChar, 10);
2377 TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.value 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.value ));
2382 /***********************************************************************/
2384 #ifdef SA_ENABLE_PCI_TRIGGER
2386 osti_memset(buffer, 0, buffLen);
2389 if ((ostiGetTransportParam(
2391 globalStr, /* key */
2392 SwParmsStr, /* subkey1 */
2393 agNULL, /* subkey2 */
2396 agNULL, /* subkey5 */
2397 "PciTrigger", /* valueName */
2401 ) == tiSuccess) && (lenRecv != 0))
2404 if (osti_strncmp(buffer, "0x", 2) == 0)
2406 SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 0);
2410 SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 10);
2412 TI_DBG1(("tdsaGetSwConfigParams: PciTrigger %d\n",SwConfig->PCI_trigger));
2414 #endif /* SA_ENABLE_PCI_TRIGGER */
2417 TI_DBG6(("tdsaGetSwConfigParams: $$$$$$$$$$$$$$$$$ merge $$$$$$$$$$$$$\n"));
2418 #if defined(SALLSDK_DEBUG)
2419 TI_DBG2(("tdsaGetSwConfigParams: SwConfig->sallDebugLevel %d\n", SwConfig->sallDebugLevel));
2422 #ifdef SA_ENABLE_PCI_TRIGGER
2423 TI_DBG1(("tdsaGetSwConfigParams: SwConfig->PCI_trigger 0x%x 0x%x\n",SwConfig->PCI_trigger, tdsaRoot->itdsaIni->tdsaAllShared->SwConfig.PCI_trigger));
2424 #endif /* SA_ENABLE_PCI_TRIGGER */
2428 TI_DBG6(("tdsaLoLevelGetResource: SASConnectTimeLimit 0x%x\n",
2429 tdsaAllShared->SASConnectTimeLimit));
2435 /*****************************************************************************
2436 *! \brief tdsaParseLinkRateMode
2438 * Purpose: This function parses link rate and mode.
2440 * \param LinkRate: Link rate specified by user.
2441 * \param Mode: Link rate specified by user.
2444 * Value combined with Linkrate and Mode
2448 *****************************************************************************/
2450 tdsaParseLinkRateMode(
2455 bit32 OpticalModeRead,
2461 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2462 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
2464 TI_DBG3(("tdsaParseLinkRateMode: index 0x%X\n",index));
2465 TI_DBG3(("tdsaParseLinkRateMode: LinkRateRead 0x%X LinkRate 0x%X\n",LinkRateRead,LinkRate));
2466 TI_DBG3(("tdsaParseLinkRateMode: ModeRead 0x%X Mode 0x%X\n",ModeRead,Mode));
2467 TI_DBG3(("tdsaParseLinkRateMode: OpticalModeRead 0x%X OpticalMode 0x%X\n",OpticalModeRead,OpticalMode));
2470 if (LinkRateRead == agTRUE)
2475 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
2479 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x2;
2483 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x4;
2487 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x8;
2489 if (LinkRate == 0 || LinkRate > 0xF )
2491 /* not allowed, set the rate to default 1.5 G */
2492 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = 0;
2493 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
2494 TI_DBG1(("tdsaParseLinkRateMode: LinkRate == 0 || LinkRate >= 0x%x\n",tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2496 TI_DBG2(("tdsaParseLinkRateMode:A index 0x%x LinkRate 0x%x Mode 0x%x\n",index,LinkRate,Mode));
2500 if ( ModeRead == agTRUE)
2505 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x10;
2509 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x20;
2511 if (Mode == 0 || Mode >= 4 )
2513 /* not allowed, set the mode to default SAS/SATA */
2514 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties & 0xf;
2515 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x30;
2517 TI_DBG2(("tdsaParseLinkRateMode:1 index 0x%x Mode 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2520 if ( OpticalModeRead == agTRUE)
2523 agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
2525 if (OpticalMode == 0)
2527 TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 0 phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2529 else if(OpticalMode == 1)
2531 if(tIsSPCV12or6G(agRoot))
2533 TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 1 phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2534 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
2538 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
2539 tdsaAllShared->Ports[index].agPhyConfig.phyProperties &= 0xFFFFFFF0;
2540 tdsaAllShared->Ports[index].agPhyConfig.phyProperties |= 0x4;
2543 else if(OpticalMode == 2 )
2545 if(tIsSPCV12or6G(agRoot))
2547 TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 2 phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2548 tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 20);
2552 TD_ASSERT(0, "SPC optical mode 2");
2555 TI_DBG1(("tdsaParseLinkRateMode: OpticalMode %d phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2559 TI_DBG1(("tdsaParseLinkRateMode: OpticalMode unknown %d phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2564 TI_DBG1(("tdsaParseLinkRateMode: OpticalMode off phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2567 TI_DBG1(("tdsaParseLinkRateMode: phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2574 /*****************************************************************************
2575 *! \brief tdsaGetHwConfigParams
2577 * Purpose: This function reads hardware configuration parameters from the
2578 * configuration file
2580 * \param tiRoot: Pointer to driver/port instance.
2586 *****************************************************************************/
2588 tdsaGetHwConfigParams(
2592 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2593 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
2594 agsaHwConfig_t *HwConfig;
2598 char *pLastUsedChar = agNULL;
2599 char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
2600 char globalStr[] = "Global";
2601 char HwParmsStr[] = "HWParms";
2604 agsaPhyAnalogSetupTable_t *phyRegTable;
2606 TI_DBG6(("tdsaGetHwConfigParams: start\n"));
2607 TI_DBG6(("tdsaGetHwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
2610 buffLen = sizeof(tmpBuffer);
2612 osti_memset(buffer, 0, buffLen);
2614 HwConfig = (agsaHwConfig_t *)&(tdsaAllShared->HwConfig);
2615 phyRegTable = (agsaPhyAnalogSetupTable_t *)&(HwConfig->phyAnalogConfig);
2617 osti_memset(HwConfig, 0, sizeof(agsaHwConfig_t));
2621 and are overwritten later by the configuration file contents
2622 turning off hw control interrupt coalescing
2624 tdsaAllShared->FWMaxPorts = DEFAULT_FW_MAX_PORTS; /* 8, applicable only to SPC not to SPCv */
2625 HwConfig->phyCount = TD_MAX_NUM_PHYS;
2626 HwConfig->hwInterruptCoalescingTimer = 1;
2627 HwConfig->hwInterruptCoalescingControl = 0;
2628 tdsaAllShared->phyCalibration = 0;
2629 HwConfig->hwOption = 0; /* default: PI/CI addresses are 32-bit */
2631 osti_memset(buffer, 0, buffLen);
2634 if ((ostiGetTransportParam(
2636 globalStr, /* key */
2637 HwParmsStr, /* subkey1 */
2638 agNULL, /* subkey2 */
2641 agNULL, /* subkey5 */
2642 "HwIntCoalTimer", /* valueName */
2646 ) == tiSuccess) && (lenRecv != 0))
2648 if (osti_strncmp(buffer, "0x", 2) == 0)
2650 HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 0);
2654 HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 10);
2658 osti_memset(buffer, 0, buffLen);
2661 if ((ostiGetTransportParam(
2663 globalStr, /* key */
2664 HwParmsStr, /* subkey1 */
2665 agNULL, /* subkey2 */
2668 agNULL, /* subkey5 */
2669 "HwIntCoalControl", /* valueName */
2673 ) == tiSuccess) && (lenRecv != 0))
2675 if (osti_strncmp(buffer, "0x", 2) == 0)
2677 HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 0);
2681 HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 10);
2685 /* For hwInterruptCoalescingTimer, 0 disables interrrupt, not allowed */
2686 if (HwConfig->hwInterruptCoalescingControl == 1 && HwConfig->hwInterruptCoalescingTimer == 0)
2688 HwConfig->hwInterruptCoalescingTimer = 1;
2691 osti_memset(buffer, 0, buffLen);
2694 /* interrupt reassetion field*/
2695 if ((ostiGetTransportParam(
2697 globalStr, /* key */
2698 HwParmsStr, /* subkey1 */
2699 agNULL, /* subkey2 */
2702 agNULL, /* subkey5 */
2703 "IntReassertionOpt", /* valueName */
2707 ) == tiSuccess) && (lenRecv != 0))
2709 if (osti_strncmp(buffer, "0x", 2) == 0)
2711 HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 0);
2715 HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 10);
2719 osti_memset(buffer, 0, buffLen);
2722 /* interrupt reassetion field*/
2723 if ((ostiGetTransportParam(
2725 globalStr, /* key */
2726 HwParmsStr, /* subkey1 */
2727 agNULL, /* subkey2 */
2730 agNULL, /* subkey5 */
2731 "HwOption", /* valueName */
2735 ) == tiSuccess) && (lenRecv != 0))
2737 if (osti_strncmp(buffer, "0x", 2) == 0)
2739 HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 0);
2743 HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 10);
2747 osti_memset(buffer, 0, buffLen);
2750 /* interrupt reassetion field*/
2751 if ((ostiGetTransportParam(
2753 globalStr, /* key */
2754 HwParmsStr, /* subkey1 */
2755 agNULL, /* subkey2 */
2758 agNULL, /* subkey5 */
2759 "MaxFWPorts", /* valueName */
2763 ) == tiSuccess) && (lenRecv != 0))
2765 if (osti_strncmp(buffer, "0x", 2) == 0)
2767 tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 0);
2771 tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 10);
2775 osti_memset(buffer, 0, buffLen);
2778 if ((ostiGetTransportParam(
2780 globalStr, /* key */
2781 HwParmsStr, /* subkey1 */
2782 agNULL, /* subkey2 */
2785 agNULL, /* subkey5 */
2786 "phyCalibration", /* valueName */
2790 ) == tiSuccess) && (lenRecv != 0))
2792 if (osti_strncmp(buffer, "0x", 2) == 0)
2794 tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 0);
2798 tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 10);
2802 osti_memset(buffer, 0, buffLen);
2806 /* phy calibration */
2807 for (i=0;i<MAX_INDEX;i++)
2811 osti_sprintf(phyReg,"spaReg%d%d",i,j);
2812 TI_DBG6(("tdsaGetHwConfigParams: phyReg %s\n", phyReg));
2816 if ((ostiGetTransportParam(
2818 globalStr, /* key */
2819 HwParmsStr, /* subkey1 */
2820 agNULL, /* subkey2 */
2823 agNULL, /* subkey5 */
2824 phyReg, /* valueName */
2828 ) == tiSuccess) && (lenRecv != 0))
2830 if (osti_strncmp(buffer, "0x", 2) == 0)
2832 phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 0);
2836 phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 10);
2840 osti_memset(buffer, 0, buffLen);
2845 if ((ostiGetTransportParam(
2847 globalStr, /* key */
2848 HwParmsStr, /* subkey1 */
2849 agNULL, /* subkey2 */
2852 agNULL, /* subkey5 */
2853 phyReg, /* valueName */
2857 ) == tiSuccess) && (lenRecv != 0))
2859 if (osti_strncmp(buffer, "0x", 2) == 0)
2861 phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 0);
2865 phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 10);
2869 osti_memset(buffer, 0, buffLen);
2874 if ((ostiGetTransportParam(
2876 globalStr, /* key */
2877 HwParmsStr, /* subkey1 */
2878 agNULL, /* subkey2 */
2881 agNULL, /* subkey5 */
2882 phyReg, /* valueName */
2886 ) == tiSuccess) && (lenRecv != 0))
2888 if (osti_strncmp(buffer, "0x", 2) == 0)
2890 phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 0);
2894 phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 10);
2898 osti_memset(buffer, 0, buffLen);
2903 if ((ostiGetTransportParam(
2905 globalStr, /* key */
2906 HwParmsStr, /* subkey1 */
2907 agNULL, /* subkey2 */
2910 agNULL, /* subkey5 */
2911 phyReg, /* valueName */
2915 ) == tiSuccess) && (lenRecv != 0))
2917 if (osti_strncmp(buffer, "0x", 2) == 0)
2919 phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 0);
2923 phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 10);
2927 osti_memset(buffer, 0, buffLen);
2932 if ((ostiGetTransportParam(
2934 globalStr, /* key */
2935 HwParmsStr, /* subkey1 */
2936 agNULL, /* subkey2 */
2939 agNULL, /* subkey5 */
2940 phyReg, /* valueName */
2944 ) == tiSuccess) && (lenRecv != 0))
2946 if (osti_strncmp(buffer, "0x", 2) == 0)
2948 phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 0);
2952 phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 10);
2956 osti_memset(buffer, 0, buffLen);
2961 if ((ostiGetTransportParam(
2963 globalStr, /* key */
2964 HwParmsStr, /* subkey1 */
2965 agNULL, /* subkey2 */
2968 agNULL, /* subkey5 */
2969 phyReg, /* valueName */
2973 ) == tiSuccess) && (lenRecv != 0))
2975 if (osti_strncmp(buffer, "0x", 2) == 0)
2977 phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 0);
2981 phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 10);
2985 osti_memset(buffer, 0, buffLen);
2990 if ((ostiGetTransportParam(
2992 globalStr, /* key */
2993 HwParmsStr, /* subkey1 */
2994 agNULL, /* subkey2 */
2997 agNULL, /* subkey5 */
2998 phyReg, /* valueName */
3002 ) == tiSuccess) && (lenRecv != 0))
3004 if (osti_strncmp(buffer, "0x", 2) == 0)
3006 phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 0);
3010 phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 10);
3014 osti_memset(buffer, 0, buffLen);
3019 if ((ostiGetTransportParam(
3021 globalStr, /* key */
3022 HwParmsStr, /* subkey1 */
3023 agNULL, /* subkey2 */
3026 agNULL, /* subkey5 */
3027 phyReg, /* valueName */
3031 ) == tiSuccess) && (lenRecv != 0))
3033 if (osti_strncmp(buffer, "0x", 2) == 0)
3035 phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 0);
3039 phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 10);
3043 osti_memset(buffer, 0, buffLen);
3048 if ((ostiGetTransportParam(
3050 globalStr, /* key */
3051 HwParmsStr, /* subkey1 */
3052 agNULL, /* subkey2 */
3055 agNULL, /* subkey5 */
3056 phyReg, /* valueName */
3060 ) == tiSuccess) && (lenRecv != 0))
3062 if (osti_strncmp(buffer, "0x", 2) == 0)
3064 phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 0);
3068 phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 10);
3072 osti_memset(buffer, 0, buffLen);
3077 if ((ostiGetTransportParam(
3079 globalStr, /* key */
3080 HwParmsStr, /* subkey1 */
3081 agNULL, /* subkey2 */
3084 agNULL, /* subkey5 */
3085 phyReg, /* valueName */
3089 ) == tiSuccess) && (lenRecv != 0))
3091 if (osti_strncmp(buffer, "0x", 2) == 0)
3093 phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 0);
3097 phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 10);
3101 osti_memset(buffer, 0, buffLen);
3109 /*****************************************************************************
3110 *! \brief tdsaGetCardPhyParams
3112 * Purpose: This function reads phy-related configuration parameters from the
3113 * configuration file
3115 * \param tiRoot: Pointer to driver/port instance.
3119 * \note - just a place holder for now
3121 *****************************************************************************/
3123 tdsaGetCardPhyParams(
3127 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3128 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3129 agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
3133 char *pLastUsedChar = agNULL;
3134 char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3135 char *globalStr = tdsaAllShared->CardIDString;
3136 char phyParmsStr[12];
3138 bit32 LinkRate = 15, Mode = 3, OpticalMode = 0; //VG
3139 bit32 LinkRateRead = agTRUE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
3140 bit32 flag = agFALSE; /* true only for PM8008 or PM8009 (SPCv and SPCve) controller */
3142 TI_DBG6(("tdsaGetCardPhyParams: start \n"));
3143 TI_DBG6(("tdsaGetCardPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3145 if (tiIS_8PHY(agRoot))
3147 TI_DBG6(("tdsaGetCardPhyParams: SPCv or SPCve \n"));
3150 TI_DBG6(("tdsaGetCardPhyParams: flag %d\n", flag));
3154 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3156 /* setting default phy properties */
3157 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3158 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3159 /* 1.5G only, SAS/SATA, no spin-up control */
3160 tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 */
3163 #ifdef INITIATOR_DRIVER
3165 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3167 /* setting default phy properties */
3168 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3169 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3170 /* 1.5G/3G , SAS/SATA, no spin-up control */
3171 tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37; /* 55 */
3172 TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3176 #ifdef TARGET_DRIVER
3178 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3180 /* setting default phy properties */
3181 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3182 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3183 /* 1.5G/3G , SAS/SATA, no spin-up control */
3184 tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37; /* 55 */
3185 TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3190 #endif /* REMOVED */
3194 buffLen = sizeof(tmpBuffer);
3196 osti_memset(buffer, 0, buffLen);
3199 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3201 if (flag == agFALSE)
3203 osti_sprintf(phyParmsStr,"PhyParms%d", i);
3209 osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
3213 osti_sprintf(phyParmsStr,"PhyParms%d", i);
3217 TI_DBG6(("tdsaGetCardPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
3219 TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3222 if ((ostiGetTransportParam (
3234 ) == tiSuccess) && (lenRecv != 0))
3236 if (osti_strncmp(buffer, "0x", 2) == 0)
3238 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3239 TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3243 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3244 TI_DBG6(("tdsaGetCardPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3249 osti_memset(buffer, 0, buffLen);
3252 if ((ostiGetTransportParam (
3264 ) == tiSuccess) && (lenRecv != 0))
3266 if (osti_strncmp(buffer, "0x", 2) == 0)
3268 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3269 TI_DBG6(("tdsaGetCardPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3273 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3274 TI_DBG6(("tdsaGetCardPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3277 TI_DBG6(("tdsaGetCardPhyParams: loop phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3279 /* phy properties */
3280 osti_memset(buffer, 0, buffLen);
3283 if ((ostiGetTransportParam (
3295 ) == tiSuccess) && (lenRecv != 0))
3297 LinkRateRead = agTRUE;
3298 if (osti_strncmp(buffer, "0x", 2) == 0)
3300 LinkRate = osti_strtoul(buffer, &pLastUsedChar, 0);
3301 TI_DBG6(("tdsaGetCardPhyParams: phy %d linkrate 0x%x \n", i, LinkRate));
3305 LinkRate = osti_strtoul(buffer, &pLastUsedChar, 10);
3306 TI_DBG6(("tdsaGetCardPhyParams: phy %d linkrate %d \n", i, LinkRate));
3310 TI_DBG2(("tdsaGetCardPhyParams: phy %d linkrate %d \n", i, LinkRate));
3313 osti_memset(buffer, 0, buffLen);
3316 if ((ostiGetTransportParam (
3328 ) == tiSuccess) && (lenRecv != 0))
3331 if (osti_strncmp(buffer, "0x", 2) == 0)
3333 Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
3334 TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode 0x%x \n", i, Mode));
3338 Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
3339 TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode %d \n", i, Mode));
3343 osti_memset(buffer, 0, buffLen);
3346 if ((ostiGetTransportParam (
3358 ) == tiSuccess) && (lenRecv != 0))
3360 OpticalModeRead = agTRUE;
3361 if (osti_strncmp(buffer, "0x", 2) == 0)
3363 OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
3364 TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
3368 OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
3369 TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
3373 tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
3375 TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3378 /**********************************************/
3379 osti_memset(buffer, 0, buffLen);
3381 LinkRateRead = agTRUE;//VG
3383 OpticalModeRead = agFALSE;
3393 /*****************************************************************************
3394 *! \brief tdsaGetGlobalPhyParams
3396 * Purpose: This function reads phy-related configuration parameters from the
3397 * configuration file
3399 * \param tiRoot: Pointer to driver/port instance.
3403 * \note - just a place holder for now
3405 *****************************************************************************/
3407 tdsaGetGlobalPhyParams(
3411 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3412 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3413 agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
3417 char *pLastUsedChar = agNULL;
3418 char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3419 char globalStr[] = "Global";
3420 char phyParmsStr[12];
3422 bit32 LinkRate = 15/*7*/, Mode = 3, OpticalMode = 0;
3423 bit32 LinkRateRead = agFALSE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
3424 bit32 flag = agFALSE; /* true only for PM8008 or PM8009 (SPCv and SPCve) controller */
3426 TI_DBG6(("tdsaGetGlobalPhyParams: start \n"));
3427 TI_DBG6(("tdsaGetGlobalPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3429 if (tiIS_8PHY(agRoot) )
3431 TI_DBG6(("tdsaGetGlobalPhyParams: SPCv or SPCve \n"));
3435 TI_DBG6(("tdsaGetGlobalPhyParams: flag %d\n", flag));
3438 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3440 /* setting default phy properties */
3441 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3442 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3443 /* 1.5G only, SAS/SATA, no spin-up control */
3444 tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 */
3448 #ifdef INITIATOR_DRIVER
3449 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3451 /* setting default phy properties */
3452 if (flag == agFALSE) /* SPC or SPCv+ */
3454 if (0 <= i && i <= 7)
3456 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3457 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3461 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
3462 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
3465 else /* SPCv or SPCve */
3467 if (0 <= i && i <= 3)
3469 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3470 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3472 else if (4 <= i && i <= 7)
3474 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3475 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
3477 else /* don't care */
3479 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
3480 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f);
3484 /* 1.5G/3G , SAS/SATA, no spin-up control */
3485 tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 55 */
3486 TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3490 #ifdef TARGET_DRIVER
3491 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3493 /* setting default phy properties */
3494 /* SPC; narrow ports; 8 ports
3495 SPCv, SPCve wide port; 8 ports
3496 SPCv+ wide port; 16 ports
3498 if (tiIS_SPC(agRoot))
3500 if (0 <= i && i <= 7)
3502 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3503 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3507 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3508 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3511 else if (tiIS_16PHY(agRoot))
3513 if (0 <= i && i <= 7)
3515 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3516 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3520 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3521 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3526 if (0 <= i && i <= 3)
3528 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3529 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3531 else if (4 <= i && i <= 7)
3533 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3534 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3536 else /* don't care */
3538 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3539 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f+i);
3542 /* 1.5G/3G , SAS/SATA, no spin-up control */
3543 tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 The default is 1.5G and will be changed based on the registry value */
3544 TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3552 buffLen = sizeof(tmpBuffer);
3554 osti_memset(buffer, 0, buffLen);
3557 /* needs to read Phy's id frame */
3558 for (i=0;i<TD_MAX_NUM_PHYS;i++)
3560 if (flag == agFALSE)
3562 osti_sprintf(phyParmsStr,"PhyParms%d", i);
3568 osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
3572 osti_sprintf(phyParmsStr,"PhyParms%d", i);
3576 TI_DBG6(("tdsaGetGlobalPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
3579 if ((ostiGetTransportParam (
3591 ) == tiSuccess) && (lenRecv != 0))
3593 if (osti_strncmp(buffer, "0x", 2) == 0)
3595 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3596 TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3600 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3601 TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3607 osti_memset(buffer, 0, buffLen);
3610 if ((ostiGetTransportParam (
3622 ) == tiSuccess) && (lenRecv != 0))
3624 if (osti_strncmp(buffer, "0x", 2) == 0)
3626 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3627 TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3631 OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3632 TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3636 TI_DBG6(("tdsaGetGlobalPhyParams: loop phy %d hi 0x%x lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID)), SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3638 /* phy properties */
3639 osti_memset(buffer, 0, buffLen);
3642 if ((ostiGetTransportParam (
3654 ) == tiSuccess) && (lenRecv != 0))
3656 LinkRateRead = agTRUE;
3657 if (osti_strncmp(buffer, "0x", 2) == 0)
3659 LinkRate = osti_strtoul(buffer, &pLastUsedChar, 0);
3660 TI_DBG2(("tdsaGetGlobalPhyParams: phy %d linkrate 0x%x \n", i, LinkRate));
3664 LinkRate = osti_strtoul(buffer, &pLastUsedChar, 10);
3665 TI_DBG2(("tdsaGetGlobalPhyParams: phy %d linkrate %d \n", i, LinkRate));
3670 osti_memset(buffer, 0, buffLen);
3673 if ((ostiGetTransportParam (
3685 ) == tiSuccess) && (lenRecv != 0))
3688 if (osti_strncmp(buffer, "0x", 2) == 0)
3690 Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
3691 TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode 0x%x \n", i, Mode));
3695 Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
3696 TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode %d \n", i, Mode));
3700 osti_memset(buffer, 0, buffLen);
3703 if ((ostiGetTransportParam (
3715 ) == tiSuccess) && (lenRecv != 0))
3717 OpticalModeRead = agTRUE;
3718 if (osti_strncmp(buffer, "0x", 2) == 0)
3720 OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
3721 TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
3725 OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
3726 TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
3730 TI_DBG2(("tdsaGetGlobalPhyParams:A phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3731 tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
3733 TI_DBG2(("tdsaGetGlobalPhyParams:B phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3737 /**********************************************/
3738 osti_memset(buffer, 0, buffLen);
3740 /* restore default */
3744 LinkRateRead = agTRUE;//VG
3746 OpticalModeRead = agFALSE;
3754 /*****************************************************************************
3755 *! \brief tdsaGetPortParams
3757 * Purpose: This function reads port-related configuration parameters from the
3758 * configuration file
3760 * \param tiRoot: Pointer to driver/port instance.
3764 * \note - just a place holder for now
3766 *****************************************************************************/
3772 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3773 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3779 char *pLastUsedChar = agNULL;
3780 char tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3781 char globalStr[] = "Global";
3782 char portParmsStr[] = "PortParms";
3784 TI_DBG6(("tdsaGetPortParams: start \n"));
3785 TI_DBG6(("tdsaGetPortParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3788 buffLen = sizeof(tmpBuffer);
3789 osti_memset(buffer, 0, buffLen);
3791 if ((ostiGetTransportParam (
3803 ) == tiSuccess) && (lenRecv != 0))
3805 if (osti_strncmp(buffer, "0x", 2) == 0)
3807 tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 0);
3811 tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 10);
3813 TI_DBG6(("tdsaGetPortParams: in \n"));
3815 osti_memset(buffer, 0, buffLen);
3818 TI_DBG6(("tdsaGetPortParams: out \n"));
3826 #ifdef FW_EVT_LOG_TST
3827 void saLogDump(agsaRoot_t *agRoot,
3829 U32 **eventLogAddress);
3831 void tiLogDump(tiRoot_t *tiRoot, U32 *size, U32 **addr)
3833 tdsaRoot_t *tdsaRoot;
3834 tdsaContext_t *tdsaAllShared;
3836 tdsaRoot = (tdsaRoot_t*)tiRoot->tdData;
3837 tdsaAllShared = (tdsaContext_t*)&(tdsaRoot->tdsaAllShared);
3838 saLogDump(&tdsaAllShared->agRootNonInt, size, addr);
3844 /*****************************************************************************
3845 *! \brief tiCOMPortInit
3847 * Purpose: This function is called to initialize the port hardware.
3848 * This call could only be called until after the successful
3849 * completion tiCOMInit().
3851 * \param tiRoot: Pointer to root data structure.
3852 * \param sysIntsActive: system interrupt flag
3855 * tiSuccess: Successful.
3860 *****************************************************************************/
3867 tdsaRoot_t *tdsaRoot;
3868 tdsaContext_t *tdsaAllShared;
3870 tiLoLevelResource_t *loResource;
3871 bit32 status = tiError;
3874 agsaQueueConfig_t *QueueConfig;
3876 #ifdef CONTROLLER_STATUS_TESTING
3877 static agsaControllerStatus_t agcontrollerStatus;
3878 #endif /* CONTROLLER_STATUS_TESTING */
3880 #ifdef CONTROLLER_INFO_TESTING
3881 static agsaControllerInfo_t agcontrollerInfo;
3882 #endif /* CONTROLLER_INFO_TESTING */
3884 #ifdef CONTROLLER_ENCRYPT_TESTING
3885 static agsaEncryptInfo_t agsaEncryptInfo;
3886 #endif /* CONTROLLER_INFO_TESTING */
3888 static agsaMemoryRequirement_t agMemoryRequirement;
3891 static bit8 payload[56];
3894 #if defined(FDS_DM) || defined(FDS_SM)
3895 static agsaMemoryRequirement_t memRequirement;
3896 bit32 maxQueueSets = 0;
3897 bit32 LLMemCount = 0;
3898 bit32 usecsPerTick = 0;
3899 static agsaSwConfig_t tmpLLSwConfig;
3903 static dmRoot_t *dmRoot = agNULL;
3905 static dmSwConfig_t dmSwConfig;
3907 static dmMemoryRequirement_t dmMemRequirement;
3908 bit32 DMMemCount = 0;
3911 #if defined(FDS_DM) && defined(FDS_SM)
3912 bit32 dmUsecsPerTick = 0;
3913 bit32 dmMaxNumLocks = 0;
3917 smRoot_t *smRoot = agNULL;
3918 // smSwConfig_t smSwConfig;
3919 static smMemoryRequirement_t smMemRequirement;
3920 bit32 SMMemCount = 0;
3923 #ifndef TURN_OFF_HDA
3924 static agsaFwImg_t HDAImg;
3925 #endif /* TURN_OFF_HDA */
3927 TI_DBG3(("tiCOMPortInit: start\n"));
3928 TI_DBG6(("tiCOMPortInit: sizeof agsaMemoryRequirement_t %d\n", (int)sizeof(agsaMemoryRequirement_t)));
3930 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3931 tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3933 osti_memset(&agMemoryRequirement, 0, sizeof(agsaMemoryRequirement_t));
3935 * don't do anything if reset is in progress
3937 if (tdsaAllShared->flags.resetInProgress == agTRUE)
3939 TI_DBG1(("tiCOMPortInit: resetinProgress error\n"));
3943 loResource = &(tdsaAllShared->loResource);
3945 agRoot = &(tdsaAllShared->agRootNonInt);
3946 tdsaAllShared->flags.sysIntsActive = sysIntsActive;
3949 gets port-related parameters; not in use for now
3950 tdsaGetPortParams(tiRoot);
3953 /* call these before agroot is created for testing */
3956 #ifdef CONTROLLER_STATUS_TESTING
3957 TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
3958 #endif /* CONTROLLER_INFO_TESTING */
3960 #ifdef CONTROLLER_INFO_TESTING
3961 TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
3962 #endif /* CONTROLLER_INFO_TESTING */
3964 #ifdef CONTROLLER_ENCRYPT_TESTING
3965 TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo ) ));
3966 #endif /* CONTROLLER_INFO_TESTING */
3969 tdsaGetSwConfigParams(tiRoot);
3970 tdsaPrintSwConfig(&(tdsaAllShared->SwConfig));
3972 /* setting interrupt requirements */
3973 tdsaAllShared->SwConfig.max_MSIX_InterruptVectors = loResource->loLevelOption.maxInterruptVectors;
3974 tdsaAllShared->SwConfig.max_MSI_InterruptVectors = loResource->loLevelOption.max_MSI_InterruptVectors;
3975 tdsaAllShared->SwConfig.legacyInt_X = loResource->loLevelOption.flag;
3976 TI_DBG2(("tiCOMPortInit: got max_MSIX_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSIX_InterruptVectors));
3977 TI_DBG2(("tiCOMPortInit: got max_MSI_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSI_InterruptVectors));
3978 TI_DBG2(("tiCOMPortInit: got flag - legacyInt_X %d \n", tdsaAllShared->SwConfig.legacyInt_X));
3980 /* error checking for interrupt types */
3982 ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3983 (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0) &&
3984 (tdsaAllShared->SwConfig.legacyInt_X == 0))
3986 ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0) &&
3987 (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0) &&
3988 (tdsaAllShared->SwConfig.legacyInt_X == 0))
3990 ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3991 (tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0) &&
3992 (tdsaAllShared->SwConfig.legacyInt_X == 0))
3994 ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3995 (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0) &&
3996 (tdsaAllShared->SwConfig.legacyInt_X != 0))
4003 TI_DBG1(("tiCOMPortInit: incorrect interrupt\n"));
4007 QueueConfig = &tdsaAllShared->QueueConfig;
4009 for(i=0;i<QueueConfig->numInboundQueues;i++)
4011 QueueConfig->inboundQueues[i].elementCount = tdsaAllShared->InboundQueueSize[i];
4012 QueueConfig->inboundQueues[i].elementSize = tdsaAllShared->InboundQueueEleSize[i];
4013 QueueConfig->inboundQueues[i].priority = tdsaAllShared->InboundQueuePriority[i];
4014 QueueConfig->inboundQueues[i].reserved = 0;
4015 TI_DBG6(("tiCOMPortInit: InboundQueuePriroity %d \n", tdsaAllShared->InboundQueuePriority[i]));
4017 for(i=0;i<QueueConfig->numOutboundQueues;i++)
4019 QueueConfig->outboundQueues[i].elementCount = tdsaAllShared->OutboundQueueSize[i];
4020 QueueConfig->outboundQueues[i].elementSize = tdsaAllShared->OutboundQueueEleSize[i];
4021 QueueConfig->outboundQueues[i].interruptDelay = tdsaAllShared->OutboundQueueInterruptDelay[i]; /* default 0; no interrupt delay */
4022 QueueConfig->outboundQueues[i].interruptCount = tdsaAllShared->OutboundQueueInterruptCount[i]; /* default 1 */
4023 QueueConfig->outboundQueues[i].interruptEnable = tdsaAllShared->OutboundQueueInterruptEnable[i]; /* default 1 */
4024 QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
4025 if (tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0)
4027 QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSIX_InterruptVectors;
4029 else if (tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0)
4031 QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSI_InterruptVectors;
4035 QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
4037 TI_DBG6(("tiCOMPortInit: OutboundQueueInterruptDelay %d OutboundQueueInterruptCount %d OutboundQueueInterruptEnable %d\n", tdsaAllShared->OutboundQueueInterruptDelay[i], tdsaAllShared->OutboundQueueInterruptCount[i], tdsaAllShared->OutboundQueueInterruptEnable[i]));
4041 QueueConfig->queueOption = tdsaAllShared->QueueOption;
4043 tdsaAllShared->SwConfig.param3 = (void *)QueueConfig;
4044 tdsaAllShared->SwConfig.stallUsec = 10;
4046 /* finds a first high priority queue for SMP */
4047 tdsaAllShared->SMPQNum = 0; /* default */
4048 for(i=0;i<QueueConfig->numInboundQueues;i++)
4050 if (QueueConfig->inboundQueues[i].priority != DEFAULT_INBOUND_QUEUE_PRIORITY) /* 0 */
4052 tdsaAllShared->SMPQNum = i;
4057 tdsaGetHwConfigParams(tiRoot);
4059 tdsaPrintHwConfig(&(tdsaAllShared->HwConfig));
4061 #ifdef TARGET_DRIVER
4062 /* target, not yet */
4063 if (tdsaAllShared->currentOperation & TD_OPERATION_TARGET)
4065 ttdssGetTargetParams(tiRoot);
4069 #if defined(FDS_DM) && defined(FDS_SM)
4071 needs to call saGetRequirements() to find out agMemoryRequirement.count requested by LL
4073 osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4075 saGetRequirements(agRoot,
4081 TI_DBG1(("tiCOMPortInit: usecsPerTick %d\n", usecsPerTick));
4083 TI_DBG1(("tiCOMPortInit: LL memRequirement.count %d\n", memRequirement.count));
4084 TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4085 LLMemCount = memRequirement.count;
4088 needs to call dmGetRequirements() to find out dmMemoryRequirement.count requested by DM
4091 dmGetRequirements(dmRoot,
4098 TI_DBG1(("tiCOMPortInit: DM dmmemRequirement.count %d\n", dmMemRequirement.count));
4099 TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4101 DMMemCount = dmMemRequirement.count;
4102 SMMemCount = loResource->loLevelMem.count - LLMemCount - DMMemCount;
4103 agMemoryRequirement.count = LLMemCount;
4105 TI_DBG1(("tiCOMPortInit: SMMemCount %d\n", SMMemCount));
4108 #elif defined(FDS_DM)
4110 needs to call saGetRequirements() to find out agMemoryRequirement.count requested by LL
4112 osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4114 saGetRequirements(agRoot,
4121 TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
4122 TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4124 LLMemCount = memRequirement.count;
4125 DMMemCount = loResource->loLevelMem.count - LLMemCount;
4127 agMemoryRequirement.count = LLMemCount;
4129 #elif defined(FDS_SM)
4130 osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4132 saGetRequirements(agRoot,
4139 TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
4140 TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4142 LLMemCount = memRequirement.count;
4143 SMMemCount = loResource->loLevelMem.count - LLMemCount;
4145 agMemoryRequirement.count = LLMemCount;
4149 agMemoryRequirement.count = loResource->loLevelMem.count;
4153 #if defined(FDS_DM) && defined(FDS_SM)
4155 for(i=0;i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
4157 TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].physAddrUpper, loResource->loLevelMem.mem[i].physAddrLower, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].alignment));
4158 TI_DBG2(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4163 TI_DBG6(("tiCOMPortInit: AGSA_NUM_MEM_CHUNKS %d\n", AGSA_NUM_MEM_CHUNKS));
4164 for(i=0;i<AGSA_NUM_MEM_CHUNKS;i++)
4166 agMemoryRequirement.agMemory[i].virtPtr = agNULL;
4167 agMemoryRequirement.agMemory[i].osHandle = agNULL;
4168 agMemoryRequirement.agMemory[i].phyAddrUpper = 0;
4169 agMemoryRequirement.agMemory[i].phyAddrLower = 0;
4170 agMemoryRequirement.agMemory[i].totalLength = 0;
4171 agMemoryRequirement.agMemory[i].numElements = 0;
4172 agMemoryRequirement.agMemory[i].singleElementLength = 0;
4173 agMemoryRequirement.agMemory[i].alignment = 0;
4174 agMemoryRequirement.agMemory[i].type = 0;
4175 agMemoryRequirement.agMemory[i].reserved = 0;
4178 for(i=0;i<(int)agMemoryRequirement.count;i++)
4180 TI_DBG2(("tiCOMPortInit: LL copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4181 agMemoryRequirement.agMemory[i].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4182 agMemoryRequirement.agMemory[i].osHandle = loResource->loLevelMem.mem[i].osHandle;
4183 agMemoryRequirement.agMemory[i].phyAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4184 agMemoryRequirement.agMemory[i].phyAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4185 agMemoryRequirement.agMemory[i].totalLength = loResource->loLevelMem.mem[i].totalLength;
4186 agMemoryRequirement.agMemory[i].numElements = loResource->loLevelMem.mem[i].numElements;
4187 agMemoryRequirement.agMemory[i].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4188 agMemoryRequirement.agMemory[i].alignment = loResource->loLevelMem.mem[i].alignment;
4189 if (loResource->loLevelMem.mem[i].type == TI_DMA_MEM)
4191 agMemoryRequirement.agMemory[i].type = AGSA_DMA_MEM;
4193 else if (loResource->loLevelMem.mem[i].type == TI_CACHED_MEM)
4195 agMemoryRequirement.agMemory[i].type = AGSA_CACHED_MEM;
4198 else if (loResource->loLevelMem.mem[i].type == TI_CACHED_DMA_MEM)
4200 agMemoryRequirement.agMemory[i].type = AGSA_CACHED_DMA_MEM;
4203 agMemoryRequirement.agMemory[i].reserved = loResource->loLevelMem.mem[i].reserved;
4204 TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4205 TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4206 loResource->loLevelMem.mem[i].physAddrUpper,
4207 loResource->loLevelMem.mem[i].physAddrLower,
4208 loResource->loLevelMem.mem[i].totalLength,
4209 loResource->loLevelMem.mem[i].numElements));
4210 TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4211 loResource->loLevelMem.mem[i].singleElementLength,
4212 loResource->loLevelMem.mem[i].alignment,
4213 loResource->loLevelMem.mem[i].type,
4214 loResource->loLevelMem.mem[i].reserved));
4217 osti_memset(&(tdsaAllShared->tdFWControlEx), 0, sizeof(tdFWControlEx_t));
4220 * Note: Be sure to call this only once since sallsdk does initialization only once
4221 * saInitialize(IN, IN, IN, IN, IN);
4224 TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdDeviceIdVendId %x\n",tdsaAllShared->tdDeviceIdVendId));
4225 TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdSubVendorId= SUB_VEN_ID %x\n",tdsaAllShared->tdSubVendorId));
4227 TI_DBG1(("tiCOMPortInit: swConfig->param1 hwDEVICE_ID_VENDID %x\n", tdsaAllShared->SwConfig.param1 ));
4228 TI_DBG1(("tiCOMPortInit: swConfig->param2 hwSVID %x\n", tdsaAllShared->SwConfig.param2));
4231 1. Read hostDirectAccessSupport
4232 2. If set, read HDA images based on chip ID
4235 t_MacroCheck(agRoot);
4237 #ifndef TURN_OFF_HDA
4238 if (tdsaAllShared->SwConfig.hostDirectAccessSupport != 0)
4240 osti_memset(&HDAImg, 0, sizeof(HDAImg));
4241 if (tiIS_SPC(agRoot))
4243 TI_DBG1(("tiCOMPortInit: SPC HDA\n"));
4244 HDAImg.aap1Img = (bit8*)(&aap1array);
4245 HDAImg.aap1Len = sizeof( aap1array);
4246 HDAImg.iopImg = (bit8*)(&ioparray);
4247 HDAImg.iopLen = sizeof( ioparray);
4248 HDAImg.istrImg = (bit8*)(&istrarray);
4249 HDAImg.istrLen = sizeof( istrarray);
4251 HDAImg.ilaImg = (bit8*)(&ilaarray);
4252 HDAImg.ilaLen = sizeof(ilaarray);
4254 else if (tiIS_SPC6V(agRoot))
4256 TI_DBG1(("tiCOMPortInit: SPCv HDA\n"));
4257 HDAImg.aap1Img = (bit8*)(&spcv_aap1array);
4258 HDAImg.aap1Len = sizeof( spcv_aap1array);
4259 HDAImg.iopImg = (bit8*)(&spcv_ioparray);
4260 HDAImg.iopLen = sizeof( spcv_ioparray);
4262 HDAImg.ilaImg = (bit8*)(&spcv_ilaarray);
4263 HDAImg.ilaLen = sizeof(spcv_ilaarray);
4265 else if (tIsSPCV12G(agRoot))
4267 TI_DBG1(("tiCOMPortInit: SPCv12G HDA\n"));
4268 HDAImg.aap1Img = (bit8*)(&spcv12g_raaearray);
4269 HDAImg.aap1Len = sizeof( spcv12g_raaearray);
4270 HDAImg.iopImg = (bit8*)(&spcv12g_ioparray);
4271 HDAImg.iopLen = sizeof( spcv12g_ioparray);
4273 HDAImg.ilaImg = (bit8*)(&spcv12g_ilaarray);
4274 HDAImg.ilaLen = sizeof(spcv12g_ilaarray);
4278 TI_DBG1(("tiCOMPortInit: HDA Mode Unknown chip type 0x%08x\n",ossaHwRegReadConfig32(agRoot,0 )));
4281 TI_DBG1(("tiCOMPortInit: HDA aap1Len 0x%08x iopLen 0x%08x ilaLen 0x%08x\n",HDAImg.aap1Len,HDAImg.iopLen,HDAImg.ilaLen ));
4282 tdsaAllShared->SwConfig.param4 = &(HDAImg);
4286 TI_DBG1(("tiCOMPortInit: HDA off\n"));
4287 tdsaAllShared->SwConfig.param4 = agNULL;
4289 #endif /* TURN_OFF_HDA */
4291 if (tiIS_SPC(agRoot))
4293 /* FW config is only for SPC */
4294 tdsaAllShared->SwConfig.FWConfig = 0;
4295 /* default port recovery timer 0x32 = 50 = 5000ms and port reset timer 3 (300 ms)*/
4296 tdsaAllShared->SwConfig.PortRecoveryResetTimer = 0x30032;
4297 TI_DBG1(("tiCOMPortInit:only for SPC FWConfig set\n"));
4300 tdsaAllShared->SwConfig.fatalErrorInterruptVector = loResource->loLevelOption.maxInterruptVectors > 31 ? 31 : loResource->loLevelOption.maxInterruptVectors -1;
4302 TI_DBG1(("tiCOMPortInit: SwConfig->FWConfig 0x%x\n", tdsaAllShared->SwConfig.FWConfig));
4303 TI_DBG1(("tiCOMPortInit: SwConfig->fatalErrorInterruptVector 0x%x\n", tdsaAllShared->SwConfig.fatalErrorInterruptVector));
4304 TI_DBG1(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d\n", loResource->loLevelOption.usecsPerTick));
4306 status = saInitialize(agRoot,
4307 &agMemoryRequirement,
4308 &(tdsaAllShared->HwConfig),
4309 /* &temp_HwConfig, */
4310 &(tdsaAllShared->SwConfig),
4311 loResource->loLevelOption.usecsPerTick);
4313 TI_DBG6(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d 0x%x\n", loResource->loLevelOption.usecsPerTick, loResource->loLevelOption.usecsPerTick));
4315 /*TI_DBG6(("tiCOMPortInit: tdsaAllShared->SwConfig.enableDIF %d\n", tdsaAllShared->SwConfig.enableDIF)); */
4316 /*TI_DBG6(("tiCOMPortInit: tdsaAllShared->SwConfig.enableEncryption %d\n", tdsaAllShared->SwConfig.enableEncryption)); */
4318 if(status == AGSA_RC_FAILURE )
4320 TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_FAILURE, status 0x%x\n", status));
4324 if( status == AGSA_RC_VERSION_INCOMPATIBLE)
4326 TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_VERSION_INCOMPATIBLE, status 0x%x\n", status));
4330 /* let's make sdkData same for Int and Non-int agRoots */
4331 tdsaAllShared->agRootInt.sdkData = tdsaAllShared->agRootNonInt.sdkData;
4334 /* mark the port as initialized */
4335 for(i=0;i<TD_MAX_NUM_PHYS;i++)
4337 tdsaAllShared->Ports[i].flags.portInitialized = agTRUE;
4340 #ifdef INITIATOR_DRIVER //ini. only in stsdkll spec (TP)
4341 /* register device registration callback function */
4342 TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device registration\n"));
4343 status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_ADDED, (void *)ossaDeviceRegistrationCB);
4344 if (status == AGSA_RC_FAILURE)
4346 TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register failed\n"));
4350 TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register succeeded\n"));
4354 /* register device deregistration callback function */
4355 TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device de-registration\n"));
4356 status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_REMOVED, (void *)ossaDeregisterDeviceHandleCB);
4357 if (status == AGSA_RC_FAILURE)
4359 TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister failed\n"));
4363 TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister succeeded\n"));
4367 /* temporary to test saEchoCommand() */
4372 payload[55] = gEcho;
4373 TI_DBG2(("tiCOMPortInit: calling saEchoCommand gEcho %d\n", gEcho));
4374 saEchoCommand(agRoot, agNULL, tdsaRotateQnumber(tiRoot, agNULL), (void *)&payload);
4378 #ifdef CONTROLLER_STATUS_TESTING
4379 TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
4380 #endif /* CONTROLLER_INFO_TESTING */
4382 #ifdef CONTROLLER_INFO_TESTING
4383 TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
4384 #endif /* CONTROLLER_INFO_TESTING */
4386 #ifdef CONTROLLER_ENCRYPT_TESTING
4387 TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
4388 #endif /* CONTROLLER_INFO_TESTING */
4392 /* temporary to test saSetVPDCommand() and saGetVPDCommand */
4394 #endif /* VPD_TESTING */
4396 #if defined(FDS_DM) && defined(FDS_SM)
4397 /* initialize DM then SM */
4399 dmRoot = &(tdsaAllShared->dmRoot);
4400 osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
4402 dmMemRequirement.count = DMMemCount;
4404 for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
4406 TI_DBG2(("tiCOMPortInit: DM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4407 dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4408 dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4409 dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4410 dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4411 dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4412 dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4413 dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4414 dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4415 dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4416 dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4417 TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4418 TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4419 loResource->loLevelMem.mem[i].physAddrUpper,
4420 loResource->loLevelMem.mem[i].physAddrLower,
4421 loResource->loLevelMem.mem[i].totalLength,
4422 loResource->loLevelMem.mem[i].numElements));
4423 TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4424 loResource->loLevelMem.mem[i].singleElementLength,
4425 loResource->loLevelMem.mem[i].alignment,
4426 loResource->loLevelMem.mem[i].type,
4427 loResource->loLevelMem.mem[i].reserved));
4431 status = dmInitialize(dmRoot,
4434 &(tdsaAllShared->dmSwConfig), //&dmSwConfig, /* start here */
4435 loResource->loLevelOption.usecsPerTick);
4437 if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
4439 TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
4444 smRoot = &(tdsaAllShared->smRoot);
4445 osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
4447 smMemRequirement.count = SMMemCount;
4449 for(i=(LLMemCount + DMMemCount);i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
4451 TI_DBG1(("tiCOMPortInit: SM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4452 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4453 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4454 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4455 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4456 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4457 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4458 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4459 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4460 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].type = loResource->loLevelMem.mem[i].type;
4461 smMemRequirement.smMemory[i-LLMemCount-DMMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4462 TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4463 TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4464 loResource->loLevelMem.mem[i].physAddrUpper,
4465 loResource->loLevelMem.mem[i].physAddrLower,
4466 loResource->loLevelMem.mem[i].totalLength,
4467 loResource->loLevelMem.mem[i].numElements));
4468 TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4469 loResource->loLevelMem.mem[i].singleElementLength,
4470 loResource->loLevelMem.mem[i].alignment,
4471 loResource->loLevelMem.mem[i].type,
4472 loResource->loLevelMem.mem[i].reserved));
4476 status = smInitialize(smRoot,
4479 &(tdsaAllShared->smSwConfig), //&smSwConfig, /* start here */
4480 loResource->loLevelOption.usecsPerTick);
4482 if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
4484 TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
4488 #elif defined(FDS_DM)
4489 dmRoot = &(tdsaAllShared->dmRoot);
4490 osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
4492 dmMemRequirement.count = DMMemCount;
4494 for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
4496 TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4497 dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4498 dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4499 dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4500 dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4501 dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4502 dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4503 dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4504 dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4505 dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4506 dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4507 TI_DBG6(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].physAddrUpper, loResource->loLevelMem.mem[i].physAddrLower, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].alignment));
4508 TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4512 status = dmInitialize(dmRoot,
4515 &(tdsaAllShared->dmSwConfig), //&dmSwConfig, /* start here */
4516 loResource->loLevelOption.usecsPerTick);
4518 if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
4520 TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
4524 #elif defined(FDS_SM)
4525 smRoot = &(tdsaAllShared->smRoot);
4526 osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
4528 smMemRequirement.count = SMMemCount;
4530 for(i=LLMemCount;i<(int)(LLMemCount + SMMemCount);i++)
4532 TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4533 smMemRequirement.smMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4534 smMemRequirement.smMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4535 smMemRequirement.smMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4536 smMemRequirement.smMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4537 smMemRequirement.smMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4538 smMemRequirement.smMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4539 smMemRequirement.smMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4540 smMemRequirement.smMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4541 smMemRequirement.smMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4542 smMemRequirement.smMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4543 TI_DBG6(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d alignment %d\n", i, loResource->loLevelMem.mem[i].physAddrUpper, loResource->loLevelMem.mem[i].physAddrLower, loResource->loLevelMem.mem[i].totalLength, loResource->loLevelMem.mem[i].alignment));
4544 TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4548 status = smInitialize(smRoot,
4551 &(tdsaAllShared->smSwConfig), //&smSwConfig, /* start here */
4552 loResource->loLevelOption.usecsPerTick);
4554 if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
4556 TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
4561 #endif /* FDS_DM && FDS_SM */
4563 /* call these again after agroot is created for testing */
4564 #ifdef CONTROLLER_STATUS_TESTING
4565 TI_DBG1(("tiCOMPortInit:again saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
4566 #endif /* CONTROLLER_INFO_TESTING */
4568 #ifdef CONTROLLER_INFO_TESTING
4569 TI_DBG1(("tiCOMPortInit:again saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
4570 #endif /* CONTROLLER_INFO_TESTING */
4572 #ifdef CONTROLLER_ENCRYPT_TESTING
4573 TI_DBG1(("tiCOMPortInit:again saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
4574 #endif /* CONTROLLER_INFO_TESTING */
4577 if (tiSuccess == tiCOMConfigureSgpio(tiRoot, agTRUE))
4579 TI_DBG2(("tiCOMPortInit: Successfully sent request to enable SGPIO\n"));
4583 TI_DBG1(("tiCOMPortInit: Failed to enable SGPIO\n"));
4589 /*****************************************************************************
4590 *! \brief SendSgpioRequest
4592 * Purpose: This function is used to send SGPIO request during initialization
4594 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
4596 * \param regType: Register Type
4597 * \param regIndex: Register Index
4598 * \param regCount: Register Count
4599 * \param writeData: Part of the request
4602 * tiSuccess on success
4603 * Other status on failure
4605 *****************************************************************************/
4606 static bit32 SendSgpioRequest(
4614 static bit32 buffer[128] = {0};
4615 bit32 status = tiError;
4616 bit32 retVal = IOCTL_CALL_FAIL;
4617 tiIOCTLPayload_t *agIOCTLPayload = (tiIOCTLPayload_t *) buffer;
4618 agsaSGpioReqResponse_t *pSGpioReq = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
4619 agsaSGpioReqResponse_t *pSgpioResponse = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
4623 /* Frame the Ioctl payload */
4624 agIOCTLPayload->MajorFunction = IOCTL_MJ_SGPIO;
4625 agIOCTLPayload->Length = sizeof(agsaSGpioReqResponse_t);
4627 /* Frame the SGPIO request */
4628 pSGpioReq->smpFrameType = SMP_REQUEST;
4629 pSGpioReq->function = AGSA_WRITE_SGPIO_REGISTER;
4630 pSGpioReq->registerType = regType;
4631 pSGpioReq->registerIndex = regIndex;
4632 pSGpioReq->registerCount = regCount;
4633 memcpy(pSGpioReq->readWriteData, writeData, regCount * 4);
4635 /* Send the SGPIO request */
4636 sgpioResponseSet = 0;
4637 retVal = tdsaSGpioIoctlSetup(tiRoot, agNULL, agIOCTLPayload, agNULL, agNULL);
4638 if (retVal != IOCTL_CALL_PENDING)
4642 /* Waiting for SGPIO Response */
4643 while(!sgpioResponseSet)
4645 tiCOMDelayedInterruptHandler(tiRoot, 0, 1, tiNonInterruptContext);
4647 sgpioResponseSet = 0;
4648 /* Check the ioctl result */
4649 if(agIOCTLPayload->Status != IOCTL_ERR_STATUS_OK)
4653 /* Check the sgpio function result */
4654 if(pSgpioResponse->functionResult != 0x00)
4666 /*****************************************************************************
4667 *! \brief tiCOMConfigureSgpio
4669 * Purpose: This function is used to configure SGPIO during initialization
4671 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
4673 * \param enableSgpio: Enable / Disable SGPIO
4676 * tiSuccess on success
4677 * Other status on failure
4679 *****************************************************************************/
4680 bit32 tiCOMConfigureSgpio(
4685 bit32 status = tiError;
4688 bit32 writeData[OSSA_SGPIO_MAX_READ_DATA_COUNT] = {0};
4689 agsaSGpioCfg0_t *pCfg0 = (agsaSGpioCfg0_t *) &writeData[0];
4690 agsaSGpioCfg1_t *pCfg1 = (agsaSGpioCfg1_t *) &writeData[1];
4691 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
4692 tdsaContext_t *tdsaAllShared = (tdsaContext_t *) &tdsaRoot->tdsaAllShared;
4693 bit32 phyCount = tdsaAllShared->phyCount;
4697 /* Configure both CFG[0] and CFG[1] */
4701 pCfg0->gpioEnable = 1;
4703 /* The following are the default values for CFG[1] suggested by SFF-8485 spec */
4704 /* Maximum Activity ON: 2 */
4705 /* Forced Activity OFF: 1 */
4706 pCfg1->maxActOn = 2;
4707 pCfg1->forceActOff = 1;
4711 /* Configure CFG[0] only */
4715 pCfg0->gpioEnable = 0;
4718 status = SendSgpioRequest(tiRoot, AGSA_SGPIO_CONFIG_REG, 0, regCount, writeData);
4719 if((tiSuccess == status) && (enableSgpio))
4721 /* Write default values to transmit registers */
4722 /* RegisterCount = Number of phys present in HBA / 4 */
4723 regCount = phyCount / 4;
4724 for(i = 0; i < regCount; i++)
4726 /* Following are the default values specified in SFF-8485 spec */
4730 writeData[i] = 0xA0A0A0A0;
4732 status = SendSgpioRequest(tiRoot, AGSA_SGPIO_DRIVE_BY_DRIVE_TRANSMIT_REG, 0, regCount, writeData);
4739 /*****************************************************************************
4740 *! \brief tiCOMPortStart
4742 * Purpose: This function is called to bring the port hardware online. This
4743 * call could only be called until after the successful completion
4746 * \param tiRoot: Pointer to root data structure.
4747 * \param portID: A ID for this portal to be used by the TD Layer
4748 * to get the portal configuration information.
4749 * \param portalContext: Pointer to the context for this portal.
4750 * \param option: An option for starting a port
4753 * tiSuccess: Successful.
4757 * If sas or sata initiator, this will be called 8 (the number of phys) times.
4758 * If both sas and sata initiator, this will be called 16 times
4760 *****************************************************************************/
4761 /* portID is used as PhyID
4762 Should return always tiSuccess. PortStarted is returned in ossaHwCB()
4768 tiPortalContext_t * portalContext,
4772 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
4773 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
4774 agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
4775 agsaSASProtocolTimerConfigurationPage_t SASConfigPage;
4776 bit32 status = AGSA_RC_FAILURE;
4777 static bit32 IsSendSASConfigPage = agFALSE;
4780 TI_DBG3(("tiCOMPortStart: start portID %d\n", portID));
4783 * return error if reset is in progress
4785 if (tdsaAllShared->flags.resetInProgress == agTRUE)
4787 TI_DBG1(("tiCOMPortStart: reset error\n"));
4793 * port is not initialized, return error
4795 if (tdsaAllShared->Ports[portID].flags.portInitialized == agFALSE)
4797 TI_DBG1(("tiCOMPortStart: not intialized error\n"));
4801 /* portal has been started. */
4802 if (portalContext->tdData != NULL)
4804 if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
4806 TI_DBG3 (("tiCOMPortStart : Cannot start port again: Port has already been started\n"));
4811 (void *) tdsaAllShared->Ports[portID].tiPortalContext
4817 portalContext->tdData = &(tdsaAllShared->Ports[portID]);
4818 TI_DBG4 (("tiCOMPortStart : saving portalconext portID %d tdsaAllShared %p\n", portID, tdsaAllShared));
4819 /* saving tiportalContext_t */
4820 tdsaAllShared->Ports[portID].tiPortalContext = portalContext;
4821 TI_DBG4(("tiCOMPortStart : portID/phyID %d tiPortalContext %p\n", portID, tdsaAllShared->Ports[portID].tiPortalContext));
4824 where is "tdsaAllShared->Ports[0].portContext" set?
4827 if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
4829 TI_DBG1(("tiCOMPortStart: port already has been started \n"));
4835 hardcode sasID frame. It should be read by ostigettransportparams later from configuration file
4837 #ifdef INITIATOR_DRIVER
4839 tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = 0;
4840 tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
4841 = SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
4842 tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4844 tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4848 #ifdef TARGET_DRIVER
4850 tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
4851 tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp = 0;
4852 tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4853 tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4857 #if defined (INITIATOR_DRIVER) && defined (TARGET_DRIVER)
4859 /* for combo testing */
4860 tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
4861 tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
4862 = SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
4863 tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4865 tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4870 TI_DBG6(("tiCOMPortStart: before pid %d\n", portID));
4871 tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
4873 TI_DBG6(("tiCOMPortStart: sysIntsActive %s\n",
4874 (tdsaAllShared->flags.sysIntsActive == agTRUE) ? "agTRUE" : "agFALSE"));
4876 /* Read global configuration first then card-specific configuration */
4878 /* the following must be processed only once */
4879 if ( tdsaAllShared->first_process == agFALSE)
4881 tdsaGetGlobalPhyParams(tiRoot);
4882 tdsaGetCardPhyParams(tiRoot);
4883 tdsaAllShared->first_process = agTRUE;
4886 TI_DBG6(("tiCOMPortStart: after pid %d\n", portID));
4887 tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
4892 if (tdsaAllShared->phyCalibration)
4894 /* Change default phy calibration */
4895 tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
4896 (tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | 0x80;
4897 /* Setting index of phy calibration table index
4898 portID is used as phy calibration table index
4900 tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
4901 (tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | (portID << 8);
4903 TI_DBG2(("tiCOMPortStart: tdsaAllShared->Ports[0x%x].agPhyConfig.phyProperties 0x%x\n",
4904 portID, tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
4909 tdsaAllShared->Ports[portID].agPhyConfig.phyProperties = tdsaAllShared->Ports[portID].agPhyConfig.phyProperties | 0x40000;
4910 TI_DBG1(("tiCOMPortStart:gSSC_Disable tdsaAllShared->Ports[portID].agPhyConfig.phyProperties 0x%x\n", tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
4914 if(tIsSPCV12or6G(agRoot) && !IsSendSASConfigPage) /* Not SPC */
4916 /* call saSetControllerConfig() to set STP_IDLE_TIME; All others are the defaults */
4917 osti_memset(&SASConfigPage, 0, sizeof(agsaSASProtocolTimerConfigurationPage_t));
4918 SASConfigPage.pageCode = AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE;
4919 SASConfigPage.MST_MSI = 3 << 15; /* enables both MCT for SSP target and initiator */
4920 SASConfigPage.STP_SSP_MCT_TMO = (tdsaAllShared->STP_MCT_TMO << 16) | tdsaAllShared->SSP_MCT_TMO; /* default of 3200 us for STP and SSP maximum connection time */
4921 SASConfigPage.STP_FRM_TMO = (tdsaAllShared->MAX_OPEN_TIME << 24) | (tdsaAllShared->SMP_MAX_CONN_TIMER << 16) | tdsaAllShared->STP_FRM_TMO; /* MAX_OPEN_TIME, SMP_MAX_CONN_TIMER, STP frame timeout */
4922 SASConfigPage.STP_IDLE_TMO = tdsaAllShared->stp_idle_time;
4923 if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF)
4925 SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF;
4927 SASConfigPage.OPNRJT_RTRY_INTVL = (tdsaAllShared->MFD << 16) | tdsaAllShared->OPNRJT_RTRY_INTVL; /* Multi Data Fetach enabled and 2 us for Open Reject Retry interval */
4928 SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = (tdsaAllShared->DOPNRJT_RTRY_TMO << 16) | tdsaAllShared->COPNRJT_RTRY_TMO; /* 128 us for ORR Timeout for DATA phase and 32 us for ORR Timeout for command phase */
4929 SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = (tdsaAllShared->DOPNRJT_RTRY_THR << 16) | tdsaAllShared->COPNRJT_RTRY_THR; /* 16 for ORR backoff threshold for DATA phase and 1024 for ORR backoff threshold for command phase */
4930 SASConfigPage.MAX_AIP = tdsaAllShared->MAX_AIP; /* MAX AIP. Default is 0x200000 */
4932 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.pageCode 0x%08x\n",SASConfigPage.pageCode));
4933 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MST_MSI 0x%08x\n",SASConfigPage.MST_MSI));
4934 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_SSP_MCT_TMO 0x%08x\n",SASConfigPage.STP_SSP_MCT_TMO));
4935 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_FRM_TMO 0x%08x\n",SASConfigPage.STP_FRM_TMO));
4936 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_IDLE_TMO 0x%08x\n",SASConfigPage.STP_IDLE_TMO));
4937 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.OPNRJT_RTRY_INTVL 0x%08x\n",SASConfigPage.OPNRJT_RTRY_INTVL));
4938 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO));
4939 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR));
4940 TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MAX_AIP 0x%08x\n",SASConfigPage.MAX_AIP));
4942 status = saSetControllerConfig(agRoot,
4944 AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE,
4945 sizeof(agsaSASProtocolTimerConfigurationPage_t),
4948 if (status != AGSA_RC_SUCCESS)
4950 TI_DBG1(("tiCOMPortStart: calling saSetControllerConfig() failed\n"));
4954 TI_DBG2(("tiCOMPortStart: calling saSetControllerConfig() is OK\n"));
4956 IsSendSASConfigPage = agTRUE;
4960 TI_DBG1(("tiCOMPortStart: saSetControllerConfig not called tIsSPCV12or6G %d IsSendSASConfigPage %d\n",tIsSPCV12or6G(agRoot),IsSendSASConfigPage));
4963 /* maps portID to phyID */
4964 status = saPhyStart(agRoot,
4968 &(tdsaAllShared->Ports[portID].agPhyConfig),
4969 &(tdsaAllShared->Ports[portID].SASID)
4972 TI_DBG6(("tiCOMPortStart: saPhyStart status %d\n", status));
4974 if (status == AGSA_RC_SUCCESS)
4976 TI_DBG3(("tiCOMPortStart : calling portstarted\n"));
4981 (void *) tdsaAllShared->Ports[portID].tiPortalContext
4987 TI_DBG3(("tiCOMPortStart : cant' start port\n"));
4993 /*****************************************************************************
4994 *! \brief tiCOMPortStop
4996 * Purpose: This function is called to bring the port hardware down.
4998 * \param tiRoot: Pointer to root data structure.
4999 * \param portalContext: Pointer to the context for this portal.
5002 * tiSuccess: Successful.
5007 *****************************************************************************/
5011 tiPortalContext_t *portalContext
5014 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5015 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5016 tdList_t *PortContextList;
5017 tdsaPortContext_t *onePortContext = agNULL;
5018 agsaRoot_t *agRoot = agNULL;
5020 bit32 found = agFALSE;
5022 #ifdef CONTROLLER_STATUS_TESTING
5023 agsaControllerStatus_t agcontrollerStatus;
5024 #endif /* CONTROLLER_STATUS_TESTING */
5027 TI_DBG3(("tiCOMPortStop: start\n"));
5029 find the portcontext
5030 find phys belonging to that portcotext
5031 call saPhyStop for all those phys
5033 remove the portcontext from the portcontext list
5036 agRoot = &(tdsaAllShared->agRootNonInt);
5038 #ifdef CONTROLLER_STATUS_TESTING
5039 TI_DBG1(("tiCOMPortStop: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
5040 #endif /* CONTROLLER_INFO_TESTING */
5042 if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
5044 TI_DBG1(("tiCOMPortStop: empty tdsaPortContext\n"));
5048 /* find a right portcontext */
5049 PortContextList = tdsaAllShared->MainPortContextList.flink;
5050 while (PortContextList != &(tdsaAllShared->MainPortContextList))
5052 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
5053 if (onePortContext == agNULL)
5055 TI_DBG1(("tiCOMPortStop: onePortContext is NULL!!!\n"));
5058 if (onePortContext->tiPortalContext == portalContext)
5060 TI_DBG6(("tiCOMPortStop: found; oneportContext ID %d\n", onePortContext->id));
5064 PortContextList = PortContextList->flink;
5067 if (found == agFALSE)
5069 TI_DBG1(("tiCOMPortStop: No corressponding tdsaPortContext\n"));
5073 #ifdef INITIATOR_DRIVER
5074 /* reset the fields of portcontext */
5075 onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED;
5076 onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START;
5077 #endif /* INITIATOR_DRIVER */
5079 onePortContext->Count = 0;
5080 onePortContext->agContext.osData = onePortContext;
5081 for(i=0;i<TD_MAX_NUM_PHYS;i++)
5083 if (onePortContext->PhyIDList[i] == agTRUE)
5085 tdsaAllShared->Ports[i].portContext = agNULL;
5086 #ifdef CCFLAGS_PHYCONTROL_COUNTS
5087 if( tiIS_SPC(agRoot) )
5090 saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_ERROR_COUNTS, agNULL);
5091 saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_CLEAR_ERROR_COUNTS, agNULL);
5092 saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_BW_COUNTS, agNULL);
5096 TI_DBG1(("\ntiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
5097 saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_PAGE, i);
5098 saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_BW_COUNTERS_PAGE,i);
5099 saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ANALOG_SETTINGS_PAGE,i);
5100 saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_GENERAL_STATUS_PAGE,i);
5101 saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_CLR_PAGE,i);
5103 TI_DBG1(("tiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
5107 #endif /* CCFLAGS_PHYCONTROL_COUNTS */
5108 saPhyStop(agRoot, &onePortContext->agContext, 0, i);
5116 /*****************************************************************************
5117 *! \brief tiCOMGetPortInfo
5119 * Purpose: This function is called to return information about the specific
5123 * \param tiRoot: Pointer to driver/port instance.
5124 * \param portalContext Pointer to the context for this portal.
5125 * \param tiPortInfo: Pointer to port information structure.
5127 * \Return: tiSuccess
5129 *****************************************************************************/
5131 can't find tdsaportcontext in this function
5132 since discovery has not been called by OS layer yet
5133 Therefore, hardcoded value are being returned for now
5135 osGLOBAL bit32 tiCOMGetPortInfo(
5137 tiPortalContext_t *portalContext,
5138 tiPortInfo_t *tiPortInfo
5142 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5143 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5144 tdList_t *PortContextList;
5145 tdsaPortContext_t *onePortContext = agNULL;
5146 bit32 found = agFALSE;
5147 static bit8 localname[68], remotename[68];
5149 TI_DBG6(("tiCOMGetPortInfo: start\n"));
5152 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
5153 if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
5155 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
5156 TI_DBG1(("tiCOMGetPortInfo: No tdsaPortContext\n"));
5161 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
5164 /* find a corresponding portcontext */
5165 PortContextList = tdsaAllShared->MainPortContextList.flink;
5166 while (PortContextList != &(tdsaAllShared->MainPortContextList))
5168 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
5169 TI_DBG3(("tiCOMGetPortInfo: oneportContext pid %d\n", onePortContext->id));
5170 if (onePortContext->tiPortalContext == portalContext && onePortContext->valid == agTRUE)
5172 TI_DBG3(("tiCOMGetPortInfo: found; oneportContext pid %d\n", onePortContext->id));
5176 PortContextList = PortContextList->flink;
5179 if (found == agFALSE)
5181 TI_DBG1(("tiCOMGetPortInfo: First, No corresponding tdsaPortContext\n"));
5185 if (onePortContext == agNULL)
5187 TI_DBG1(("tiCOMGetPortInfo: Second, No corressponding tdsaPortContext\n"));
5191 osti_memset(localname, 0, sizeof(localname));
5192 osti_memset(remotename, 0, sizeof(remotename));
5195 Parse the type of port then fill in the information
5197 if ( onePortContext->sasRemoteAddressHi == 0xFFFFFFFF && onePortContext->sasRemoteAddressLo == 0xFFFFFFFF)
5199 /* directly attached SATA port */
5200 osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
5201 osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
5202 tiPortInfo->localNameLen = 8;
5203 /* information is from SATA ID device data. remoteName is serial number, firmware version, model number */
5204 osti_memcpy(remotename, onePortContext->remoteName, 68);
5205 tiPortInfo->remoteNameLen = 68;
5209 /* copy hi address and low address */
5210 osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
5211 osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
5212 tiPortInfo->localNameLen = 8;
5213 osti_memcpy(remotename, &(onePortContext->sasRemoteAddressHi), 4);
5214 osti_memcpy(&(remotename[4]), &(onePortContext->sasRemoteAddressLo), 4);
5215 tiPortInfo->remoteNameLen = 8;
5218 tiPortInfo->localName = (char *)&localname;
5219 tiPortInfo->remoteName = (char *)&remotename;
5226 /*****************************************************************************
5228 * tiCOMSetControllerConfig
5230 * Purpose: This function is called to set the controller's advanced configuration.
5231 * The status is reported via ostiPortEvent().
5235 * tiRoot: Pointer to driver/port instance.
5238 * tiSuccess: The setting controller configuration was started.
5239 * tiError: The setting controller configuration was not started.
5241 *****************************************************************************/
5242 osGLOBAL bit32 tiCOMSetControllerConfig (
5250 bit32 returnCode = AGSA_RC_BUSY;
5251 bit32 tiStatus = tiSuccess;
5252 tdsaRoot_t *tdsaRoot ;
5253 tdsaContext_t *tdsaAllShared ;
5255 TD_ASSERT(tiRoot, "tiRoot");
5256 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5257 TD_ASSERT(tdsaRoot, "tdsaRoot");
5259 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5260 TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5261 agRoot = &(tdsaAllShared->agRootNonInt);
5262 TD_ASSERT(agRoot, "agRoot");
5264 agRoot = &(tdsaAllShared->agRootNonInt);
5266 TI_DBG1(("tiCOMSetControllerConfig:\n" ));
5268 /*do some sanity checking */
5269 if ( ((modePage == TI_INTERRUPT_CONFIGURATION_PAGE) && (length != sizeof(tiInterruptConfigPage_t ))) ||
5270 ((modePage == TI_ENCRYPTION_GENERAL_CONFIG_PAGE) && (length != sizeof(tiEncryptGeneralPage_t ))) ||
5271 ((modePage == TI_ENCRYPTION_DEK_CONFIG_PAGE) && (length != sizeof(tiEncryptDekConfigPage_t))) ||
5272 ((modePage == TI_ENCRYPTION_CONTROL_PARM_PAGE) && (length != sizeof(tiEncryptControlParamPage_t ))) ||
5273 ((modePage == TI_ENCRYPTION_HMAC_CONFIG_PAGE) && (length != sizeof(tiEncryptHMACConfigPage_t ))) ||
5274 ((modePage == TI_SAS_PROTOCOL_TIMER_CONFIG_PAGE) && (length != sizeof(tiSASProtocolTimerConfigurationPage_t ))) )
5280 returnCode = saSetControllerConfig(agRoot, 0, modePage, length, buffer, context);
5282 if (returnCode == AGSA_RC_SUCCESS)
5284 tiStatus = tiSuccess;
5286 else if (returnCode == AGSA_RC_BUSY)
5298 /*****************************************************************************
5300 * tiCOMGetControllerConfig
5302 * Purpose: This function is called to get the controller's advanced configuration.
5303 * The status is reported via ostiPortEvent().
5307 * tiRoot: Pointer to driver/port instance.
5308 * flag: Interrupt Vector Mask
5309 * This parameter is valid only when modePage is set to TI_INTERRUPT_CONFIGURATION_PAGE.
5310 * When the modePage field is set to TI_INTERRUPT_CONFIGURATION_PAGE,
5311 * this field contains a bitmap of interrupt vectors for which interrupt coalescing parameters are retrieved.
5313 * tiSuccess: The controller configuration retrival was started.
5314 * tiError: The controller configuration retrival was not started.
5316 *****************************************************************************/
5317 osGLOBAL bit32 tiCOMGetControllerConfig (
5325 bit32 returnCode = AGSA_RC_BUSY;
5326 bit32 tiStatus = tiSuccess;
5327 tdsaRoot_t *tdsaRoot ;
5328 tdsaContext_t *tdsaAllShared ;
5330 TD_ASSERT(tiRoot, "tiRoot");
5331 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5332 TD_ASSERT(tdsaRoot, "tdsaRoot");
5334 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5335 TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5336 agRoot = &(tdsaAllShared->agRootNonInt);
5337 TD_ASSERT(agRoot, "agRoot");
5339 agRoot = &(tdsaAllShared->agRootNonInt);
5341 TI_DBG1(("tiCOMGetControllerConfig: modePage 0x%x context %p\n",modePage,context ));
5343 returnCode = saGetControllerConfig(agRoot, 0, modePage, flag, 0, context);
5345 if (returnCode == AGSA_RC_SUCCESS)
5347 tiStatus = tiSuccess;
5348 TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiSuccess\n",modePage ));
5350 else if (returnCode == AGSA_RC_BUSY)
5353 TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiBusy\n",modePage ));
5358 TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiError\n",modePage ));
5364 /*****************************************************************************
5366 * tiCOMEncryptGetInfo
5368 * Purpose: This function is called to return information about the encryption
5369 * engine for the specified port.
5373 * tiRoot: Pointer to driver/port instance.
5376 * tiSuccess The request is being processed
5377 * tiNotSupported Encryption is not supported
5379 *****************************************************************************/
5380 osGLOBAL bit32 tiCOMEncryptGetInfo(tiRoot_t *tiRoot)
5382 tiEncryptInfo_t tiEncryptInfo;
5383 agsaEncryptInfo_t agsaEncryptInfo;
5384 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5385 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5387 tiEncryptPort_t tiEncryptPort;
5391 agRoot = &(tdsaAllShared->agRootNonInt);
5393 returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
5394 TI_DBG1(("tiCOMEncryptGetInfo: returnCode 0x%x\n", returnCode));
5396 if (returnCode == AGSA_RC_SUCCESS)
5398 tiStatus = tiSuccess;
5401 * The data encoded in the agsaEncryptInfo must be converted
5402 * to match the fields of the tiEncryptInfo structure.
5404 * No sector information is currently available.
5406 osti_memset(&tiEncryptInfo, 0x0, sizeof(tiEncryptInfo_t));
5409 if (agsaEncryptInfo.encryptionCipherMode == agsaEncryptCipherModeXTS)
5411 tiEncryptInfo.securityCipherMode = TI_ENCRYPT_ATTRIB_CIPHER_XTS;
5414 if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMF)
5416 tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_FACT_INIT;
5418 else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMA)
5420 tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_A;
5422 else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMB)
5424 tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_B;
5427 tiEncryptInfo.status = agsaEncryptInfo.status;
5429 tiEncryptPort.pData = &tiEncryptInfo;
5431 /* The low level returns synchronously, so fake a port event now.*/
5432 tiEncryptPort.encryptEvent = tiEncryptGetInfo;
5433 tiEncryptPort.subEvent = 0;
5435 ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
5439 if (returnCode == AGSA_RC_NOT_SUPPORTED)
5441 tiStatus = tiNotSupported;
5442 TI_DBG1(("tiCOMEncryptGetInfo: tiNotSupported\n"));
5446 TI_DBG1(("tiCOMEncryptGetInfo: tiError returnCode 0x%x\n",returnCode));
5450 tiEncryptPort.pData = NULL;
5456 /*****************************************************************************
5458 * tiCOMEncryptSetMode
5460 * Purpose: This function is called to set the encryption security and cipher modes
5461 * for the encryption engine.
5465 * tiRoot: Pointer to driver/port instance.
5468 * tiSuccess The request is being processed
5469 * tiError The encryption engine is not in factory init mode or multiple
5470 * security modes were specified.
5472 *****************************************************************************/
5474 osGLOBAL bit32 tiCOMEncryptSetMode(tiRoot_t *tiRoot,
5475 bit32 securityCipherMode)
5479 agsaEncryptInfo_t mode;
5480 agsaEncryptInfo_t *pmode = &mode;
5482 tdsaRoot_t *tdsaRoot ;
5483 tdsaContext_t *tdsaAllShared;
5486 TD_ASSERT(tiRoot, "tiRoot");
5487 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5488 TD_ASSERT(tdsaRoot, "tdsaRoot");
5490 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5491 TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5492 agRoot = &(tdsaAllShared->agRootNonInt);
5493 TD_ASSERT(agRoot, "agRoot");
5495 pmode->encryptionSecurityMode = 0;
5496 pmode->encryptionCipherMode = 0;
5499 TI_DBG1(("tiCOMEncryptSetMode:\n"));
5502 if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_A ) == TI_ENCRYPT_SEC_MODE_A)
5504 pmode->encryptionSecurityMode = agsaEncryptSMA;
5507 if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_B ) == TI_ENCRYPT_SEC_MODE_B)
5509 pmode->encryptionSecurityMode = agsaEncryptSMB;
5512 if( (securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_XTS) == TI_ENCRYPT_ATTRIB_CIPHER_XTS)
5514 pmode->encryptionCipherMode |= agsaEncryptCipherModeXTS;
5517 /* ECB is not supported in SPCv */
5518 if(( securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_ECB) == TI_ENCRYPT_ATTRIB_CIPHER_ECB)
5523 returnCode = saEncryptSetMode(agRoot,agNULL, 0, pmode );
5525 if (returnCode == AGSA_RC_SUCCESS)
5527 tiStatus = tiSuccess;
5529 else if (returnCode == AGSA_RC_BUSY)
5531 TI_DBG1(("tiCOMEncryptSetMode:tiBusy\n"));
5536 TI_DBG1(("tiCOMEncryptSetMode:tiError\n"));
5543 /*****************************************************************************
5545 * tiCOMEncryptDekAdd
5547 * Purpose: This function is called to add a DEK to the controller cache.
5551 * tiRoot: Pointer to driver/port instance.
5552 * kekIndext: Index of the KEK table
5553 * dekTableSelect: Number of the DEK table receiving a new entry
5554 * dekAddrHi: Upper 32-bits of the DEK table physical address
5555 * dekAddrLo: Lower 32-bits of the DEK table physical address
5556 * dekIndex: Number of the first entry in the DEK table that will inserted in the cache
5557 * dekNumberOfEntries: Number of entries to be inserted in the cache
5558 * dekBlobFormat: Specifies the DEK blob format
5559 * dekTableKeyEntrySize: Encoded value for DEK Entry Size in the DEK Table
5562 * tiSuccess The request is being processed
5563 * tiError An invalid parameter was specified
5565 *****************************************************************************/
5566 osGLOBAL bit32 tiCOMEncryptDekAdd(tiRoot_t *tiRoot,
5568 bit32 dekTableSelect,
5572 bit32 dekNumberOfEntries,
5573 bit32 dekBlobFormat,
5574 bit32 dekTableKeyEntrySize
5581 tdsaRoot_t *tdsaRoot ;
5582 tdsaContext_t *tdsaAllShared ;
5584 TD_ASSERT(tiRoot, "tiRoot");
5585 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5586 TD_ASSERT(tdsaRoot, "tdsaRoot");
5588 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5589 TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5590 agRoot = &(tdsaAllShared->agRootNonInt);
5591 TD_ASSERT(agRoot, "agRoot");
5594 agRoot = &(tdsaAllShared->agRootNonInt);
5597 TI_DBG1(("tiCOMEncryptDekAdd:\n" ));
5599 returnCode = saEncryptDekCacheUpdate(agRoot,
5609 dekTableKeyEntrySize
5612 if (returnCode == AGSA_RC_SUCCESS)
5614 tiStatus = tiSuccess;
5616 else if (returnCode == AGSA_RC_BUSY)
5628 /*****************************************************************************
5630 * tiCOMEncryptDekInvalidate
5632 * Purpose: This function is called to remove a DEK entry from the hardware cache.
5636 * tiRoot: Pointer to driver/port instance.
5637 * dekTable DEK table that will be affected
5638 * dekIndex: DEK table entry that will be affected. The value 0xfffffff clears the cache.
5641 * tiSuccess The request is being processed
5642 * tiError An invalid parameter was specified
5643 * tiBusy An operation is already in progress
5645 *****************************************************************************/
5647 osGLOBAL bit32 tiCOMEncryptDekInvalidate(tiRoot_t *tiRoot,
5652 tdsaRoot_t *tdsaRoot;
5653 tdsaContext_t *tdsaAllShared;
5656 tiEncryptPort_t tiEncryptPort;
5657 tiEncryptDek_t tiEncryptDek;
5661 TD_ASSERT(tiRoot, "tiRoot");
5662 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5663 TD_ASSERT(tdsaRoot, "tdsaRoot");
5665 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5666 TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5667 agRoot = &(tdsaAllShared->agRootNonInt);
5668 TD_ASSERT(agRoot, "agRoot");
5670 TI_DBG1(("tiCOMEncryptDekInvalidate:dekTable 0x%x dekIndex 0x%x\n", dekTable, dekIndex));
5672 returnCode = saEncryptDekCacheInvalidate(agRoot, agNULL, 0, dekTable, dekIndex);
5674 if (returnCode == AGSA_RC_SUCCESS)
5676 tiStatus = tiSuccess;
5680 if (returnCode == AGSA_RC_NOT_SUPPORTED)
5682 tiStatus = tiNotSupported;
5684 else if (returnCode == AGSA_RC_BUSY)
5693 tiEncryptDek.dekTable = dekTable;
5694 tiEncryptDek.dekIndex = dekIndex;
5696 tiEncryptPort.encryptEvent = tiEncryptDekInvalidate;
5697 tiEncryptPort.subEvent = 0;
5698 tiEncryptPort.pData = (void *) &tiEncryptDek;
5700 ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
5706 /*****************************************************************************
5708 * tiCOMEncryptKekAdd
5710 * Purpose: This function is called to add a KEK in the register specified by
5711 * the index parameter.
5715 * tiRoot: Pointer to driver/port instance.
5716 * kekIndex: KEK table entry that will be affected
5717 * wrapperKekIndex KEK table entry that encrypt the KEK blob
5718 * encryptKekBlob KEK blob that will be added
5721 * tiSuccess The request is being processed
5722 * tiError An invalid parameter was specified
5723 * tiBusy A KEK operation is already in progress
5725 *****************************************************************************/
5727 osGLOBAL bit32 tiCOMEncryptKekAdd(tiRoot_t *tiRoot,
5729 bit32 wrapperKekIndex,
5731 tiEncryptKekBlob_t *encryptKekBlob)
5733 tdsaRoot_t *tdsaRoot;
5734 tdsaContext_t *tdsaAllShared;
5737 bit32 returnCode= AGSA_RC_BUSY;
5738 bit32 tiStatus= tiError;
5740 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5741 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5743 agRoot = &(tdsaAllShared->agRootNonInt);
5745 TI_DBG1(("tiCOMEncryptDekInvalidate: kekIndex 0x%x wrapperKekIndex 0x%x\n", kekIndex , wrapperKekIndex));
5747 returnCode = saEncryptKekUpdate(agRoot,
5750 AGSA_ENCRYPT_STORE_NVRAM,
5754 (agsaEncryptKekBlob_t *) encryptKekBlob);
5756 if (returnCode == AGSA_RC_SUCCESS)
5758 tiStatus = tiSuccess;
5760 else if (returnCode == AGSA_RC_BUSY)
5771 #ifdef HIALEAH_ENCRYPTION
5773 osGLOBAL bit32 tiCOMEncryptHilSet(tiRoot_t *tiRoot )
5775 tdsaRoot_t *tdsaRoot;
5776 tdsaContext_t *tdsaAllShared;
5778 agsaEncryptInfo_t agsaEncryptInfo;
5780 bit32 returnCode= tiBusy;
5781 bit32 tiStatus= tiError;
5783 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5784 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5786 agRoot = &(tdsaAllShared->agRootNonInt);
5789 returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
5790 TI_DBG1(("tiCOMEncryptHilSet: saEncryptGetMode returnCode 0x%x agsaEncryptInfo status 0x%x Smode 0x%x CMode 0x%x\n",
5792 agsaEncryptInfo.status,
5793 agsaEncryptInfo.encryptionSecurityMode,
5794 agsaEncryptInfo.encryptionCipherMode ));
5796 if (returnCode == AGSA_RC_FAILURE)
5798 TI_DBG1(("tiCOMEncryptHilSet:agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5799 if(agsaEncryptInfo.status == 0x81)
5801 TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISMATCH agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5802 returnCode = saEncryptHilUpdate(agRoot,
5805 if (returnCode == AGSA_RC_SUCCESS)
5807 TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_SUCCESS\n"));
5810 else if(agsaEncryptInfo.status == 0x80)
5812 ostidisableEncryption(tiRoot);
5813 TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISSING agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5814 returnCode = AGSA_RC_SUCCESS;
5818 TI_DBG1(("tiCOMEncryptHilSet: not status 0x81 agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5819 returnCode = AGSA_RC_FAILURE;
5823 if (returnCode == AGSA_RC_SUCCESS)
5825 tiStatus = tiSuccess;
5827 else if (returnCode == AGSA_RC_BUSY)
5829 TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_BUSY\n"));
5834 TI_DBG1(("tiCOMEncryptHilSet:tiError\n"));
5840 #endif /* HIALEAH_ENCRYPTION */
5842 /*****************************************************************************
5844 * tiCOMEncryptKekStore
5846 * Purpose: This function is called to store a KEK in NVRAM. If -1 is specified
5847 * as the KEK index, then all KEKs will be stored.
5851 * tiRoot: Pointer to driver/port instance.
5852 * kekIndex: The KEK to be stored in NVRAM
5855 * tiSuccess The request is being processed
5856 * tiError An invalid parameter was specified
5857 * tiBusy A KEK operation is already in progress
5859 *****************************************************************************/
5861 osGLOBAL bit32 tiCOMEncryptKekStore(tiRoot_t *tiRoot,
5865 tdsaRoot_t *tdsaRoot;
5866 tdsaContext_t *tdsaAllShared;
5870 bit32 returnCode= AGSA_RC_BUSY;
5872 bit32 tiStatus = tiError;
5875 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5876 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5878 agRoot = &(tdsaAllShared->agRootNonInt);
5881 TI_DBG1(("tiCOMEncryptKekStore: Needs code !!!! kekIndex 0x%x\n", kekIndex ));
5883 returnCode = fcEncryptKekStore(agRoot, kekIndex);
5885 if (returnCode == AGSA_RC_SUCCESS)
5887 tiStatus = tiSuccess;
5889 else if (returnCode == AGSA_RC_BUSY)
5901 /*****************************************************************************
5903 * tiCOMEncryptKekLoad
5905 * Purpose: This function is called to load a KEK from NVRAM. If -1 is specified
5906 * as the KEK index, then all KEKs will be loaded.
5910 * tiRoot: Pointer to driver/port instance.
5911 * kekIndex: The KEK to be loaded in NVRAM
5914 * tiSuccess The request is being processed
5915 * tiError An invalid parameter was specified
5916 * tiBusy A KEK operation is already in progress
5918 *****************************************************************************/
5920 osGLOBAL bit32 tiCOMEncryptKekLoad(tiRoot_t *tiRoot,
5924 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5925 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5929 bit32 tiStatus = tiError;
5932 agRoot = &(tdsaAllShared->agRootNonInt);
5935 returnCode = fcEncryptKekLoad(agRoot, kekIndex);
5937 if (returnCode == AGSA_RC_SUCCESS)
5939 tiStatus = tiSuccess;
5941 else if (returnCode == AGSA_RC_BUSY)
5953 /*****************************************************************************
5955 * tiCOMEncryptSelfTest
5957 * Purpose: This function starts the encryption self test. For the encryption self test, IOs must be quiesced.
5958 * The completion of this function is via ostiPortEvent().
5962 * tiRoot: Pointer to driver/port instance.
5963 * type: Types of test
5966 Others are reserved.
5968 Size of the test descriptor in bytes, e.g.,
5969 Sizeof(tiEncryptSelfTestDescriptor_t)
5970 Sizeof(tiEncryptHMACTestDescriptor_t)
5971 * TestDescriptor address of the test descriptor structure.
5974 * tiSuccess The request is being processed
5975 * tiError An invalid parameter was specified
5976 * tiBusy A encrytion operation is already in progress
5978 *****************************************************************************/
5979 osGLOBAL bit32 tiCOMEncryptSelfTest(
5983 void *TestDescriptor
5986 tdsaRoot_t *tdsaRoot = agNULL;
5987 tdsaContext_t *tdsaAllShared = agNULL;
5988 agsaRoot_t *agRoot = agNULL;
5990 bit32 returnCode = AGSA_RC_BUSY;
5991 bit32 tiStatus = tiError;
5993 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
5994 TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
5996 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5997 TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
5999 agRoot = &(tdsaAllShared->agRootNonInt);
6000 TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6002 TI_DBG1(("tiCOMEncryptSelfTest: type = 0x%x length = 0x%x\n", type, length));
6004 /*do some sanity checking */
6005 if ( ((type == TI_ENCRYPTION_TEST_TYPE_BIST) && (length != sizeof(tiEncryptSelfTestDescriptor_t ))) ||
6006 ((type == TI_ENCRYPTION_TEST_TYPE_HMAC) && (length != sizeof(tiEncryptHMACTestDescriptor_t))) )
6008 TI_DBG1(("tiCOMEncryptSelfTest: type or length error, type 0x%x length 0x%x\n", type, length));
6013 returnCode = saEncryptSelftestExecute(agRoot,
6021 if (returnCode == AGSA_RC_SUCCESS)
6023 tiStatus = tiSuccess;
6025 else if (returnCode == AGSA_RC_BUSY)
6038 /*****************************************************************************
6042 * Purpose: This function is called to login to or logout out from the controller by an operator.
6043 The status is reported via ostiPortEvent().
6047 * tiRoot: Pointer to driver/port instance.
6048 * flag: operator flag.
6049 Bits 0-3: Access type (ACS)
6052 All others are reserved.
6053 Bit 4: KEYopr pinned in the KEK table (PIN)
6054 0: Not pinned. Operator ID table will be searched during authentication.
6055 1: Pinned. OPRIDX is referenced to unwrap the certificate.
6057 Bits 8-15: KEKopr Index in the KEK Table (OPRIDX). If KEKopr is pinned in the KEK table, OPRIDX is to reference the KEK for authentication
6058 Bits 16-31: Reserved.
6060 cert: The pointer to the operator's certificate. The size of the certificate is 40 bytes.
6063 * tiSuccess Log in or log out was started.
6064 * tiError Log in or log out was not started.
6065 * tiBusy A operator management operation is already in progress
6067 *****************************************************************************/
6068 osGLOBAL bit32 tiCOMSetOperator(
6074 tdsaRoot_t *tdsaRoot = agNULL;
6075 tdsaContext_t *tdsaAllShared = agNULL;
6076 agsaRoot_t *agRoot = agNULL;
6078 bit32 returnCode = AGSA_RC_FAILURE;
6079 bit32 tiStatus = tiError;
6081 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6082 TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6084 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6085 TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6087 agRoot = &(tdsaAllShared->agRootNonInt);
6088 TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6090 TI_DBG1(("tiCOMSetOperator: flag = 0x%x \n", flag));
6092 returnCode = saSetOperator(agRoot,
6098 if (returnCode == AGSA_RC_SUCCESS)
6100 tiStatus = tiSuccess;
6102 else if (returnCode == AGSA_RC_BUSY)
6114 /*****************************************************************************
6118 * Purpose: This function is used to retrieve the role and ID of the current operator or all operators.
6119 The status is reported via ostiPortEvent().
6123 * tiRoot: Pointer to driver/port instance.
6124 * option: Types of get operations
6125 0x1: Current operator only
6127 All others are reserved.
6128 AddrHi Upper 32-bit host physical address to store operator certificates.
6129 This field is used only when option is 0x2
6130 AddrLo Lower 32-bit host physical address to store operator certificates.
6131 This field is used only when option is 0x2
6134 * tiSuccess The operation was started..
6135 * tiError The operation was not started.
6136 * tiBusy A operator management operation is already in progress
6138 *****************************************************************************/
6139 osGLOBAL bit32 tiCOMGetOperator(
6146 tdsaRoot_t *tdsaRoot = agNULL;
6147 tdsaContext_t *tdsaAllShared = agNULL;
6148 agsaRoot_t *agRoot = agNULL;
6150 bit32 returnCode = AGSA_RC_FAILURE;
6151 bit32 tiStatus = tiError;
6153 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6154 TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6156 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6157 TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6159 agRoot = &(tdsaAllShared->agRootNonInt);
6160 TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6162 TI_DBG1(("tiCOMGetOperator: option = 0x%x \n", option));
6164 returnCode = saGetOperator(agRoot,
6171 if (returnCode == AGSA_RC_SUCCESS)
6173 tiStatus = tiSuccess;
6175 else if (returnCode == AGSA_RC_BUSY)
6187 /*****************************************************************************
6189 * tiCOMOperationManagement
6191 * Purpose: this function is used to manage operators, e.g. adding or deleting an operator..
6195 * tiRoot: Pointer to driver/port instance.
6196 * flag: operation flag.
6197 Bits 0-7: Operator Management Operation(OMO)
6199 1: Delete an operator.
6200 2: Delete all operators.
6201 Others are reserved.
6202 Bit 8: Pinned to KEK RAM (PKR)
6203 0: Operator's KEK is stored in the operator ID table(OID_TLB) only.
6204 1: Operator's KEK is pinned to the internal KEK RAM (1 of the 16 entries) and is also stored in OID_TLB.
6205 Bits 9-10: KEKopr blob format (KBF)
6207 01b: AGSA_ENCRYPTED_KEK_PMCA.
6208 10b: AGSA_ENCRYPTED_KEK_PMCB.
6210 Bits 11-15: Reserved
6211 Bits 16-23: KEKauth Index in the KEK Table (AUTIDX)
6212 Bits 24-31: KEKopr Index in the KEK Table (OPRIDX). This field is valid only when PKR is 1.
6215 01b: Crypto officer role.
6217 All others are reserved.
6219 * idString: Pointer to the tiID_t structure describing the ID string
6220 * kekBlob Pointer to the tiEncryptKekBlob_t structure describing KBLOB.
6223 * tiSuccess The request is being processed
6224 * tiError An invalid parameter was specified
6225 * tiBusy A operator management operation is already in progress
6227 *****************************************************************************/
6228 osGLOBAL bit32 tiCOMOperatorManagement(
6233 tiEncryptKekBlob_t *kekBlob
6236 tdsaRoot_t *tdsaRoot = agNULL;
6237 tdsaContext_t *tdsaAllShared = agNULL;
6238 agsaRoot_t *agRoot = agNULL;
6240 bit32 returnCode = AGSA_RC_BUSY;
6241 bit32 tiStatus = tiError;
6243 tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6244 TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6246 tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6247 TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6249 agRoot = &(tdsaAllShared->agRootNonInt);
6250 TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6252 TI_DBG1(("tiCOMOperatorManagement: flag = 0x%x role = 0x%x\n", flag, role));
6254 returnCode = saOperatorManagement(agRoot,
6259 (agsaID_t*)idString,
6260 (agsaEncryptKekBlob_t *)kekBlob
6263 if (returnCode == AGSA_RC_SUCCESS)
6265 tiStatus = tiSuccess;
6267 else if (returnCode == AGSA_RC_BUSY)
6279 /*****************************************************************************
6280 *! \brief tdssRemoveSASSATAFromSharedcontext
6282 * Purpose: This function removes all discovered devices belonging to
6283 * a given portcontext from device list
6286 * \param agRoot Pointer to the root data structure of
6287 * TD and Lower layer
6288 * \param tsddPortContext_Instance Pointer to the target port context
6292 *****************************************************************************/
6293 #ifdef INITIATOR_DRIVER /*TBD: added to compile tgt_drv. (TP)*/
6295 tdssRemoveSASSATAFromSharedcontext(
6297 tdsaPortContext_t *PortContext_Instance
6300 tdsaDeviceData_t *oneDeviceData = agNULL;
6301 tdList_t *DeviceListList;
6302 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
6303 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
6304 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6305 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6307 TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: start\n"));
6308 TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d\n", PortContext_Instance->id));
6310 /* find oneDeviceData belonging to the portcontext */
6311 DeviceListList = tdsaAllShared->MainDeviceList.flink;
6312 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6314 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6315 if (oneDeviceData == agNULL)
6317 TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: oneDeviceData is NULL!!!\n"));
6320 if (oneDeviceData->tdPortContext == PortContext_Instance)
6322 TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d did %d\n", PortContext_Instance->id, oneDeviceData->id));
6323 TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
6324 TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
6326 /* reset valid bit */
6327 oneDeviceData->valid = agFALSE;
6328 oneDeviceData->valid2 = agFALSE;
6329 oneDeviceData->registered = agFALSE;
6330 /* notify only reported devices to OS layer*/
6331 if ( DEVICE_IS_SSP_TARGET(oneDeviceData) ||
6332 DEVICE_IS_STP_TARGET(oneDeviceData) ||
6333 DEVICE_IS_SATA_DEVICE(oneDeviceData)
6338 PortContext_Instance->tiPortalContext,
6339 &(oneDeviceData->tiDeviceHandle),
6340 tiIntrEventTypeDeviceChange,
6345 DeviceListList = DeviceListList->flink;
6346 /* to-do: deregister */
6347 #ifdef REMOVED /* don't remove device from the device list. May screw up ordering */
6348 TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
6349 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
6354 TI_DBG6(("tdssRemoveSASSATAFromSharedcontext: move to the next\n"));
6355 DeviceListList = DeviceListList->flink;
6362 /*****************************************************************************
6363 *! \brief tdssRemoveSASSATAFromSharedcontextByReset
6365 * Purpose: This function removes all ports and discovered devices
6368 * \param agRoot Pointer to the root data structure of
6369 * TD and Lower layer
6373 *****************************************************************************/
6375 tdssRemoveSASSATAFromSharedcontextByReset(
6379 tdsaPortContext_t *onePortContext = agNULL;
6380 tdsaDeviceData_t *oneDeviceData = agNULL;
6381 tdList_t *PortContextList;
6382 tdList_t *DeviceListList;
6383 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
6384 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
6385 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6386 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6388 dmRoot_t *dmRoot = agNULL;
6389 dmPortContext_t *dmPortContext = agNULL;
6390 dmPortInfo_t dmPortInfo;
6393 smRoot_t *smRoot = &(tdsaAllShared->smRoot);
6394 smDeviceHandle_t *smDeviceHandle = agNULL;
6395 agsaDevHandle_t *agDevHandle = agNULL;
6398 TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: start\n"));
6401 dmRoot = &(tdsaAllShared->dmRoot);
6403 /* looping throuhg all portcontext */
6404 PortContextList = tdsaAllShared->MainPortContextList.flink;
6405 while (PortContextList != &(tdsaAllShared->MainPortContextList))
6407 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6408 if (onePortContext == agNULL)
6410 TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: onePortContext is NULL!!!\n"));
6413 TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneportContext pid %d\n", onePortContext->id));
6414 TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", onePortContext->sasLocalAddressHi));
6415 TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", onePortContext->sasLocalAddressLo));
6417 if (onePortContext->UseDM == agTRUE)
6419 dmPortContext = &(onePortContext->dmPortContext);
6420 dmDestroyPort(dmRoot, dmPortContext, &dmPortInfo);
6424 tdsaPortContextReInit(tiRoot, onePortContext);
6426 PortContextList = PortContextList->flink;
6427 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
6428 TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
6429 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
6430 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
6433 /* reinitialize the device data belonging to this portcontext */
6434 DeviceListList = tdsaAllShared->MainDeviceList.flink;
6435 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6437 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6438 if (oneDeviceData == agNULL)
6440 TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneDeviceData is NULL!!!\n"));
6444 TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: did %d\n", oneDeviceData->id));
6445 TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
6446 TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
6449 agDevHandle = oneDeviceData->agDevHandle;
6450 smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle);
6451 smDeregisterDevice(smRoot, agDevHandle, smDeviceHandle);
6454 tdsaDeviceDataReInit(tiRoot, oneDeviceData);
6456 DeviceListList = DeviceListList->flink;
6457 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6458 osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t));
6459 TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
6460 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
6461 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6462 /* no dequeue from Mainlink for consistant ordering of devices */
6472 /*****************************************************************************
6473 *! \brief tdssAddSASToSharedcontext
6475 * Purpose: This function adds a discovered device to a device list of
6478 * \param tsddPortContext_Instance Pointer to the target port context
6479 * \param agRoot Pointer to the root data structure of
6480 * TD and Lower layer
6481 * \param agDevHandle Pointer to a device handle
6485 *****************************************************************************/
6487 tdssAddSASToSharedcontext(
6488 tdsaPortContext_t *tdsaPortContext_Instance,
6490 agsaDevHandle_t *agDevHandle, /* this is NULL */
6491 tdsaSASSubID_t *agSASSubID,
6492 bit32 registered, /* no longer in use */
6498 tdsaPortContext_t *onePortContext = agNULL;
6499 tdList_t *PortContextList;
6500 tdsaDeviceData_t *oneDeviceData = agNULL;
6501 tdList_t *DeviceListList;
6502 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
6503 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
6504 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6505 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6506 bit32 new_device = agTRUE;
6507 bit32 Indenom = tdsaAllShared->QueueConfig.numInboundQueues;
6508 bit32 Outdenom = tdsaAllShared->QueueConfig.numOutboundQueues;
6509 bit8 dev_s_rate = 0;
6511 bit8 connectionRate;
6512 bit32 found = agFALSE;
6514 TI_DBG3(("tdssAddSASToSharedcontext: start\n"));
6516 find a right portcontext
6517 then, get devicedata from FreeLink in DeviceList
6518 then, do pointer operations
6519 then, add the devicedata to the portcontext
6522 /* find a right portcontext */
6523 PortContextList = tdsaAllShared->MainPortContextList.flink;
6524 while (PortContextList != &(tdsaAllShared->MainPortContextList))
6526 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6527 if (onePortContext == tdsaPortContext_Instance)
6529 TI_DBG3(("tdssAddSASToSharedContext: found; oneportContext ID %d\n", onePortContext->id));
6533 PortContextList = PortContextList->flink;
6536 if (found == agTRUE)
6538 TI_DBG3(("tdssAddSASToSharedcontext: found pid %d\n", onePortContext->id));
6542 TI_DBG1(("tdssAddSASToSharedcontext: Error!!! no portcontext found!!!\n"));
6546 /* find a device's existence */
6547 DeviceListList = tdsaAllShared->MainDeviceList.flink;
6548 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6550 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6551 if (oneDeviceData == agNULL)
6553 TI_DBG1(("tdssAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
6556 if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
6557 (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
6558 (oneDeviceData->tdPortContext == onePortContext)
6561 TI_DBG1(("tdssAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6562 new_device = agFALSE;
6565 DeviceListList = DeviceListList->flink;
6569 if (new_device == agTRUE)
6571 TI_DBG3(("tdssAddSASToSharedcontext: new device\n"));
6573 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6574 if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
6576 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6577 TI_DBG1(("tdssAddSASToSharedContext: empty DeviceData FreeLink\n"));
6581 TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
6582 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6583 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
6585 TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
6587 onePortContext->Count++;
6588 oneDeviceData->DeviceType = TD_SAS_DEVICE;
6589 oneDeviceData->agRoot = agRoot;
6591 if (flag == TD_OPERATION_TARGET)
6593 oneDeviceData->agDevHandle = agDevHandle;
6594 agDevHandle->osData = oneDeviceData; /* TD layer */
6597 /* saving sas address */
6598 oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
6599 oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
6600 oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
6601 oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
6603 oneDeviceData->tdPortContext = onePortContext;
6604 oneDeviceData->valid = agTRUE;
6607 oneDeviceData->directlyAttached = agTRUE;
6608 /* parse sasIDframe to fill in agDeviceInfo */
6609 DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
6610 DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
6611 DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
6613 DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
6615 sasorsata = SAS_DEVICE_TYPE; /* SAS target (SAS disk or expander) */
6616 connectionRate = onePortContext->LinkRate;
6617 dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
6618 dev_s_rate = (bit8)(dev_s_rate | connectionRate);
6619 DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
6622 DEVINFO_PUT_SAS_ADDRESSLO(
6623 &oneDeviceData->agDeviceInfo,
6624 agSASSubID->sasAddressLo
6626 DEVINFO_PUT_SAS_ADDRESSHI(
6627 &oneDeviceData->agDeviceInfo,
6628 agSASSubID->sasAddressHi
6631 oneDeviceData->agContext.osData = oneDeviceData;
6632 oneDeviceData->agContext.sdkData = agNULL;
6634 if (flag == TD_OPERATION_INITIATOR)
6636 if (oneDeviceData->registered == agFALSE )
6638 if( tdsaAllShared->sflag )
6640 if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
6642 TI_DBG1(("tdssAddSASToSharedcontext: First, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
6643 oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
6647 saRegisterNewDevice( /* tdssAddSASToSharedcontext */
6649 &oneDeviceData->agContext,
6651 &oneDeviceData->agDeviceInfo,
6652 onePortContext->agPortContext,
6657 oneDeviceData->phyID = phyID;
6658 oneDeviceData->InQID = oneDeviceData->id % Indenom;
6660 #ifdef TARGET_DRIVER
6662 bit32 localId = oneDeviceData->id;
6664 oneDeviceData->OutQID = localId % Outdenom;
6665 TI_DBG1(("tdssAddSASToSharedcontext: OutQID %d\n", oneDeviceData->OutQID)); /* tdsaRotateQnumber for tgt*/
6668 #endif /* TARGET_DRIVER */
6670 TI_DBG4(("tdssAddSASToSharedcontext: SSP target %d STP target %d SATA device %d\n", DEVICE_IS_SSP_TARGET(oneDeviceData), DEVICE_IS_STP_TARGET(oneDeviceData), DEVICE_IS_SATA_DEVICE(oneDeviceData)));
6671 /* add the devicedata to the portcontext */
6672 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6673 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
6674 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6675 TI_DBG4(("tdssAddSASToSharedContext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
6676 TI_DBG4(("tdssAddSASToSharedContext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
6679 else /* old device */
6681 TI_DBG3(("tdssAddSASToSharedcontext: old device\n"));
6682 TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
6684 oneDeviceData->DeviceType = TD_SAS_DEVICE;
6685 oneDeviceData->agRoot = agRoot;
6687 if (flag == TD_OPERATION_TARGET)
6689 oneDeviceData->agDevHandle = agDevHandle;
6690 agDevHandle->osData = oneDeviceData; /* TD layer */
6693 /* saving sas address */
6694 oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
6695 oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
6696 oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
6697 oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
6700 oneDeviceData->tdPortContext = onePortContext;
6701 oneDeviceData->valid = agTRUE;
6703 oneDeviceData->directlyAttached = agTRUE;
6705 if (oneDeviceData->registered == agFALSE)
6707 TI_DBG1(("tdssAddSASToSharedcontext: registering\n"));
6708 /* parse sasIDframe to fill in agDeviceInfo */
6709 DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
6710 DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
6711 DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
6712 DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
6714 sasorsata = SAS_DEVICE_TYPE; /* SAS target (SAS disk or expander) */
6715 connectionRate = onePortContext->LinkRate;
6716 dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
6717 dev_s_rate = (bit8)(dev_s_rate | connectionRate);
6718 DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
6721 DEVINFO_PUT_SAS_ADDRESSLO(
6722 &oneDeviceData->agDeviceInfo,
6723 agSASSubID->sasAddressLo
6725 DEVINFO_PUT_SAS_ADDRESSHI(
6726 &oneDeviceData->agDeviceInfo,
6727 agSASSubID->sasAddressHi
6730 oneDeviceData->agContext.osData = oneDeviceData;
6731 oneDeviceData->agContext.sdkData = agNULL;
6733 if (flag == TD_OPERATION_INITIATOR)
6735 if( tdsaAllShared->sflag )
6737 if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
6739 TI_DBG1(("tdssAddSASToSharedcontext: Second, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
6740 oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
6743 saRegisterNewDevice( /* tdssAddSASToSharedcontext */
6745 &oneDeviceData->agContext,
6747 &oneDeviceData->agDeviceInfo,
6748 onePortContext->agPortContext,
6759 oneDeviceData->phyID = phyID;
6760 oneDeviceData->InQID = oneDeviceData->id % Indenom;
6761 oneDeviceData->OutQID = oneDeviceData->id % Outdenom;
6763 TI_DBG1(("tdssAddSASToSharedcontext: A OutQID %d\n", oneDeviceData->OutQID));
6764 TI_DBG4(("tdssAddSASToSharedcontext: SSP target %d STP target %d SATA device %d\n", DEVICE_IS_SSP_TARGET(oneDeviceData), DEVICE_IS_STP_TARGET(oneDeviceData), DEVICE_IS_SATA_DEVICE(oneDeviceData)));
6765 TI_DBG4(("tdssAddSASToSharedContext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
6774 /*****************************************************************************
6775 *! \brief tdssRemoveDevicedataFromSharedcontext
6777 * Purpose: This function removes a discovered device from a device list of
6780 * \param tsddPortContext_Ins Pointer to the target port context
6781 * \param tdsaDeviceData_Ins Pointer to the target device
6782 * \param agRoot Pointer to the root data structure of
6783 * TD and Lower layer
6788 *****************************************************************************/
6790 tdssRemoveSASFromSharedcontext(
6791 tdsaPortContext_t *tdsaPortContext_Ins,
6792 tdsaDeviceData_t *tdsaDeviceData_Ins,
6796 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
6797 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
6798 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6799 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6800 tdsaPortContext_t *onePortContext = agNULL;
6801 tdList_t *PortContextList;
6802 tdsaDeviceData_t *oneDeviceData = agNULL;
6803 tdList_t *DeviceListList;
6804 bit32 found = agTRUE;
6806 TI_DBG3(("tdssRemoveSASFromSharedcontext: start\n"));
6807 /* find a right portcontext */
6808 PortContextList = tdsaAllShared->MainPortContextList.flink;
6809 while (PortContextList != &(tdsaAllShared->MainPortContextList))
6811 onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6812 if (onePortContext == agNULL)
6814 TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: onePortContext is NULL!!!\n"));
6817 if (onePortContext == tdsaPortContext_Ins)
6819 TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: found; oneportContext ID %d\n", onePortContext->id));
6822 PortContextList = PortContextList->flink;
6825 /* find a device's existence */
6826 DeviceListList = tdsaAllShared->MainDeviceList.flink;
6827 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6829 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6830 if (oneDeviceData == agNULL)
6832 TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: oneDeviceData is NULL!!!\n"));
6835 if ((oneDeviceData->SASAddressID.sasAddressHi
6836 == SA_DEVINFO_GET_SAS_ADDRESSHI(&tdsaDeviceData_Ins->agDeviceInfo))
6838 (oneDeviceData->SASAddressID.sasAddressLo ==
6839 SA_DEVINFO_GET_SAS_ADDRESSLO(&tdsaDeviceData_Ins->agDeviceInfo)))
6841 TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6845 DeviceListList = DeviceListList->flink;
6848 if (found == agFALSE)
6850 TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: can't find the right devicedata in MainLink\n"));
6854 /* remove it and put it back to FreeLink of Devicedata */
6855 TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: removing ... pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6857 /* invalidate the device but keep it on the list for persistency */
6858 oneDeviceData->valid = agFALSE;
6863 /*****************************************************************************
6864 *! \brief tdssRemoveAllDevicedataFromPortcontext
6866 * Purpose: This function removes all discovered devices from a device list of
6869 * \param tdsaDeviceData Pointer to a device header
6873 *****************************************************************************/
6875 tdssRemoveAllDevicelistFromPortcontext(
6876 tdsaPortContext_t *PortContext_Ins,
6881 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
6882 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
6883 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6884 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6885 tdsaDeviceData_t *oneDeviceData = agNULL;
6886 tdList_t *DeviceListList;
6888 TI_DBG6(("tdssRemoveAllDevicedataFromPortcontext: start\n"));
6891 loop through device list and find the matching portcontext. Then invalidate the
6894 DeviceListList = tdsaAllShared->MainDeviceList.flink;
6895 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6897 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6898 if (oneDeviceData == agNULL)
6900 TI_DBG1(("tdssRemoveAllDevicelistFromPortcontext: oneDeviceData is NULL!!!\n"));
6903 if (oneDeviceData->tdPortContext == PortContext_Ins)
6905 TI_DBG4(("tdssRemoveAllDevicelistFromPortcontext: pid %d did %d\n", PortContext_Ins->id, oneDeviceData->id));
6906 PortContext_Ins->Count--;
6907 oneDeviceData->valid = agFALSE;
6909 DeviceListList = DeviceListList->flink;
6916 #ifdef INITIATOR_DRIVER
6918 /*****************************************************************************
6919 *! \brief tdssNewAddSASToSharedcontext
6921 * Purpose: This function adds a discovered SAS device to a device list of
6922 * a shared context. Used only in discovery.
6924 * \param agRoot Pointer to chip/driver Instance.
6925 * \param onePortContext Pointer to the target port context
6926 * \param agSASSubID Pointer to the SAS identification.
6929 * Pointer to the device data
6931 *****************************************************************************/
6932 osGLOBAL tdsaDeviceData_t *
6933 tdssNewAddSASToSharedcontext(
6935 tdsaPortContext_t *onePortContext,
6936 tdsaSASSubID_t *agSASSubID,
6937 tdsaDeviceData_t *oneExpDeviceData,
6941 tdsaDeviceData_t *oneDeviceData = agNULL;
6942 tdList_t *DeviceListList;
6943 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
6944 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
6945 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
6946 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6947 bit32 new_device = agTRUE;
6949 TI_DBG3(("tdssNewAddSASToSharedcontext: start\n"));
6951 find a right portcontext
6952 then, get devicedata from FreeLink in DeviceList
6953 then, do pointer operations
6954 then, add the devicedata to the portcontext
6958 TI_DBG3(("tdssNewAddSASToSharedcontext: oneportContext ID %d\n", onePortContext->id));
6959 /* find a device's existence */
6960 DeviceListList = tdsaAllShared->MainDeviceList.flink;
6961 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6963 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6964 if (oneDeviceData == agNULL)
6966 TI_DBG1(("tdssNewAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
6969 if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
6970 (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
6971 (oneDeviceData->tdPortContext == onePortContext)
6974 TI_DBG3(("tdssNewAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6975 new_device = agFALSE;
6978 DeviceListList = DeviceListList->flink;
6982 if (new_device == agTRUE)
6984 TI_DBG3(("tdssNewAddSASToSharedcontext: new device\n"));
6985 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6986 if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
6988 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6989 TI_DBG1(("tdssNewAddSASToSharedcontext: empty DeviceData FreeLink\n"));
6993 TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
6994 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6995 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
6997 TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
6999 onePortContext->Count++;
7000 oneDeviceData->agRoot = agRoot;
7001 /* saving sas address */
7002 oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
7003 oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
7004 oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
7005 oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
7006 oneDeviceData->tdPortContext = onePortContext;
7007 /* handles both SAS target and STP-target, SATA-device */
7008 if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
7010 oneDeviceData->DeviceType = TD_SAS_DEVICE;
7014 oneDeviceData->DeviceType = TD_SATA_DEVICE;
7017 oneDeviceData->ExpDevice = oneExpDeviceData;
7018 /* set phyID only when it has initial value of 0xFF */
7019 if (oneDeviceData->phyID == 0xFF)
7021 oneDeviceData->phyID = phyID;
7024 oneDeviceData->valid = agTRUE;
7027 /* incremental discovery */
7028 /* add device to incremental-related link. Report using this link
7029 when incremental discovery is done */
7030 if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
7032 TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
7033 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7034 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7035 oneDeviceData->valid2 = agTRUE;
7039 TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
7040 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7041 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7042 oneDeviceData->valid = agTRUE;
7045 /* add the devicedata to the portcontext */
7046 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7047 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
7048 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7049 TI_DBG4(("tdssNewAddSASToSharedcontext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
7050 TI_DBG4(("tdssNewAddSASToSharedcontext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
7052 else /* old device */
7054 TI_DBG3(("tdssNewAddSASToSharedcontext: old device\n"));
7055 TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
7057 oneDeviceData->agRoot = agRoot;
7058 /* saving sas address */
7059 oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
7060 oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
7061 oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
7062 oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
7063 oneDeviceData->tdPortContext = onePortContext;
7064 /* handles both SAS target and STP-target, SATA-device */
7065 if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
7067 oneDeviceData->DeviceType = TD_SAS_DEVICE;
7071 oneDeviceData->DeviceType = TD_SATA_DEVICE;
7074 oneDeviceData->ExpDevice = oneExpDeviceData;
7075 /* set phyID only when it has initial value of 0xFF */
7076 if (oneDeviceData->phyID == 0xFF)
7078 oneDeviceData->phyID = phyID;
7082 oneDeviceData->valid = agTRUE;
7084 if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
7086 TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
7087 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7088 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7089 oneDeviceData->valid2 = agTRUE;
7093 TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
7094 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7095 TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7096 oneDeviceData->valid = agTRUE;
7099 TI_DBG4(("tdssNewAddSASToSharedcontext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
7102 return oneDeviceData;
7105 /*****************************************************************************
7106 *! \brief tdsaFindRegNValid
7108 * Purpose: This function finds a device which is registered and valid in
7109 * the device list. Used only in incremental discovery.
7111 * \param agRoot Pointer to chip/driver Instance.
7112 * \param onePortContext Pointer to the target port context
7113 * \param tdsaDeviceData Pointer to a device list header
7114 * \param agSASSubID Pointer to the SAS identification.
7117 * Pointer to the device data
7119 *****************************************************************************/
7120 osGLOBAL tdsaDeviceData_t *
7123 tdsaPortContext_t *onePortContext,
7124 tdsaSASSubID_t *agSASSubID
7127 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
7128 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
7129 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7130 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7131 tdsaDeviceData_t *oneDeviceData = agNULL;
7132 tdList_t *DeviceListList;
7133 bit32 found = agFALSE;
7135 TI_DBG3(("tdsaFindRegNValid: start\n"));
7137 /* find a device's existence */
7138 DeviceListList = tdsaAllShared->MainDeviceList.flink;
7139 if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_FULL_START)
7141 TI_DBG3(("tdsaFindRegNValid: Full discovery\n"));
7142 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7144 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7145 if (oneDeviceData == agNULL)
7147 TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
7150 if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7151 (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7152 (oneDeviceData->registered == agTRUE) &&
7153 (oneDeviceData->valid == agTRUE) &&
7154 (oneDeviceData->tdPortContext == onePortContext)
7157 TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7158 TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7159 TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7163 DeviceListList = DeviceListList->flink;
7168 /* incremental discovery */
7169 TI_DBG3(("tdsaFindRegNValid: Incremental discovery\n"));
7170 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7172 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7173 if (oneDeviceData == agNULL)
7175 TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
7178 if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7179 (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7180 (oneDeviceData->registered == agTRUE) &&
7181 (oneDeviceData->valid2 == agTRUE) &&
7182 (oneDeviceData->tdPortContext == onePortContext)
7185 TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7186 TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7187 TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7191 DeviceListList = DeviceListList->flink;
7197 if (found == agFALSE)
7199 TI_DBG3(("tdsaFindRegNValid: end returning NULL\n"));
7204 TI_DBG3(("tdsaFindRegNValid: end returning NOT NULL\n"));
7205 return oneDeviceData;
7210 //registered to LL or not
7211 /*****************************************************************************
7212 *! \brief tdssNewSASorNot
7214 * Purpose: This function finds whether a device is registered or not
7216 * \param agRoot Pointer to chip/driver Instance.
7217 * \param onePortContext Pointer to the target port context
7218 * \param agSASSubID Pointer to the SAS identification.
7221 * agTRUE Device is not registered (New device).
7222 * agFALSE Device is registered (Old device).
7224 *****************************************************************************/
7228 tdsaPortContext_t *onePortContext,
7229 tdsaSASSubID_t *agSASSubID
7232 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
7233 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
7234 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7235 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7236 tdsaDeviceData_t *oneDeviceData = agNULL;
7237 tdList_t *DeviceListList;
7240 TI_DBG3(("tdssNewSASorNot: start\n"));
7242 /* find a device's existence */
7243 DeviceListList = tdsaAllShared->MainDeviceList.flink;
7244 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7246 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7247 if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7248 (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7249 (oneDeviceData->registered == agTRUE) &&
7250 (oneDeviceData->tdPortContext == onePortContext)
7253 TI_DBG3(("tdssNewSASorNot: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7257 DeviceListList = DeviceListList->flink;
7262 TI_DBG3(("tdssNewSASorNot: end\n"));
7269 /*****************************************************************************
7270 *! \brief tdssSASDiscoveringExpanderAlloc
7272 * Purpose: This function allocates an expander from the pre-allocated memory
7275 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7277 * \param onePortContext: Pointer to the portal context instance.
7278 * \param oneDeviceData: Pointer to the device data.
7281 * Pointer to expander on success
7286 *****************************************************************************/
7287 osGLOBAL tdsaExpander_t *
7288 tdssSASDiscoveringExpanderAlloc(
7290 tdsaPortContext_t *onePortContext,
7291 tdsaDeviceData_t *oneDeviceData
7294 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7295 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7296 tdsaExpander_t *oneExpander = agNULL;
7297 tdList_t *ExpanderList;
7300 move the expander from freeExpanderList
7301 and ground the expander by TDLIST_DEQUEUE_THIS
7305 TI_DBG3(("tdssSASDiscoveringExpanderAlloc: start\n"));
7306 TI_DBG3(("tdssSASDiscoveringExpanderAlloc: did %d\n", oneDeviceData->id));
7307 TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7308 TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7310 if (onePortContext->valid == agFALSE)
7312 TI_DBG1(("tdssSASDiscoveringExpanderAlloc: aborting discovery\n"));
7313 tdsaSASDiscoverAbort(tiRoot, onePortContext);
7317 tdsaDumpAllFreeExp(tiRoot);
7319 if (TDLIST_EMPTY(&(tdsaAllShared->freeExpanderList)))
7321 TI_DBG1(("tdssSASDiscoveringExpanderAlloc: no free expanders\n"));
7325 tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7326 TDLIST_DEQUEUE_FROM_HEAD(&ExpanderList, &(tdsaAllShared->freeExpanderList));
7327 tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7328 // oneExpander = TDLIST_OBJECT_BASE(tdsaContext_t, freeExpanderList, ExpanderList);
7329 oneExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7331 if (oneExpander != agNULL)
7333 TI_DBG3(("tdssSASDiscoveringExpanderAlloc: expander id %d\n", oneExpander->id));
7335 tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7336 TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
7337 tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7339 oneExpander->tdDevice = oneDeviceData;
7340 oneExpander->tdUpStreamExpander = agNULL;
7341 oneExpander->tdCurrentDownStreamExpander = agNULL;
7342 oneExpander->tdReturnginExpander = agNULL;
7343 oneExpander->hasUpStreamDevice = agFALSE;
7344 oneExpander->numOfUpStreamPhys = 0;
7345 oneExpander->currentUpStreamPhyIndex = 0;
7346 oneExpander->discoveringPhyId = 0;
7347 oneExpander->underDiscovering = agFALSE;
7348 osti_memset( &(oneExpander->currentIndex), 0, sizeof(oneExpander->currentIndex));
7350 oneDeviceData->tdExpander = oneExpander;
7356 /*****************************************************************************
7357 *! \brief tdssSASDiscoveringExpanderAdd
7359 * Purpose: This function adds an expander to the expander list.
7361 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7363 * \param onePortContext: Pointer to the portal context instance.
7364 * \param oneExpander: Pointer to the expander data.
7371 *****************************************************************************/
7373 tdssSASDiscoveringExpanderAdd(
7375 tdsaPortContext_t *onePortContext,
7376 tdsaExpander_t *oneExpander
7379 #ifdef TD_INTERNAL_DEBUG
7380 tdList_t *ExpanderList;
7381 tdsaExpander_t *tempExpander;
7384 /* move the expander to discoveringExpanderList */
7386 TI_DBG3(("tdssSASDiscoveringExpanderAdd: start\n"));
7387 TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", oneExpander->id));
7388 TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7389 TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7391 if (onePortContext->valid == agFALSE)
7393 TI_DBG1(("tdssSASDiscoveringExpanderAdd: aborting discovery\n"));
7394 tdsaSASDiscoverAbort(tiRoot, onePortContext);
7399 if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
7401 TI_DBG3(("tdssSASDiscoveringExpanderAdd: UPSTREAM\n"));
7403 else if (onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
7405 TI_DBG3(("tdssSASDiscoveringExpanderAdd: DOWNSTREAM\n"));
7409 TI_DBG3(("tdssSASDiscoveringExpanderAdd: status %d\n", onePortContext->discovery.status));
7412 TI_DBG3(("tdssSASDiscoveringExpanderAdd: BEFORE\n"));
7413 tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7416 if ( oneExpander->underDiscovering == agFALSE)
7418 TI_DBG3(("tdssSASDiscoveringExpanderAdd: ADDED \n"));
7420 oneExpander->underDiscovering = agTRUE;
7421 tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7422 TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(onePortContext->discovery.discoveringExpanderList));
7423 tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7426 TI_DBG3(("tdssSASDiscoveringExpanderAdd: AFTER\n"));
7427 tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7429 #ifdef TD_INTERNAL_DEBUG
7431 if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7433 TI_DBG3(("tdssSASDiscoveringExpanderAdd: empty discoveringExpanderList\n"));
7436 ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7437 while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7439 tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7440 TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", tempExpander->id));
7441 ExpanderList = ExpanderList->flink;
7450 tdssSASFindDiscoveringExpander(
7452 tdsaPortContext_t *onePortContext,
7453 tdsaExpander_t *oneExpander
7456 tdList_t *ExpanderList;
7457 tdsaExpander_t *tempExpander;
7458 tdsaPortContext_t *tmpOnePortContext = onePortContext;
7459 bit32 ret = agFALSE;
7461 TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7462 TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7464 if (TDLIST_EMPTY(&(tmpOnePortContext->discovery.discoveringExpanderList)))
7466 TI_DBG1(("tdssSASFindDiscoveringExpander: empty discoveringExpanderList\n"));
7469 ExpanderList = tmpOnePortContext->discovery.discoveringExpanderList.flink;
7470 while (ExpanderList != &(tmpOnePortContext->discovery.discoveringExpanderList))
7472 tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7473 if (tempExpander == oneExpander)
7475 TI_DBG3(("tdssSASFindDiscoveringExpander: match!!! expander id %d\n", tempExpander->id));
7476 TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressHi));
7477 TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressLo));
7482 ExpanderList = ExpanderList->flink;
7490 /* move the expander to freeExpanderList */
7491 /*****************************************************************************
7492 *! \brief tdssSASDiscoveringExpanderRemove
7494 * Purpose: This function removes an expander from the expander list.
7496 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7498 * \param onePortContext: Pointer to the portal context instance.
7499 * \param oneExpander: Pointer to the expander data.
7506 *****************************************************************************/
7508 tdssSASDiscoveringExpanderRemove(
7510 tdsaPortContext_t *onePortContext,
7511 tdsaExpander_t *oneExpander
7514 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7515 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7516 #ifdef TD_INTERNAL_DEBUG
7517 tdList_t *ExpanderList;
7518 tdsaExpander_t *tempExpander;
7521 TI_DBG3(("tdssSASDiscoveringExpanderRemove: start\n"));
7522 TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", oneExpander->id));
7523 TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7524 TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7527 TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
7528 tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7529 tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
7530 tdsaDumpAllFreeExp(tiRoot);
7532 #ifdef TD_INTERNAL_DEBUG
7534 TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
7535 if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7537 TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
7539 ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7540 while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7542 tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7543 TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
7544 ExpanderList = ExpanderList->flink;
7548 // if is temporary till smp problem is fixed
7549 if (tdssSASFindDiscoveringExpander(tiRoot, onePortContext, oneExpander) == agTRUE)
7551 oneExpander->underDiscovering = agFALSE;
7552 oneExpander->discoveringPhyId = 0;
7553 tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7554 TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
7556 if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
7558 TI_DBG3(("tdssSASDiscoveringExpanderRemove: DISCOVERY_UP_STREAM\n"));
7559 TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->upNode), &(onePortContext->discovery.UpdiscoveringExpanderList));
7560 onePortContext->discovery.NumOfUpExp++;
7564 TI_DBG3(("tdssSASDiscoveringExpanderRemove: Status %d\n", onePortContext->discovery.status));
7565 TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(tdsaAllShared->freeExpanderList));
7568 tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7572 TI_DBG1(("tdssSASDiscoveringExpanderRemove: !!! problem !!!\n"));
7575 TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
7576 tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7577 tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
7579 tdsaDumpAllFreeExp(tiRoot);
7581 #ifdef TD_INTERNAL_DEBUG
7583 TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
7584 if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7586 TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
7588 ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7589 while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7591 tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7592 TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
7593 ExpanderList = ExpanderList->flink;
7602 /*****************************************************************************
7603 *! \brief tdssNewAddSATAToSharedcontext
7605 * Purpose: This function adds a discovered SATA device to a device list of
7606 * a shared context. Used only in discovery.
7608 * \param tiRoot Pointer to the OS Specific module allocated tiRoot_t
7610 * \param agRoot Pointer to chip/driver Instance.
7611 * \param onePortContext Pointer to the target port context
7612 * \param tdsaDeviceData Pointer to a device list header
7613 * \param agSATADeviceInfo Pointer to the SATA device information.
7614 * \param Signature Pointer to SATA signature
7615 * \param pm Port multiplier
7616 * \param pmField Port multiplier field
7617 * \param connectionRate Connection rate
7620 * Pointer to the device data
7622 *****************************************************************************/
7623 osGLOBAL tdsaDeviceData_t *
7624 tdssNewAddSATAToSharedcontext(tiRoot_t *tiRoot,
7626 tdsaPortContext_t *onePortContext,
7627 agsaSATADeviceInfo_t *agSATADeviceInfo,
7631 bit32 connectionRate,
7632 tdsaDeviceData_t *oneExpDeviceData,
7636 tdsaDeviceData_t *oneDeviceData = agNULL;
7637 tdList_t *DeviceListList;
7638 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7639 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7640 int new_device = agTRUE;
7642 TI_DBG5(("tdssNewAddSATAToSharedcontext: start\n"));
7646 TI_DBG5(("tdssNewAddSATAToSharedcontext: oneportContext ID %d\n", onePortContext->id));
7650 /* Find a device's existence */
7651 DeviceListList = tdsaAllShared->MainDeviceList.flink;
7652 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7654 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7656 if ((osti_memcmp (((char *)&oneDeviceData->satDevData.satIdentifyData),
7657 ((char *)&agSATADeviceInfo->sataIdentifyData),
7658 sizeof(agsaSATAIdentifyData_t)) == 0))
7660 TI_DBG5(("tdssNewAddSATAToSharedcontext: pid %d did %d\n",
7661 onePortContext->id, oneDeviceData->id));
7662 new_device = agFALSE;
7665 DeviceListList = DeviceListList->flink;
7673 if (new_device == agTRUE)
7675 TI_DBG5(("tdssNewAddSATAToSharedcontext: new device\n"));
7677 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7678 if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
7680 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7681 TI_DBG1(("tdssNewAddSATAToSharedcontext: ERROR empty DeviceData FreeLink\n"));
7682 return oneDeviceData;
7685 TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
7686 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7687 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
7689 onePortContext->Count++;
7690 oneDeviceData->DeviceType = TD_SATA_DEVICE;
7691 oneDeviceData->agRoot = agRoot;
7692 TI_DBG5(("tdssNewAddSATAToSharedcontext: oneDeviceData %p\n", oneDeviceData));
7693 TI_DBG5(("tdssNewAddSATAToSharedcontext: pSatDevData=%p\n", &oneDeviceData->satDevData));
7696 /* saving PortMultiplier(PM) field */
7697 oneDeviceData->satDevData.satPMField = pmField;
7699 /* saving signature */
7700 osti_memcpy(&(oneDeviceData->satDevData.satSignature), Signature, 8);
7704 ATA device type; here should be either ATA_ATA_DEVICE or ATA_ATAPI_DEVICE
7706 oneDeviceData->satDevData.satDeviceType = tdssSATADeviceTypeDecode(agSATADeviceInfo->signature);
7707 TI_DBG3(("tdssNewAddSATAToSharedcontext: device type %d\n", oneDeviceData->satDevData.satDeviceType));
7709 #ifdef RPM_SOC_REMOVED
7710 /* print device signature - Word8 */
7711 TI_DBG3(("tdssNewAddSATAToSharedcontext: Word8 %x signature: %x %x %x %x %x %x %x %x\n",
7712 agSATADeviceInfo->sataIdentifyData.word1_9[7],
7713 agSATADeviceInfo->signature[0], agSATADeviceInfo->signature[1],
7714 agSATADeviceInfo->signature[2], agSATADeviceInfo->signature[3],
7715 agSATADeviceInfo->signature[4], agSATADeviceInfo->signature[5],
7716 agSATADeviceInfo->signature[6], agSATADeviceInfo->signature[7] ));
7721 oneDeviceData->tdPortContext = onePortContext;
7722 oneDeviceData->valid = agTRUE;
7724 oneDeviceData->ExpDevice = oneExpDeviceData;
7725 oneDeviceData->phyID = phyID;
7727 /* Add the devicedata to the portcontext */
7728 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7729 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
7730 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7731 TI_DBG5(("tdssNewAddSATAToSharedcontext: one case pid %d did %d \n",
7732 onePortContext->id, oneDeviceData->id));
7734 else /* old device */
7736 TI_DBG5(("tdssNewAddSATAToSharedcontext: old device\n"));
7738 onePortContext->Count++;
7740 oneDeviceData->DeviceType = TD_SATA_DEVICE;
7741 oneDeviceData->agRoot = agRoot;
7743 oneDeviceData->tdPortContext = onePortContext;
7744 oneDeviceData->valid = agTRUE;
7746 oneDeviceData->ExpDevice = oneExpDeviceData;
7747 oneDeviceData->phyID = phyID;
7751 return oneDeviceData;
7754 #endif /* SATA_ENABLE */
7755 #endif /* TD_DISCOVER */
7756 #endif /* INITIATOR_DRIVER */
7758 #ifdef TARGET_DRIVER
7759 /*****************************************************************************
7760 *! \brief tdssReportRemovals
7762 * Purpose: This function goes through device list and removes all devices
7763 * belong to the portcontext. This function also deregiters those
7764 * devices. This function is called in case of incremental discovery
7767 * \param agRoot : Pointer to chip/driver Instance.
7768 * \param onePortContext: Pointer to the portal context instance.
7769 * \param oneDeviceData: Pointer to the device data.
7776 *****************************************************************************/
7778 ttdssReportRemovals(
7780 tdsaPortContext_t *onePortContext,
7784 tdsaDeviceData_t *oneDeviceData = agNULL;
7785 tdList_t *DeviceListList;
7786 tdsaRootOsData_t *osData = (tdsaRootOsData_t *)agRoot->osData;
7787 tiRoot_t *tiRoot = (tiRoot_t *)osData->tiRoot;
7788 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7789 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7790 bit32 removed = agFALSE;
7791 agsaEventSource_t *eventSource;
7794 tdsaDeviceData_t *tmpDeviceData = agNULL;
7796 TI_DBG1(("ttdssReportRemovals: start\n"));
7797 /* in case nothing was registered */
7798 PhyID = onePortContext->eventPhyID;
7799 if (tdsaAllShared->eventSource[PhyID].EventValid == agTRUE &&
7800 onePortContext->RegisteredDevNums == 0 &&
7804 TI_DBG1(("ttdssReportRemovals: calling saHwEventAck\n"));
7805 eventSource = &(tdsaAllShared->eventSource[PhyID].Source);
7806 HwAckSatus = saHwEventAck(
7808 agNULL, /* agContext */
7810 eventSource, /* agsaEventSource_t */
7814 if ( HwAckSatus != AGSA_RC_SUCCESS)
7816 TI_DBG1(("ttdssReportRemovals: failing in saHwEventAck; status %d\n", HwAckSatus));
7820 tdsaAllShared->eventSource[PhyID].EventValid = agFALSE;
7821 if (onePortContext->valid == agFALSE)
7823 tdsaPortContextReInit(tiRoot, onePortContext);
7825 put all devices belonging to the onePortContext
7826 back to the free link
7828 tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
7829 TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
7830 TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
7831 tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
7836 if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
7838 TI_DBG1(("ttdssReportRemovals: empty device list\n"));
7842 DeviceListList = tdsaAllShared->MainDeviceList.flink;
7843 while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7845 oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7846 if( oneDeviceData == agNULL )
7850 TI_DBG1(("ttdssReportRemovals: loop did %d\n", oneDeviceData->id));
7851 TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
7852 TI_DBG1(("ttdssReportRemovals: valid %d valid2 %d\n", oneDeviceData->valid, oneDeviceData->valid2));
7853 TI_DBG1(("ttdssReportRemovals: directlyAttached %d registered %d\n", oneDeviceData->directlyAttached, oneDeviceData->registered));
7854 if ( oneDeviceData->tdPortContext == onePortContext)
7856 TI_DBG1(("ttdssReportRemovals: right portcontext pid %d\n", onePortContext->id));
7857 if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE)
7859 TI_DBG1(("ttdssReportRemovals: removing\n"));
7861 /* notify only reported devices to OS layer*/
7864 /* all targets except expanders */
7865 TI_DBG1(("ttdssReportRemovals: calling tdsaAbortAll\n"));
7866 TI_DBG1(("ttdssReportRemovals: did %d\n", oneDeviceData->id));
7867 TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
7868 tmpDeviceData = oneDeviceData;
7869 ttdsaAbortAll(tiRoot, agRoot, oneDeviceData);
7872 /* reset valid bit */
7873 oneDeviceData->valid = agFALSE;
7874 oneDeviceData->valid2 = agFALSE;
7875 oneDeviceData->registered = agFALSE;
7877 /* called by port invalid case */
7880 oneDeviceData->tdPortContext = agNULL;
7882 #ifdef REMOVED /* removed */
7883 /* directly attached SATA -> always remove it */
7884 if (oneDeviceData->DeviceType == TD_SATA_DEVICE &&
7885 oneDeviceData->directlyAttached == agTRUE)
7887 TI_DBG1(("ttdssReportRemovals: device did %d\n", oneDeviceData->id));
7888 tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7889 TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
7890 TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceLis));
7891 DeviceListList = tdsaAllShared->MainDeviceList.flink;
7892 if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
7894 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7899 tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7904 DeviceListList = DeviceListList->flink;
7906 #endif /* REMOVED */
7907 DeviceListList = DeviceListList->flink;
7911 if (oneDeviceData->tdPortContext != agNULL)
7913 TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid %d oneportcontext pid %d\n", oneDeviceData->tdPortContext->id, onePortContext->id));
7917 TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid NULL oneportcontext pid %d\n", onePortContext->id));
7919 DeviceListList = DeviceListList->flink;
7923 if (removed == agTRUE)
7925 TI_DBG1(("ttdssReportRemovals: removed at the end\n"));
7928 onePortContext->tiPortalContext,
7929 &(tmpDeviceData->tiDeviceHandle),
7930 tiTgtEventTypeDeviceChange,
7938 #endif /* TARGET_DRIVER */
7941 /*****************************************************************************
7942 *! \brief tdsaRotateQnumber
7944 * Purpose: This function generates inbound queue number.
7946 * \param tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7954 *****************************************************************************/
7956 tdsaRotateQnumber(tiRoot_t *tiRoot,
7957 tdsaDeviceData_t *oneDeviceData )
7961 TI_DBG6(("tdsaRotateQnumber: start\n"));
7962 if (oneDeviceData == agNULL)
7966 ret = (oneDeviceData->OutQID << 16) | oneDeviceData->InQID;
7971 tdsaRotateQnumber1(tiRoot_t *tiRoot,
7972 tdsaDeviceData_t *oneDeviceData )
7974 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7975 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7976 // static int Last_Q;
7977 // bit32 denom = tdsaAllShared->QueueConfig.numOutboundQueues;
7979 if (oneDeviceData == agNULL)
7985 /* alway use highest Q number */
7986 ret = ((tdsaAllShared->QueueConfig.numOutboundQueues-1) << 16) | (tdsaAllShared->QueueConfig.numInboundQueues-1);
7993 tdsaRotateQnumber(tiRoot_t *tiRoot,
7994 tdsaDeviceData_t *oneDeviceData )
7996 tdsaRoot_t *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
7997 tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7998 bit32 denom = tdsaAllShared->QueueConfig.numInboundQueues;
8001 /* inbound queue number */
8002 tdsaAllShared->IBQnumber++;
8003 if (tdsaAllShared->IBQnumber % denom == 0) /* % Qnumber*/
8005 tdsaAllShared->IBQnumber = 0;
8007 TI_DBG6(("tdsaRotateQnumber: IBQnumber %d\n", tdsaAllShared->IBQnumber));
8010 /* outbound queue number */
8011 tdsaAllShared->OBQnumber++;
8012 denom = tdsaAllShared->QueueConfig.numOutboundQueues;
8013 if (tdsaAllShared->OBQnumber % denom == 0) /* % Qnumber*/
8015 tdsaAllShared->OBQnumber = 0;
8017 TI_DBG6(("tdsaRotateQnumber: OBQnumber %d\n", tdsaAllShared->OBQnumber));
8019 ret = (tdsaAllShared->OBQnumber << 16) | tdsaAllShared->IBQnumber;
8025 void t_MacroCheck( agsaRoot_t *agRoot)
8027 TI_DBG1(("t_MacroCheck:tIsSPC %d\n",tIsSPC(agRoot)));
8028 TI_DBG1(("t_MacroCheck:tIsSPCHIL %d\n",tIsSPCHIL(agRoot)));
8029 TI_DBG1(("t_MacroCheck:tIsSPCv %d\n",tIsSPCv(agRoot)));
8030 TI_DBG1(("t_MacroCheck:tIsSPCve %d\n",tIsSPCve(agRoot)));
8031 TI_DBG1(("t_MacroCheck:tIsSPCvplus %d\n",tIsSPCvplus(agRoot)));
8032 TI_DBG1(("t_MacroCheck:tIsSPCveplus %d\n",tIsSPCveplus(agRoot)));
8033 TI_DBG1(("t_MacroCheck:tIsSPCADAPvplus %d\n",tIsSPCADAPvplus(agRoot)));
8034 TI_DBG1(("t_MacroCheck:tIsSPCADAPveplus %d\n",tIsSPCADAPveplus(agRoot)));
8035 TI_DBG1(("t_MacroCheck:tIsSPC12Gv %d\n",tIsSPC12Gv(agRoot)));
8036 TI_DBG1(("t_MacroCheck:tIsSPC12Gve %d\n",tIsSPC12Gve(agRoot)));
8037 TI_DBG1(("t_MacroCheck:tIsSPC12Gvplus %d\n",tIsSPC12Gvplus(agRoot)));
8038 TI_DBG1(("t_MacroCheck:tIsSPC12Gveplus %d\n",tIsSPC12Gveplus(agRoot)));
8039 TI_DBG1(("t_MacroCheck:tiIS_SPC %d\n",tiIS_SPC(agRoot) ));
8040 TI_DBG1(("t_MacroCheck:tiIS_HIL %d\n",tiIS_HIL(agRoot) ));
8041 TI_DBG1(("t_MacroCheck:tiIS_SPC6V %d\n",tiIS_SPC6V(agRoot) ));
8042 TI_DBG1(("t_MacroCheck:tiIS_SPC_ENC %d\n",tiIS_SPC_ENC(agRoot) ));
8043 TI_DBG1(("t_MacroCheck:tIsSPCV12G %d\n",tIsSPCV12G(agRoot) ));