xref: /freebsd/sys/dev/pms/RefTisa/tisa/sassata/common/tdport.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
1*4e1bc9a0SAchim Leubner /*******************************************************************************
2*4e1bc9a0SAchim Leubner *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3*4e1bc9a0SAchim Leubner *
4*4e1bc9a0SAchim Leubner *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5*4e1bc9a0SAchim Leubner *that the following conditions are met:
6*4e1bc9a0SAchim Leubner *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7*4e1bc9a0SAchim Leubner *following disclaimer.
8*4e1bc9a0SAchim Leubner *2. Redistributions in binary form must reproduce the above copyright notice,
9*4e1bc9a0SAchim Leubner *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10*4e1bc9a0SAchim Leubner *with the distribution.
11*4e1bc9a0SAchim Leubner *
12*4e1bc9a0SAchim Leubner *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13*4e1bc9a0SAchim Leubner *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14*4e1bc9a0SAchim Leubner *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15*4e1bc9a0SAchim Leubner *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16*4e1bc9a0SAchim Leubner *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17*4e1bc9a0SAchim Leubner *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18*4e1bc9a0SAchim Leubner *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19*4e1bc9a0SAchim Leubner *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20*4e1bc9a0SAchim Leubner 
21*4e1bc9a0SAchim Leubner ********************************************************************************/
22*4e1bc9a0SAchim Leubner /*******************************************************************************/
23*4e1bc9a0SAchim Leubner /** \file
24*4e1bc9a0SAchim Leubner  *
25*4e1bc9a0SAchim Leubner  * tdport.c
26*4e1bc9a0SAchim Leubner  * This file contains port realted functions such as tiCOMPortStart()
27*4e1bc9a0SAchim Leubner  *
28*4e1bc9a0SAchim Leubner  */
29*4e1bc9a0SAchim Leubner #include <sys/cdefs.h>
30*4e1bc9a0SAchim Leubner #include <dev/pms/config.h>
31*4e1bc9a0SAchim Leubner 
32*4e1bc9a0SAchim Leubner #include <dev/pms/freebsd/driver/common/osenv.h>
33*4e1bc9a0SAchim Leubner #include <dev/pms/freebsd/driver/common/ostypes.h>
34*4e1bc9a0SAchim Leubner #include <dev/pms/freebsd/driver/common/osdebug.h>
35*4e1bc9a0SAchim Leubner 
36*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/api/sa.h>
37*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/api/saapi.h>
38*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/spc/sadefs.h>
39*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
40*4e1bc9a0SAchim Leubner 
41*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/titypes.h>
42*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/ostiapi.h>
43*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/tiapi.h>
44*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/api/tiglobal.h>
45*4e1bc9a0SAchim Leubner 
46*4e1bc9a0SAchim Leubner #ifdef FDS_SM
47*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sat/api/sm.h>
48*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sat/api/smapi.h>
49*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sat/api/tdsmapi.h>
50*4e1bc9a0SAchim Leubner #endif
51*4e1bc9a0SAchim Leubner 
52*4e1bc9a0SAchim Leubner #ifdef FDS_DM
53*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/discovery/api/dm.h>
54*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/discovery/api/dmapi.h>
55*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/discovery/api/tddmapi.h>
56*4e1bc9a0SAchim Leubner #endif
57*4e1bc9a0SAchim Leubner 
58*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
59*4e1bc9a0SAchim Leubner #include <dev/pms/freebsd/driver/common/osstring.h>
60*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
61*4e1bc9a0SAchim Leubner 
62*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
63*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
64*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
65*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
66*4e1bc9a0SAchim Leubner #endif
67*4e1bc9a0SAchim Leubner 
68*4e1bc9a0SAchim Leubner #ifdef TARGET_DRIVER
69*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
70*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
71*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
72*4e1bc9a0SAchim Leubner #endif
73*4e1bc9a0SAchim Leubner 
74*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
75*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
76*4e1bc9a0SAchim Leubner 
77*4e1bc9a0SAchim Leubner #ifndef TURN_OFF_HDA
78*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/aap1img.h> /* SPC HDA */
79*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/ilaimg.h>
80*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/iopimg.h>
81*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/istrimg.h>
82*4e1bc9a0SAchim Leubner 
83*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/aap18008.h>	/* SPCv HDA */
84*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/iop8008.h>
85*4e1bc9a0SAchim Leubner 
86*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/ila8008.h> /* Ila common to SPCv SPCvp versions */
87*4e1bc9a0SAchim Leubner 
88*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/raae8070.h>	/* SPCv 12g HDA */
89*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/iop8070.h>
90*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/hda/64k/ila8070.h> /* Ila 12g  SPCv SPCvp versions */
91*4e1bc9a0SAchim Leubner 
92*4e1bc9a0SAchim Leubner #endif /* TURN_OFF_HDA */
93*4e1bc9a0SAchim Leubner 
94*4e1bc9a0SAchim Leubner 
95*4e1bc9a0SAchim Leubner bit32 gSSC_Disable = 0;
96*4e1bc9a0SAchim Leubner bit32 volatile sgpioResponseSet = 0;
97*4e1bc9a0SAchim Leubner 
98*4e1bc9a0SAchim Leubner #ifdef ECHO_TESTING
99*4e1bc9a0SAchim Leubner /* temporary to test saEchoCommand() */
100*4e1bc9a0SAchim Leubner bit8 gEcho;
101*4e1bc9a0SAchim Leubner #endif
102*4e1bc9a0SAchim Leubner bit32 tiCOMConfigureSgpio(
103*4e1bc9a0SAchim Leubner                         tiRoot_t    *tiRoot,
104*4e1bc9a0SAchim Leubner                         bit8        enableSgpio
105*4e1bc9a0SAchim Leubner                         );
106*4e1bc9a0SAchim Leubner 
107*4e1bc9a0SAchim Leubner 
108*4e1bc9a0SAchim Leubner /*****************************************************************************
109*4e1bc9a0SAchim Leubner *! \brief tdsaGetSwConfigParams
110*4e1bc9a0SAchim Leubner *
111*4e1bc9a0SAchim Leubner *  Purpose:  This function reads software configuration parameters from the
112*4e1bc9a0SAchim Leubner *            configuration file
113*4e1bc9a0SAchim Leubner *
114*4e1bc9a0SAchim Leubner *  \param  tiRoot:            Pointer to driver/port instance.
115*4e1bc9a0SAchim Leubner *
116*4e1bc9a0SAchim Leubner *  \return: None
117*4e1bc9a0SAchim Leubner *
118*4e1bc9a0SAchim Leubner *  \note -
119*4e1bc9a0SAchim Leubner *
120*4e1bc9a0SAchim Leubner *****************************************************************************/
121*4e1bc9a0SAchim Leubner osGLOBAL void
tdsaGetSwConfigParams(tiRoot_t * tiRoot)122*4e1bc9a0SAchim Leubner tdsaGetSwConfigParams(
123*4e1bc9a0SAchim Leubner                       tiRoot_t *tiRoot
124*4e1bc9a0SAchim Leubner                       )
125*4e1bc9a0SAchim Leubner {
126*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
127*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
128*4e1bc9a0SAchim Leubner   agsaSwConfig_t *SwConfig;
129*4e1bc9a0SAchim Leubner   agsaQueueConfig_t   *QueueConfig;
130*4e1bc9a0SAchim Leubner   char           *buffer;
131*4e1bc9a0SAchim Leubner   bit32          buffLen;
132*4e1bc9a0SAchim Leubner   bit32          lenRecv = 0;
133*4e1bc9a0SAchim Leubner   char           *pLastUsedChar = agNULL;
134*4e1bc9a0SAchim Leubner   char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
135*4e1bc9a0SAchim Leubner   char           globalStr[]     = "Global";
136*4e1bc9a0SAchim Leubner   char           iniParmsStr[]   = "InitiatorParms";
137*4e1bc9a0SAchim Leubner   char           SwParmsStr[]   = "SWParms";
138*4e1bc9a0SAchim Leubner   char           OBQueueProps[] = "OBQueueProps";
139*4e1bc9a0SAchim Leubner   char           IBQueueProps[] = "IBQueueProps";
140*4e1bc9a0SAchim Leubner   char           IBQueueSize[40];
141*4e1bc9a0SAchim Leubner   char           OBQueueSize[40];
142*4e1bc9a0SAchim Leubner   char           IBQueueEleSize[40];
143*4e1bc9a0SAchim Leubner   char           OBQueueEleSize[40];
144*4e1bc9a0SAchim Leubner   char           OBQueueInterruptCount[40];
145*4e1bc9a0SAchim Leubner   char           OBQueueInterruptDelay[40];
146*4e1bc9a0SAchim Leubner   char           OBQueueInterruptEnable[40];
147*4e1bc9a0SAchim Leubner   char           IBQueuePriority[40];
148*4e1bc9a0SAchim Leubner   char           *cardNum = tdsaAllShared->CardIDString;
149*4e1bc9a0SAchim Leubner   bit32          i;
150*4e1bc9a0SAchim Leubner   bit32          enableDIF;
151*4e1bc9a0SAchim Leubner   bit32          enableEncryption;
152*4e1bc9a0SAchim Leubner #ifdef SA_CONFIG_MDFD_REGISTRY
153*4e1bc9a0SAchim Leubner   bit32          disableMDF;
154*4e1bc9a0SAchim Leubner #endif
155*4e1bc9a0SAchim Leubner 
156*4e1bc9a0SAchim Leubner #ifdef FDS_DM
157*4e1bc9a0SAchim Leubner   dmSwConfig_t   *dmSwConfig;
158*4e1bc9a0SAchim Leubner #endif
159*4e1bc9a0SAchim Leubner #ifdef FDS_SM
160*4e1bc9a0SAchim Leubner   smSwConfig_t   *smSwConfig;
161*4e1bc9a0SAchim Leubner #endif
162*4e1bc9a0SAchim Leubner 
163*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetSwConfigParams: start\n"));
164*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetSwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
165*4e1bc9a0SAchim Leubner 
166*4e1bc9a0SAchim Leubner   buffer = tmpBuffer;
167*4e1bc9a0SAchim Leubner   buffLen = sizeof(tmpBuffer);
168*4e1bc9a0SAchim Leubner 
169*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
170*4e1bc9a0SAchim Leubner 
171*4e1bc9a0SAchim Leubner   /* the followings are the default values */
172*4e1bc9a0SAchim Leubner   SwConfig = (agsaSwConfig_t *)&(tdsaAllShared->SwConfig);
173*4e1bc9a0SAchim Leubner   QueueConfig = (agsaQueueConfig_t *)&(tdsaAllShared->QueueConfig);
174*4e1bc9a0SAchim Leubner 
175*4e1bc9a0SAchim Leubner #ifdef FDS_DM
176*4e1bc9a0SAchim Leubner   dmSwConfig = (dmSwConfig_t *)&(tdsaAllShared->dmSwConfig);
177*4e1bc9a0SAchim Leubner #endif
178*4e1bc9a0SAchim Leubner #ifdef FDS_SM
179*4e1bc9a0SAchim Leubner   smSwConfig = (smSwConfig_t *)&(tdsaAllShared->smSwConfig);
180*4e1bc9a0SAchim Leubner #endif
181*4e1bc9a0SAchim Leubner 
182*4e1bc9a0SAchim Leubner   /*
183*4e1bc9a0SAchim Leubner     just default values
184*4e1bc9a0SAchim Leubner     and are overwritten later by the configuration file contents
185*4e1bc9a0SAchim Leubner   */
186*4e1bc9a0SAchim Leubner   SwConfig->numDevHandles = DEFAULT_MAX_DEV;
187*4e1bc9a0SAchim Leubner 
188*4e1bc9a0SAchim Leubner   SwConfig->maxActiveIOs = DEFAULT_MAX_ACTIVE_IOS;
189*4e1bc9a0SAchim Leubner   SwConfig->smpReqTimeout = DEFAULT_SMP_TIMEOUT; /* DEFAULT_VALUE; */
190*4e1bc9a0SAchim Leubner   SwConfig->numberOfEventRegClients = DEFAULT_NUM_REG_CLIENTS;
191*4e1bc9a0SAchim Leubner   SwConfig->sizefEventLog1 = HOST_EVENT_LOG_SIZE;
192*4e1bc9a0SAchim Leubner   SwConfig->sizefEventLog2 = HOST_EVENT_LOG_SIZE;
193*4e1bc9a0SAchim Leubner   SwConfig->eventLog1Option = DEFAULT_EVENT_LOG_OPTION;
194*4e1bc9a0SAchim Leubner   SwConfig->eventLog2Option = DEFAULT_EVENT_LOG_OPTION;
195*4e1bc9a0SAchim Leubner   SwConfig->fatalErrorInterruptEnable = 1;
196*4e1bc9a0SAchim Leubner   SwConfig->fatalErrorInterruptVector = 0; /* Was 1 */
197*4e1bc9a0SAchim Leubner   SwConfig->hostDirectAccessSupport = 0;
198*4e1bc9a0SAchim Leubner   SwConfig->hostDirectAccessMode = 0;
199*4e1bc9a0SAchim Leubner   SwConfig->FWConfig = 0;
200*4e1bc9a0SAchim Leubner   SwConfig->enableDIF = agFALSE;
201*4e1bc9a0SAchim Leubner   SwConfig->enableEncryption = agFALSE;
202*4e1bc9a0SAchim Leubner 
203*4e1bc9a0SAchim Leubner #ifdef SA_CONFIG_MDFD_REGISTRY
204*4e1bc9a0SAchim Leubner   SwConfig->disableMDF = agFALSE;
205*4e1bc9a0SAchim Leubner #endif
206*4e1bc9a0SAchim Leubner 
207*4e1bc9a0SAchim Leubner   SwConfig->param1 = tdsaAllShared->tdDeviceIdVendId;
208*4e1bc9a0SAchim Leubner   SwConfig->param2 = tdsaAllShared->tdSubVendorId;
209*4e1bc9a0SAchim Leubner 
210*4e1bc9a0SAchim Leubner 
211*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
212*4e1bc9a0SAchim Leubner   SwConfig->sallDebugLevel = 1; /* DEFAULT_VALUE; */
213*4e1bc9a0SAchim Leubner #endif
214*4e1bc9a0SAchim Leubner #if defined(DM_DEBUG)
215*4e1bc9a0SAchim Leubner   dmSwConfig->DMDebugLevel = 1; /* DEFAULT_VALUE; */
216*4e1bc9a0SAchim Leubner #endif
217*4e1bc9a0SAchim Leubner #if defined(SM_DEBUG)
218*4e1bc9a0SAchim Leubner   smSwConfig->SMDebugLevel = 1; /* DEFAULT_VALUE; */
219*4e1bc9a0SAchim Leubner #endif
220*4e1bc9a0SAchim Leubner 
221*4e1bc9a0SAchim Leubner   tdsaAllShared->portTMO = PORT_RECOVERY_TIMEOUT;   /* default 5 sec */
222*4e1bc9a0SAchim Leubner   tdsaAllShared->stp_idle_time = STP_IDLE_TIME;     /* default 5 us */
223*4e1bc9a0SAchim Leubner   tdsaAllShared->itNexusTimeout = IT_NEXUS_TIMEOUT; /* default 2000 ms */
224*4e1bc9a0SAchim Leubner 
225*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
226*4e1bc9a0SAchim Leubner   lenRecv = 0;
227*4e1bc9a0SAchim Leubner 
228*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
229*4e1bc9a0SAchim Leubner                              tiRoot,
230*4e1bc9a0SAchim Leubner                              globalStr,
231*4e1bc9a0SAchim Leubner                              iniParmsStr,
232*4e1bc9a0SAchim Leubner                              agNULL,
233*4e1bc9a0SAchim Leubner                              agNULL,
234*4e1bc9a0SAchim Leubner                              agNULL,
235*4e1bc9a0SAchim Leubner                              agNULL,
236*4e1bc9a0SAchim Leubner                              "MaxTargets",
237*4e1bc9a0SAchim Leubner                              buffer,
238*4e1bc9a0SAchim Leubner                              buffLen,
239*4e1bc9a0SAchim Leubner                              &lenRecv
240*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
241*4e1bc9a0SAchim Leubner   {
242*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
243*4e1bc9a0SAchim Leubner     {
244*4e1bc9a0SAchim Leubner       SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 0);
245*4e1bc9a0SAchim Leubner     }
246*4e1bc9a0SAchim Leubner     else
247*4e1bc9a0SAchim Leubner     {
248*4e1bc9a0SAchim Leubner       SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 10);
249*4e1bc9a0SAchim Leubner     }
250*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: MaxTargets  %d\n",SwConfig->numDevHandles  ));
251*4e1bc9a0SAchim Leubner   }
252*4e1bc9a0SAchim Leubner 
253*4e1bc9a0SAchim Leubner   /*
254*4e1bc9a0SAchim Leubner    * read the NumInboundQueue parameter
255*4e1bc9a0SAchim Leubner    */
256*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
257*4e1bc9a0SAchim Leubner   lenRecv = 0;
258*4e1bc9a0SAchim Leubner 
259*4e1bc9a0SAchim Leubner   QueueConfig->numInboundQueues = DEFAULT_NUM_INBOUND_QUEUE;  /* default 1 Inbound queue */
260*4e1bc9a0SAchim Leubner 
261*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
262*4e1bc9a0SAchim Leubner                              tiRoot,
263*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
264*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
265*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
266*4e1bc9a0SAchim Leubner                              agNULL,
267*4e1bc9a0SAchim Leubner                              agNULL,
268*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
269*4e1bc9a0SAchim Leubner                              "NumInboundQueues", /* valueName */
270*4e1bc9a0SAchim Leubner                              buffer,
271*4e1bc9a0SAchim Leubner                              buffLen,
272*4e1bc9a0SAchim Leubner                              &lenRecv
273*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
274*4e1bc9a0SAchim Leubner   {
275*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
276*4e1bc9a0SAchim Leubner     {
277*4e1bc9a0SAchim Leubner       QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
278*4e1bc9a0SAchim Leubner     }
279*4e1bc9a0SAchim Leubner     else
280*4e1bc9a0SAchim Leubner     {
281*4e1bc9a0SAchim Leubner       QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
282*4e1bc9a0SAchim Leubner     }
283*4e1bc9a0SAchim Leubner 
284*4e1bc9a0SAchim Leubner     if (QueueConfig->numInboundQueues > AGSA_MAX_INBOUND_Q)
285*4e1bc9a0SAchim Leubner     {
286*4e1bc9a0SAchim Leubner       QueueConfig->numInboundQueues = AGSA_MAX_INBOUND_Q;
287*4e1bc9a0SAchim Leubner     }
288*4e1bc9a0SAchim Leubner   }
289*4e1bc9a0SAchim Leubner 
290*4e1bc9a0SAchim Leubner   /*
291*4e1bc9a0SAchim Leubner    * read the NumOutboundQueue parameter
292*4e1bc9a0SAchim Leubner    */
293*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
294*4e1bc9a0SAchim Leubner   lenRecv = 0;
295*4e1bc9a0SAchim Leubner 
296*4e1bc9a0SAchim Leubner   QueueConfig->numOutboundQueues = DEFAULT_NUM_OUTBOUND_QUEUE;  /* default 1 Outbound queue */
297*4e1bc9a0SAchim Leubner 
298*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
299*4e1bc9a0SAchim Leubner                              tiRoot,
300*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
301*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
302*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
303*4e1bc9a0SAchim Leubner                              agNULL,
304*4e1bc9a0SAchim Leubner                              agNULL,
305*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
306*4e1bc9a0SAchim Leubner                              "NumOutboundQueues", /* valueName */
307*4e1bc9a0SAchim Leubner                              buffer,
308*4e1bc9a0SAchim Leubner                              buffLen,
309*4e1bc9a0SAchim Leubner                              &lenRecv
310*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
311*4e1bc9a0SAchim Leubner   {
312*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
313*4e1bc9a0SAchim Leubner     {
314*4e1bc9a0SAchim Leubner       QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
315*4e1bc9a0SAchim Leubner     }
316*4e1bc9a0SAchim Leubner     else
317*4e1bc9a0SAchim Leubner     {
318*4e1bc9a0SAchim Leubner       QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
319*4e1bc9a0SAchim Leubner     }
320*4e1bc9a0SAchim Leubner 
321*4e1bc9a0SAchim Leubner     if (QueueConfig->numOutboundQueues > AGSA_MAX_OUTBOUND_Q)
322*4e1bc9a0SAchim Leubner     {
323*4e1bc9a0SAchim Leubner       QueueConfig->numOutboundQueues = AGSA_MAX_OUTBOUND_Q;
324*4e1bc9a0SAchim Leubner     }
325*4e1bc9a0SAchim Leubner   }
326*4e1bc9a0SAchim Leubner 
327*4e1bc9a0SAchim Leubner   /*
328*4e1bc9a0SAchim Leubner    * read the outbound queue option
329*4e1bc9a0SAchim Leubner    */
330*4e1bc9a0SAchim Leubner 
331*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
332*4e1bc9a0SAchim Leubner   lenRecv = 0;
333*4e1bc9a0SAchim Leubner 
334*4e1bc9a0SAchim Leubner   tdsaAllShared->QueueOption = DEFAULT_QUEUE_OPTION;  /* default 0 Outbound queue element */
335*4e1bc9a0SAchim Leubner 
336*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
337*4e1bc9a0SAchim Leubner                              tiRoot,
338*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
339*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
340*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
341*4e1bc9a0SAchim Leubner                              agNULL,
342*4e1bc9a0SAchim Leubner                              agNULL,
343*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
344*4e1bc9a0SAchim Leubner                              "QueueOption", /* valueName */
345*4e1bc9a0SAchim Leubner                              buffer,
346*4e1bc9a0SAchim Leubner                              buffLen,
347*4e1bc9a0SAchim Leubner                              &lenRecv
348*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
349*4e1bc9a0SAchim Leubner   {
350*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
351*4e1bc9a0SAchim Leubner     {
352*4e1bc9a0SAchim Leubner       tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
353*4e1bc9a0SAchim Leubner     }
354*4e1bc9a0SAchim Leubner     else
355*4e1bc9a0SAchim Leubner     {
356*4e1bc9a0SAchim Leubner       tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
357*4e1bc9a0SAchim Leubner     }
358*4e1bc9a0SAchim Leubner   }
359*4e1bc9a0SAchim Leubner 
360*4e1bc9a0SAchim Leubner   /*
361*4e1bc9a0SAchim Leubner    * read the MaxActiveIO parameter
362*4e1bc9a0SAchim Leubner    */
363*4e1bc9a0SAchim Leubner 
364*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
365*4e1bc9a0SAchim Leubner   lenRecv = 0;
366*4e1bc9a0SAchim Leubner 
367*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
368*4e1bc9a0SAchim Leubner                              tiRoot,
369*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
370*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
371*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
372*4e1bc9a0SAchim Leubner                              agNULL,
373*4e1bc9a0SAchim Leubner                              agNULL,
374*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
375*4e1bc9a0SAchim Leubner                              "MaxActiveIO", /* valueName */
376*4e1bc9a0SAchim Leubner                              buffer,
377*4e1bc9a0SAchim Leubner                              buffLen,
378*4e1bc9a0SAchim Leubner                              &lenRecv
379*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
380*4e1bc9a0SAchim Leubner   {
381*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
382*4e1bc9a0SAchim Leubner     {
383*4e1bc9a0SAchim Leubner       SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 0);
384*4e1bc9a0SAchim Leubner       TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 1 !!!\n"));
385*4e1bc9a0SAchim Leubner     }
386*4e1bc9a0SAchim Leubner     else
387*4e1bc9a0SAchim Leubner     {
388*4e1bc9a0SAchim Leubner       SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 10);
389*4e1bc9a0SAchim Leubner       TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 2 !!!\n"));
390*4e1bc9a0SAchim Leubner     }
391*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 3 !!!\n"));
392*4e1bc9a0SAchim Leubner   }
393*4e1bc9a0SAchim Leubner 
394*4e1bc9a0SAchim Leubner 
395*4e1bc9a0SAchim Leubner 
396*4e1bc9a0SAchim Leubner   /*
397*4e1bc9a0SAchim Leubner    * read the SMPTO parameter (SMP Timeout)
398*4e1bc9a0SAchim Leubner    */
399*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
400*4e1bc9a0SAchim Leubner   lenRecv = 0;
401*4e1bc9a0SAchim Leubner 
402*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
403*4e1bc9a0SAchim Leubner                              tiRoot,
404*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
405*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
406*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
407*4e1bc9a0SAchim Leubner                              agNULL,
408*4e1bc9a0SAchim Leubner                              agNULL,
409*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
410*4e1bc9a0SAchim Leubner                              "SMPTO", /* valueName */
411*4e1bc9a0SAchim Leubner                              buffer,
412*4e1bc9a0SAchim Leubner                              buffLen,
413*4e1bc9a0SAchim Leubner                              &lenRecv
414*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
415*4e1bc9a0SAchim Leubner   {
416*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
417*4e1bc9a0SAchim Leubner     {
418*4e1bc9a0SAchim Leubner       SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
419*4e1bc9a0SAchim Leubner     }
420*4e1bc9a0SAchim Leubner     else
421*4e1bc9a0SAchim Leubner     {
422*4e1bc9a0SAchim Leubner       SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
423*4e1bc9a0SAchim Leubner     }
424*4e1bc9a0SAchim Leubner   }
425*4e1bc9a0SAchim Leubner 
426*4e1bc9a0SAchim Leubner 
427*4e1bc9a0SAchim Leubner   /*
428*4e1bc9a0SAchim Leubner    * read the NumRegClients parameter (SMP Timeout)
429*4e1bc9a0SAchim Leubner    */
430*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
431*4e1bc9a0SAchim Leubner   lenRecv = 0;
432*4e1bc9a0SAchim Leubner 
433*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
434*4e1bc9a0SAchim Leubner                              tiRoot,
435*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
436*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
437*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
438*4e1bc9a0SAchim Leubner                              agNULL,
439*4e1bc9a0SAchim Leubner                              agNULL,
440*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
441*4e1bc9a0SAchim Leubner                              "NumRegClients", /* valueName */
442*4e1bc9a0SAchim Leubner                              buffer,
443*4e1bc9a0SAchim Leubner                              buffLen,
444*4e1bc9a0SAchim Leubner                              &lenRecv
445*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
446*4e1bc9a0SAchim Leubner   {
447*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
448*4e1bc9a0SAchim Leubner     {
449*4e1bc9a0SAchim Leubner       SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 0);
450*4e1bc9a0SAchim Leubner     }
451*4e1bc9a0SAchim Leubner     else
452*4e1bc9a0SAchim Leubner     {
453*4e1bc9a0SAchim Leubner       SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 10);
454*4e1bc9a0SAchim Leubner     }
455*4e1bc9a0SAchim Leubner   }
456*4e1bc9a0SAchim Leubner 
457*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
458*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
459*4e1bc9a0SAchim Leubner   lenRecv = 0;
460*4e1bc9a0SAchim Leubner 
461*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
462*4e1bc9a0SAchim Leubner                              tiRoot,
463*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
464*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
465*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
466*4e1bc9a0SAchim Leubner                              agNULL,
467*4e1bc9a0SAchim Leubner                              agNULL,
468*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
469*4e1bc9a0SAchim Leubner                              "LLDebugLevel", /* valueName */
470*4e1bc9a0SAchim Leubner                              buffer,
471*4e1bc9a0SAchim Leubner                              buffLen,
472*4e1bc9a0SAchim Leubner                              &lenRecv
473*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
474*4e1bc9a0SAchim Leubner   {
475*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
476*4e1bc9a0SAchim Leubner     {
477*4e1bc9a0SAchim Leubner       SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
478*4e1bc9a0SAchim Leubner     }
479*4e1bc9a0SAchim Leubner     else
480*4e1bc9a0SAchim Leubner     {
481*4e1bc9a0SAchim Leubner       SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
482*4e1bc9a0SAchim Leubner     }
483*4e1bc9a0SAchim Leubner   }
484*4e1bc9a0SAchim Leubner #endif
485*4e1bc9a0SAchim Leubner 
486*4e1bc9a0SAchim Leubner #if defined(DM_DEBUG)
487*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
488*4e1bc9a0SAchim Leubner   lenRecv = 0;
489*4e1bc9a0SAchim Leubner 
490*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
491*4e1bc9a0SAchim Leubner                              tiRoot,
492*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
493*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
494*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
495*4e1bc9a0SAchim Leubner                              agNULL,
496*4e1bc9a0SAchim Leubner                              agNULL,
497*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
498*4e1bc9a0SAchim Leubner                              "DMDebugLevel", /* valueName */
499*4e1bc9a0SAchim Leubner                              buffer,
500*4e1bc9a0SAchim Leubner                              buffLen,
501*4e1bc9a0SAchim Leubner                              &lenRecv
502*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
503*4e1bc9a0SAchim Leubner   {
504*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
505*4e1bc9a0SAchim Leubner     {
506*4e1bc9a0SAchim Leubner       dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
507*4e1bc9a0SAchim Leubner     }
508*4e1bc9a0SAchim Leubner     else
509*4e1bc9a0SAchim Leubner     {
510*4e1bc9a0SAchim Leubner       dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
511*4e1bc9a0SAchim Leubner     }
512*4e1bc9a0SAchim Leubner   }
513*4e1bc9a0SAchim Leubner #endif
514*4e1bc9a0SAchim Leubner 
515*4e1bc9a0SAchim Leubner #if defined(SM_DEBUG)
516*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
517*4e1bc9a0SAchim Leubner   lenRecv = 0;
518*4e1bc9a0SAchim Leubner 
519*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
520*4e1bc9a0SAchim Leubner                              tiRoot,
521*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
522*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
523*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
524*4e1bc9a0SAchim Leubner                              agNULL,
525*4e1bc9a0SAchim Leubner                              agNULL,
526*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
527*4e1bc9a0SAchim Leubner                              "SMDebugLevel", /* valueName */
528*4e1bc9a0SAchim Leubner                              buffer,
529*4e1bc9a0SAchim Leubner                              buffLen,
530*4e1bc9a0SAchim Leubner                              &lenRecv
531*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
532*4e1bc9a0SAchim Leubner   {
533*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
534*4e1bc9a0SAchim Leubner     {
535*4e1bc9a0SAchim Leubner       smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
536*4e1bc9a0SAchim Leubner     }
537*4e1bc9a0SAchim Leubner     else
538*4e1bc9a0SAchim Leubner     {
539*4e1bc9a0SAchim Leubner       smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
540*4e1bc9a0SAchim Leubner     }
541*4e1bc9a0SAchim Leubner   }
542*4e1bc9a0SAchim Leubner #endif
543*4e1bc9a0SAchim Leubner 
544*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
545*4e1bc9a0SAchim Leubner   lenRecv = 0;
546*4e1bc9a0SAchim Leubner 
547*4e1bc9a0SAchim Leubner   for (i=0;i<QueueConfig->numInboundQueues;i++)
548*4e1bc9a0SAchim Leubner   {
549*4e1bc9a0SAchim Leubner     osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
550*4e1bc9a0SAchim Leubner     osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
551*4e1bc9a0SAchim Leubner     osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
552*4e1bc9a0SAchim Leubner 
553*4e1bc9a0SAchim Leubner     /*
554*4e1bc9a0SAchim Leubner      * read the IBQueueSize
555*4e1bc9a0SAchim Leubner      */
556*4e1bc9a0SAchim Leubner 
557*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
558*4e1bc9a0SAchim Leubner     lenRecv = 0;
559*4e1bc9a0SAchim Leubner 
560*4e1bc9a0SAchim Leubner     tdsaAllShared->InboundQueueSize[i] = DEFAULT_INBOUND_QUEUE_SIZE;  /* default 256 Inbound queue size */
561*4e1bc9a0SAchim Leubner 
562*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
563*4e1bc9a0SAchim Leubner                              tiRoot,
564*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
565*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
566*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
567*4e1bc9a0SAchim Leubner                              agNULL,
568*4e1bc9a0SAchim Leubner                              agNULL,
569*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
570*4e1bc9a0SAchim Leubner                              IBQueueSize, /* valueName */
571*4e1bc9a0SAchim Leubner                              buffer,
572*4e1bc9a0SAchim Leubner                              buffLen,
573*4e1bc9a0SAchim Leubner                              &lenRecv
574*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
575*4e1bc9a0SAchim Leubner     {
576*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
577*4e1bc9a0SAchim Leubner       {
578*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
579*4e1bc9a0SAchim Leubner       }
580*4e1bc9a0SAchim Leubner       else
581*4e1bc9a0SAchim Leubner       {
582*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
583*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
584*4e1bc9a0SAchim Leubner       }
585*4e1bc9a0SAchim Leubner     }
586*4e1bc9a0SAchim Leubner 
587*4e1bc9a0SAchim Leubner 
588*4e1bc9a0SAchim Leubner     /*
589*4e1bc9a0SAchim Leubner      * read the IBQueueEleSize
590*4e1bc9a0SAchim Leubner      */
591*4e1bc9a0SAchim Leubner 
592*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
593*4e1bc9a0SAchim Leubner     lenRecv = 0;
594*4e1bc9a0SAchim Leubner 
595*4e1bc9a0SAchim Leubner     tdsaAllShared->InboundQueueEleSize[i] = DEFAULT_INBOUND_QUEUE_ELE_SIZE;  /* default 128 Inbound queue element */
596*4e1bc9a0SAchim Leubner 
597*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
598*4e1bc9a0SAchim Leubner                              tiRoot,
599*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
600*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
601*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
602*4e1bc9a0SAchim Leubner                              agNULL,
603*4e1bc9a0SAchim Leubner                              agNULL,
604*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
605*4e1bc9a0SAchim Leubner                              IBQueueEleSize, /* valueName */
606*4e1bc9a0SAchim Leubner                              buffer,
607*4e1bc9a0SAchim Leubner                              buffLen,
608*4e1bc9a0SAchim Leubner                              &lenRecv
609*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
610*4e1bc9a0SAchim Leubner     {
611*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
612*4e1bc9a0SAchim Leubner       {
613*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
614*4e1bc9a0SAchim Leubner       }
615*4e1bc9a0SAchim Leubner       else
616*4e1bc9a0SAchim Leubner       {
617*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
618*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
619*4e1bc9a0SAchim Leubner       }
620*4e1bc9a0SAchim Leubner     }
621*4e1bc9a0SAchim Leubner 
622*4e1bc9a0SAchim Leubner     /*
623*4e1bc9a0SAchim Leubner      * read the IBQueuePriority
624*4e1bc9a0SAchim Leubner      */
625*4e1bc9a0SAchim Leubner 
626*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
627*4e1bc9a0SAchim Leubner     lenRecv = 0;
628*4e1bc9a0SAchim Leubner 
629*4e1bc9a0SAchim Leubner     tdsaAllShared->InboundQueuePriority[i] = DEFAULT_INBOUND_QUEUE_PRIORITY; /* default 0 Inbound queue priority */
630*4e1bc9a0SAchim Leubner 
631*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
632*4e1bc9a0SAchim Leubner                              tiRoot,
633*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
634*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
635*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
636*4e1bc9a0SAchim Leubner                              agNULL,
637*4e1bc9a0SAchim Leubner                              agNULL,
638*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
639*4e1bc9a0SAchim Leubner                              IBQueuePriority, /* valueName */
640*4e1bc9a0SAchim Leubner                              buffer,
641*4e1bc9a0SAchim Leubner                              buffLen,
642*4e1bc9a0SAchim Leubner                              &lenRecv
643*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
644*4e1bc9a0SAchim Leubner     {
645*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
646*4e1bc9a0SAchim Leubner       {
647*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
648*4e1bc9a0SAchim Leubner       }
649*4e1bc9a0SAchim Leubner       else
650*4e1bc9a0SAchim Leubner       {
651*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
652*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d priority %d\n", i, tdsaAllShared->InboundQueuePriority[i]));
653*4e1bc9a0SAchim Leubner       }
654*4e1bc9a0SAchim Leubner     }
655*4e1bc9a0SAchim Leubner 
656*4e1bc9a0SAchim Leubner     /**********************************************/
657*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
658*4e1bc9a0SAchim Leubner     lenRecv = 0;
659*4e1bc9a0SAchim Leubner   }/* end of loop */
660*4e1bc9a0SAchim Leubner 
661*4e1bc9a0SAchim Leubner 
662*4e1bc9a0SAchim Leubner 
663*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
664*4e1bc9a0SAchim Leubner   lenRecv = 0;
665*4e1bc9a0SAchim Leubner 
666*4e1bc9a0SAchim Leubner   for (i=0;i<QueueConfig->numOutboundQueues;i++)
667*4e1bc9a0SAchim Leubner   {
668*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
669*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
670*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
671*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
672*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
673*4e1bc9a0SAchim Leubner 
674*4e1bc9a0SAchim Leubner     /*
675*4e1bc9a0SAchim Leubner      * read the OBQueueSize
676*4e1bc9a0SAchim Leubner      */
677*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
678*4e1bc9a0SAchim Leubner     lenRecv = 0;
679*4e1bc9a0SAchim Leubner 
680*4e1bc9a0SAchim Leubner 
681*4e1bc9a0SAchim Leubner     tdsaAllShared->OutboundQueueSize[i] = DEFAULT_OUTBOUND_QUEUE_SIZE;  /* default 256 Outbound queue size */
682*4e1bc9a0SAchim Leubner 
683*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
684*4e1bc9a0SAchim Leubner                              tiRoot,
685*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
686*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
687*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
688*4e1bc9a0SAchim Leubner                              agNULL,
689*4e1bc9a0SAchim Leubner                              agNULL,
690*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
691*4e1bc9a0SAchim Leubner                              OBQueueSize, /* valueName */
692*4e1bc9a0SAchim Leubner                              buffer,
693*4e1bc9a0SAchim Leubner                              buffLen,
694*4e1bc9a0SAchim Leubner                              &lenRecv
695*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
696*4e1bc9a0SAchim Leubner     {
697*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
698*4e1bc9a0SAchim Leubner       {
699*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
700*4e1bc9a0SAchim Leubner       }
701*4e1bc9a0SAchim Leubner       else
702*4e1bc9a0SAchim Leubner       {
703*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
704*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
705*4e1bc9a0SAchim Leubner 
706*4e1bc9a0SAchim Leubner       }
707*4e1bc9a0SAchim Leubner     }
708*4e1bc9a0SAchim Leubner 
709*4e1bc9a0SAchim Leubner 
710*4e1bc9a0SAchim Leubner     /*
711*4e1bc9a0SAchim Leubner      * read the OBQueueEleSize
712*4e1bc9a0SAchim Leubner      */
713*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
714*4e1bc9a0SAchim Leubner     lenRecv = 0;
715*4e1bc9a0SAchim Leubner 
716*4e1bc9a0SAchim Leubner 
717*4e1bc9a0SAchim Leubner     tdsaAllShared->OutboundQueueEleSize[i] = DEFAULT_OUTBOUND_QUEUE_ELE_SIZE;  /* default 128 Outbound queue element */
718*4e1bc9a0SAchim Leubner 
719*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
720*4e1bc9a0SAchim Leubner                              tiRoot,
721*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
722*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
723*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
724*4e1bc9a0SAchim Leubner                              agNULL,
725*4e1bc9a0SAchim Leubner                              agNULL,
726*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
727*4e1bc9a0SAchim Leubner                              OBQueueEleSize, /* valueName */
728*4e1bc9a0SAchim Leubner                              buffer,
729*4e1bc9a0SAchim Leubner                              buffLen,
730*4e1bc9a0SAchim Leubner                              &lenRecv
731*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
732*4e1bc9a0SAchim Leubner     {
733*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
734*4e1bc9a0SAchim Leubner       {
735*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
736*4e1bc9a0SAchim Leubner       }
737*4e1bc9a0SAchim Leubner       else
738*4e1bc9a0SAchim Leubner       {
739*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
740*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
741*4e1bc9a0SAchim Leubner 
742*4e1bc9a0SAchim Leubner       }
743*4e1bc9a0SAchim Leubner     }
744*4e1bc9a0SAchim Leubner 
745*4e1bc9a0SAchim Leubner 
746*4e1bc9a0SAchim Leubner     /*
747*4e1bc9a0SAchim Leubner      * read the OBQueueInterruptDelay
748*4e1bc9a0SAchim Leubner      */
749*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
750*4e1bc9a0SAchim Leubner     lenRecv = 0;
751*4e1bc9a0SAchim Leubner 
752*4e1bc9a0SAchim Leubner 
753*4e1bc9a0SAchim Leubner     tdsaAllShared->OutboundQueueInterruptDelay[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_DELAY;  /* default 1 Outbound interrupt delay */
754*4e1bc9a0SAchim Leubner 
755*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
756*4e1bc9a0SAchim Leubner                              tiRoot,
757*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
758*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
759*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
760*4e1bc9a0SAchim Leubner                              agNULL,
761*4e1bc9a0SAchim Leubner                              agNULL,
762*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
763*4e1bc9a0SAchim Leubner                              OBQueueInterruptDelay, /* valueName */
764*4e1bc9a0SAchim Leubner                              buffer,
765*4e1bc9a0SAchim Leubner                              buffLen,
766*4e1bc9a0SAchim Leubner                              &lenRecv
767*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
768*4e1bc9a0SAchim Leubner     {
769*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
770*4e1bc9a0SAchim Leubner       {
771*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
772*4e1bc9a0SAchim Leubner       }
773*4e1bc9a0SAchim Leubner       else
774*4e1bc9a0SAchim Leubner       {
775*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
776*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt delay %d\n", i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
777*4e1bc9a0SAchim Leubner 
778*4e1bc9a0SAchim Leubner       }
779*4e1bc9a0SAchim Leubner     }
780*4e1bc9a0SAchim Leubner 
781*4e1bc9a0SAchim Leubner     /*
782*4e1bc9a0SAchim Leubner      * read the OBQueueInterruptCount
783*4e1bc9a0SAchim Leubner      */
784*4e1bc9a0SAchim Leubner 
785*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
786*4e1bc9a0SAchim Leubner     lenRecv = 0;
787*4e1bc9a0SAchim Leubner 
788*4e1bc9a0SAchim Leubner     tdsaAllShared->OutboundQueueInterruptCount[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_COUNT;  /* default 1 Outbound interrupt count */
789*4e1bc9a0SAchim Leubner 
790*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
791*4e1bc9a0SAchim Leubner                              tiRoot,
792*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
793*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
794*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
795*4e1bc9a0SAchim Leubner                              agNULL,
796*4e1bc9a0SAchim Leubner                              agNULL,
797*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
798*4e1bc9a0SAchim Leubner                              OBQueueInterruptCount, /* valueName */
799*4e1bc9a0SAchim Leubner                              buffer,
800*4e1bc9a0SAchim Leubner                              buffLen,
801*4e1bc9a0SAchim Leubner                              &lenRecv
802*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
803*4e1bc9a0SAchim Leubner     {
804*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
805*4e1bc9a0SAchim Leubner       {
806*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
807*4e1bc9a0SAchim Leubner       }
808*4e1bc9a0SAchim Leubner       else
809*4e1bc9a0SAchim Leubner       {
810*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
811*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt count %d\n", i, tdsaAllShared->OutboundQueueInterruptCount[i]));
812*4e1bc9a0SAchim Leubner       }
813*4e1bc9a0SAchim Leubner     }
814*4e1bc9a0SAchim Leubner 
815*4e1bc9a0SAchim Leubner 
816*4e1bc9a0SAchim Leubner     /*
817*4e1bc9a0SAchim Leubner      * read the OBQueueInterruptEnable
818*4e1bc9a0SAchim Leubner      */
819*4e1bc9a0SAchim Leubner 
820*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
821*4e1bc9a0SAchim Leubner     lenRecv = 0;
822*4e1bc9a0SAchim Leubner 
823*4e1bc9a0SAchim Leubner     tdsaAllShared->OutboundQueueInterruptEnable[i] = DEFAULT_OUTBOUND_INTERRUPT_ENABLE;  /* default 1 Outbound interrupt is enabled */
824*4e1bc9a0SAchim Leubner 
825*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
826*4e1bc9a0SAchim Leubner                              tiRoot,
827*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
828*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
829*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
830*4e1bc9a0SAchim Leubner                              agNULL,
831*4e1bc9a0SAchim Leubner                              agNULL,
832*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
833*4e1bc9a0SAchim Leubner                              OBQueueInterruptEnable, /* valueName */
834*4e1bc9a0SAchim Leubner                              buffer,
835*4e1bc9a0SAchim Leubner                              buffLen,
836*4e1bc9a0SAchim Leubner                              &lenRecv
837*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
838*4e1bc9a0SAchim Leubner     {
839*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
840*4e1bc9a0SAchim Leubner       {
841*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
842*4e1bc9a0SAchim Leubner       }
843*4e1bc9a0SAchim Leubner       else
844*4e1bc9a0SAchim Leubner       {
845*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
846*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt enable %d\n", i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
847*4e1bc9a0SAchim Leubner       }
848*4e1bc9a0SAchim Leubner     }
849*4e1bc9a0SAchim Leubner 
850*4e1bc9a0SAchim Leubner     /**********************************************/
851*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
852*4e1bc9a0SAchim Leubner     lenRecv = 0;
853*4e1bc9a0SAchim Leubner 
854*4e1bc9a0SAchim Leubner   }/* end of loop */
855*4e1bc9a0SAchim Leubner 
856*4e1bc9a0SAchim Leubner 
857*4e1bc9a0SAchim Leubner 
858*4e1bc9a0SAchim Leubner   /********************READ CARD SPECIFIC *******************************************************/
859*4e1bc9a0SAchim Leubner 
860*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
861*4e1bc9a0SAchim Leubner   lenRecv = 0;
862*4e1bc9a0SAchim Leubner 
863*4e1bc9a0SAchim Leubner   for (i=0;i<QueueConfig->numInboundQueues;i++)
864*4e1bc9a0SAchim Leubner   {
865*4e1bc9a0SAchim Leubner     osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
866*4e1bc9a0SAchim Leubner     osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
867*4e1bc9a0SAchim Leubner     osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
868*4e1bc9a0SAchim Leubner 
869*4e1bc9a0SAchim Leubner     /*
870*4e1bc9a0SAchim Leubner      * read the IBQueueSize
871*4e1bc9a0SAchim Leubner      */
872*4e1bc9a0SAchim Leubner 
873*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
874*4e1bc9a0SAchim Leubner     lenRecv = 0;
875*4e1bc9a0SAchim Leubner 
876*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
877*4e1bc9a0SAchim Leubner                              tiRoot,
878*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
879*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
880*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
881*4e1bc9a0SAchim Leubner                              agNULL,
882*4e1bc9a0SAchim Leubner                              agNULL,
883*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
884*4e1bc9a0SAchim Leubner                              IBQueueSize, /* valueName */
885*4e1bc9a0SAchim Leubner                              buffer,
886*4e1bc9a0SAchim Leubner                              buffLen,
887*4e1bc9a0SAchim Leubner                              &lenRecv
888*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
889*4e1bc9a0SAchim Leubner     {
890*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
891*4e1bc9a0SAchim Leubner       {
892*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
893*4e1bc9a0SAchim Leubner       }
894*4e1bc9a0SAchim Leubner       else
895*4e1bc9a0SAchim Leubner       {
896*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
897*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
898*4e1bc9a0SAchim Leubner       }
899*4e1bc9a0SAchim Leubner     }
900*4e1bc9a0SAchim Leubner 
901*4e1bc9a0SAchim Leubner     /*
902*4e1bc9a0SAchim Leubner      * read the IBQueueEleSize
903*4e1bc9a0SAchim Leubner      */
904*4e1bc9a0SAchim Leubner 
905*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
906*4e1bc9a0SAchim Leubner     lenRecv = 0;
907*4e1bc9a0SAchim Leubner 
908*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
909*4e1bc9a0SAchim Leubner                              tiRoot,
910*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
911*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
912*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
913*4e1bc9a0SAchim Leubner                              agNULL,
914*4e1bc9a0SAchim Leubner                              agNULL,
915*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
916*4e1bc9a0SAchim Leubner                              IBQueueEleSize, /* valueName */
917*4e1bc9a0SAchim Leubner                              buffer,
918*4e1bc9a0SAchim Leubner                              buffLen,
919*4e1bc9a0SAchim Leubner                              &lenRecv
920*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
921*4e1bc9a0SAchim Leubner     {
922*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
923*4e1bc9a0SAchim Leubner       {
924*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
925*4e1bc9a0SAchim Leubner       }
926*4e1bc9a0SAchim Leubner       else
927*4e1bc9a0SAchim Leubner       {
928*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
929*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
930*4e1bc9a0SAchim Leubner       }
931*4e1bc9a0SAchim Leubner     }
932*4e1bc9a0SAchim Leubner 
933*4e1bc9a0SAchim Leubner     /*
934*4e1bc9a0SAchim Leubner      * read the IBQueuePriority
935*4e1bc9a0SAchim Leubner      */
936*4e1bc9a0SAchim Leubner 
937*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
938*4e1bc9a0SAchim Leubner     lenRecv = 0;
939*4e1bc9a0SAchim Leubner 
940*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
941*4e1bc9a0SAchim Leubner                              tiRoot,
942*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
943*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
944*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
945*4e1bc9a0SAchim Leubner                              agNULL,
946*4e1bc9a0SAchim Leubner                              agNULL,
947*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
948*4e1bc9a0SAchim Leubner                              IBQueuePriority, /* valueName */
949*4e1bc9a0SAchim Leubner                              buffer,
950*4e1bc9a0SAchim Leubner                              buffLen,
951*4e1bc9a0SAchim Leubner                              &lenRecv
952*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
953*4e1bc9a0SAchim Leubner     {
954*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
955*4e1bc9a0SAchim Leubner       {
956*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
957*4e1bc9a0SAchim Leubner       }
958*4e1bc9a0SAchim Leubner       else
959*4e1bc9a0SAchim Leubner       {
960*4e1bc9a0SAchim Leubner         tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
961*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d priority %d\n", cardNum, i, tdsaAllShared->InboundQueuePriority[i]));
962*4e1bc9a0SAchim Leubner       }
963*4e1bc9a0SAchim Leubner     }
964*4e1bc9a0SAchim Leubner 
965*4e1bc9a0SAchim Leubner     /**********************************************/
966*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
967*4e1bc9a0SAchim Leubner     lenRecv = 0;
968*4e1bc9a0SAchim Leubner   }/* end of loop */
969*4e1bc9a0SAchim Leubner 
970*4e1bc9a0SAchim Leubner 
971*4e1bc9a0SAchim Leubner 
972*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
973*4e1bc9a0SAchim Leubner   lenRecv = 0;
974*4e1bc9a0SAchim Leubner 
975*4e1bc9a0SAchim Leubner   for (i=0;i<QueueConfig->numOutboundQueues;i++)
976*4e1bc9a0SAchim Leubner   {
977*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
978*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
979*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
980*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
981*4e1bc9a0SAchim Leubner     osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
982*4e1bc9a0SAchim Leubner 
983*4e1bc9a0SAchim Leubner     /*
984*4e1bc9a0SAchim Leubner      * read the OBQueueSize
985*4e1bc9a0SAchim Leubner      */
986*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
987*4e1bc9a0SAchim Leubner     lenRecv = 0;
988*4e1bc9a0SAchim Leubner 
989*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
990*4e1bc9a0SAchim Leubner                              tiRoot,
991*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
992*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
993*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
994*4e1bc9a0SAchim Leubner                              agNULL,
995*4e1bc9a0SAchim Leubner                              agNULL,
996*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
997*4e1bc9a0SAchim Leubner                              OBQueueSize, /* valueName */
998*4e1bc9a0SAchim Leubner                              buffer,
999*4e1bc9a0SAchim Leubner                              buffLen,
1000*4e1bc9a0SAchim Leubner                              &lenRecv
1001*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1002*4e1bc9a0SAchim Leubner     {
1003*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1004*4e1bc9a0SAchim Leubner       {
1005*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1006*4e1bc9a0SAchim Leubner       }
1007*4e1bc9a0SAchim Leubner       else
1008*4e1bc9a0SAchim Leubner       {
1009*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1010*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
1011*4e1bc9a0SAchim Leubner 
1012*4e1bc9a0SAchim Leubner       }
1013*4e1bc9a0SAchim Leubner     }
1014*4e1bc9a0SAchim Leubner 
1015*4e1bc9a0SAchim Leubner     /*
1016*4e1bc9a0SAchim Leubner      * read the OBQueueEleSize
1017*4e1bc9a0SAchim Leubner      */
1018*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
1019*4e1bc9a0SAchim Leubner     lenRecv = 0;
1020*4e1bc9a0SAchim Leubner 
1021*4e1bc9a0SAchim Leubner 
1022*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
1023*4e1bc9a0SAchim Leubner                              tiRoot,
1024*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
1025*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1026*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
1027*4e1bc9a0SAchim Leubner                              agNULL,
1028*4e1bc9a0SAchim Leubner                              agNULL,
1029*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1030*4e1bc9a0SAchim Leubner                              OBQueueEleSize, /* valueName */
1031*4e1bc9a0SAchim Leubner                              buffer,
1032*4e1bc9a0SAchim Leubner                              buffLen,
1033*4e1bc9a0SAchim Leubner                              &lenRecv
1034*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1035*4e1bc9a0SAchim Leubner     {
1036*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1037*4e1bc9a0SAchim Leubner       {
1038*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1039*4e1bc9a0SAchim Leubner       }
1040*4e1bc9a0SAchim Leubner       else
1041*4e1bc9a0SAchim Leubner       {
1042*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1043*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
1044*4e1bc9a0SAchim Leubner 
1045*4e1bc9a0SAchim Leubner       }
1046*4e1bc9a0SAchim Leubner     }
1047*4e1bc9a0SAchim Leubner 
1048*4e1bc9a0SAchim Leubner     /*
1049*4e1bc9a0SAchim Leubner      * read the OBQueueInterruptDelay
1050*4e1bc9a0SAchim Leubner      */
1051*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
1052*4e1bc9a0SAchim Leubner     lenRecv = 0;
1053*4e1bc9a0SAchim Leubner 
1054*4e1bc9a0SAchim Leubner 
1055*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
1056*4e1bc9a0SAchim Leubner                              tiRoot,
1057*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
1058*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1059*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
1060*4e1bc9a0SAchim Leubner                              agNULL,
1061*4e1bc9a0SAchim Leubner                              agNULL,
1062*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1063*4e1bc9a0SAchim Leubner                              OBQueueInterruptDelay, /* valueName */
1064*4e1bc9a0SAchim Leubner                              buffer,
1065*4e1bc9a0SAchim Leubner                              buffLen,
1066*4e1bc9a0SAchim Leubner                              &lenRecv
1067*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1068*4e1bc9a0SAchim Leubner     {
1069*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1070*4e1bc9a0SAchim Leubner       {
1071*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1072*4e1bc9a0SAchim Leubner       }
1073*4e1bc9a0SAchim Leubner       else
1074*4e1bc9a0SAchim Leubner       {
1075*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1076*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt delay %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
1077*4e1bc9a0SAchim Leubner 
1078*4e1bc9a0SAchim Leubner       }
1079*4e1bc9a0SAchim Leubner     }
1080*4e1bc9a0SAchim Leubner 
1081*4e1bc9a0SAchim Leubner     /*
1082*4e1bc9a0SAchim Leubner      * read the OBQueueInterruptCount
1083*4e1bc9a0SAchim Leubner      */
1084*4e1bc9a0SAchim Leubner 
1085*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
1086*4e1bc9a0SAchim Leubner     lenRecv = 0;
1087*4e1bc9a0SAchim Leubner 
1088*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
1089*4e1bc9a0SAchim Leubner                              tiRoot,
1090*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
1091*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1092*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
1093*4e1bc9a0SAchim Leubner                              agNULL,
1094*4e1bc9a0SAchim Leubner                              agNULL,
1095*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1096*4e1bc9a0SAchim Leubner                              OBQueueInterruptCount, /* valueName */
1097*4e1bc9a0SAchim Leubner                              buffer,
1098*4e1bc9a0SAchim Leubner                              buffLen,
1099*4e1bc9a0SAchim Leubner                              &lenRecv
1100*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1101*4e1bc9a0SAchim Leubner     {
1102*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1103*4e1bc9a0SAchim Leubner       {
1104*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1105*4e1bc9a0SAchim Leubner       }
1106*4e1bc9a0SAchim Leubner       else
1107*4e1bc9a0SAchim Leubner       {
1108*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1109*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt count %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptCount[i]));
1110*4e1bc9a0SAchim Leubner       }
1111*4e1bc9a0SAchim Leubner     }
1112*4e1bc9a0SAchim Leubner 
1113*4e1bc9a0SAchim Leubner 
1114*4e1bc9a0SAchim Leubner     /*
1115*4e1bc9a0SAchim Leubner      * read the OBQueueInterruptEnable
1116*4e1bc9a0SAchim Leubner      */
1117*4e1bc9a0SAchim Leubner 
1118*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
1119*4e1bc9a0SAchim Leubner     lenRecv = 0;
1120*4e1bc9a0SAchim Leubner 
1121*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
1122*4e1bc9a0SAchim Leubner                              tiRoot,
1123*4e1bc9a0SAchim Leubner                              cardNum,   /* key */
1124*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1125*4e1bc9a0SAchim Leubner                              OBQueueProps,      /* subkey2 */
1126*4e1bc9a0SAchim Leubner                              agNULL,
1127*4e1bc9a0SAchim Leubner                              agNULL,
1128*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1129*4e1bc9a0SAchim Leubner                              OBQueueInterruptEnable, /* valueName */
1130*4e1bc9a0SAchim Leubner                              buffer,
1131*4e1bc9a0SAchim Leubner                              buffLen,
1132*4e1bc9a0SAchim Leubner                              &lenRecv
1133*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1134*4e1bc9a0SAchim Leubner     {
1135*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1136*4e1bc9a0SAchim Leubner       {
1137*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1138*4e1bc9a0SAchim Leubner       }
1139*4e1bc9a0SAchim Leubner       else
1140*4e1bc9a0SAchim Leubner       {
1141*4e1bc9a0SAchim Leubner         tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1142*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt enable %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
1143*4e1bc9a0SAchim Leubner       }
1144*4e1bc9a0SAchim Leubner     }
1145*4e1bc9a0SAchim Leubner 
1146*4e1bc9a0SAchim Leubner 
1147*4e1bc9a0SAchim Leubner     /**********************************************/
1148*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
1149*4e1bc9a0SAchim Leubner     lenRecv = 0;
1150*4e1bc9a0SAchim Leubner 
1151*4e1bc9a0SAchim Leubner   }/* end of loop */
1152*4e1bc9a0SAchim Leubner 
1153*4e1bc9a0SAchim Leubner   /* process event log related parameters */
1154*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1155*4e1bc9a0SAchim Leubner   lenRecv = 0;
1156*4e1bc9a0SAchim Leubner 
1157*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1158*4e1bc9a0SAchim Leubner                              tiRoot,
1159*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1160*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1161*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1162*4e1bc9a0SAchim Leubner                              agNULL,
1163*4e1bc9a0SAchim Leubner                              agNULL,
1164*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1165*4e1bc9a0SAchim Leubner                              "EventLogSize1", /* valueName */
1166*4e1bc9a0SAchim Leubner                              buffer,
1167*4e1bc9a0SAchim Leubner                              buffLen,
1168*4e1bc9a0SAchim Leubner                              &lenRecv
1169*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1170*4e1bc9a0SAchim Leubner   {
1171*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1172*4e1bc9a0SAchim Leubner     {
1173*4e1bc9a0SAchim Leubner       SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 0);
1174*4e1bc9a0SAchim Leubner     }
1175*4e1bc9a0SAchim Leubner     else
1176*4e1bc9a0SAchim Leubner     {
1177*4e1bc9a0SAchim Leubner       SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 10);
1178*4e1bc9a0SAchim Leubner     }
1179*4e1bc9a0SAchim Leubner   }
1180*4e1bc9a0SAchim Leubner 
1181*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1182*4e1bc9a0SAchim Leubner   lenRecv = 0;
1183*4e1bc9a0SAchim Leubner 
1184*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1185*4e1bc9a0SAchim Leubner                              tiRoot,
1186*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1187*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1188*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1189*4e1bc9a0SAchim Leubner                              agNULL,
1190*4e1bc9a0SAchim Leubner                              agNULL,
1191*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1192*4e1bc9a0SAchim Leubner                              "EventLogOption1", /* valueName */
1193*4e1bc9a0SAchim Leubner                              buffer,
1194*4e1bc9a0SAchim Leubner                              buffLen,
1195*4e1bc9a0SAchim Leubner                              &lenRecv
1196*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1197*4e1bc9a0SAchim Leubner   {
1198*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1199*4e1bc9a0SAchim Leubner     {
1200*4e1bc9a0SAchim Leubner       SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1201*4e1bc9a0SAchim Leubner     }
1202*4e1bc9a0SAchim Leubner     else
1203*4e1bc9a0SAchim Leubner     {
1204*4e1bc9a0SAchim Leubner       SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1205*4e1bc9a0SAchim Leubner     }
1206*4e1bc9a0SAchim Leubner   }
1207*4e1bc9a0SAchim Leubner 
1208*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1209*4e1bc9a0SAchim Leubner   lenRecv = 0;
1210*4e1bc9a0SAchim Leubner 
1211*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1212*4e1bc9a0SAchim Leubner                              tiRoot,
1213*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1214*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1215*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1216*4e1bc9a0SAchim Leubner                              agNULL,
1217*4e1bc9a0SAchim Leubner                              agNULL,
1218*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1219*4e1bc9a0SAchim Leubner                              "EventLogSize2", /* valueName *//* IOP size in K dWords   */
1220*4e1bc9a0SAchim Leubner                              buffer,
1221*4e1bc9a0SAchim Leubner                              buffLen,
1222*4e1bc9a0SAchim Leubner                              &lenRecv
1223*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1224*4e1bc9a0SAchim Leubner   {
1225*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1226*4e1bc9a0SAchim Leubner     {
1227*4e1bc9a0SAchim Leubner       SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 0);
1228*4e1bc9a0SAchim Leubner     }
1229*4e1bc9a0SAchim Leubner     else
1230*4e1bc9a0SAchim Leubner     {
1231*4e1bc9a0SAchim Leubner       SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 10);
1232*4e1bc9a0SAchim Leubner     }
1233*4e1bc9a0SAchim Leubner   }
1234*4e1bc9a0SAchim Leubner 
1235*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1236*4e1bc9a0SAchim Leubner   lenRecv = 0;
1237*4e1bc9a0SAchim Leubner 
1238*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1239*4e1bc9a0SAchim Leubner                              tiRoot,
1240*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1241*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1242*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1243*4e1bc9a0SAchim Leubner                              agNULL,
1244*4e1bc9a0SAchim Leubner                              agNULL,
1245*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1246*4e1bc9a0SAchim Leubner                              "EventLogOption2", /* valueName */
1247*4e1bc9a0SAchim Leubner                              buffer,
1248*4e1bc9a0SAchim Leubner                              buffLen,
1249*4e1bc9a0SAchim Leubner                              &lenRecv
1250*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1251*4e1bc9a0SAchim Leubner   {
1252*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1253*4e1bc9a0SAchim Leubner     {
1254*4e1bc9a0SAchim Leubner       SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1255*4e1bc9a0SAchim Leubner     }
1256*4e1bc9a0SAchim Leubner     else
1257*4e1bc9a0SAchim Leubner     {
1258*4e1bc9a0SAchim Leubner       SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1259*4e1bc9a0SAchim Leubner     }
1260*4e1bc9a0SAchim Leubner   }
1261*4e1bc9a0SAchim Leubner   /* end of event log related parameters */
1262*4e1bc9a0SAchim Leubner 
1263*4e1bc9a0SAchim Leubner   /*
1264*4e1bc9a0SAchim Leubner     HDA parameters
1265*4e1bc9a0SAchim Leubner   */
1266*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1267*4e1bc9a0SAchim Leubner   lenRecv = 0;
1268*4e1bc9a0SAchim Leubner 
1269*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1270*4e1bc9a0SAchim Leubner                              tiRoot,
1271*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1272*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1273*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1274*4e1bc9a0SAchim Leubner                              agNULL,
1275*4e1bc9a0SAchim Leubner                              agNULL,
1276*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1277*4e1bc9a0SAchim Leubner                              "HDASupport", /* valueName */
1278*4e1bc9a0SAchim Leubner                              buffer,
1279*4e1bc9a0SAchim Leubner                              buffLen,
1280*4e1bc9a0SAchim Leubner                              &lenRecv
1281*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1282*4e1bc9a0SAchim Leubner   {
1283*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1284*4e1bc9a0SAchim Leubner     {
1285*4e1bc9a0SAchim Leubner       SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 0);
1286*4e1bc9a0SAchim Leubner     }
1287*4e1bc9a0SAchim Leubner     else
1288*4e1bc9a0SAchim Leubner     {
1289*4e1bc9a0SAchim Leubner       SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 10);
1290*4e1bc9a0SAchim Leubner     }
1291*4e1bc9a0SAchim Leubner   }
1292*4e1bc9a0SAchim Leubner 
1293*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1294*4e1bc9a0SAchim Leubner   lenRecv = 0;
1295*4e1bc9a0SAchim Leubner 
1296*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1297*4e1bc9a0SAchim Leubner                              tiRoot,
1298*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1299*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1300*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1301*4e1bc9a0SAchim Leubner                              agNULL,
1302*4e1bc9a0SAchim Leubner                              agNULL,
1303*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1304*4e1bc9a0SAchim Leubner                              "HDAMode", /* valueName */
1305*4e1bc9a0SAchim Leubner                              buffer,
1306*4e1bc9a0SAchim Leubner                              buffLen,
1307*4e1bc9a0SAchim Leubner                              &lenRecv
1308*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1309*4e1bc9a0SAchim Leubner   {
1310*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1311*4e1bc9a0SAchim Leubner     {
1312*4e1bc9a0SAchim Leubner       SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 0);
1313*4e1bc9a0SAchim Leubner     }
1314*4e1bc9a0SAchim Leubner     else
1315*4e1bc9a0SAchim Leubner     {
1316*4e1bc9a0SAchim Leubner       SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 10);
1317*4e1bc9a0SAchim Leubner     }
1318*4e1bc9a0SAchim Leubner   }
1319*4e1bc9a0SAchim Leubner   /* the end of HDA parameters */
1320*4e1bc9a0SAchim Leubner 
1321*4e1bc9a0SAchim Leubner   /* FW configuration */
1322*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1323*4e1bc9a0SAchim Leubner   lenRecv = 0;
1324*4e1bc9a0SAchim Leubner 
1325*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1326*4e1bc9a0SAchim Leubner                              tiRoot,
1327*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1328*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1329*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1330*4e1bc9a0SAchim Leubner                              agNULL,
1331*4e1bc9a0SAchim Leubner                              agNULL,
1332*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1333*4e1bc9a0SAchim Leubner                              "FWConfig", /* valueName */
1334*4e1bc9a0SAchim Leubner                              buffer,
1335*4e1bc9a0SAchim Leubner                              buffLen,
1336*4e1bc9a0SAchim Leubner                              &lenRecv
1337*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1338*4e1bc9a0SAchim Leubner   {
1339*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1340*4e1bc9a0SAchim Leubner     {
1341*4e1bc9a0SAchim Leubner       SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 0);
1342*4e1bc9a0SAchim Leubner     }
1343*4e1bc9a0SAchim Leubner     else
1344*4e1bc9a0SAchim Leubner     {
1345*4e1bc9a0SAchim Leubner       SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 10);
1346*4e1bc9a0SAchim Leubner     }
1347*4e1bc9a0SAchim Leubner   }
1348*4e1bc9a0SAchim Leubner   /* The end of FW configuration */
1349*4e1bc9a0SAchim Leubner 
1350*4e1bc9a0SAchim Leubner   /* IQ Normal priority and High priority */
1351*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1352*4e1bc9a0SAchim Leubner   lenRecv = 0;
1353*4e1bc9a0SAchim Leubner 
1354*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1355*4e1bc9a0SAchim Leubner                              tiRoot,
1356*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1357*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1358*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
1359*4e1bc9a0SAchim Leubner                              agNULL,
1360*4e1bc9a0SAchim Leubner                              agNULL,
1361*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1362*4e1bc9a0SAchim Leubner                              "IQNQDepth", /* valueName */
1363*4e1bc9a0SAchim Leubner                              buffer,
1364*4e1bc9a0SAchim Leubner                              buffLen,
1365*4e1bc9a0SAchim Leubner                              &lenRecv
1366*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1367*4e1bc9a0SAchim Leubner     {
1368*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1369*4e1bc9a0SAchim Leubner       {
1370*4e1bc9a0SAchim Leubner         QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
1371*4e1bc9a0SAchim Leubner       }
1372*4e1bc9a0SAchim Leubner       else
1373*4e1bc9a0SAchim Leubner       {
1374*4e1bc9a0SAchim Leubner         QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
1375*4e1bc9a0SAchim Leubner       }
1376*4e1bc9a0SAchim Leubner     }
1377*4e1bc9a0SAchim Leubner 
1378*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1379*4e1bc9a0SAchim Leubner   lenRecv = 0;
1380*4e1bc9a0SAchim Leubner 
1381*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1382*4e1bc9a0SAchim Leubner                              tiRoot,
1383*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1384*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1385*4e1bc9a0SAchim Leubner                              IBQueueProps,/* subkey2 */
1386*4e1bc9a0SAchim Leubner                              agNULL,
1387*4e1bc9a0SAchim Leubner                              agNULL,
1388*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1389*4e1bc9a0SAchim Leubner                              "IQHQDepth", /* valueName */
1390*4e1bc9a0SAchim Leubner                              buffer,
1391*4e1bc9a0SAchim Leubner                              buffLen,
1392*4e1bc9a0SAchim Leubner                              &lenRecv
1393*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1394*4e1bc9a0SAchim Leubner     {
1395*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1396*4e1bc9a0SAchim Leubner       {
1397*4e1bc9a0SAchim Leubner         QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
1398*4e1bc9a0SAchim Leubner       }
1399*4e1bc9a0SAchim Leubner       else
1400*4e1bc9a0SAchim Leubner       {
1401*4e1bc9a0SAchim Leubner         QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
1402*4e1bc9a0SAchim Leubner       }
1403*4e1bc9a0SAchim Leubner     }
1404*4e1bc9a0SAchim Leubner   /* End IQ Normal priority and High priority */
1405*4e1bc9a0SAchim Leubner 
1406*4e1bc9a0SAchim Leubner   /* Start port timeout value */
1407*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1408*4e1bc9a0SAchim Leubner   lenRecv = 0;
1409*4e1bc9a0SAchim Leubner 
1410*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1411*4e1bc9a0SAchim Leubner                              tiRoot,
1412*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1413*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1414*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1415*4e1bc9a0SAchim Leubner                              agNULL,
1416*4e1bc9a0SAchim Leubner                              agNULL,
1417*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1418*4e1bc9a0SAchim Leubner                              "PortTMO", /* valueName */
1419*4e1bc9a0SAchim Leubner                              buffer,
1420*4e1bc9a0SAchim Leubner                              buffLen,
1421*4e1bc9a0SAchim Leubner                              &lenRecv
1422*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1423*4e1bc9a0SAchim Leubner     {
1424*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1425*4e1bc9a0SAchim Leubner       {
1426*4e1bc9a0SAchim Leubner         tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1427*4e1bc9a0SAchim Leubner       }
1428*4e1bc9a0SAchim Leubner       else
1429*4e1bc9a0SAchim Leubner       {
1430*4e1bc9a0SAchim Leubner         tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1431*4e1bc9a0SAchim Leubner       }
1432*4e1bc9a0SAchim Leubner     }
1433*4e1bc9a0SAchim Leubner   /* End port timeout value */
1434*4e1bc9a0SAchim Leubner 
1435*4e1bc9a0SAchim Leubner #ifdef SA_ENABLE_TRACE_FUNCTIONS
1436*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1437*4e1bc9a0SAchim Leubner   lenRecv = 0;
1438*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1439*4e1bc9a0SAchim Leubner                              tiRoot,
1440*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1441*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1442*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1443*4e1bc9a0SAchim Leubner                              agNULL,
1444*4e1bc9a0SAchim Leubner                              agNULL,
1445*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1446*4e1bc9a0SAchim Leubner                              "TraceDestination", /* valueName */
1447*4e1bc9a0SAchim Leubner                              buffer,
1448*4e1bc9a0SAchim Leubner                              buffLen,
1449*4e1bc9a0SAchim Leubner                              &lenRecv
1450*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1451*4e1bc9a0SAchim Leubner   {
1452*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1453*4e1bc9a0SAchim Leubner     {
1454*4e1bc9a0SAchim Leubner       SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 0);
1455*4e1bc9a0SAchim Leubner     }
1456*4e1bc9a0SAchim Leubner     else
1457*4e1bc9a0SAchim Leubner     {
1458*4e1bc9a0SAchim Leubner       SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 10);
1459*4e1bc9a0SAchim Leubner     }
1460*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceDestination %d\n",SwConfig->TraceDestination));
1461*4e1bc9a0SAchim Leubner   }
1462*4e1bc9a0SAchim Leubner 
1463*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1464*4e1bc9a0SAchim Leubner   lenRecv = 0;
1465*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1466*4e1bc9a0SAchim Leubner                              tiRoot,
1467*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1468*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1469*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1470*4e1bc9a0SAchim Leubner                              agNULL,
1471*4e1bc9a0SAchim Leubner                              agNULL,
1472*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1473*4e1bc9a0SAchim Leubner                              "TraceMask", /* valueName */
1474*4e1bc9a0SAchim Leubner                              buffer,
1475*4e1bc9a0SAchim Leubner                              buffLen,
1476*4e1bc9a0SAchim Leubner                              &lenRecv
1477*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1478*4e1bc9a0SAchim Leubner   {
1479*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1480*4e1bc9a0SAchim Leubner     {
1481*4e1bc9a0SAchim Leubner       SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 0);
1482*4e1bc9a0SAchim Leubner     }
1483*4e1bc9a0SAchim Leubner     else
1484*4e1bc9a0SAchim Leubner     {
1485*4e1bc9a0SAchim Leubner       SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 10);
1486*4e1bc9a0SAchim Leubner     }
1487*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceMask %d %X\n",SwConfig->TraceMask,SwConfig->TraceMask));
1488*4e1bc9a0SAchim Leubner   }
1489*4e1bc9a0SAchim Leubner #endif /*# SA_ENABLE_TRACE_FUNCTIONS */
1490*4e1bc9a0SAchim Leubner 
1491*4e1bc9a0SAchim Leubner #ifdef AGTIAPI_CTL
1492*4e1bc9a0SAchim Leubner   /*
1493*4e1bc9a0SAchim Leubner    * read the SAS Connection Time Limit parameter
1494*4e1bc9a0SAchim Leubner    */
1495*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1496*4e1bc9a0SAchim Leubner   lenRecv = 0;
1497*4e1bc9a0SAchim Leubner   tdsaAllShared->SASConnectTimeLimit = 0;
1498*4e1bc9a0SAchim Leubner 
1499*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1500*4e1bc9a0SAchim Leubner                              tiRoot,
1501*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1502*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1503*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1504*4e1bc9a0SAchim Leubner                              agNULL,
1505*4e1bc9a0SAchim Leubner                              agNULL,
1506*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1507*4e1bc9a0SAchim Leubner                              "SASCTL",    /* valueName */
1508*4e1bc9a0SAchim Leubner                              buffer,
1509*4e1bc9a0SAchim Leubner                              buffLen,
1510*4e1bc9a0SAchim Leubner                              &lenRecv
1511*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1512*4e1bc9a0SAchim Leubner   {
1513*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1514*4e1bc9a0SAchim Leubner       tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 0);
1515*4e1bc9a0SAchim Leubner     else
1516*4e1bc9a0SAchim Leubner       tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 10);
1517*4e1bc9a0SAchim Leubner   }
1518*4e1bc9a0SAchim Leubner #endif
1519*4e1bc9a0SAchim Leubner 
1520*4e1bc9a0SAchim Leubner   /* Start FCA value */
1521*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1522*4e1bc9a0SAchim Leubner   lenRecv = 0;
1523*4e1bc9a0SAchim Leubner 
1524*4e1bc9a0SAchim Leubner   tdsaAllShared->FCA = 1; /* No FCA by default */
1525*4e1bc9a0SAchim Leubner 
1526*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1527*4e1bc9a0SAchim Leubner                              tiRoot,
1528*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1529*4e1bc9a0SAchim Leubner                              "InitiatorParms",  /* subkey1 */
1530*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1531*4e1bc9a0SAchim Leubner                              agNULL,
1532*4e1bc9a0SAchim Leubner                              agNULL,
1533*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1534*4e1bc9a0SAchim Leubner                              "FCA", /* valueName */
1535*4e1bc9a0SAchim Leubner                              buffer,
1536*4e1bc9a0SAchim Leubner                              buffLen,
1537*4e1bc9a0SAchim Leubner                              &lenRecv
1538*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1539*4e1bc9a0SAchim Leubner     {
1540*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1541*4e1bc9a0SAchim Leubner       {
1542*4e1bc9a0SAchim Leubner         tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 0);
1543*4e1bc9a0SAchim Leubner       }
1544*4e1bc9a0SAchim Leubner       else
1545*4e1bc9a0SAchim Leubner       {
1546*4e1bc9a0SAchim Leubner         tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 10);
1547*4e1bc9a0SAchim Leubner       }
1548*4e1bc9a0SAchim Leubner     }
1549*4e1bc9a0SAchim Leubner   /* End FCA value */
1550*4e1bc9a0SAchim Leubner 
1551*4e1bc9a0SAchim Leubner   /* Start ResetInDiscovery value */
1552*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1553*4e1bc9a0SAchim Leubner   lenRecv = 0;
1554*4e1bc9a0SAchim Leubner 
1555*4e1bc9a0SAchim Leubner   tdsaAllShared->ResetInDiscovery = 0; /* No ResetInDiscovery by default */
1556*4e1bc9a0SAchim Leubner 
1557*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1558*4e1bc9a0SAchim Leubner                              tiRoot,
1559*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1560*4e1bc9a0SAchim Leubner                              "InitiatorParms",  /* subkey1 */
1561*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1562*4e1bc9a0SAchim Leubner                              agNULL,
1563*4e1bc9a0SAchim Leubner                              agNULL,
1564*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1565*4e1bc9a0SAchim Leubner                              "ResetInDiscovery", /* valueName */
1566*4e1bc9a0SAchim Leubner                              buffer,
1567*4e1bc9a0SAchim Leubner                              buffLen,
1568*4e1bc9a0SAchim Leubner                              &lenRecv
1569*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1570*4e1bc9a0SAchim Leubner     {
1571*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
1572*4e1bc9a0SAchim Leubner       {
1573*4e1bc9a0SAchim Leubner         tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 0);
1574*4e1bc9a0SAchim Leubner       }
1575*4e1bc9a0SAchim Leubner       else
1576*4e1bc9a0SAchim Leubner       {
1577*4e1bc9a0SAchim Leubner         tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 10);
1578*4e1bc9a0SAchim Leubner       }
1579*4e1bc9a0SAchim Leubner     }
1580*4e1bc9a0SAchim Leubner   /* End ResetInDiscovery value */
1581*4e1bc9a0SAchim Leubner 
1582*4e1bc9a0SAchim Leubner   /* Start MCN value */
1583*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1584*4e1bc9a0SAchim Leubner   lenRecv = 0;
1585*4e1bc9a0SAchim Leubner 
1586*4e1bc9a0SAchim Leubner   tdsaAllShared->MCN = 1; /* default MCN */
1587*4e1bc9a0SAchim Leubner 
1588*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1589*4e1bc9a0SAchim Leubner                              tiRoot,
1590*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1591*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1592*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1593*4e1bc9a0SAchim Leubner                              agNULL,
1594*4e1bc9a0SAchim Leubner                              agNULL,
1595*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1596*4e1bc9a0SAchim Leubner                              "MCN", /* valueName */
1597*4e1bc9a0SAchim Leubner                              buffer,
1598*4e1bc9a0SAchim Leubner                              buffLen,
1599*4e1bc9a0SAchim Leubner                              &lenRecv
1600*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1601*4e1bc9a0SAchim Leubner   {
1602*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1603*4e1bc9a0SAchim Leubner     {
1604*4e1bc9a0SAchim Leubner       tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 0);
1605*4e1bc9a0SAchim Leubner     }
1606*4e1bc9a0SAchim Leubner     else
1607*4e1bc9a0SAchim Leubner     {
1608*4e1bc9a0SAchim Leubner       tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 10);
1609*4e1bc9a0SAchim Leubner     }
1610*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: MCN %d\n", tdsaAllShared->MCN));
1611*4e1bc9a0SAchim Leubner   }
1612*4e1bc9a0SAchim Leubner   /* End MCN value */
1613*4e1bc9a0SAchim Leubner 
1614*4e1bc9a0SAchim Leubner   /* Start sflag value */
1615*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1616*4e1bc9a0SAchim Leubner   lenRecv = 0;
1617*4e1bc9a0SAchim Leubner 
1618*4e1bc9a0SAchim Leubner   tdsaAllShared->sflag = 0; /* default sflag */
1619*4e1bc9a0SAchim Leubner 
1620*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1621*4e1bc9a0SAchim Leubner                              tiRoot,
1622*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1623*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1624*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
1625*4e1bc9a0SAchim Leubner                              agNULL,
1626*4e1bc9a0SAchim Leubner                              agNULL,
1627*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1628*4e1bc9a0SAchim Leubner                              "Sflag",     /* valueName */
1629*4e1bc9a0SAchim Leubner                              buffer,
1630*4e1bc9a0SAchim Leubner                              buffLen,
1631*4e1bc9a0SAchim Leubner                              &lenRecv
1632*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1633*4e1bc9a0SAchim Leubner   {
1634*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1635*4e1bc9a0SAchim Leubner     {
1636*4e1bc9a0SAchim Leubner       tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 0);
1637*4e1bc9a0SAchim Leubner     }
1638*4e1bc9a0SAchim Leubner     else
1639*4e1bc9a0SAchim Leubner     {
1640*4e1bc9a0SAchim Leubner       tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 10);
1641*4e1bc9a0SAchim Leubner     }
1642*4e1bc9a0SAchim Leubner     TI_DBG1(("tdsaGetSwConfigParams: sflag %d\n", tdsaAllShared->sflag));
1643*4e1bc9a0SAchim Leubner   }
1644*4e1bc9a0SAchim Leubner   /* End sflag value */
1645*4e1bc9a0SAchim Leubner 
1646*4e1bc9a0SAchim Leubner   /* Start enable DIF */
1647*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1648*4e1bc9a0SAchim Leubner   lenRecv = 0;
1649*4e1bc9a0SAchim Leubner 
1650*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1651*4e1bc9a0SAchim Leubner                              tiRoot,
1652*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1653*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1654*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1655*4e1bc9a0SAchim Leubner                              agNULL,
1656*4e1bc9a0SAchim Leubner                              agNULL,
1657*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1658*4e1bc9a0SAchim Leubner                              "enableDIF", /* valueName */
1659*4e1bc9a0SAchim Leubner                              buffer,
1660*4e1bc9a0SAchim Leubner                              buffLen,
1661*4e1bc9a0SAchim Leubner                              &lenRecv
1662*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1663*4e1bc9a0SAchim Leubner   {
1664*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1665*4e1bc9a0SAchim Leubner     {
1666*4e1bc9a0SAchim Leubner       enableDIF = osti_strtoul (buffer, &pLastUsedChar, 0);
1667*4e1bc9a0SAchim Leubner     }
1668*4e1bc9a0SAchim Leubner     else
1669*4e1bc9a0SAchim Leubner     {
1670*4e1bc9a0SAchim Leubner       enableDIF = osti_strtoul (buffer, &pLastUsedChar, 10);
1671*4e1bc9a0SAchim Leubner     }
1672*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: enableDIF %d\n", enableDIF));
1673*4e1bc9a0SAchim Leubner     if (enableDIF)
1674*4e1bc9a0SAchim Leubner     {
1675*4e1bc9a0SAchim Leubner       SwConfig->enableDIF = agTRUE;
1676*4e1bc9a0SAchim Leubner     }
1677*4e1bc9a0SAchim Leubner     else
1678*4e1bc9a0SAchim Leubner     {
1679*4e1bc9a0SAchim Leubner       SwConfig->enableDIF = agFALSE;
1680*4e1bc9a0SAchim Leubner     }
1681*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableDIF %d\n", SwConfig->enableDIF));
1682*4e1bc9a0SAchim Leubner   }
1683*4e1bc9a0SAchim Leubner   /* End enable DIF */
1684*4e1bc9a0SAchim Leubner 
1685*4e1bc9a0SAchim Leubner 
1686*4e1bc9a0SAchim Leubner   /* Start enable Encryption */
1687*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1688*4e1bc9a0SAchim Leubner   lenRecv = 0;
1689*4e1bc9a0SAchim Leubner 
1690*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1691*4e1bc9a0SAchim Leubner                              tiRoot,
1692*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1693*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1694*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1695*4e1bc9a0SAchim Leubner                              agNULL,
1696*4e1bc9a0SAchim Leubner                              agNULL,
1697*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1698*4e1bc9a0SAchim Leubner                              "enableEncryption", /* valueName */
1699*4e1bc9a0SAchim Leubner                              buffer,
1700*4e1bc9a0SAchim Leubner                              buffLen,
1701*4e1bc9a0SAchim Leubner                              &lenRecv
1702*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1703*4e1bc9a0SAchim Leubner   {
1704*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1705*4e1bc9a0SAchim Leubner     {
1706*4e1bc9a0SAchim Leubner       enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 0);
1707*4e1bc9a0SAchim Leubner     }
1708*4e1bc9a0SAchim Leubner     else
1709*4e1bc9a0SAchim Leubner     {
1710*4e1bc9a0SAchim Leubner       enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 10);
1711*4e1bc9a0SAchim Leubner     }
1712*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: enableEncryption %d\n", enableEncryption));
1713*4e1bc9a0SAchim Leubner     if (enableEncryption)
1714*4e1bc9a0SAchim Leubner     {
1715*4e1bc9a0SAchim Leubner       SwConfig->enableEncryption = agTRUE;
1716*4e1bc9a0SAchim Leubner     }
1717*4e1bc9a0SAchim Leubner     else
1718*4e1bc9a0SAchim Leubner     {
1719*4e1bc9a0SAchim Leubner       SwConfig->enableEncryption = agFALSE;
1720*4e1bc9a0SAchim Leubner     }
1721*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableEncryption %d\n", SwConfig->enableEncryption));
1722*4e1bc9a0SAchim Leubner   }
1723*4e1bc9a0SAchim Leubner   /* End enable Encryption */
1724*4e1bc9a0SAchim Leubner 
1725*4e1bc9a0SAchim Leubner   /* Start allow connection rate change */
1726*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1727*4e1bc9a0SAchim Leubner   lenRecv = 0;
1728*4e1bc9a0SAchim Leubner   tdsaAllShared->RateAdjust = 0; /* No rate adjust by default */
1729*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1730*4e1bc9a0SAchim Leubner                              tiRoot,
1731*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1732*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1733*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1734*4e1bc9a0SAchim Leubner                              agNULL,
1735*4e1bc9a0SAchim Leubner                              agNULL,
1736*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1737*4e1bc9a0SAchim Leubner                              "RateAdjust", /* valueName */
1738*4e1bc9a0SAchim Leubner                              buffer,
1739*4e1bc9a0SAchim Leubner                              buffLen,
1740*4e1bc9a0SAchim Leubner                              &lenRecv
1741*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1742*4e1bc9a0SAchim Leubner   {
1743*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1744*4e1bc9a0SAchim Leubner     {
1745*4e1bc9a0SAchim Leubner       tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 0);
1746*4e1bc9a0SAchim Leubner     }
1747*4e1bc9a0SAchim Leubner     else
1748*4e1bc9a0SAchim Leubner     {
1749*4e1bc9a0SAchim Leubner       tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 10);
1750*4e1bc9a0SAchim Leubner     }
1751*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: tdsaAllShared->RateAdjust %d\n", tdsaAllShared->RateAdjust));
1752*4e1bc9a0SAchim Leubner   }
1753*4e1bc9a0SAchim Leubner   /* End allow connection rate change */
1754*4e1bc9a0SAchim Leubner 
1755*4e1bc9a0SAchim Leubner 
1756*4e1bc9a0SAchim Leubner #ifdef SA_CONFIG_MDFD_REGISTRY
1757*4e1bc9a0SAchim Leubner   /* Start disable MDF */
1758*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1759*4e1bc9a0SAchim Leubner   lenRecv = 0;
1760*4e1bc9a0SAchim Leubner 
1761*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1762*4e1bc9a0SAchim Leubner                              tiRoot,
1763*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1764*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1765*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1766*4e1bc9a0SAchim Leubner                              agNULL,
1767*4e1bc9a0SAchim Leubner                              agNULL,
1768*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1769*4e1bc9a0SAchim Leubner                              "disableMDF", /* valueName */
1770*4e1bc9a0SAchim Leubner                              buffer,
1771*4e1bc9a0SAchim Leubner                              buffLen,
1772*4e1bc9a0SAchim Leubner                              &lenRecv
1773*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1774*4e1bc9a0SAchim Leubner   {
1775*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1776*4e1bc9a0SAchim Leubner     {
1777*4e1bc9a0SAchim Leubner       disableMDF = osti_strtoul (buffer, &pLastUsedChar, 0);
1778*4e1bc9a0SAchim Leubner     }
1779*4e1bc9a0SAchim Leubner     else
1780*4e1bc9a0SAchim Leubner     {
1781*4e1bc9a0SAchim Leubner       disableMDF = osti_strtoul (buffer, &pLastUsedChar, 10);
1782*4e1bc9a0SAchim Leubner     }
1783*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: disableMDF %d\n", disableMDF));
1784*4e1bc9a0SAchim Leubner     if (disableMDF)
1785*4e1bc9a0SAchim Leubner     {
1786*4e1bc9a0SAchim Leubner       SwConfig->disableMDF = agTRUE;
1787*4e1bc9a0SAchim Leubner     }
1788*4e1bc9a0SAchim Leubner     else
1789*4e1bc9a0SAchim Leubner     {
1790*4e1bc9a0SAchim Leubner       SwConfig->disableMDF = agFALSE;
1791*4e1bc9a0SAchim Leubner     }
1792*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetSwConfigParams: SwConfig->disableMDF %d\n", SwConfig->disableMDF));
1793*4e1bc9a0SAchim Leubner   }
1794*4e1bc9a0SAchim Leubner   /* End disable MDF */
1795*4e1bc9a0SAchim Leubner #endif /*SA_CONFIG_MDFD_REGISTRY*/
1796*4e1bc9a0SAchim Leubner 
1797*4e1bc9a0SAchim Leubner   /* Start IT_NEXUS_TIMEOUT */
1798*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1799*4e1bc9a0SAchim Leubner   lenRecv = 0;
1800*4e1bc9a0SAchim Leubner 
1801*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1802*4e1bc9a0SAchim Leubner                              tiRoot,
1803*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1804*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1805*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1806*4e1bc9a0SAchim Leubner                              agNULL,
1807*4e1bc9a0SAchim Leubner                              agNULL,
1808*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1809*4e1bc9a0SAchim Leubner                              "IT_NEXUS_TIMEOUT", /* valueName */
1810*4e1bc9a0SAchim Leubner                              buffer,
1811*4e1bc9a0SAchim Leubner                              buffLen,
1812*4e1bc9a0SAchim Leubner                              &lenRecv
1813*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1814*4e1bc9a0SAchim Leubner   {
1815*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1816*4e1bc9a0SAchim Leubner     {
1817*4e1bc9a0SAchim Leubner       tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
1818*4e1bc9a0SAchim Leubner     }
1819*4e1bc9a0SAchim Leubner     else
1820*4e1bc9a0SAchim Leubner     {
1821*4e1bc9a0SAchim Leubner       tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
1822*4e1bc9a0SAchim Leubner     }
1823*4e1bc9a0SAchim Leubner     TI_DBG1(("tdsaGetSwConfigParams: tdsaAllShared->itNexusTimeout %d\n", tdsaAllShared->itNexusTimeout));
1824*4e1bc9a0SAchim Leubner   }
1825*4e1bc9a0SAchim Leubner   /* End IT_NEXUS_TIMEOUT */
1826*4e1bc9a0SAchim Leubner 
1827*4e1bc9a0SAchim Leubner   /* Start stp idle time */
1828*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1829*4e1bc9a0SAchim Leubner   lenRecv = 0;
1830*4e1bc9a0SAchim Leubner 
1831*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1832*4e1bc9a0SAchim Leubner                              tiRoot,
1833*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1834*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1835*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1836*4e1bc9a0SAchim Leubner                              agNULL,
1837*4e1bc9a0SAchim Leubner                              agNULL,
1838*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1839*4e1bc9a0SAchim Leubner                              "STPIdleTime", /* valueName */
1840*4e1bc9a0SAchim Leubner                              buffer,
1841*4e1bc9a0SAchim Leubner                              buffLen,
1842*4e1bc9a0SAchim Leubner                              &lenRecv
1843*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1844*4e1bc9a0SAchim Leubner   {
1845*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1846*4e1bc9a0SAchim Leubner     {
1847*4e1bc9a0SAchim Leubner       tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 0);
1848*4e1bc9a0SAchim Leubner     }
1849*4e1bc9a0SAchim Leubner     else
1850*4e1bc9a0SAchim Leubner     {
1851*4e1bc9a0SAchim Leubner       tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 10);
1852*4e1bc9a0SAchim Leubner     }
1853*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: STPIdleTime %d\n", tdsaAllShared->stp_idle_time));
1854*4e1bc9a0SAchim Leubner   }
1855*4e1bc9a0SAchim Leubner   /* End stp idle time */
1856*4e1bc9a0SAchim Leubner 
1857*4e1bc9a0SAchim Leubner   /* Start STP_MCT_TMO */
1858*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1859*4e1bc9a0SAchim Leubner   lenRecv = 0;
1860*4e1bc9a0SAchim Leubner 
1861*4e1bc9a0SAchim Leubner   tdsaAllShared->STP_MCT_TMO = 32;
1862*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1863*4e1bc9a0SAchim Leubner                              tiRoot,
1864*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1865*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1866*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1867*4e1bc9a0SAchim Leubner                              agNULL,
1868*4e1bc9a0SAchim Leubner                              agNULL,
1869*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1870*4e1bc9a0SAchim Leubner                              "SAS_STP_MCT_TMO", /* valueName */
1871*4e1bc9a0SAchim Leubner                              buffer,
1872*4e1bc9a0SAchim Leubner                              buffLen,
1873*4e1bc9a0SAchim Leubner                              &lenRecv
1874*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1875*4e1bc9a0SAchim Leubner   {
1876*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1877*4e1bc9a0SAchim Leubner     {
1878*4e1bc9a0SAchim Leubner       tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1879*4e1bc9a0SAchim Leubner     }
1880*4e1bc9a0SAchim Leubner     else
1881*4e1bc9a0SAchim Leubner     {
1882*4e1bc9a0SAchim Leubner       tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1883*4e1bc9a0SAchim Leubner     }
1884*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: STP_MCT_TMO %d\n", tdsaAllShared->STP_MCT_TMO));
1885*4e1bc9a0SAchim Leubner   }
1886*4e1bc9a0SAchim Leubner   /* End  STP_MCT_TMO */
1887*4e1bc9a0SAchim Leubner 
1888*4e1bc9a0SAchim Leubner   /* Start SSP_MCT_TMO */
1889*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1890*4e1bc9a0SAchim Leubner   lenRecv = 0;
1891*4e1bc9a0SAchim Leubner   tdsaAllShared->SSP_MCT_TMO = 32;
1892*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1893*4e1bc9a0SAchim Leubner                              tiRoot,
1894*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1895*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1896*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1897*4e1bc9a0SAchim Leubner                              agNULL,
1898*4e1bc9a0SAchim Leubner                              agNULL,
1899*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1900*4e1bc9a0SAchim Leubner                              "SAS_SSP_MCT_TMO", /* valueName */
1901*4e1bc9a0SAchim Leubner                              buffer,
1902*4e1bc9a0SAchim Leubner                              buffLen,
1903*4e1bc9a0SAchim Leubner                              &lenRecv
1904*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1905*4e1bc9a0SAchim Leubner   {
1906*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1907*4e1bc9a0SAchim Leubner     {
1908*4e1bc9a0SAchim Leubner       tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1909*4e1bc9a0SAchim Leubner     }
1910*4e1bc9a0SAchim Leubner     else
1911*4e1bc9a0SAchim Leubner     {
1912*4e1bc9a0SAchim Leubner       tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1913*4e1bc9a0SAchim Leubner     }
1914*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: SSP_MCT_TMO %d\n", tdsaAllShared->SSP_MCT_TMO));
1915*4e1bc9a0SAchim Leubner   }
1916*4e1bc9a0SAchim Leubner   /* End  SSP_MCT_TMO */
1917*4e1bc9a0SAchim Leubner 
1918*4e1bc9a0SAchim Leubner 
1919*4e1bc9a0SAchim Leubner   /* Start MAX_OPEN_TIME */
1920*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1921*4e1bc9a0SAchim Leubner   lenRecv = 0;
1922*4e1bc9a0SAchim Leubner   tdsaAllShared->MAX_OPEN_TIME = 5;
1923*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1924*4e1bc9a0SAchim Leubner                              tiRoot,
1925*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1926*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1927*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1928*4e1bc9a0SAchim Leubner                              agNULL,
1929*4e1bc9a0SAchim Leubner                              agNULL,
1930*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1931*4e1bc9a0SAchim Leubner                              "SAS_MAX_OPEN_TIME", /* valueName */
1932*4e1bc9a0SAchim Leubner                              buffer,
1933*4e1bc9a0SAchim Leubner                              buffLen,
1934*4e1bc9a0SAchim Leubner                              &lenRecv
1935*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1936*4e1bc9a0SAchim Leubner   {
1937*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1938*4e1bc9a0SAchim Leubner     {
1939*4e1bc9a0SAchim Leubner       tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 0);
1940*4e1bc9a0SAchim Leubner     }
1941*4e1bc9a0SAchim Leubner     else
1942*4e1bc9a0SAchim Leubner     {
1943*4e1bc9a0SAchim Leubner       tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 10);
1944*4e1bc9a0SAchim Leubner     }
1945*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: MAX_OPEN_TIME %d\n", tdsaAllShared->MAX_OPEN_TIME));
1946*4e1bc9a0SAchim Leubner   }
1947*4e1bc9a0SAchim Leubner   /* End  MAX_OPEN_TIME */
1948*4e1bc9a0SAchim Leubner 
1949*4e1bc9a0SAchim Leubner 
1950*4e1bc9a0SAchim Leubner   /* Start SMP_MAX_CONN_TIMER */
1951*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1952*4e1bc9a0SAchim Leubner   lenRecv = 0;
1953*4e1bc9a0SAchim Leubner   tdsaAllShared->SMP_MAX_CONN_TIMER = 0xFF;
1954*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1955*4e1bc9a0SAchim Leubner                              tiRoot,
1956*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1957*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1958*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1959*4e1bc9a0SAchim Leubner                              agNULL,
1960*4e1bc9a0SAchim Leubner                              agNULL,
1961*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1962*4e1bc9a0SAchim Leubner                              "SAS_SMP_MAX_CONN_TIMER", /* valueName */
1963*4e1bc9a0SAchim Leubner                              buffer,
1964*4e1bc9a0SAchim Leubner                              buffLen,
1965*4e1bc9a0SAchim Leubner                              &lenRecv
1966*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1967*4e1bc9a0SAchim Leubner   {
1968*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1969*4e1bc9a0SAchim Leubner     {
1970*4e1bc9a0SAchim Leubner       tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 0);
1971*4e1bc9a0SAchim Leubner     }
1972*4e1bc9a0SAchim Leubner     else
1973*4e1bc9a0SAchim Leubner     {
1974*4e1bc9a0SAchim Leubner       tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 10);
1975*4e1bc9a0SAchim Leubner     }
1976*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: SMP_MAX_CONN_TIMER %d\n", tdsaAllShared->SMP_MAX_CONN_TIMER));
1977*4e1bc9a0SAchim Leubner   }
1978*4e1bc9a0SAchim Leubner   /* End  SMP_MAX_CONN_TIMER */
1979*4e1bc9a0SAchim Leubner 
1980*4e1bc9a0SAchim Leubner   /* Start STP_FRM_TMO */
1981*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
1982*4e1bc9a0SAchim Leubner   lenRecv = 0;
1983*4e1bc9a0SAchim Leubner   tdsaAllShared->STP_FRM_TMO = 0;
1984*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
1985*4e1bc9a0SAchim Leubner                              tiRoot,
1986*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
1987*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
1988*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
1989*4e1bc9a0SAchim Leubner                              agNULL,
1990*4e1bc9a0SAchim Leubner                              agNULL,
1991*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
1992*4e1bc9a0SAchim Leubner                              "SAS_STP_FRM_TMO", /* valueName */
1993*4e1bc9a0SAchim Leubner                              buffer,
1994*4e1bc9a0SAchim Leubner                              buffLen,
1995*4e1bc9a0SAchim Leubner                              &lenRecv
1996*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
1997*4e1bc9a0SAchim Leubner   {
1998*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
1999*4e1bc9a0SAchim Leubner     {
2000*4e1bc9a0SAchim Leubner       tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2001*4e1bc9a0SAchim Leubner     }
2002*4e1bc9a0SAchim Leubner     else
2003*4e1bc9a0SAchim Leubner     {
2004*4e1bc9a0SAchim Leubner       tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2005*4e1bc9a0SAchim Leubner     }
2006*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: STP_FRM_TMO %d\n", tdsaAllShared->STP_FRM_TMO));
2007*4e1bc9a0SAchim Leubner   }
2008*4e1bc9a0SAchim Leubner   /* End  STP_FRM_TMO */
2009*4e1bc9a0SAchim Leubner 
2010*4e1bc9a0SAchim Leubner   /* Start MFD_OPNRJT_RTRY_INTVL */
2011*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2012*4e1bc9a0SAchim Leubner   lenRecv = 0;
2013*4e1bc9a0SAchim Leubner   tdsaAllShared->MFD = 1; /* disabled  by default */
2014*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2015*4e1bc9a0SAchim Leubner                              tiRoot,
2016*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2017*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2018*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
2019*4e1bc9a0SAchim Leubner                              agNULL,
2020*4e1bc9a0SAchim Leubner                              agNULL,
2021*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2022*4e1bc9a0SAchim Leubner                              "SAS_MFD", /* valueName */
2023*4e1bc9a0SAchim Leubner                              buffer,
2024*4e1bc9a0SAchim Leubner                              buffLen,
2025*4e1bc9a0SAchim Leubner                              &lenRecv
2026*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2027*4e1bc9a0SAchim Leubner   {
2028*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2029*4e1bc9a0SAchim Leubner     {
2030*4e1bc9a0SAchim Leubner       tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 0);
2031*4e1bc9a0SAchim Leubner     }
2032*4e1bc9a0SAchim Leubner     else
2033*4e1bc9a0SAchim Leubner     {
2034*4e1bc9a0SAchim Leubner       tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 10);
2035*4e1bc9a0SAchim Leubner     }
2036*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: MFD %d\n", tdsaAllShared->MFD));
2037*4e1bc9a0SAchim Leubner   }
2038*4e1bc9a0SAchim Leubner   /* End  MFD_OPNRJT_RTRY_INTVL */
2039*4e1bc9a0SAchim Leubner 
2040*4e1bc9a0SAchim Leubner   /* Start MFD_OPNRJT_RTRY_INTVL */
2041*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2042*4e1bc9a0SAchim Leubner   lenRecv = 0;
2043*4e1bc9a0SAchim Leubner   tdsaAllShared->OPNRJT_RTRY_INTVL = 2;
2044*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2045*4e1bc9a0SAchim Leubner                              tiRoot,
2046*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2047*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2048*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
2049*4e1bc9a0SAchim Leubner                              agNULL,
2050*4e1bc9a0SAchim Leubner                              agNULL,
2051*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2052*4e1bc9a0SAchim Leubner                              "SAS_OPNRJT_RTRY_INTVL", /* valueName */
2053*4e1bc9a0SAchim Leubner                              buffer,
2054*4e1bc9a0SAchim Leubner                              buffLen,
2055*4e1bc9a0SAchim Leubner                              &lenRecv
2056*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2057*4e1bc9a0SAchim Leubner   {
2058*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2059*4e1bc9a0SAchim Leubner     {
2060*4e1bc9a0SAchim Leubner       tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 0);
2061*4e1bc9a0SAchim Leubner     }
2062*4e1bc9a0SAchim Leubner     else
2063*4e1bc9a0SAchim Leubner     {
2064*4e1bc9a0SAchim Leubner       tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 10);
2065*4e1bc9a0SAchim Leubner     }
2066*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: OPNRJT_RTRY_INTVL %d\n", tdsaAllShared->OPNRJT_RTRY_INTVL));
2067*4e1bc9a0SAchim Leubner   }
2068*4e1bc9a0SAchim Leubner   /* End  MFD_OPNRJT_RTRY_INTVL */
2069*4e1bc9a0SAchim Leubner 
2070*4e1bc9a0SAchim Leubner   /* Start DOPNRJT_RTRY_TMO */
2071*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2072*4e1bc9a0SAchim Leubner   lenRecv = 0;
2073*4e1bc9a0SAchim Leubner   tdsaAllShared->DOPNRJT_RTRY_TMO = 128;
2074*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2075*4e1bc9a0SAchim Leubner                              tiRoot,
2076*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2077*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2078*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
2079*4e1bc9a0SAchim Leubner                              agNULL,
2080*4e1bc9a0SAchim Leubner                              agNULL,
2081*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2082*4e1bc9a0SAchim Leubner                              "SAS_DOPNRJT_RTRY_TMO", /* valueName */
2083*4e1bc9a0SAchim Leubner                              buffer,
2084*4e1bc9a0SAchim Leubner                              buffLen,
2085*4e1bc9a0SAchim Leubner                              &lenRecv
2086*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2087*4e1bc9a0SAchim Leubner   {
2088*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2089*4e1bc9a0SAchim Leubner     {
2090*4e1bc9a0SAchim Leubner       tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2091*4e1bc9a0SAchim Leubner     }
2092*4e1bc9a0SAchim Leubner     else
2093*4e1bc9a0SAchim Leubner     {
2094*4e1bc9a0SAchim Leubner       tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2095*4e1bc9a0SAchim Leubner     }
2096*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_TMO %d\n", tdsaAllShared->DOPNRJT_RTRY_TMO));
2097*4e1bc9a0SAchim Leubner   }
2098*4e1bc9a0SAchim Leubner   /* End  DOPNRJT_RTRY_TMO */
2099*4e1bc9a0SAchim Leubner 
2100*4e1bc9a0SAchim Leubner   /* Start COPNRJT_RTRY_TMO */
2101*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2102*4e1bc9a0SAchim Leubner   lenRecv = 0;
2103*4e1bc9a0SAchim Leubner //  tdsaAllShared->COPNRJT_RTRY_TMO = 32;
2104*4e1bc9a0SAchim Leubner   tdsaAllShared->COPNRJT_RTRY_TMO = 128;
2105*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2106*4e1bc9a0SAchim Leubner                              tiRoot,
2107*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2108*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2109*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
2110*4e1bc9a0SAchim Leubner                              agNULL,
2111*4e1bc9a0SAchim Leubner                              agNULL,
2112*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2113*4e1bc9a0SAchim Leubner                              "SAS_COPNRJT_RTRY_TMO", /* valueName */
2114*4e1bc9a0SAchim Leubner                              buffer,
2115*4e1bc9a0SAchim Leubner                              buffLen,
2116*4e1bc9a0SAchim Leubner                              &lenRecv
2117*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2118*4e1bc9a0SAchim Leubner   {
2119*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2120*4e1bc9a0SAchim Leubner     {
2121*4e1bc9a0SAchim Leubner       tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2122*4e1bc9a0SAchim Leubner     }
2123*4e1bc9a0SAchim Leubner     else
2124*4e1bc9a0SAchim Leubner     {
2125*4e1bc9a0SAchim Leubner       tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2126*4e1bc9a0SAchim Leubner     }
2127*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_TMO %d\n", tdsaAllShared->COPNRJT_RTRY_TMO));
2128*4e1bc9a0SAchim Leubner   }
2129*4e1bc9a0SAchim Leubner   /* End  COPNRJT_RTRY_TMO */
2130*4e1bc9a0SAchim Leubner 
2131*4e1bc9a0SAchim Leubner   /* Start DOPNRJT_RTRY_THR */
2132*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2133*4e1bc9a0SAchim Leubner   lenRecv = 0;
2134*4e1bc9a0SAchim Leubner //  tdsaAllShared->DOPNRJT_RTRY_THR = 16; /* FW default */
2135*4e1bc9a0SAchim Leubner   /*
2136*4e1bc9a0SAchim Leubner     Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second.
2137*4e1bc9a0SAchim Leubner     Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128 is tdsaAllShared->DOPNRJT_RTRY_TMO
2138*4e1bc9a0SAchim Leubner   */
2139*4e1bc9a0SAchim Leubner   tdsaAllShared->DOPNRJT_RTRY_THR = 23438;
2140*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2141*4e1bc9a0SAchim Leubner                              tiRoot,
2142*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2143*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2144*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
2145*4e1bc9a0SAchim Leubner                              agNULL,
2146*4e1bc9a0SAchim Leubner                              agNULL,
2147*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2148*4e1bc9a0SAchim Leubner                              "SAS_DOPNRJT_RTRY_THR", /* valueName */
2149*4e1bc9a0SAchim Leubner                              buffer,
2150*4e1bc9a0SAchim Leubner                              buffLen,
2151*4e1bc9a0SAchim Leubner                              &lenRecv
2152*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2153*4e1bc9a0SAchim Leubner   {
2154*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2155*4e1bc9a0SAchim Leubner     {
2156*4e1bc9a0SAchim Leubner       tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
2157*4e1bc9a0SAchim Leubner     }
2158*4e1bc9a0SAchim Leubner     else
2159*4e1bc9a0SAchim Leubner     {
2160*4e1bc9a0SAchim Leubner       tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
2161*4e1bc9a0SAchim Leubner     }
2162*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_THR %d\n", tdsaAllShared->DOPNRJT_RTRY_THR));
2163*4e1bc9a0SAchim Leubner   }
2164*4e1bc9a0SAchim Leubner   /* End  DOPNRJT_RTRY_THR */
2165*4e1bc9a0SAchim Leubner 
2166*4e1bc9a0SAchim Leubner   /* Start COPNRJT_RTRY_THR */
2167*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2168*4e1bc9a0SAchim Leubner   lenRecv = 0;
2169*4e1bc9a0SAchim Leubner //  tdsaAllShared->COPNRJT_RTRY_THR = 1024; /* FW default */
2170*4e1bc9a0SAchim Leubner   /*
2171*4e1bc9a0SAchim Leubner     Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second.
2172*4e1bc9a0SAchim Leubner     Assuming a bigger value 3 second, 3000000/128 =  23437.5 where 128 is tdsaAllShared->COPNRJT_RTRY_TMO
2173*4e1bc9a0SAchim Leubner   */
2174*4e1bc9a0SAchim Leubner   tdsaAllShared->COPNRJT_RTRY_THR = 23438;
2175*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2176*4e1bc9a0SAchim Leubner                              tiRoot,
2177*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2178*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2179*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
2180*4e1bc9a0SAchim Leubner                              agNULL,
2181*4e1bc9a0SAchim Leubner                              agNULL,
2182*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2183*4e1bc9a0SAchim Leubner                              "SAS_COPNRJT_RTRY_THR", /* valueName */
2184*4e1bc9a0SAchim Leubner                              buffer,
2185*4e1bc9a0SAchim Leubner                              buffLen,
2186*4e1bc9a0SAchim Leubner                              &lenRecv
2187*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2188*4e1bc9a0SAchim Leubner   {
2189*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2190*4e1bc9a0SAchim Leubner     {
2191*4e1bc9a0SAchim Leubner       tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
2192*4e1bc9a0SAchim Leubner     }
2193*4e1bc9a0SAchim Leubner     else
2194*4e1bc9a0SAchim Leubner     {
2195*4e1bc9a0SAchim Leubner       tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
2196*4e1bc9a0SAchim Leubner     }
2197*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_THR %d\n", tdsaAllShared->COPNRJT_RTRY_THR));
2198*4e1bc9a0SAchim Leubner   }
2199*4e1bc9a0SAchim Leubner   /* End  COPNRJT_RTRY_THR */
2200*4e1bc9a0SAchim Leubner 
2201*4e1bc9a0SAchim Leubner   /* Start MAX_AIP */
2202*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2203*4e1bc9a0SAchim Leubner   lenRecv = 0;
2204*4e1bc9a0SAchim Leubner   tdsaAllShared->MAX_AIP = 0x200000;
2205*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2206*4e1bc9a0SAchim Leubner                              tiRoot,
2207*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2208*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2209*4e1bc9a0SAchim Leubner                              agNULL,/* subkey2 */
2210*4e1bc9a0SAchim Leubner                              agNULL,
2211*4e1bc9a0SAchim Leubner                              agNULL,
2212*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2213*4e1bc9a0SAchim Leubner                              "SAS_MAX_AIP", /* valueName */
2214*4e1bc9a0SAchim Leubner                              buffer,
2215*4e1bc9a0SAchim Leubner                              buffLen,
2216*4e1bc9a0SAchim Leubner                              &lenRecv
2217*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2218*4e1bc9a0SAchim Leubner   {
2219*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2220*4e1bc9a0SAchim Leubner     {
2221*4e1bc9a0SAchim Leubner       tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 0);
2222*4e1bc9a0SAchim Leubner     }
2223*4e1bc9a0SAchim Leubner     else
2224*4e1bc9a0SAchim Leubner     {
2225*4e1bc9a0SAchim Leubner       tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 10);
2226*4e1bc9a0SAchim Leubner     }
2227*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetSwConfigParams: MAX_AIP %d\n", tdsaAllShared->MAX_AIP));
2228*4e1bc9a0SAchim Leubner   }
2229*4e1bc9a0SAchim Leubner   /* End  MAX_AIP */
2230*4e1bc9a0SAchim Leubner 
2231*4e1bc9a0SAchim Leubner   /***********************************************************************/
2232*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2233*4e1bc9a0SAchim Leubner   lenRecv = 0;
2234*4e1bc9a0SAchim Leubner 
2235*4e1bc9a0SAchim Leubner 
2236*4e1bc9a0SAchim Leubner     /*
2237*4e1bc9a0SAchim Leubner     typedef struct agsaMPIContext_s
2238*4e1bc9a0SAchim Leubner     {
2239*4e1bc9a0SAchim Leubner       bit32   MPITableType;
2240*4e1bc9a0SAchim Leubner       bit32   offset;
2241*4e1bc9a0SAchim Leubner       bit32   value;
2242*4e1bc9a0SAchim Leubner     } agsaMPIContext_t;
2243*4e1bc9a0SAchim Leubner     */
2244*4e1bc9a0SAchim Leubner 
2245*4e1bc9a0SAchim Leubner   {
2246*4e1bc9a0SAchim Leubner     bit32 MpiContextvalue  = 0;
2247*4e1bc9a0SAchim Leubner     SwConfig->mpiContextTable = agNULL;
2248*4e1bc9a0SAchim Leubner     SwConfig->mpiContextTablelen = 0;
2249*4e1bc9a0SAchim Leubner 
2250*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam(
2251*4e1bc9a0SAchim Leubner                                tiRoot,
2252*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2253*4e1bc9a0SAchim Leubner                                SwParmsStr,  /* subkey1 */
2254*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2255*4e1bc9a0SAchim Leubner                                agNULL,
2256*4e1bc9a0SAchim Leubner                                agNULL,
2257*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2258*4e1bc9a0SAchim Leubner                                "MpiContext", /* valueName */
2259*4e1bc9a0SAchim Leubner                                buffer,
2260*4e1bc9a0SAchim Leubner                                buffLen,
2261*4e1bc9a0SAchim Leubner                                &lenRecv
2262*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
2263*4e1bc9a0SAchim Leubner     {
2264*4e1bc9a0SAchim Leubner 
2265*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
2266*4e1bc9a0SAchim Leubner       {
2267*4e1bc9a0SAchim Leubner         MpiContextvalue = osti_strtoul (buffer, &pLastUsedChar, 0);
2268*4e1bc9a0SAchim Leubner       }
2269*4e1bc9a0SAchim Leubner       else
2270*4e1bc9a0SAchim Leubner       {
2271*4e1bc9a0SAchim Leubner         MpiContextvalue =  osti_strtoul (buffer, &pLastUsedChar, 10);
2272*4e1bc9a0SAchim Leubner       }
2273*4e1bc9a0SAchim Leubner 
2274*4e1bc9a0SAchim Leubner 
2275*4e1bc9a0SAchim Leubner       if (MpiContextvalue  == 0)
2276*4e1bc9a0SAchim Leubner       {
2277*4e1bc9a0SAchim Leubner         SwConfig->mpiContextTable = agNULL;
2278*4e1bc9a0SAchim Leubner         SwConfig->mpiContextTablelen = 0;
2279*4e1bc9a0SAchim Leubner       }
2280*4e1bc9a0SAchim Leubner       else
2281*4e1bc9a0SAchim Leubner       {
2282*4e1bc9a0SAchim Leubner         tdsaRoot_t    *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2283*4e1bc9a0SAchim Leubner         if(agNULL != tdsaRoot)
2284*4e1bc9a0SAchim Leubner         {
2285*4e1bc9a0SAchim Leubner           tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = 0xFF;
2286*4e1bc9a0SAchim Leubner           tdsaRoot->tdsaAllShared.MpiOverride.offset = 0;
2287*4e1bc9a0SAchim Leubner           tdsaRoot->tdsaAllShared.MpiOverride.value = 0;
2288*4e1bc9a0SAchim Leubner 
2289*4e1bc9a0SAchim Leubner           SwConfig->mpiContextTable = &(tdsaRoot->tdsaAllShared.MpiOverride);
2290*4e1bc9a0SAchim Leubner           SwConfig->mpiContextTablelen = sizeof(agsaMPIContext_t);
2291*4e1bc9a0SAchim Leubner         }
2292*4e1bc9a0SAchim Leubner 
2293*4e1bc9a0SAchim Leubner         TI_DBG1(("tdsaGetSwConfigParams: MpiContext %p Len %d\n", SwConfig->mpiContextTable, SwConfig->mpiContextTablelen));
2294*4e1bc9a0SAchim Leubner 
2295*4e1bc9a0SAchim Leubner       }
2296*4e1bc9a0SAchim Leubner     }
2297*4e1bc9a0SAchim Leubner 
2298*4e1bc9a0SAchim Leubner     if(SwConfig->mpiContextTable != agNULL )
2299*4e1bc9a0SAchim Leubner     {
2300*4e1bc9a0SAchim Leubner       tdsaRoot_t    *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2301*4e1bc9a0SAchim Leubner       if(agNULL != tdsaRoot)
2302*4e1bc9a0SAchim Leubner       {
2303*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2304*4e1bc9a0SAchim Leubner                                    tiRoot,
2305*4e1bc9a0SAchim Leubner                                    globalStr,   /* key */
2306*4e1bc9a0SAchim Leubner                                    SwParmsStr,  /* subkey1 */
2307*4e1bc9a0SAchim Leubner                                    agNULL,      /* subkey2 */
2308*4e1bc9a0SAchim Leubner                                    agNULL,
2309*4e1bc9a0SAchim Leubner                                    agNULL,
2310*4e1bc9a0SAchim Leubner                                    agNULL,      /* subkey5 */
2311*4e1bc9a0SAchim Leubner                                    "MpiTableType", /* valueName */
2312*4e1bc9a0SAchim Leubner                                    buffer,
2313*4e1bc9a0SAchim Leubner                                    buffLen,
2314*4e1bc9a0SAchim Leubner                                    &lenRecv
2315*4e1bc9a0SAchim Leubner                                    ) == tiSuccess) && (lenRecv != 0))
2316*4e1bc9a0SAchim Leubner         {
2317*4e1bc9a0SAchim Leubner           if (osti_strncmp(buffer, "0x", 2) == 0)
2318*4e1bc9a0SAchim Leubner           {
2319*4e1bc9a0SAchim Leubner             tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = osti_strtoul (buffer, &pLastUsedChar, 0);
2320*4e1bc9a0SAchim Leubner           }
2321*4e1bc9a0SAchim Leubner           else
2322*4e1bc9a0SAchim Leubner           {
2323*4e1bc9a0SAchim Leubner             tdsaRoot->tdsaAllShared.MpiOverride.MPITableType =  osti_strtoul (buffer, &pLastUsedChar, 10);
2324*4e1bc9a0SAchim Leubner           }
2325*4e1bc9a0SAchim Leubner         TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.MPITableType  0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.MPITableType ));
2326*4e1bc9a0SAchim Leubner         }
2327*4e1bc9a0SAchim Leubner 
2328*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2329*4e1bc9a0SAchim Leubner                                    tiRoot,
2330*4e1bc9a0SAchim Leubner                                    globalStr,   /* key */
2331*4e1bc9a0SAchim Leubner                                    SwParmsStr,  /* subkey1 */
2332*4e1bc9a0SAchim Leubner                                    agNULL,      /* subkey2 */
2333*4e1bc9a0SAchim Leubner                                    agNULL,
2334*4e1bc9a0SAchim Leubner                                    agNULL,
2335*4e1bc9a0SAchim Leubner                                    agNULL,      /* subkey5 */
2336*4e1bc9a0SAchim Leubner                                    "MpiTableOffset", /* valueName */
2337*4e1bc9a0SAchim Leubner                                    buffer,
2338*4e1bc9a0SAchim Leubner                                    buffLen,
2339*4e1bc9a0SAchim Leubner                                    &lenRecv
2340*4e1bc9a0SAchim Leubner                                    ) == tiSuccess) && (lenRecv != 0))
2341*4e1bc9a0SAchim Leubner         {
2342*4e1bc9a0SAchim Leubner           if (osti_strncmp(buffer, "0x", 2) == 0)
2343*4e1bc9a0SAchim Leubner           {
2344*4e1bc9a0SAchim Leubner             tdsaRoot->tdsaAllShared.MpiOverride.offset = osti_strtoul (buffer, &pLastUsedChar, 0);
2345*4e1bc9a0SAchim Leubner           }
2346*4e1bc9a0SAchim Leubner           else
2347*4e1bc9a0SAchim Leubner           {
2348*4e1bc9a0SAchim Leubner             tdsaRoot->tdsaAllShared.MpiOverride.offset =  osti_strtoul (buffer, &pLastUsedChar, 10);
2349*4e1bc9a0SAchim Leubner           }
2350*4e1bc9a0SAchim Leubner 
2351*4e1bc9a0SAchim Leubner         TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.offset 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.offset ));
2352*4e1bc9a0SAchim Leubner         }
2353*4e1bc9a0SAchim Leubner 
2354*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2355*4e1bc9a0SAchim Leubner                                    tiRoot,
2356*4e1bc9a0SAchim Leubner                                    globalStr,   /* key */
2357*4e1bc9a0SAchim Leubner                                    SwParmsStr,  /* subkey1 */
2358*4e1bc9a0SAchim Leubner                                    agNULL,      /* subkey2 */
2359*4e1bc9a0SAchim Leubner                                    agNULL,
2360*4e1bc9a0SAchim Leubner                                    agNULL,
2361*4e1bc9a0SAchim Leubner                                    agNULL,      /* subkey5 */
2362*4e1bc9a0SAchim Leubner                                    "MpiTableValue", /* valueName */
2363*4e1bc9a0SAchim Leubner                                    buffer,
2364*4e1bc9a0SAchim Leubner                                    buffLen,
2365*4e1bc9a0SAchim Leubner                                    &lenRecv
2366*4e1bc9a0SAchim Leubner                                    ) == tiSuccess) && (lenRecv != 0))
2367*4e1bc9a0SAchim Leubner         {
2368*4e1bc9a0SAchim Leubner           if (osti_strncmp(buffer, "0x", 2) == 0)
2369*4e1bc9a0SAchim Leubner           {
2370*4e1bc9a0SAchim Leubner             tdsaRoot->tdsaAllShared.MpiOverride.value = osti_strtoul (buffer, &pLastUsedChar, 0);
2371*4e1bc9a0SAchim Leubner           }
2372*4e1bc9a0SAchim Leubner           else
2373*4e1bc9a0SAchim Leubner           {
2374*4e1bc9a0SAchim Leubner             tdsaRoot->tdsaAllShared.MpiOverride.value =  osti_strtoul (buffer, &pLastUsedChar, 10);
2375*4e1bc9a0SAchim Leubner           }
2376*4e1bc9a0SAchim Leubner           TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.value 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.value ));
2377*4e1bc9a0SAchim Leubner         }
2378*4e1bc9a0SAchim Leubner       }
2379*4e1bc9a0SAchim Leubner     }
2380*4e1bc9a0SAchim Leubner   }
2381*4e1bc9a0SAchim Leubner   /***********************************************************************/
2382*4e1bc9a0SAchim Leubner 
2383*4e1bc9a0SAchim Leubner #ifdef SA_ENABLE_PCI_TRIGGER
2384*4e1bc9a0SAchim Leubner 
2385*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2386*4e1bc9a0SAchim Leubner   lenRecv = 0;
2387*4e1bc9a0SAchim Leubner 
2388*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2389*4e1bc9a0SAchim Leubner                              tiRoot,
2390*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2391*4e1bc9a0SAchim Leubner                              SwParmsStr,  /* subkey1 */
2392*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
2393*4e1bc9a0SAchim Leubner                              agNULL,
2394*4e1bc9a0SAchim Leubner                              agNULL,
2395*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2396*4e1bc9a0SAchim Leubner                              "PciTrigger", /* valueName */
2397*4e1bc9a0SAchim Leubner                              buffer,
2398*4e1bc9a0SAchim Leubner                              buffLen,
2399*4e1bc9a0SAchim Leubner                              &lenRecv
2400*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2401*4e1bc9a0SAchim Leubner   {
2402*4e1bc9a0SAchim Leubner 
2403*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2404*4e1bc9a0SAchim Leubner     {
2405*4e1bc9a0SAchim Leubner       SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 0);
2406*4e1bc9a0SAchim Leubner     }
2407*4e1bc9a0SAchim Leubner     else
2408*4e1bc9a0SAchim Leubner     {
2409*4e1bc9a0SAchim Leubner       SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 10);
2410*4e1bc9a0SAchim Leubner     }
2411*4e1bc9a0SAchim Leubner     TI_DBG1(("tdsaGetSwConfigParams: PciTrigger %d\n",SwConfig->PCI_trigger));
2412*4e1bc9a0SAchim Leubner   }
2413*4e1bc9a0SAchim Leubner #endif /* SA_ENABLE_PCI_TRIGGER */
2414*4e1bc9a0SAchim Leubner 
2415*4e1bc9a0SAchim Leubner 
2416*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetSwConfigParams: $$$$$$$$$$$$$$$$$ merge $$$$$$$$$$$$$\n"));
2417*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
2418*4e1bc9a0SAchim Leubner   TI_DBG2(("tdsaGetSwConfigParams: SwConfig->sallDebugLevel %d\n", SwConfig->sallDebugLevel));
2419*4e1bc9a0SAchim Leubner #endif
2420*4e1bc9a0SAchim Leubner 
2421*4e1bc9a0SAchim Leubner #ifdef SA_ENABLE_PCI_TRIGGER
2422*4e1bc9a0SAchim Leubner   TI_DBG1(("tdsaGetSwConfigParams: SwConfig->PCI_trigger  0x%x   0x%x\n",SwConfig->PCI_trigger, tdsaRoot->itdsaIni->tdsaAllShared->SwConfig.PCI_trigger));
2423*4e1bc9a0SAchim Leubner #endif /* SA_ENABLE_PCI_TRIGGER */
2424*4e1bc9a0SAchim Leubner 
2425*4e1bc9a0SAchim Leubner 
2426*4e1bc9a0SAchim Leubner #ifdef AGTIAPI_CTL
2427*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaLoLevelGetResource: SASConnectTimeLimit 0x%x\n",
2428*4e1bc9a0SAchim Leubner            tdsaAllShared->SASConnectTimeLimit));
2429*4e1bc9a0SAchim Leubner #endif
2430*4e1bc9a0SAchim Leubner 
2431*4e1bc9a0SAchim Leubner   return;
2432*4e1bc9a0SAchim Leubner }
2433*4e1bc9a0SAchim Leubner 
2434*4e1bc9a0SAchim Leubner /*****************************************************************************
2435*4e1bc9a0SAchim Leubner *! \brief  tdsaParseLinkRateMode
2436*4e1bc9a0SAchim Leubner *
2437*4e1bc9a0SAchim Leubner *  Purpose:  This function parses link rate and mode.
2438*4e1bc9a0SAchim Leubner *
2439*4e1bc9a0SAchim Leubner *  \param   LinkRate: Link rate specified by user.
2440*4e1bc9a0SAchim Leubner *  \param   Mode: Link rate specified by user.
2441*4e1bc9a0SAchim Leubner *
2442*4e1bc9a0SAchim Leubner *  \return:
2443*4e1bc9a0SAchim Leubner *           Value combined with Linkrate and Mode
2444*4e1bc9a0SAchim Leubner *
2445*4e1bc9a0SAchim Leubner *   \note:
2446*4e1bc9a0SAchim Leubner *
2447*4e1bc9a0SAchim Leubner *****************************************************************************/
2448*4e1bc9a0SAchim Leubner osGLOBAL void
tdsaParseLinkRateMode(tiRoot_t * tiRoot,bit32 index,bit32 LinkRateRead,bit32 ModeRead,bit32 OpticalModeRead,bit32 LinkRate,bit32 Mode,bit32 OpticalMode)2449*4e1bc9a0SAchim Leubner tdsaParseLinkRateMode(
2450*4e1bc9a0SAchim Leubner                       tiRoot_t *tiRoot,
2451*4e1bc9a0SAchim Leubner                       bit32 index,
2452*4e1bc9a0SAchim Leubner                       bit32 LinkRateRead,
2453*4e1bc9a0SAchim Leubner                       bit32 ModeRead,
2454*4e1bc9a0SAchim Leubner                       bit32 OpticalModeRead,
2455*4e1bc9a0SAchim Leubner                       bit32 LinkRate,
2456*4e1bc9a0SAchim Leubner                       bit32 Mode,
2457*4e1bc9a0SAchim Leubner                       bit32 OpticalMode
2458*4e1bc9a0SAchim Leubner                       )
2459*4e1bc9a0SAchim Leubner {
2460*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2461*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
2462*4e1bc9a0SAchim Leubner 
2463*4e1bc9a0SAchim Leubner   TI_DBG3(("tdsaParseLinkRateMode: index 0x%X\n",index));
2464*4e1bc9a0SAchim Leubner   TI_DBG3(("tdsaParseLinkRateMode: LinkRateRead 0x%X    LinkRate 0x%X\n",LinkRateRead,LinkRate));
2465*4e1bc9a0SAchim Leubner   TI_DBG3(("tdsaParseLinkRateMode: ModeRead 0x%X        Mode 0x%X\n",ModeRead,Mode));
2466*4e1bc9a0SAchim Leubner   TI_DBG3(("tdsaParseLinkRateMode: OpticalModeRead 0x%X OpticalMode 0x%X\n",OpticalModeRead,OpticalMode));
2467*4e1bc9a0SAchim Leubner 
2468*4e1bc9a0SAchim Leubner 
2469*4e1bc9a0SAchim Leubner   if (LinkRateRead == agTRUE)
2470*4e1bc9a0SAchim Leubner   {
2471*4e1bc9a0SAchim Leubner     /* link rate */
2472*4e1bc9a0SAchim Leubner     if (LinkRate & 0x1)
2473*4e1bc9a0SAchim Leubner     {
2474*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
2475*4e1bc9a0SAchim Leubner     }
2476*4e1bc9a0SAchim Leubner     if (LinkRate & 0x2)
2477*4e1bc9a0SAchim Leubner     {
2478*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x2;
2479*4e1bc9a0SAchim Leubner     }
2480*4e1bc9a0SAchim Leubner     if (LinkRate & 0x4)
2481*4e1bc9a0SAchim Leubner     {
2482*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x4;
2483*4e1bc9a0SAchim Leubner     }
2484*4e1bc9a0SAchim Leubner     if (LinkRate & 0x8)
2485*4e1bc9a0SAchim Leubner     {
2486*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x8;
2487*4e1bc9a0SAchim Leubner     }
2488*4e1bc9a0SAchim Leubner     if (LinkRate == 0 || LinkRate > 0xF )
2489*4e1bc9a0SAchim Leubner     {
2490*4e1bc9a0SAchim Leubner       /* not allowed, set the rate to default 1.5 G */
2491*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = 0;
2492*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
2493*4e1bc9a0SAchim Leubner       TI_DBG1(("tdsaParseLinkRateMode:  LinkRate == 0 || LinkRate >= 0x%x\n",tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2494*4e1bc9a0SAchim Leubner     }
2495*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaParseLinkRateMode:A index 0x%x LinkRate 0x%x Mode 0x%x\n",index,LinkRate,Mode));
2496*4e1bc9a0SAchim Leubner 
2497*4e1bc9a0SAchim Leubner   }
2498*4e1bc9a0SAchim Leubner 
2499*4e1bc9a0SAchim Leubner   if ( ModeRead == agTRUE)
2500*4e1bc9a0SAchim Leubner   {
2501*4e1bc9a0SAchim Leubner     /* mode */
2502*4e1bc9a0SAchim Leubner     if (Mode & 0x1)
2503*4e1bc9a0SAchim Leubner     {
2504*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x10;
2505*4e1bc9a0SAchim Leubner     }
2506*4e1bc9a0SAchim Leubner     if (Mode & 0x2)
2507*4e1bc9a0SAchim Leubner     {
2508*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x20;
2509*4e1bc9a0SAchim Leubner     }
2510*4e1bc9a0SAchim Leubner     if (Mode == 0 || Mode >= 4 )
2511*4e1bc9a0SAchim Leubner     {
2512*4e1bc9a0SAchim Leubner       /* not allowed, set the mode to default SAS/SATA */
2513*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties & 0xf;
2514*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x30;
2515*4e1bc9a0SAchim Leubner     }
2516*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaParseLinkRateMode:1 index 0x%x Mode 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2517*4e1bc9a0SAchim Leubner   }
2518*4e1bc9a0SAchim Leubner 
2519*4e1bc9a0SAchim Leubner   if ( OpticalModeRead == agTRUE)
2520*4e1bc9a0SAchim Leubner   {
2521*4e1bc9a0SAchim Leubner     /* setting bit20 */
2522*4e1bc9a0SAchim Leubner     agsaRoot_t     *agRoot = &tdsaAllShared->agRootInt;
2523*4e1bc9a0SAchim Leubner 
2524*4e1bc9a0SAchim Leubner     if (OpticalMode == 0)
2525*4e1bc9a0SAchim Leubner     {
2526*4e1bc9a0SAchim Leubner       TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 0  phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2527*4e1bc9a0SAchim Leubner     }
2528*4e1bc9a0SAchim Leubner     else if(OpticalMode == 1)
2529*4e1bc9a0SAchim Leubner     {
2530*4e1bc9a0SAchim Leubner       if(tIsSPCV12or6G(agRoot))
2531*4e1bc9a0SAchim Leubner       {
2532*4e1bc9a0SAchim Leubner         TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 1  phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2533*4e1bc9a0SAchim Leubner         tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
2534*4e1bc9a0SAchim Leubner       }
2535*4e1bc9a0SAchim Leubner       else
2536*4e1bc9a0SAchim Leubner       {
2537*4e1bc9a0SAchim Leubner         tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
2538*4e1bc9a0SAchim Leubner         tdsaAllShared->Ports[index].agPhyConfig.phyProperties &= 0xFFFFFFF0;
2539*4e1bc9a0SAchim Leubner         tdsaAllShared->Ports[index].agPhyConfig.phyProperties |= 0x4;
2540*4e1bc9a0SAchim Leubner       }
2541*4e1bc9a0SAchim Leubner     }
2542*4e1bc9a0SAchim Leubner     else if(OpticalMode == 2 )
2543*4e1bc9a0SAchim Leubner     {
2544*4e1bc9a0SAchim Leubner       if(tIsSPCV12or6G(agRoot))
2545*4e1bc9a0SAchim Leubner       {
2546*4e1bc9a0SAchim Leubner         TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 2  phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2547*4e1bc9a0SAchim Leubner         tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 20);
2548*4e1bc9a0SAchim Leubner       }
2549*4e1bc9a0SAchim Leubner       else
2550*4e1bc9a0SAchim Leubner       {
2551*4e1bc9a0SAchim Leubner         TD_ASSERT(0, "SPC optical mode 2");
2552*4e1bc9a0SAchim Leubner       }
2553*4e1bc9a0SAchim Leubner 
2554*4e1bc9a0SAchim Leubner       TI_DBG1(("tdsaParseLinkRateMode: OpticalMode %d phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2555*4e1bc9a0SAchim Leubner     }
2556*4e1bc9a0SAchim Leubner     else
2557*4e1bc9a0SAchim Leubner     {
2558*4e1bc9a0SAchim Leubner        TI_DBG1(("tdsaParseLinkRateMode: OpticalMode unknown %d  phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2559*4e1bc9a0SAchim Leubner     }
2560*4e1bc9a0SAchim Leubner   }
2561*4e1bc9a0SAchim Leubner   else
2562*4e1bc9a0SAchim Leubner   {
2563*4e1bc9a0SAchim Leubner     TI_DBG1(("tdsaParseLinkRateMode: OpticalMode off phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2564*4e1bc9a0SAchim Leubner   }
2565*4e1bc9a0SAchim Leubner 
2566*4e1bc9a0SAchim Leubner   TI_DBG1(("tdsaParseLinkRateMode: phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2567*4e1bc9a0SAchim Leubner 
2568*4e1bc9a0SAchim Leubner 
2569*4e1bc9a0SAchim Leubner   return;
2570*4e1bc9a0SAchim Leubner }
2571*4e1bc9a0SAchim Leubner 
2572*4e1bc9a0SAchim Leubner 
2573*4e1bc9a0SAchim Leubner /*****************************************************************************
2574*4e1bc9a0SAchim Leubner *! \brief tdsaGetHwConfigParams
2575*4e1bc9a0SAchim Leubner *
2576*4e1bc9a0SAchim Leubner *  Purpose:  This function reads hardware configuration parameters from the
2577*4e1bc9a0SAchim Leubner *            configuration file
2578*4e1bc9a0SAchim Leubner *
2579*4e1bc9a0SAchim Leubner *  \param  tiRoot:            Pointer to driver/port instance.
2580*4e1bc9a0SAchim Leubner *
2581*4e1bc9a0SAchim Leubner *  \return: None
2582*4e1bc9a0SAchim Leubner *
2583*4e1bc9a0SAchim Leubner *  \note -
2584*4e1bc9a0SAchim Leubner *
2585*4e1bc9a0SAchim Leubner *****************************************************************************/
2586*4e1bc9a0SAchim Leubner osGLOBAL void
tdsaGetHwConfigParams(tiRoot_t * tiRoot)2587*4e1bc9a0SAchim Leubner tdsaGetHwConfigParams(
2588*4e1bc9a0SAchim Leubner                       tiRoot_t *tiRoot
2589*4e1bc9a0SAchim Leubner                       )
2590*4e1bc9a0SAchim Leubner {
2591*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2592*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
2593*4e1bc9a0SAchim Leubner   agsaHwConfig_t *HwConfig;
2594*4e1bc9a0SAchim Leubner   char           *buffer;
2595*4e1bc9a0SAchim Leubner   bit32          buffLen;
2596*4e1bc9a0SAchim Leubner   bit32          lenRecv = 0;
2597*4e1bc9a0SAchim Leubner   char           *pLastUsedChar = agNULL;
2598*4e1bc9a0SAchim Leubner   char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
2599*4e1bc9a0SAchim Leubner   char           globalStr[]     = "Global";
2600*4e1bc9a0SAchim Leubner   char           HwParmsStr[]   = "HWParms";
2601*4e1bc9a0SAchim Leubner   char           phyReg[10];
2602*4e1bc9a0SAchim Leubner   int            i,j;
2603*4e1bc9a0SAchim Leubner   agsaPhyAnalogSetupTable_t *phyRegTable;
2604*4e1bc9a0SAchim Leubner 
2605*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetHwConfigParams: start\n"));
2606*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetHwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
2607*4e1bc9a0SAchim Leubner 
2608*4e1bc9a0SAchim Leubner   buffer = tmpBuffer;
2609*4e1bc9a0SAchim Leubner   buffLen = sizeof(tmpBuffer);
2610*4e1bc9a0SAchim Leubner 
2611*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2612*4e1bc9a0SAchim Leubner 
2613*4e1bc9a0SAchim Leubner   HwConfig = (agsaHwConfig_t *)&(tdsaAllShared->HwConfig);
2614*4e1bc9a0SAchim Leubner   phyRegTable = (agsaPhyAnalogSetupTable_t *)&(HwConfig->phyAnalogConfig);
2615*4e1bc9a0SAchim Leubner 
2616*4e1bc9a0SAchim Leubner   osti_memset(HwConfig, 0, sizeof(agsaHwConfig_t));
2617*4e1bc9a0SAchim Leubner 
2618*4e1bc9a0SAchim Leubner   /*
2619*4e1bc9a0SAchim Leubner     just default values
2620*4e1bc9a0SAchim Leubner     and are overwritten later by the configuration file contents
2621*4e1bc9a0SAchim Leubner     turning off hw control interrupt coalescing
2622*4e1bc9a0SAchim Leubner   */
2623*4e1bc9a0SAchim Leubner   tdsaAllShared->FWMaxPorts = DEFAULT_FW_MAX_PORTS; /* 8, applicable only to SPC not to SPCv */
2624*4e1bc9a0SAchim Leubner   HwConfig->phyCount = TD_MAX_NUM_PHYS;
2625*4e1bc9a0SAchim Leubner   HwConfig->hwInterruptCoalescingTimer = 1;
2626*4e1bc9a0SAchim Leubner   HwConfig->hwInterruptCoalescingControl = 0;
2627*4e1bc9a0SAchim Leubner   tdsaAllShared->phyCalibration = 0;
2628*4e1bc9a0SAchim Leubner   HwConfig->hwOption = 0; /* default: PI/CI addresses are 32-bit */
2629*4e1bc9a0SAchim Leubner 
2630*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2631*4e1bc9a0SAchim Leubner   lenRecv = 0;
2632*4e1bc9a0SAchim Leubner 
2633*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2634*4e1bc9a0SAchim Leubner                              tiRoot,
2635*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2636*4e1bc9a0SAchim Leubner                              HwParmsStr,  /* subkey1 */
2637*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
2638*4e1bc9a0SAchim Leubner                              agNULL,
2639*4e1bc9a0SAchim Leubner                              agNULL,
2640*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2641*4e1bc9a0SAchim Leubner                              "HwIntCoalTimer", /* valueName */
2642*4e1bc9a0SAchim Leubner                              buffer,
2643*4e1bc9a0SAchim Leubner                              buffLen,
2644*4e1bc9a0SAchim Leubner                              &lenRecv
2645*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2646*4e1bc9a0SAchim Leubner   {
2647*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2648*4e1bc9a0SAchim Leubner     {
2649*4e1bc9a0SAchim Leubner       HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 0);
2650*4e1bc9a0SAchim Leubner     }
2651*4e1bc9a0SAchim Leubner     else
2652*4e1bc9a0SAchim Leubner     {
2653*4e1bc9a0SAchim Leubner       HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 10);
2654*4e1bc9a0SAchim Leubner     }
2655*4e1bc9a0SAchim Leubner   }
2656*4e1bc9a0SAchim Leubner 
2657*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2658*4e1bc9a0SAchim Leubner   lenRecv = 0;
2659*4e1bc9a0SAchim Leubner 
2660*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2661*4e1bc9a0SAchim Leubner                              tiRoot,
2662*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2663*4e1bc9a0SAchim Leubner                              HwParmsStr,  /* subkey1 */
2664*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
2665*4e1bc9a0SAchim Leubner                              agNULL,
2666*4e1bc9a0SAchim Leubner                              agNULL,
2667*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2668*4e1bc9a0SAchim Leubner                              "HwIntCoalControl", /* valueName */
2669*4e1bc9a0SAchim Leubner                              buffer,
2670*4e1bc9a0SAchim Leubner                              buffLen,
2671*4e1bc9a0SAchim Leubner                              &lenRecv
2672*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2673*4e1bc9a0SAchim Leubner   {
2674*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2675*4e1bc9a0SAchim Leubner     {
2676*4e1bc9a0SAchim Leubner       HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 0);
2677*4e1bc9a0SAchim Leubner     }
2678*4e1bc9a0SAchim Leubner     else
2679*4e1bc9a0SAchim Leubner     {
2680*4e1bc9a0SAchim Leubner       HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 10);
2681*4e1bc9a0SAchim Leubner     }
2682*4e1bc9a0SAchim Leubner   }
2683*4e1bc9a0SAchim Leubner 
2684*4e1bc9a0SAchim Leubner   /* For hwInterruptCoalescingTimer, 0 disables interrrupt, not allowed */
2685*4e1bc9a0SAchim Leubner   if (HwConfig->hwInterruptCoalescingControl == 1 && HwConfig->hwInterruptCoalescingTimer == 0)
2686*4e1bc9a0SAchim Leubner   {
2687*4e1bc9a0SAchim Leubner     HwConfig->hwInterruptCoalescingTimer = 1;
2688*4e1bc9a0SAchim Leubner   }
2689*4e1bc9a0SAchim Leubner 
2690*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2691*4e1bc9a0SAchim Leubner   lenRecv = 0;
2692*4e1bc9a0SAchim Leubner 
2693*4e1bc9a0SAchim Leubner   /* interrupt reassetion field*/
2694*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2695*4e1bc9a0SAchim Leubner                              tiRoot,
2696*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2697*4e1bc9a0SAchim Leubner                              HwParmsStr,  /* subkey1 */
2698*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
2699*4e1bc9a0SAchim Leubner                              agNULL,
2700*4e1bc9a0SAchim Leubner                              agNULL,
2701*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2702*4e1bc9a0SAchim Leubner                              "IntReassertionOpt", /* valueName */
2703*4e1bc9a0SAchim Leubner                              buffer,
2704*4e1bc9a0SAchim Leubner                              buffLen,
2705*4e1bc9a0SAchim Leubner                              &lenRecv
2706*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2707*4e1bc9a0SAchim Leubner   {
2708*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2709*4e1bc9a0SAchim Leubner     {
2710*4e1bc9a0SAchim Leubner       HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 0);
2711*4e1bc9a0SAchim Leubner     }
2712*4e1bc9a0SAchim Leubner     else
2713*4e1bc9a0SAchim Leubner     {
2714*4e1bc9a0SAchim Leubner       HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 10);
2715*4e1bc9a0SAchim Leubner     }
2716*4e1bc9a0SAchim Leubner   }
2717*4e1bc9a0SAchim Leubner 
2718*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2719*4e1bc9a0SAchim Leubner   lenRecv = 0;
2720*4e1bc9a0SAchim Leubner 
2721*4e1bc9a0SAchim Leubner   /* interrupt reassetion field*/
2722*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2723*4e1bc9a0SAchim Leubner                              tiRoot,
2724*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2725*4e1bc9a0SAchim Leubner                              HwParmsStr,  /* subkey1 */
2726*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
2727*4e1bc9a0SAchim Leubner                              agNULL,
2728*4e1bc9a0SAchim Leubner                              agNULL,
2729*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2730*4e1bc9a0SAchim Leubner                              "HwOption", /* valueName */
2731*4e1bc9a0SAchim Leubner                              buffer,
2732*4e1bc9a0SAchim Leubner                              buffLen,
2733*4e1bc9a0SAchim Leubner                              &lenRecv
2734*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2735*4e1bc9a0SAchim Leubner   {
2736*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2737*4e1bc9a0SAchim Leubner     {
2738*4e1bc9a0SAchim Leubner       HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 0);
2739*4e1bc9a0SAchim Leubner     }
2740*4e1bc9a0SAchim Leubner     else
2741*4e1bc9a0SAchim Leubner     {
2742*4e1bc9a0SAchim Leubner       HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 10);
2743*4e1bc9a0SAchim Leubner     }
2744*4e1bc9a0SAchim Leubner   }
2745*4e1bc9a0SAchim Leubner 
2746*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2747*4e1bc9a0SAchim Leubner   lenRecv = 0;
2748*4e1bc9a0SAchim Leubner 
2749*4e1bc9a0SAchim Leubner   /* interrupt reassetion field*/
2750*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2751*4e1bc9a0SAchim Leubner                              tiRoot,
2752*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2753*4e1bc9a0SAchim Leubner                              HwParmsStr,  /* subkey1 */
2754*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
2755*4e1bc9a0SAchim Leubner                              agNULL,
2756*4e1bc9a0SAchim Leubner                              agNULL,
2757*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2758*4e1bc9a0SAchim Leubner                              "MaxFWPorts", /* valueName */
2759*4e1bc9a0SAchim Leubner                              buffer,
2760*4e1bc9a0SAchim Leubner                              buffLen,
2761*4e1bc9a0SAchim Leubner                              &lenRecv
2762*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2763*4e1bc9a0SAchim Leubner   {
2764*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2765*4e1bc9a0SAchim Leubner     {
2766*4e1bc9a0SAchim Leubner       tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 0);
2767*4e1bc9a0SAchim Leubner     }
2768*4e1bc9a0SAchim Leubner     else
2769*4e1bc9a0SAchim Leubner     {
2770*4e1bc9a0SAchim Leubner       tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 10);
2771*4e1bc9a0SAchim Leubner     }
2772*4e1bc9a0SAchim Leubner   }
2773*4e1bc9a0SAchim Leubner 
2774*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2775*4e1bc9a0SAchim Leubner   lenRecv = 0;
2776*4e1bc9a0SAchim Leubner 
2777*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam(
2778*4e1bc9a0SAchim Leubner                              tiRoot,
2779*4e1bc9a0SAchim Leubner                              globalStr,   /* key */
2780*4e1bc9a0SAchim Leubner                              HwParmsStr,  /* subkey1 */
2781*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey2 */
2782*4e1bc9a0SAchim Leubner                              agNULL,
2783*4e1bc9a0SAchim Leubner                              agNULL,
2784*4e1bc9a0SAchim Leubner                              agNULL,      /* subkey5 */
2785*4e1bc9a0SAchim Leubner                              "phyCalibration", /* valueName */
2786*4e1bc9a0SAchim Leubner                              buffer,
2787*4e1bc9a0SAchim Leubner                              buffLen,
2788*4e1bc9a0SAchim Leubner                              &lenRecv
2789*4e1bc9a0SAchim Leubner                              ) == tiSuccess) && (lenRecv != 0))
2790*4e1bc9a0SAchim Leubner   {
2791*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
2792*4e1bc9a0SAchim Leubner     {
2793*4e1bc9a0SAchim Leubner       tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 0);
2794*4e1bc9a0SAchim Leubner     }
2795*4e1bc9a0SAchim Leubner     else
2796*4e1bc9a0SAchim Leubner     {
2797*4e1bc9a0SAchim Leubner       tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 10);
2798*4e1bc9a0SAchim Leubner     }
2799*4e1bc9a0SAchim Leubner   }
2800*4e1bc9a0SAchim Leubner 
2801*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
2802*4e1bc9a0SAchim Leubner   lenRecv = 0;
2803*4e1bc9a0SAchim Leubner 
2804*4e1bc9a0SAchim Leubner 
2805*4e1bc9a0SAchim Leubner   /* phy calibration */
2806*4e1bc9a0SAchim Leubner   for (i=0;i<MAX_INDEX;i++)
2807*4e1bc9a0SAchim Leubner   {
2808*4e1bc9a0SAchim Leubner     for(j=0;j<10;j++)
2809*4e1bc9a0SAchim Leubner     {
2810*4e1bc9a0SAchim Leubner       osti_sprintf(phyReg,"spaReg%d%d",i,j);
2811*4e1bc9a0SAchim Leubner       TI_DBG6(("tdsaGetHwConfigParams: phyReg %s\n", phyReg));
2812*4e1bc9a0SAchim Leubner 
2813*4e1bc9a0SAchim Leubner       if (j == 0)
2814*4e1bc9a0SAchim Leubner       {
2815*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2816*4e1bc9a0SAchim Leubner                                tiRoot,
2817*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2818*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
2819*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2820*4e1bc9a0SAchim Leubner                                agNULL,
2821*4e1bc9a0SAchim Leubner                                agNULL,
2822*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2823*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
2824*4e1bc9a0SAchim Leubner                                buffer,
2825*4e1bc9a0SAchim Leubner                                buffLen,
2826*4e1bc9a0SAchim Leubner                                &lenRecv
2827*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
2828*4e1bc9a0SAchim Leubner       {
2829*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
2830*4e1bc9a0SAchim Leubner         {
2831*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 0);
2832*4e1bc9a0SAchim Leubner         }
2833*4e1bc9a0SAchim Leubner         else
2834*4e1bc9a0SAchim Leubner         {
2835*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 10);
2836*4e1bc9a0SAchim Leubner         }
2837*4e1bc9a0SAchim Leubner       }
2838*4e1bc9a0SAchim Leubner 
2839*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
2840*4e1bc9a0SAchim Leubner       lenRecv = 0;
2841*4e1bc9a0SAchim Leubner       }
2842*4e1bc9a0SAchim Leubner       else if (j == 1)
2843*4e1bc9a0SAchim Leubner       {
2844*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2845*4e1bc9a0SAchim Leubner                                tiRoot,
2846*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2847*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
2848*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2849*4e1bc9a0SAchim Leubner                                agNULL,
2850*4e1bc9a0SAchim Leubner                                agNULL,
2851*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2852*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
2853*4e1bc9a0SAchim Leubner                                buffer,
2854*4e1bc9a0SAchim Leubner                                buffLen,
2855*4e1bc9a0SAchim Leubner                                &lenRecv
2856*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
2857*4e1bc9a0SAchim Leubner       {
2858*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
2859*4e1bc9a0SAchim Leubner         {
2860*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 0);
2861*4e1bc9a0SAchim Leubner         }
2862*4e1bc9a0SAchim Leubner         else
2863*4e1bc9a0SAchim Leubner         {
2864*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 10);
2865*4e1bc9a0SAchim Leubner         }
2866*4e1bc9a0SAchim Leubner       }
2867*4e1bc9a0SAchim Leubner 
2868*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
2869*4e1bc9a0SAchim Leubner       lenRecv = 0;
2870*4e1bc9a0SAchim Leubner       }
2871*4e1bc9a0SAchim Leubner       else if (j == 2)
2872*4e1bc9a0SAchim Leubner       {
2873*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2874*4e1bc9a0SAchim Leubner                                tiRoot,
2875*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2876*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
2877*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2878*4e1bc9a0SAchim Leubner                                agNULL,
2879*4e1bc9a0SAchim Leubner                                agNULL,
2880*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2881*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
2882*4e1bc9a0SAchim Leubner                                buffer,
2883*4e1bc9a0SAchim Leubner                                buffLen,
2884*4e1bc9a0SAchim Leubner                                &lenRecv
2885*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
2886*4e1bc9a0SAchim Leubner       {
2887*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
2888*4e1bc9a0SAchim Leubner         {
2889*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 0);
2890*4e1bc9a0SAchim Leubner         }
2891*4e1bc9a0SAchim Leubner         else
2892*4e1bc9a0SAchim Leubner         {
2893*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 10);
2894*4e1bc9a0SAchim Leubner         }
2895*4e1bc9a0SAchim Leubner       }
2896*4e1bc9a0SAchim Leubner 
2897*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
2898*4e1bc9a0SAchim Leubner       lenRecv = 0;
2899*4e1bc9a0SAchim Leubner       }
2900*4e1bc9a0SAchim Leubner       else if (j == 3)
2901*4e1bc9a0SAchim Leubner       {
2902*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2903*4e1bc9a0SAchim Leubner                                tiRoot,
2904*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2905*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
2906*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2907*4e1bc9a0SAchim Leubner                                agNULL,
2908*4e1bc9a0SAchim Leubner                                agNULL,
2909*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2910*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
2911*4e1bc9a0SAchim Leubner                                buffer,
2912*4e1bc9a0SAchim Leubner                                buffLen,
2913*4e1bc9a0SAchim Leubner                                &lenRecv
2914*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
2915*4e1bc9a0SAchim Leubner       {
2916*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
2917*4e1bc9a0SAchim Leubner         {
2918*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 0);
2919*4e1bc9a0SAchim Leubner         }
2920*4e1bc9a0SAchim Leubner         else
2921*4e1bc9a0SAchim Leubner         {
2922*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 10);
2923*4e1bc9a0SAchim Leubner         }
2924*4e1bc9a0SAchim Leubner       }
2925*4e1bc9a0SAchim Leubner 
2926*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
2927*4e1bc9a0SAchim Leubner       lenRecv = 0;
2928*4e1bc9a0SAchim Leubner       }
2929*4e1bc9a0SAchim Leubner       else if (j == 4)
2930*4e1bc9a0SAchim Leubner       {
2931*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2932*4e1bc9a0SAchim Leubner                                tiRoot,
2933*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2934*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
2935*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2936*4e1bc9a0SAchim Leubner                                agNULL,
2937*4e1bc9a0SAchim Leubner                                agNULL,
2938*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2939*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
2940*4e1bc9a0SAchim Leubner                                buffer,
2941*4e1bc9a0SAchim Leubner                                buffLen,
2942*4e1bc9a0SAchim Leubner                                &lenRecv
2943*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
2944*4e1bc9a0SAchim Leubner       {
2945*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
2946*4e1bc9a0SAchim Leubner         {
2947*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 0);
2948*4e1bc9a0SAchim Leubner         }
2949*4e1bc9a0SAchim Leubner         else
2950*4e1bc9a0SAchim Leubner         {
2951*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 10);
2952*4e1bc9a0SAchim Leubner         }
2953*4e1bc9a0SAchim Leubner       }
2954*4e1bc9a0SAchim Leubner 
2955*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
2956*4e1bc9a0SAchim Leubner       lenRecv = 0;
2957*4e1bc9a0SAchim Leubner       }
2958*4e1bc9a0SAchim Leubner       else if (j == 5)
2959*4e1bc9a0SAchim Leubner       {
2960*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2961*4e1bc9a0SAchim Leubner                                tiRoot,
2962*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2963*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
2964*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2965*4e1bc9a0SAchim Leubner                                agNULL,
2966*4e1bc9a0SAchim Leubner                                agNULL,
2967*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2968*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
2969*4e1bc9a0SAchim Leubner                                buffer,
2970*4e1bc9a0SAchim Leubner                                buffLen,
2971*4e1bc9a0SAchim Leubner                                &lenRecv
2972*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
2973*4e1bc9a0SAchim Leubner       {
2974*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
2975*4e1bc9a0SAchim Leubner         {
2976*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 0);
2977*4e1bc9a0SAchim Leubner         }
2978*4e1bc9a0SAchim Leubner         else
2979*4e1bc9a0SAchim Leubner         {
2980*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 10);
2981*4e1bc9a0SAchim Leubner         }
2982*4e1bc9a0SAchim Leubner       }
2983*4e1bc9a0SAchim Leubner 
2984*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
2985*4e1bc9a0SAchim Leubner       lenRecv = 0;
2986*4e1bc9a0SAchim Leubner       }
2987*4e1bc9a0SAchim Leubner       else if (j == 6)
2988*4e1bc9a0SAchim Leubner       {
2989*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
2990*4e1bc9a0SAchim Leubner                                tiRoot,
2991*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
2992*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
2993*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
2994*4e1bc9a0SAchim Leubner                                agNULL,
2995*4e1bc9a0SAchim Leubner                                agNULL,
2996*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
2997*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
2998*4e1bc9a0SAchim Leubner                                buffer,
2999*4e1bc9a0SAchim Leubner                                buffLen,
3000*4e1bc9a0SAchim Leubner                                &lenRecv
3001*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
3002*4e1bc9a0SAchim Leubner       {
3003*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
3004*4e1bc9a0SAchim Leubner         {
3005*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 0);
3006*4e1bc9a0SAchim Leubner         }
3007*4e1bc9a0SAchim Leubner         else
3008*4e1bc9a0SAchim Leubner         {
3009*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 10);
3010*4e1bc9a0SAchim Leubner         }
3011*4e1bc9a0SAchim Leubner       }
3012*4e1bc9a0SAchim Leubner 
3013*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
3014*4e1bc9a0SAchim Leubner       lenRecv = 0;
3015*4e1bc9a0SAchim Leubner       }
3016*4e1bc9a0SAchim Leubner       else if (j == 7)
3017*4e1bc9a0SAchim Leubner       {
3018*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
3019*4e1bc9a0SAchim Leubner                                tiRoot,
3020*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
3021*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
3022*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
3023*4e1bc9a0SAchim Leubner                                agNULL,
3024*4e1bc9a0SAchim Leubner                                agNULL,
3025*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
3026*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
3027*4e1bc9a0SAchim Leubner                                buffer,
3028*4e1bc9a0SAchim Leubner                                buffLen,
3029*4e1bc9a0SAchim Leubner                                &lenRecv
3030*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
3031*4e1bc9a0SAchim Leubner       {
3032*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
3033*4e1bc9a0SAchim Leubner         {
3034*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 0);
3035*4e1bc9a0SAchim Leubner         }
3036*4e1bc9a0SAchim Leubner         else
3037*4e1bc9a0SAchim Leubner         {
3038*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 10);
3039*4e1bc9a0SAchim Leubner         }
3040*4e1bc9a0SAchim Leubner       }
3041*4e1bc9a0SAchim Leubner 
3042*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
3043*4e1bc9a0SAchim Leubner       lenRecv = 0;
3044*4e1bc9a0SAchim Leubner       }
3045*4e1bc9a0SAchim Leubner       else if (j == 8)
3046*4e1bc9a0SAchim Leubner       {
3047*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
3048*4e1bc9a0SAchim Leubner                                tiRoot,
3049*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
3050*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
3051*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
3052*4e1bc9a0SAchim Leubner                                agNULL,
3053*4e1bc9a0SAchim Leubner                                agNULL,
3054*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
3055*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
3056*4e1bc9a0SAchim Leubner                                buffer,
3057*4e1bc9a0SAchim Leubner                                buffLen,
3058*4e1bc9a0SAchim Leubner                                &lenRecv
3059*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
3060*4e1bc9a0SAchim Leubner       {
3061*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
3062*4e1bc9a0SAchim Leubner         {
3063*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 0);
3064*4e1bc9a0SAchim Leubner         }
3065*4e1bc9a0SAchim Leubner         else
3066*4e1bc9a0SAchim Leubner         {
3067*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 10);
3068*4e1bc9a0SAchim Leubner         }
3069*4e1bc9a0SAchim Leubner       }
3070*4e1bc9a0SAchim Leubner 
3071*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
3072*4e1bc9a0SAchim Leubner       lenRecv = 0;
3073*4e1bc9a0SAchim Leubner       }
3074*4e1bc9a0SAchim Leubner       else if (j == 9)
3075*4e1bc9a0SAchim Leubner       {
3076*4e1bc9a0SAchim Leubner         if ((ostiGetTransportParam(
3077*4e1bc9a0SAchim Leubner                                tiRoot,
3078*4e1bc9a0SAchim Leubner                                globalStr,   /* key */
3079*4e1bc9a0SAchim Leubner                                HwParmsStr,  /* subkey1 */
3080*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey2 */
3081*4e1bc9a0SAchim Leubner                                agNULL,
3082*4e1bc9a0SAchim Leubner                                agNULL,
3083*4e1bc9a0SAchim Leubner                                agNULL,      /* subkey5 */
3084*4e1bc9a0SAchim Leubner                                phyReg, /* valueName */
3085*4e1bc9a0SAchim Leubner                                buffer,
3086*4e1bc9a0SAchim Leubner                                buffLen,
3087*4e1bc9a0SAchim Leubner                                &lenRecv
3088*4e1bc9a0SAchim Leubner                                ) == tiSuccess) && (lenRecv != 0))
3089*4e1bc9a0SAchim Leubner       {
3090*4e1bc9a0SAchim Leubner         if (osti_strncmp(buffer, "0x", 2) == 0)
3091*4e1bc9a0SAchim Leubner         {
3092*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 0);
3093*4e1bc9a0SAchim Leubner         }
3094*4e1bc9a0SAchim Leubner         else
3095*4e1bc9a0SAchim Leubner         {
3096*4e1bc9a0SAchim Leubner           phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 10);
3097*4e1bc9a0SAchim Leubner         }
3098*4e1bc9a0SAchim Leubner       }
3099*4e1bc9a0SAchim Leubner 
3100*4e1bc9a0SAchim Leubner       osti_memset(buffer, 0, buffLen);
3101*4e1bc9a0SAchim Leubner       lenRecv = 0;
3102*4e1bc9a0SAchim Leubner       }
3103*4e1bc9a0SAchim Leubner 
3104*4e1bc9a0SAchim Leubner     } /* inner loop */
3105*4e1bc9a0SAchim Leubner   } /* outer loop */
3106*4e1bc9a0SAchim Leubner   return;
3107*4e1bc9a0SAchim Leubner }
3108*4e1bc9a0SAchim Leubner /*****************************************************************************
3109*4e1bc9a0SAchim Leubner *! \brief tdsaGetCardPhyParams
3110*4e1bc9a0SAchim Leubner *
3111*4e1bc9a0SAchim Leubner *  Purpose:  This function reads phy-related configuration parameters from the
3112*4e1bc9a0SAchim Leubner *            configuration file
3113*4e1bc9a0SAchim Leubner *
3114*4e1bc9a0SAchim Leubner *  \param  tiRoot:            Pointer to driver/port instance.
3115*4e1bc9a0SAchim Leubner *
3116*4e1bc9a0SAchim Leubner *  \return: None
3117*4e1bc9a0SAchim Leubner *
3118*4e1bc9a0SAchim Leubner *  \note - just a place holder for now
3119*4e1bc9a0SAchim Leubner *
3120*4e1bc9a0SAchim Leubner *****************************************************************************/
3121*4e1bc9a0SAchim Leubner osGLOBAL void
tdsaGetCardPhyParams(tiRoot_t * tiRoot)3122*4e1bc9a0SAchim Leubner tdsaGetCardPhyParams(
3123*4e1bc9a0SAchim Leubner                  tiRoot_t *tiRoot
3124*4e1bc9a0SAchim Leubner                  )
3125*4e1bc9a0SAchim Leubner {
3126*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3127*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3128*4e1bc9a0SAchim Leubner   agsaRoot_t     *agRoot = &tdsaAllShared->agRootInt;
3129*4e1bc9a0SAchim Leubner   char           *buffer;
3130*4e1bc9a0SAchim Leubner   bit32          buffLen;
3131*4e1bc9a0SAchim Leubner   bit32          lenRecv = 0;
3132*4e1bc9a0SAchim Leubner   char           *pLastUsedChar = agNULL;
3133*4e1bc9a0SAchim Leubner   char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3134*4e1bc9a0SAchim Leubner   char           *globalStr = tdsaAllShared->CardIDString;
3135*4e1bc9a0SAchim Leubner   char           phyParmsStr[12];
3136*4e1bc9a0SAchim Leubner   int            i;
3137*4e1bc9a0SAchim Leubner   bit32          LinkRate = 15, Mode = 3, OpticalMode = 0; //VG
3138*4e1bc9a0SAchim Leubner   bit32          LinkRateRead = agTRUE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
3139*4e1bc9a0SAchim Leubner   bit32          flag = agFALSE; /* true only for PM8008 or PM8009 (SPCv and SPCve) controller */
3140*4e1bc9a0SAchim Leubner 
3141*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetCardPhyParams: start \n"));
3142*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetCardPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3143*4e1bc9a0SAchim Leubner 
3144*4e1bc9a0SAchim Leubner   if (tiIS_8PHY(agRoot))
3145*4e1bc9a0SAchim Leubner   {
3146*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetCardPhyParams: SPCv or SPCve \n"));
3147*4e1bc9a0SAchim Leubner     flag = agTRUE;
3148*4e1bc9a0SAchim Leubner   }
3149*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetCardPhyParams: flag %d\n", flag));
3150*4e1bc9a0SAchim Leubner 
3151*4e1bc9a0SAchim Leubner #ifdef REMOVED
3152*4e1bc9a0SAchim Leubner #ifdef FPGA_CARD
3153*4e1bc9a0SAchim Leubner   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3154*4e1bc9a0SAchim Leubner   {
3155*4e1bc9a0SAchim Leubner     /* setting default phy properties */
3156*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3157*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3158*4e1bc9a0SAchim Leubner     /* 1.5G only, SAS/SATA, no spin-up control */
3159*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 */
3160*4e1bc9a0SAchim Leubner   }
3161*4e1bc9a0SAchim Leubner #else
3162*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
3163*4e1bc9a0SAchim Leubner   /* ASIC */
3164*4e1bc9a0SAchim Leubner   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3165*4e1bc9a0SAchim Leubner   {
3166*4e1bc9a0SAchim Leubner     /* setting default phy properties */
3167*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3168*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3169*4e1bc9a0SAchim Leubner     /* 1.5G/3G , SAS/SATA, no spin-up control */
3170*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37; /* 55 */
3171*4e1bc9a0SAchim Leubner     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))));
3172*4e1bc9a0SAchim Leubner   }
3173*4e1bc9a0SAchim Leubner #endif
3174*4e1bc9a0SAchim Leubner 
3175*4e1bc9a0SAchim Leubner #ifdef TARGET_DRIVER
3176*4e1bc9a0SAchim Leubner   /* ASIC */
3177*4e1bc9a0SAchim Leubner   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3178*4e1bc9a0SAchim Leubner   {
3179*4e1bc9a0SAchim Leubner     /* setting default phy properties */
3180*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3181*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3182*4e1bc9a0SAchim Leubner     /* 1.5G/3G , SAS/SATA, no spin-up control */
3183*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37; /* 55 */
3184*4e1bc9a0SAchim Leubner     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))));
3185*4e1bc9a0SAchim Leubner   }
3186*4e1bc9a0SAchim Leubner #endif
3187*4e1bc9a0SAchim Leubner 
3188*4e1bc9a0SAchim Leubner #endif
3189*4e1bc9a0SAchim Leubner #endif /* REMOVED */
3190*4e1bc9a0SAchim Leubner 
3191*4e1bc9a0SAchim Leubner 
3192*4e1bc9a0SAchim Leubner   buffer = tmpBuffer;
3193*4e1bc9a0SAchim Leubner   buffLen = sizeof(tmpBuffer);
3194*4e1bc9a0SAchim Leubner 
3195*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
3196*4e1bc9a0SAchim Leubner   lenRecv = 0;
3197*4e1bc9a0SAchim Leubner 
3198*4e1bc9a0SAchim Leubner   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3199*4e1bc9a0SAchim Leubner   {
3200*4e1bc9a0SAchim Leubner     if (flag == agFALSE)
3201*4e1bc9a0SAchim Leubner     {
3202*4e1bc9a0SAchim Leubner       osti_sprintf(phyParmsStr,"PhyParms%d", i);
3203*4e1bc9a0SAchim Leubner     }
3204*4e1bc9a0SAchim Leubner     else
3205*4e1bc9a0SAchim Leubner     {
3206*4e1bc9a0SAchim Leubner       if (i >= 4)
3207*4e1bc9a0SAchim Leubner       {
3208*4e1bc9a0SAchim Leubner         osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
3209*4e1bc9a0SAchim Leubner       }
3210*4e1bc9a0SAchim Leubner       else
3211*4e1bc9a0SAchim Leubner       {
3212*4e1bc9a0SAchim Leubner         osti_sprintf(phyParmsStr,"PhyParms%d", i);
3213*4e1bc9a0SAchim Leubner       }
3214*4e1bc9a0SAchim Leubner     }
3215*4e1bc9a0SAchim Leubner 
3216*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetCardPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
3217*4e1bc9a0SAchim Leubner 
3218*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3219*4e1bc9a0SAchim Leubner 
3220*4e1bc9a0SAchim Leubner 
3221*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3222*4e1bc9a0SAchim Leubner                                 tiRoot,
3223*4e1bc9a0SAchim Leubner                                 globalStr,
3224*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3225*4e1bc9a0SAchim Leubner                                 agNULL,
3226*4e1bc9a0SAchim Leubner                                 agNULL,
3227*4e1bc9a0SAchim Leubner                                 agNULL,
3228*4e1bc9a0SAchim Leubner                                 agNULL,
3229*4e1bc9a0SAchim Leubner                                 "AddrHi",
3230*4e1bc9a0SAchim Leubner                                 buffer,
3231*4e1bc9a0SAchim Leubner                                 buffLen,
3232*4e1bc9a0SAchim Leubner                                 &lenRecv
3233*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3234*4e1bc9a0SAchim Leubner     {
3235*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3236*4e1bc9a0SAchim Leubner       {
3237*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3238*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3239*4e1bc9a0SAchim Leubner       }
3240*4e1bc9a0SAchim Leubner       else
3241*4e1bc9a0SAchim Leubner       {
3242*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3243*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3244*4e1bc9a0SAchim Leubner       }
3245*4e1bc9a0SAchim Leubner     }
3246*4e1bc9a0SAchim Leubner 
3247*4e1bc9a0SAchim Leubner 
3248*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3249*4e1bc9a0SAchim Leubner     lenRecv = 0;
3250*4e1bc9a0SAchim Leubner 
3251*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3252*4e1bc9a0SAchim Leubner                                 tiRoot,
3253*4e1bc9a0SAchim Leubner                                 globalStr,
3254*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3255*4e1bc9a0SAchim Leubner                                 agNULL,
3256*4e1bc9a0SAchim Leubner                                 agNULL,
3257*4e1bc9a0SAchim Leubner                                 agNULL,
3258*4e1bc9a0SAchim Leubner                                 agNULL,
3259*4e1bc9a0SAchim Leubner                                 "AddrLow",
3260*4e1bc9a0SAchim Leubner                                 buffer,
3261*4e1bc9a0SAchim Leubner                                 buffLen,
3262*4e1bc9a0SAchim Leubner                                 &lenRecv
3263*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3264*4e1bc9a0SAchim Leubner     {
3265*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3266*4e1bc9a0SAchim Leubner       {
3267*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3268*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3269*4e1bc9a0SAchim Leubner       }
3270*4e1bc9a0SAchim Leubner       else
3271*4e1bc9a0SAchim Leubner       {
3272*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3273*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3274*4e1bc9a0SAchim Leubner       }
3275*4e1bc9a0SAchim Leubner     }
3276*4e1bc9a0SAchim Leubner     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))));
3277*4e1bc9a0SAchim Leubner 
3278*4e1bc9a0SAchim Leubner     /* phy properties */
3279*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3280*4e1bc9a0SAchim Leubner     lenRecv = 0;
3281*4e1bc9a0SAchim Leubner /*
3282*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3283*4e1bc9a0SAchim Leubner                                 tiRoot,
3284*4e1bc9a0SAchim Leubner                                 globalStr,
3285*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3286*4e1bc9a0SAchim Leubner                                 agNULL,
3287*4e1bc9a0SAchim Leubner                                 agNULL,
3288*4e1bc9a0SAchim Leubner                                 agNULL,
3289*4e1bc9a0SAchim Leubner                                 agNULL,
3290*4e1bc9a0SAchim Leubner                                 "LinkRate",
3291*4e1bc9a0SAchim Leubner                                 buffer,
3292*4e1bc9a0SAchim Leubner                                 buffLen,
3293*4e1bc9a0SAchim Leubner                                 &lenRecv
3294*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3295*4e1bc9a0SAchim Leubner     {
3296*4e1bc9a0SAchim Leubner       LinkRateRead = agTRUE;
3297*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3298*4e1bc9a0SAchim Leubner       {
3299*4e1bc9a0SAchim Leubner         LinkRate = osti_strtoul(buffer, &pLastUsedChar, 0);
3300*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d linkrate 0x%x \n", i, LinkRate));
3301*4e1bc9a0SAchim Leubner       }
3302*4e1bc9a0SAchim Leubner       else
3303*4e1bc9a0SAchim Leubner       {
3304*4e1bc9a0SAchim Leubner         LinkRate = osti_strtoul(buffer, &pLastUsedChar, 10);
3305*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d linkrate %d \n", i, LinkRate));
3306*4e1bc9a0SAchim Leubner       }
3307*4e1bc9a0SAchim Leubner     }
3308*4e1bc9a0SAchim Leubner 
3309*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetCardPhyParams: phy %d linkrate %d \n", i, LinkRate));
3310*4e1bc9a0SAchim Leubner */
3311*4e1bc9a0SAchim Leubner 
3312*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3313*4e1bc9a0SAchim Leubner     lenRecv = 0;
3314*4e1bc9a0SAchim Leubner 
3315*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3316*4e1bc9a0SAchim Leubner                                 tiRoot,
3317*4e1bc9a0SAchim Leubner                                 globalStr,
3318*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3319*4e1bc9a0SAchim Leubner                                 agNULL,
3320*4e1bc9a0SAchim Leubner                                 agNULL,
3321*4e1bc9a0SAchim Leubner                                 agNULL,
3322*4e1bc9a0SAchim Leubner                                 agNULL,
3323*4e1bc9a0SAchim Leubner                                 "Mode",
3324*4e1bc9a0SAchim Leubner                                 buffer,
3325*4e1bc9a0SAchim Leubner                                 buffLen,
3326*4e1bc9a0SAchim Leubner                                 &lenRecv
3327*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3328*4e1bc9a0SAchim Leubner     {
3329*4e1bc9a0SAchim Leubner       ModeRead = agTRUE;
3330*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3331*4e1bc9a0SAchim Leubner       {
3332*4e1bc9a0SAchim Leubner         Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
3333*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode 0x%x \n", i, Mode));
3334*4e1bc9a0SAchim Leubner       }
3335*4e1bc9a0SAchim Leubner       else
3336*4e1bc9a0SAchim Leubner       {
3337*4e1bc9a0SAchim Leubner         Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
3338*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode %d \n", i, Mode));
3339*4e1bc9a0SAchim Leubner       }
3340*4e1bc9a0SAchim Leubner     }
3341*4e1bc9a0SAchim Leubner 
3342*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3343*4e1bc9a0SAchim Leubner     lenRecv = 0;
3344*4e1bc9a0SAchim Leubner 
3345*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3346*4e1bc9a0SAchim Leubner                                 tiRoot,
3347*4e1bc9a0SAchim Leubner                                 globalStr,
3348*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3349*4e1bc9a0SAchim Leubner                                 agNULL,
3350*4e1bc9a0SAchim Leubner                                 agNULL,
3351*4e1bc9a0SAchim Leubner                                 agNULL,
3352*4e1bc9a0SAchim Leubner                                 agNULL,
3353*4e1bc9a0SAchim Leubner                                 "OpticalMode",
3354*4e1bc9a0SAchim Leubner                                 buffer,
3355*4e1bc9a0SAchim Leubner                                 buffLen,
3356*4e1bc9a0SAchim Leubner                                 &lenRecv
3357*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3358*4e1bc9a0SAchim Leubner     {
3359*4e1bc9a0SAchim Leubner       OpticalModeRead = agTRUE;
3360*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3361*4e1bc9a0SAchim Leubner       {
3362*4e1bc9a0SAchim Leubner         OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
3363*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
3364*4e1bc9a0SAchim Leubner       }
3365*4e1bc9a0SAchim Leubner       else
3366*4e1bc9a0SAchim Leubner       {
3367*4e1bc9a0SAchim Leubner         OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
3368*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
3369*4e1bc9a0SAchim Leubner       }
3370*4e1bc9a0SAchim Leubner     }
3371*4e1bc9a0SAchim Leubner 
3372*4e1bc9a0SAchim Leubner     tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
3373*4e1bc9a0SAchim Leubner 
3374*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3375*4e1bc9a0SAchim Leubner 
3376*4e1bc9a0SAchim Leubner 
3377*4e1bc9a0SAchim Leubner     /**********************************************/
3378*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3379*4e1bc9a0SAchim Leubner     lenRecv = 0;
3380*4e1bc9a0SAchim Leubner     LinkRateRead = agTRUE;//VG
3381*4e1bc9a0SAchim Leubner     ModeRead = agFALSE;
3382*4e1bc9a0SAchim Leubner     OpticalModeRead = agFALSE;
3383*4e1bc9a0SAchim Leubner 
3384*4e1bc9a0SAchim Leubner   } /* end for */
3385*4e1bc9a0SAchim Leubner   return;
3386*4e1bc9a0SAchim Leubner }
3387*4e1bc9a0SAchim Leubner 
3388*4e1bc9a0SAchim Leubner 
3389*4e1bc9a0SAchim Leubner 
3390*4e1bc9a0SAchim Leubner 
3391*4e1bc9a0SAchim Leubner 
3392*4e1bc9a0SAchim Leubner /*****************************************************************************
3393*4e1bc9a0SAchim Leubner *! \brief tdsaGetGlobalPhyParams
3394*4e1bc9a0SAchim Leubner *
3395*4e1bc9a0SAchim Leubner *  Purpose:  This function reads phy-related configuration parameters from the
3396*4e1bc9a0SAchim Leubner *            configuration file
3397*4e1bc9a0SAchim Leubner *
3398*4e1bc9a0SAchim Leubner *  \param  tiRoot:            Pointer to driver/port instance.
3399*4e1bc9a0SAchim Leubner *
3400*4e1bc9a0SAchim Leubner *  \return: None
3401*4e1bc9a0SAchim Leubner *
3402*4e1bc9a0SAchim Leubner *  \note - just a place holder for now
3403*4e1bc9a0SAchim Leubner *
3404*4e1bc9a0SAchim Leubner *****************************************************************************/
3405*4e1bc9a0SAchim Leubner osGLOBAL void
tdsaGetGlobalPhyParams(tiRoot_t * tiRoot)3406*4e1bc9a0SAchim Leubner tdsaGetGlobalPhyParams(
3407*4e1bc9a0SAchim Leubner                  tiRoot_t *tiRoot
3408*4e1bc9a0SAchim Leubner                  )
3409*4e1bc9a0SAchim Leubner {
3410*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3411*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3412*4e1bc9a0SAchim Leubner   agsaRoot_t     *agRoot = &tdsaAllShared->agRootInt;
3413*4e1bc9a0SAchim Leubner   char           *buffer;
3414*4e1bc9a0SAchim Leubner   bit32          buffLen;
3415*4e1bc9a0SAchim Leubner   bit32          lenRecv = 0;
3416*4e1bc9a0SAchim Leubner   char           *pLastUsedChar = agNULL;
3417*4e1bc9a0SAchim Leubner   char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3418*4e1bc9a0SAchim Leubner   char           globalStr[]     = "Global";
3419*4e1bc9a0SAchim Leubner   char           phyParmsStr[12];
3420*4e1bc9a0SAchim Leubner   int            i;
3421*4e1bc9a0SAchim Leubner   bit32          LinkRate = 15/*7*/, Mode = 3, OpticalMode = 0;
3422*4e1bc9a0SAchim Leubner   bit32          LinkRateRead = agFALSE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
3423*4e1bc9a0SAchim Leubner   bit32          flag = agFALSE; /* true only for PM8008 or PM8009 (SPCv and SPCve) controller */
3424*4e1bc9a0SAchim Leubner 
3425*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetGlobalPhyParams: start \n"));
3426*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetGlobalPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3427*4e1bc9a0SAchim Leubner 
3428*4e1bc9a0SAchim Leubner   if (tiIS_8PHY(agRoot) )
3429*4e1bc9a0SAchim Leubner   {
3430*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetGlobalPhyParams: SPCv or SPCve \n"));
3431*4e1bc9a0SAchim Leubner     flag = agTRUE;
3432*4e1bc9a0SAchim Leubner   }
3433*4e1bc9a0SAchim Leubner 
3434*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetGlobalPhyParams: flag %d\n", flag));
3435*4e1bc9a0SAchim Leubner 
3436*4e1bc9a0SAchim Leubner #ifdef FPGA_CARD
3437*4e1bc9a0SAchim Leubner   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3438*4e1bc9a0SAchim Leubner   {
3439*4e1bc9a0SAchim Leubner     /* setting default phy properties */
3440*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3441*4e1bc9a0SAchim Leubner     OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3442*4e1bc9a0SAchim Leubner     /* 1.5G only, SAS/SATA, no spin-up control */
3443*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 */
3444*4e1bc9a0SAchim Leubner   }
3445*4e1bc9a0SAchim Leubner #else
3446*4e1bc9a0SAchim Leubner   /* ASIC */
3447*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
3448*4e1bc9a0SAchim Leubner   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3449*4e1bc9a0SAchim Leubner   {
3450*4e1bc9a0SAchim Leubner     /* setting default phy properties */
3451*4e1bc9a0SAchim Leubner     if (flag == agFALSE) /* SPC or SPCv+ */
3452*4e1bc9a0SAchim Leubner     {
3453*4e1bc9a0SAchim Leubner       if (0 <= i && i <= 7)
3454*4e1bc9a0SAchim Leubner       {
3455*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3456*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3457*4e1bc9a0SAchim Leubner       }
3458*4e1bc9a0SAchim Leubner       else
3459*4e1bc9a0SAchim Leubner       {
3460*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
3461*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
3462*4e1bc9a0SAchim Leubner       }
3463*4e1bc9a0SAchim Leubner     }
3464*4e1bc9a0SAchim Leubner     else /* SPCv or SPCve */
3465*4e1bc9a0SAchim Leubner     {
3466*4e1bc9a0SAchim Leubner       if (0 <= i && i <= 3)
3467*4e1bc9a0SAchim Leubner       {
3468*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3469*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3470*4e1bc9a0SAchim Leubner       }
3471*4e1bc9a0SAchim Leubner       else if (4 <= i && i <= 7)
3472*4e1bc9a0SAchim Leubner       {
3473*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3474*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
3475*4e1bc9a0SAchim Leubner       }
3476*4e1bc9a0SAchim Leubner       else /* don't care */
3477*4e1bc9a0SAchim Leubner       {
3478*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
3479*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f);
3480*4e1bc9a0SAchim Leubner       }
3481*4e1bc9a0SAchim Leubner 
3482*4e1bc9a0SAchim Leubner     }
3483*4e1bc9a0SAchim Leubner     /* 1.5G/3G , SAS/SATA, no spin-up control */
3484*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 55 */
3485*4e1bc9a0SAchim Leubner     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))));
3486*4e1bc9a0SAchim Leubner 
3487*4e1bc9a0SAchim Leubner   }
3488*4e1bc9a0SAchim Leubner #endif
3489*4e1bc9a0SAchim Leubner #ifdef TARGET_DRIVER
3490*4e1bc9a0SAchim Leubner    for (i=0;i<TD_MAX_NUM_PHYS;i++)
3491*4e1bc9a0SAchim Leubner   {
3492*4e1bc9a0SAchim Leubner     /* setting default phy properties */
3493*4e1bc9a0SAchim Leubner     /* SPC; narrow ports; 8 ports
3494*4e1bc9a0SAchim Leubner        SPCv, SPCve wide port; 8 ports
3495*4e1bc9a0SAchim Leubner        SPCv+ wide port; 16 ports
3496*4e1bc9a0SAchim Leubner     */
3497*4e1bc9a0SAchim Leubner     if (tiIS_SPC(agRoot))
3498*4e1bc9a0SAchim Leubner     {
3499*4e1bc9a0SAchim Leubner        if (0 <= i && i <= 7)
3500*4e1bc9a0SAchim Leubner       {
3501*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3502*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3503*4e1bc9a0SAchim Leubner       }
3504*4e1bc9a0SAchim Leubner       else
3505*4e1bc9a0SAchim Leubner       {
3506*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3507*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3508*4e1bc9a0SAchim Leubner       }
3509*4e1bc9a0SAchim Leubner     }
3510*4e1bc9a0SAchim Leubner     else if (tiIS_16PHY(agRoot))
3511*4e1bc9a0SAchim Leubner     {
3512*4e1bc9a0SAchim Leubner        if (0 <= i && i <= 7)
3513*4e1bc9a0SAchim Leubner       {
3514*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3515*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3516*4e1bc9a0SAchim Leubner       }
3517*4e1bc9a0SAchim Leubner       else
3518*4e1bc9a0SAchim Leubner       {
3519*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3520*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3521*4e1bc9a0SAchim Leubner       }
3522*4e1bc9a0SAchim Leubner     }
3523*4e1bc9a0SAchim Leubner     else
3524*4e1bc9a0SAchim Leubner     {
3525*4e1bc9a0SAchim Leubner       if (0 <= i && i <= 3)
3526*4e1bc9a0SAchim Leubner       {
3527*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3528*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3529*4e1bc9a0SAchim Leubner       }
3530*4e1bc9a0SAchim Leubner       else if (4 <= i && i <= 7)
3531*4e1bc9a0SAchim Leubner       {
3532*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3533*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3534*4e1bc9a0SAchim Leubner       }
3535*4e1bc9a0SAchim Leubner       else /* don't care */
3536*4e1bc9a0SAchim Leubner       {
3537*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3538*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f+i);
3539*4e1bc9a0SAchim Leubner       }
3540*4e1bc9a0SAchim Leubner     }
3541*4e1bc9a0SAchim Leubner     /* 1.5G/3G , SAS/SATA, no spin-up control */
3542*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 The default is 1.5G and will be changed based on the registry value */
3543*4e1bc9a0SAchim Leubner     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))));
3544*4e1bc9a0SAchim Leubner 
3545*4e1bc9a0SAchim Leubner   }
3546*4e1bc9a0SAchim Leubner #endif
3547*4e1bc9a0SAchim Leubner #endif
3548*4e1bc9a0SAchim Leubner 
3549*4e1bc9a0SAchim Leubner 
3550*4e1bc9a0SAchim Leubner   buffer = tmpBuffer;
3551*4e1bc9a0SAchim Leubner   buffLen = sizeof(tmpBuffer);
3552*4e1bc9a0SAchim Leubner 
3553*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
3554*4e1bc9a0SAchim Leubner   lenRecv = 0;
3555*4e1bc9a0SAchim Leubner 
3556*4e1bc9a0SAchim Leubner   /* needs to read Phy's id frame */
3557*4e1bc9a0SAchim Leubner   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3558*4e1bc9a0SAchim Leubner   {
3559*4e1bc9a0SAchim Leubner     if (flag == agFALSE)
3560*4e1bc9a0SAchim Leubner     {
3561*4e1bc9a0SAchim Leubner       osti_sprintf(phyParmsStr,"PhyParms%d", i);
3562*4e1bc9a0SAchim Leubner     }
3563*4e1bc9a0SAchim Leubner     else
3564*4e1bc9a0SAchim Leubner     {
3565*4e1bc9a0SAchim Leubner       if (i >= 4)
3566*4e1bc9a0SAchim Leubner       {
3567*4e1bc9a0SAchim Leubner         osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
3568*4e1bc9a0SAchim Leubner       }
3569*4e1bc9a0SAchim Leubner       else
3570*4e1bc9a0SAchim Leubner       {
3571*4e1bc9a0SAchim Leubner         osti_sprintf(phyParmsStr,"PhyParms%d", i);
3572*4e1bc9a0SAchim Leubner       }
3573*4e1bc9a0SAchim Leubner     }
3574*4e1bc9a0SAchim Leubner 
3575*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetGlobalPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
3576*4e1bc9a0SAchim Leubner 
3577*4e1bc9a0SAchim Leubner 
3578*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3579*4e1bc9a0SAchim Leubner                                 tiRoot,
3580*4e1bc9a0SAchim Leubner                                 globalStr,
3581*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3582*4e1bc9a0SAchim Leubner                                 agNULL,
3583*4e1bc9a0SAchim Leubner                                 agNULL,
3584*4e1bc9a0SAchim Leubner                                 agNULL,
3585*4e1bc9a0SAchim Leubner                                 agNULL,
3586*4e1bc9a0SAchim Leubner                                 "AddrHi",
3587*4e1bc9a0SAchim Leubner                                 buffer,
3588*4e1bc9a0SAchim Leubner                                 buffLen,
3589*4e1bc9a0SAchim Leubner                                 &lenRecv
3590*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3591*4e1bc9a0SAchim Leubner     {
3592*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3593*4e1bc9a0SAchim Leubner       {
3594*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3595*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3596*4e1bc9a0SAchim Leubner       }
3597*4e1bc9a0SAchim Leubner       else
3598*4e1bc9a0SAchim Leubner       {
3599*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3600*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3601*4e1bc9a0SAchim Leubner 
3602*4e1bc9a0SAchim Leubner       }
3603*4e1bc9a0SAchim Leubner     }
3604*4e1bc9a0SAchim Leubner 
3605*4e1bc9a0SAchim Leubner 
3606*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3607*4e1bc9a0SAchim Leubner     lenRecv = 0;
3608*4e1bc9a0SAchim Leubner 
3609*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3610*4e1bc9a0SAchim Leubner                                 tiRoot,
3611*4e1bc9a0SAchim Leubner                                 globalStr,
3612*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3613*4e1bc9a0SAchim Leubner                                 agNULL,
3614*4e1bc9a0SAchim Leubner                                 agNULL,
3615*4e1bc9a0SAchim Leubner                                 agNULL,
3616*4e1bc9a0SAchim Leubner                                 agNULL,
3617*4e1bc9a0SAchim Leubner                                 "AddrLow",
3618*4e1bc9a0SAchim Leubner                                 buffer,
3619*4e1bc9a0SAchim Leubner                                 buffLen,
3620*4e1bc9a0SAchim Leubner                                 &lenRecv
3621*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3622*4e1bc9a0SAchim Leubner     {
3623*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3624*4e1bc9a0SAchim Leubner       {
3625*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3626*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3627*4e1bc9a0SAchim Leubner       }
3628*4e1bc9a0SAchim Leubner       else
3629*4e1bc9a0SAchim Leubner       {
3630*4e1bc9a0SAchim Leubner         OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3631*4e1bc9a0SAchim Leubner         TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3632*4e1bc9a0SAchim Leubner 
3633*4e1bc9a0SAchim Leubner       }
3634*4e1bc9a0SAchim Leubner     }
3635*4e1bc9a0SAchim Leubner     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))));
3636*4e1bc9a0SAchim Leubner 
3637*4e1bc9a0SAchim Leubner     /* phy properties */
3638*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3639*4e1bc9a0SAchim Leubner     lenRecv = 0;
3640*4e1bc9a0SAchim Leubner /*
3641*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3642*4e1bc9a0SAchim Leubner                                 tiRoot,
3643*4e1bc9a0SAchim Leubner                                 globalStr,
3644*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3645*4e1bc9a0SAchim Leubner                                 agNULL,
3646*4e1bc9a0SAchim Leubner                                 agNULL,
3647*4e1bc9a0SAchim Leubner                                 agNULL,
3648*4e1bc9a0SAchim Leubner                                 agNULL,
3649*4e1bc9a0SAchim Leubner                                 "LinkRate",
3650*4e1bc9a0SAchim Leubner                                 buffer,
3651*4e1bc9a0SAchim Leubner                                 buffLen,
3652*4e1bc9a0SAchim Leubner                                 &lenRecv
3653*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3654*4e1bc9a0SAchim Leubner     {
3655*4e1bc9a0SAchim Leubner       LinkRateRead = agTRUE;
3656*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3657*4e1bc9a0SAchim Leubner       {
3658*4e1bc9a0SAchim Leubner         LinkRate = osti_strtoul(buffer, &pLastUsedChar, 0);
3659*4e1bc9a0SAchim Leubner         TI_DBG2(("tdsaGetGlobalPhyParams: phy %d linkrate 0x%x \n", i, LinkRate));
3660*4e1bc9a0SAchim Leubner       }
3661*4e1bc9a0SAchim Leubner       else
3662*4e1bc9a0SAchim Leubner       {
3663*4e1bc9a0SAchim Leubner         LinkRate = osti_strtoul(buffer, &pLastUsedChar, 10);
3664*4e1bc9a0SAchim Leubner         TI_DBG2(("tdsaGetGlobalPhyParams: phy %d linkrate %d \n", i, LinkRate));
3665*4e1bc9a0SAchim Leubner       }
3666*4e1bc9a0SAchim Leubner     }
3667*4e1bc9a0SAchim Leubner */
3668*4e1bc9a0SAchim Leubner 
3669*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3670*4e1bc9a0SAchim Leubner     lenRecv = 0;
3671*4e1bc9a0SAchim Leubner 
3672*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3673*4e1bc9a0SAchim Leubner                                 tiRoot,
3674*4e1bc9a0SAchim Leubner                                 globalStr,
3675*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3676*4e1bc9a0SAchim Leubner                                 agNULL,
3677*4e1bc9a0SAchim Leubner                                 agNULL,
3678*4e1bc9a0SAchim Leubner                                 agNULL,
3679*4e1bc9a0SAchim Leubner                                 agNULL,
3680*4e1bc9a0SAchim Leubner                                 "Mode",
3681*4e1bc9a0SAchim Leubner                                 buffer,
3682*4e1bc9a0SAchim Leubner                                 buffLen,
3683*4e1bc9a0SAchim Leubner                                 &lenRecv
3684*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3685*4e1bc9a0SAchim Leubner     {
3686*4e1bc9a0SAchim Leubner       ModeRead = agTRUE;
3687*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3688*4e1bc9a0SAchim Leubner       {
3689*4e1bc9a0SAchim Leubner         Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
3690*4e1bc9a0SAchim Leubner         TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode 0x%x \n", i, Mode));
3691*4e1bc9a0SAchim Leubner       }
3692*4e1bc9a0SAchim Leubner       else
3693*4e1bc9a0SAchim Leubner       {
3694*4e1bc9a0SAchim Leubner         Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
3695*4e1bc9a0SAchim Leubner         TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode %d \n", i, Mode));
3696*4e1bc9a0SAchim Leubner       }
3697*4e1bc9a0SAchim Leubner     }
3698*4e1bc9a0SAchim Leubner 
3699*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3700*4e1bc9a0SAchim Leubner     lenRecv = 0;
3701*4e1bc9a0SAchim Leubner 
3702*4e1bc9a0SAchim Leubner     if ((ostiGetTransportParam (
3703*4e1bc9a0SAchim Leubner                                 tiRoot,
3704*4e1bc9a0SAchim Leubner                                 globalStr,
3705*4e1bc9a0SAchim Leubner                                 phyParmsStr,
3706*4e1bc9a0SAchim Leubner                                 agNULL,
3707*4e1bc9a0SAchim Leubner                                 agNULL,
3708*4e1bc9a0SAchim Leubner                                 agNULL,
3709*4e1bc9a0SAchim Leubner                                 agNULL,
3710*4e1bc9a0SAchim Leubner                                 "OpticalMode",
3711*4e1bc9a0SAchim Leubner                                 buffer,
3712*4e1bc9a0SAchim Leubner                                 buffLen,
3713*4e1bc9a0SAchim Leubner                                 &lenRecv
3714*4e1bc9a0SAchim Leubner                                 ) == tiSuccess) && (lenRecv != 0))
3715*4e1bc9a0SAchim Leubner     {
3716*4e1bc9a0SAchim Leubner       OpticalModeRead = agTRUE;
3717*4e1bc9a0SAchim Leubner       if (osti_strncmp(buffer, "0x", 2) == 0)
3718*4e1bc9a0SAchim Leubner       {
3719*4e1bc9a0SAchim Leubner         OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
3720*4e1bc9a0SAchim Leubner         TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
3721*4e1bc9a0SAchim Leubner       }
3722*4e1bc9a0SAchim Leubner       else
3723*4e1bc9a0SAchim Leubner       {
3724*4e1bc9a0SAchim Leubner         OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
3725*4e1bc9a0SAchim Leubner         TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
3726*4e1bc9a0SAchim Leubner       }
3727*4e1bc9a0SAchim Leubner     }
3728*4e1bc9a0SAchim Leubner 
3729*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetGlobalPhyParams:A phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3730*4e1bc9a0SAchim Leubner     tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
3731*4e1bc9a0SAchim Leubner 
3732*4e1bc9a0SAchim Leubner     TI_DBG2(("tdsaGetGlobalPhyParams:B phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3733*4e1bc9a0SAchim Leubner 
3734*4e1bc9a0SAchim Leubner 
3735*4e1bc9a0SAchim Leubner 
3736*4e1bc9a0SAchim Leubner     /**********************************************/
3737*4e1bc9a0SAchim Leubner     osti_memset(buffer, 0, buffLen);
3738*4e1bc9a0SAchim Leubner     lenRecv = 0;
3739*4e1bc9a0SAchim Leubner     /* restore default */
3740*4e1bc9a0SAchim Leubner     LinkRate = 15;
3741*4e1bc9a0SAchim Leubner     Mode = 3;
3742*4e1bc9a0SAchim Leubner     OpticalMode = 0;
3743*4e1bc9a0SAchim Leubner     LinkRateRead = agTRUE;//VG
3744*4e1bc9a0SAchim Leubner     ModeRead = agFALSE;
3745*4e1bc9a0SAchim Leubner     OpticalModeRead = agFALSE;
3746*4e1bc9a0SAchim Leubner 
3747*4e1bc9a0SAchim Leubner 
3748*4e1bc9a0SAchim Leubner   } /* end for */
3749*4e1bc9a0SAchim Leubner 
3750*4e1bc9a0SAchim Leubner   return;
3751*4e1bc9a0SAchim Leubner }
3752*4e1bc9a0SAchim Leubner 
3753*4e1bc9a0SAchim Leubner /*****************************************************************************
3754*4e1bc9a0SAchim Leubner *! \brief  tdsaGetPortParams
3755*4e1bc9a0SAchim Leubner *
3756*4e1bc9a0SAchim Leubner *  Purpose:  This function reads port-related configuration parameters from the
3757*4e1bc9a0SAchim Leubner *            configuration file
3758*4e1bc9a0SAchim Leubner *
3759*4e1bc9a0SAchim Leubner *  \param  tiRoot:            Pointer to driver/port instance.
3760*4e1bc9a0SAchim Leubner *
3761*4e1bc9a0SAchim Leubner *  \return:     None
3762*4e1bc9a0SAchim Leubner *
3763*4e1bc9a0SAchim Leubner *  \note - just a place holder for now
3764*4e1bc9a0SAchim Leubner *
3765*4e1bc9a0SAchim Leubner *****************************************************************************/
3766*4e1bc9a0SAchim Leubner osGLOBAL void
tdsaGetPortParams(tiRoot_t * tiRoot)3767*4e1bc9a0SAchim Leubner tdsaGetPortParams(
3768*4e1bc9a0SAchim Leubner                   tiRoot_t *tiRoot
3769*4e1bc9a0SAchim Leubner                   )
3770*4e1bc9a0SAchim Leubner {
3771*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3772*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3773*4e1bc9a0SAchim Leubner 
3774*4e1bc9a0SAchim Leubner 
3775*4e1bc9a0SAchim Leubner   char    *buffer;
3776*4e1bc9a0SAchim Leubner   bit32   buffLen;
3777*4e1bc9a0SAchim Leubner   bit32   lenRecv = 0;
3778*4e1bc9a0SAchim Leubner   char    *pLastUsedChar = agNULL;
3779*4e1bc9a0SAchim Leubner   char    tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3780*4e1bc9a0SAchim Leubner   char    globalStr[]     = "Global";
3781*4e1bc9a0SAchim Leubner   char    portParmsStr[] = "PortParms";
3782*4e1bc9a0SAchim Leubner 
3783*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetPortParams: start \n"));
3784*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetPortParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3785*4e1bc9a0SAchim Leubner 
3786*4e1bc9a0SAchim Leubner   buffer = tmpBuffer;
3787*4e1bc9a0SAchim Leubner   buffLen = sizeof(tmpBuffer);
3788*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
3789*4e1bc9a0SAchim Leubner 
3790*4e1bc9a0SAchim Leubner   if ((ostiGetTransportParam (
3791*4e1bc9a0SAchim Leubner                               tiRoot,
3792*4e1bc9a0SAchim Leubner                               globalStr,
3793*4e1bc9a0SAchim Leubner                               portParmsStr,
3794*4e1bc9a0SAchim Leubner                               agNULL,
3795*4e1bc9a0SAchim Leubner                               agNULL,
3796*4e1bc9a0SAchim Leubner                               agNULL,
3797*4e1bc9a0SAchim Leubner                               agNULL,
3798*4e1bc9a0SAchim Leubner                               "InterruptDelay",
3799*4e1bc9a0SAchim Leubner                               buffer,
3800*4e1bc9a0SAchim Leubner                               buffLen,
3801*4e1bc9a0SAchim Leubner                               &lenRecv
3802*4e1bc9a0SAchim Leubner                               ) == tiSuccess) && (lenRecv != 0))
3803*4e1bc9a0SAchim Leubner   {
3804*4e1bc9a0SAchim Leubner     if (osti_strncmp(buffer, "0x", 2) == 0)
3805*4e1bc9a0SAchim Leubner     {
3806*4e1bc9a0SAchim Leubner       tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 0);
3807*4e1bc9a0SAchim Leubner     }
3808*4e1bc9a0SAchim Leubner     else
3809*4e1bc9a0SAchim Leubner     {
3810*4e1bc9a0SAchim Leubner       tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 10);
3811*4e1bc9a0SAchim Leubner     }
3812*4e1bc9a0SAchim Leubner     TI_DBG6(("tdsaGetPortParams: in \n"));
3813*4e1bc9a0SAchim Leubner   }
3814*4e1bc9a0SAchim Leubner   osti_memset(buffer, 0, buffLen);
3815*4e1bc9a0SAchim Leubner   lenRecv = 0;
3816*4e1bc9a0SAchim Leubner 
3817*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaGetPortParams: out \n"));
3818*4e1bc9a0SAchim Leubner 
3819*4e1bc9a0SAchim Leubner   /* and more .... */
3820*4e1bc9a0SAchim Leubner 
3821*4e1bc9a0SAchim Leubner 
3822*4e1bc9a0SAchim Leubner   return;
3823*4e1bc9a0SAchim Leubner }
3824*4e1bc9a0SAchim Leubner 
3825*4e1bc9a0SAchim Leubner #ifdef FW_EVT_LOG_TST
3826*4e1bc9a0SAchim Leubner void saLogDump(agsaRoot_t *agRoot,
3827*4e1bc9a0SAchim Leubner                U32    *eventLogSize,
3828*4e1bc9a0SAchim Leubner                U32   **eventLogAddress);
3829*4e1bc9a0SAchim Leubner 
tiLogDump(tiRoot_t * tiRoot,U32 * size,U32 ** addr)3830*4e1bc9a0SAchim Leubner void tiLogDump(tiRoot_t *tiRoot, U32 *size, U32 **addr)
3831*4e1bc9a0SAchim Leubner {
3832*4e1bc9a0SAchim Leubner   tdsaRoot_t    *tdsaRoot;
3833*4e1bc9a0SAchim Leubner   tdsaContext_t *tdsaAllShared;
3834*4e1bc9a0SAchim Leubner 
3835*4e1bc9a0SAchim Leubner   tdsaRoot = (tdsaRoot_t*)tiRoot->tdData;
3836*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t*)&(tdsaRoot->tdsaAllShared);
3837*4e1bc9a0SAchim Leubner   saLogDump(&tdsaAllShared->agRootNonInt, size, addr);
3838*4e1bc9a0SAchim Leubner }
3839*4e1bc9a0SAchim Leubner #endif
3840*4e1bc9a0SAchim Leubner 
3841*4e1bc9a0SAchim Leubner 
3842*4e1bc9a0SAchim Leubner 
3843*4e1bc9a0SAchim Leubner /*****************************************************************************
3844*4e1bc9a0SAchim Leubner *! \brief  tiCOMPortInit
3845*4e1bc9a0SAchim Leubner *
3846*4e1bc9a0SAchim Leubner *  Purpose: This function is called to initialize the port hardware.
3847*4e1bc9a0SAchim Leubner *           This call could only be called until after the successful
3848*4e1bc9a0SAchim Leubner *           completion tiCOMInit().
3849*4e1bc9a0SAchim Leubner *
3850*4e1bc9a0SAchim Leubner *  \param   tiRoot:         Pointer to root data structure.
3851*4e1bc9a0SAchim Leubner *  \param   sysIntsActive:  system interrupt flag
3852*4e1bc9a0SAchim Leubner *
3853*4e1bc9a0SAchim Leubner *  \return:
3854*4e1bc9a0SAchim Leubner *           tiSuccess:      Successful.
3855*4e1bc9a0SAchim Leubner *           Others:             Fail.
3856*4e1bc9a0SAchim Leubner *
3857*4e1bc9a0SAchim Leubner *  \note -
3858*4e1bc9a0SAchim Leubner *
3859*4e1bc9a0SAchim Leubner *****************************************************************************/
3860*4e1bc9a0SAchim Leubner osGLOBAL bit32
tiCOMPortInit(tiRoot_t * tiRoot,bit32 sysIntsActive)3861*4e1bc9a0SAchim Leubner tiCOMPortInit(
3862*4e1bc9a0SAchim Leubner               tiRoot_t      *tiRoot,
3863*4e1bc9a0SAchim Leubner               bit32         sysIntsActive
3864*4e1bc9a0SAchim Leubner               )
3865*4e1bc9a0SAchim Leubner {
3866*4e1bc9a0SAchim Leubner   tdsaRoot_t          *tdsaRoot;
3867*4e1bc9a0SAchim Leubner   tdsaContext_t       *tdsaAllShared;
3868*4e1bc9a0SAchim Leubner   agsaRoot_t          *agRoot;
3869*4e1bc9a0SAchim Leubner   tiLoLevelResource_t *loResource;
3870*4e1bc9a0SAchim Leubner   bit32                status = tiError;
3871*4e1bc9a0SAchim Leubner   bit32                i;
3872*4e1bc9a0SAchim Leubner 
3873*4e1bc9a0SAchim Leubner   agsaQueueConfig_t   *QueueConfig;
3874*4e1bc9a0SAchim Leubner 
3875*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_STATUS_TESTING
3876*4e1bc9a0SAchim Leubner   static agsaControllerStatus_t  agcontrollerStatus;
3877*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_STATUS_TESTING */
3878*4e1bc9a0SAchim Leubner 
3879*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_INFO_TESTING
3880*4e1bc9a0SAchim Leubner   static agsaControllerInfo_t  agcontrollerInfo;
3881*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
3882*4e1bc9a0SAchim Leubner 
3883*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_ENCRYPT_TESTING
3884*4e1bc9a0SAchim Leubner   static  agsaEncryptInfo_t       agsaEncryptInfo;
3885*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
3886*4e1bc9a0SAchim Leubner 
3887*4e1bc9a0SAchim Leubner   static agsaMemoryRequirement_t agMemoryRequirement;
3888*4e1bc9a0SAchim Leubner #ifdef ECHO_TESTING
3889*4e1bc9a0SAchim Leubner   /* temp */
3890*4e1bc9a0SAchim Leubner   static   bit8                     payload[56];
3891*4e1bc9a0SAchim Leubner #endif
3892*4e1bc9a0SAchim Leubner 
3893*4e1bc9a0SAchim Leubner #if defined(FDS_DM) || defined(FDS_SM)
3894*4e1bc9a0SAchim Leubner   static agsaMemoryRequirement_t memRequirement;
3895*4e1bc9a0SAchim Leubner   bit32                          maxQueueSets = 0;
3896*4e1bc9a0SAchim Leubner   bit32                          LLMemCount = 0;
3897*4e1bc9a0SAchim Leubner   bit32                          usecsPerTick = 0;
3898*4e1bc9a0SAchim Leubner   static agsaSwConfig_t          tmpLLSwConfig;
3899*4e1bc9a0SAchim Leubner #endif
3900*4e1bc9a0SAchim Leubner 
3901*4e1bc9a0SAchim Leubner #ifdef FDS_DM
3902*4e1bc9a0SAchim Leubner    static  dmRoot_t                       *dmRoot = agNULL;
3903*4e1bc9a0SAchim Leubner #ifdef FDS_SM
3904*4e1bc9a0SAchim Leubner    static dmSwConfig_t                   dmSwConfig;
3905*4e1bc9a0SAchim Leubner #endif
3906*4e1bc9a0SAchim Leubner   static dmMemoryRequirement_t   dmMemRequirement;
3907*4e1bc9a0SAchim Leubner   bit32                          DMMemCount = 0;
3908*4e1bc9a0SAchim Leubner #endif
3909*4e1bc9a0SAchim Leubner 
3910*4e1bc9a0SAchim Leubner #if defined(FDS_DM) && defined(FDS_SM)
3911*4e1bc9a0SAchim Leubner   bit32                          dmUsecsPerTick = 0;
3912*4e1bc9a0SAchim Leubner   bit32                          dmMaxNumLocks = 0;
3913*4e1bc9a0SAchim Leubner #endif
3914*4e1bc9a0SAchim Leubner 
3915*4e1bc9a0SAchim Leubner #ifdef FDS_SM
3916*4e1bc9a0SAchim Leubner   smRoot_t                       *smRoot = agNULL;
3917*4e1bc9a0SAchim Leubner //  smSwConfig_t                   smSwConfig;
3918*4e1bc9a0SAchim Leubner   static smMemoryRequirement_t   smMemRequirement;
3919*4e1bc9a0SAchim Leubner   bit32                          SMMemCount = 0;
3920*4e1bc9a0SAchim Leubner #endif
3921*4e1bc9a0SAchim Leubner 
3922*4e1bc9a0SAchim Leubner #ifndef TURN_OFF_HDA
3923*4e1bc9a0SAchim Leubner   static agsaFwImg_t                    HDAImg;
3924*4e1bc9a0SAchim Leubner #endif /*  TURN_OFF_HDA */
3925*4e1bc9a0SAchim Leubner 
3926*4e1bc9a0SAchim Leubner   TI_DBG3(("tiCOMPortInit: start\n"));
3927*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortInit: sizeof agsaMemoryRequirement_t %d\n", (int)sizeof(agsaMemoryRequirement_t)));
3928*4e1bc9a0SAchim Leubner 
3929*4e1bc9a0SAchim Leubner   tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3930*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3931*4e1bc9a0SAchim Leubner 
3932*4e1bc9a0SAchim Leubner   osti_memset(&agMemoryRequirement, 0, sizeof(agsaMemoryRequirement_t));
3933*4e1bc9a0SAchim Leubner   /*
3934*4e1bc9a0SAchim Leubner    * don't do anything if reset is in progress
3935*4e1bc9a0SAchim Leubner    */
3936*4e1bc9a0SAchim Leubner   if (tdsaAllShared->flags.resetInProgress == agTRUE)
3937*4e1bc9a0SAchim Leubner   {
3938*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: resetinProgress error\n"));
3939*4e1bc9a0SAchim Leubner     return tiError;
3940*4e1bc9a0SAchim Leubner   }
3941*4e1bc9a0SAchim Leubner 
3942*4e1bc9a0SAchim Leubner   loResource = &(tdsaAllShared->loResource);
3943*4e1bc9a0SAchim Leubner 
3944*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
3945*4e1bc9a0SAchim Leubner   tdsaAllShared->flags.sysIntsActive    = sysIntsActive;
3946*4e1bc9a0SAchim Leubner 
3947*4e1bc9a0SAchim Leubner   /*
3948*4e1bc9a0SAchim Leubner      gets port-related parameters; not in use for now
3949*4e1bc9a0SAchim Leubner      tdsaGetPortParams(tiRoot);
3950*4e1bc9a0SAchim Leubner    */
3951*4e1bc9a0SAchim Leubner 
3952*4e1bc9a0SAchim Leubner   /* call these before agroot is created  for testing */
3953*4e1bc9a0SAchim Leubner 
3954*4e1bc9a0SAchim Leubner 
3955*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_STATUS_TESTING
3956*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
3957*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
3958*4e1bc9a0SAchim Leubner 
3959*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_INFO_TESTING
3960*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
3961*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
3962*4e1bc9a0SAchim Leubner 
3963*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_ENCRYPT_TESTING
3964*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo ) ));
3965*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
3966*4e1bc9a0SAchim Leubner 
3967*4e1bc9a0SAchim Leubner 
3968*4e1bc9a0SAchim Leubner   tdsaGetSwConfigParams(tiRoot);
3969*4e1bc9a0SAchim Leubner   tdsaPrintSwConfig(&(tdsaAllShared->SwConfig));
3970*4e1bc9a0SAchim Leubner 
3971*4e1bc9a0SAchim Leubner   /* setting interrupt requirements */
3972*4e1bc9a0SAchim Leubner   tdsaAllShared->SwConfig.max_MSIX_InterruptVectors = loResource->loLevelOption.maxInterruptVectors;
3973*4e1bc9a0SAchim Leubner   tdsaAllShared->SwConfig.max_MSI_InterruptVectors = loResource->loLevelOption.max_MSI_InterruptVectors;
3974*4e1bc9a0SAchim Leubner   tdsaAllShared->SwConfig.legacyInt_X = loResource->loLevelOption.flag;
3975*4e1bc9a0SAchim Leubner   TI_DBG2(("tiCOMPortInit: got max_MSIX_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSIX_InterruptVectors));
3976*4e1bc9a0SAchim Leubner   TI_DBG2(("tiCOMPortInit: got max_MSI_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSI_InterruptVectors));
3977*4e1bc9a0SAchim Leubner   TI_DBG2(("tiCOMPortInit: got flag - legacyInt_X %d \n", tdsaAllShared->SwConfig.legacyInt_X));
3978*4e1bc9a0SAchim Leubner 
3979*4e1bc9a0SAchim Leubner   /* error checking for interrupt types */
3980*4e1bc9a0SAchim Leubner   if (
3981*4e1bc9a0SAchim Leubner       ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3982*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0)  &&
3983*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.legacyInt_X == 0))
3984*4e1bc9a0SAchim Leubner       ||
3985*4e1bc9a0SAchim Leubner       ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0) &&
3986*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0)  &&
3987*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.legacyInt_X == 0))
3988*4e1bc9a0SAchim Leubner       ||
3989*4e1bc9a0SAchim Leubner       ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3990*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0)  &&
3991*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.legacyInt_X == 0))
3992*4e1bc9a0SAchim Leubner       ||
3993*4e1bc9a0SAchim Leubner       ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3994*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0)  &&
3995*4e1bc9a0SAchim Leubner        (tdsaAllShared->SwConfig.legacyInt_X != 0))
3996*4e1bc9a0SAchim Leubner      )
3997*4e1bc9a0SAchim Leubner   {
3998*4e1bc9a0SAchim Leubner     /* do nothing */
3999*4e1bc9a0SAchim Leubner   }
4000*4e1bc9a0SAchim Leubner   else
4001*4e1bc9a0SAchim Leubner   {
4002*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: incorrect interrupt\n"));
4003*4e1bc9a0SAchim Leubner     return tiError;
4004*4e1bc9a0SAchim Leubner   }
4005*4e1bc9a0SAchim Leubner 
4006*4e1bc9a0SAchim Leubner   QueueConfig = &tdsaAllShared->QueueConfig;
4007*4e1bc9a0SAchim Leubner 
4008*4e1bc9a0SAchim Leubner   for(i=0;i<QueueConfig->numInboundQueues;i++)
4009*4e1bc9a0SAchim Leubner   {
4010*4e1bc9a0SAchim Leubner     QueueConfig->inboundQueues[i].elementCount = tdsaAllShared->InboundQueueSize[i];
4011*4e1bc9a0SAchim Leubner     QueueConfig->inboundQueues[i].elementSize = tdsaAllShared->InboundQueueEleSize[i];
4012*4e1bc9a0SAchim Leubner     QueueConfig->inboundQueues[i].priority = tdsaAllShared->InboundQueuePriority[i];
4013*4e1bc9a0SAchim Leubner     QueueConfig->inboundQueues[i].reserved = 0;
4014*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: InboundQueuePriroity %d \n", tdsaAllShared->InboundQueuePriority[i]));
4015*4e1bc9a0SAchim Leubner   }
4016*4e1bc9a0SAchim Leubner   for(i=0;i<QueueConfig->numOutboundQueues;i++)
4017*4e1bc9a0SAchim Leubner   {
4018*4e1bc9a0SAchim Leubner     QueueConfig->outboundQueues[i].elementCount = tdsaAllShared->OutboundQueueSize[i];
4019*4e1bc9a0SAchim Leubner     QueueConfig->outboundQueues[i].elementSize = tdsaAllShared->OutboundQueueEleSize[i];
4020*4e1bc9a0SAchim Leubner     QueueConfig->outboundQueues[i].interruptDelay = tdsaAllShared->OutboundQueueInterruptDelay[i]; /* default 0; no interrupt delay */
4021*4e1bc9a0SAchim Leubner     QueueConfig->outboundQueues[i].interruptCount = tdsaAllShared->OutboundQueueInterruptCount[i]; /* default 1 */
4022*4e1bc9a0SAchim Leubner     QueueConfig->outboundQueues[i].interruptEnable = tdsaAllShared->OutboundQueueInterruptEnable[i]; /* default 1 */
4023*4e1bc9a0SAchim Leubner     QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
4024*4e1bc9a0SAchim Leubner     if (tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0)
4025*4e1bc9a0SAchim Leubner     {
4026*4e1bc9a0SAchim Leubner       QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSIX_InterruptVectors;
4027*4e1bc9a0SAchim Leubner     }
4028*4e1bc9a0SAchim Leubner     else if (tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0)
4029*4e1bc9a0SAchim Leubner     {
4030*4e1bc9a0SAchim Leubner       QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSI_InterruptVectors;
4031*4e1bc9a0SAchim Leubner     }
4032*4e1bc9a0SAchim Leubner     else
4033*4e1bc9a0SAchim Leubner     {
4034*4e1bc9a0SAchim Leubner       QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
4035*4e1bc9a0SAchim Leubner     }
4036*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: OutboundQueueInterruptDelay %d OutboundQueueInterruptCount %d OutboundQueueInterruptEnable %d\n", tdsaAllShared->OutboundQueueInterruptDelay[i], tdsaAllShared->OutboundQueueInterruptCount[i], tdsaAllShared->OutboundQueueInterruptEnable[i]));
4037*4e1bc9a0SAchim Leubner 
4038*4e1bc9a0SAchim Leubner   }
4039*4e1bc9a0SAchim Leubner   /* queue option */
4040*4e1bc9a0SAchim Leubner   QueueConfig->queueOption = tdsaAllShared->QueueOption;
4041*4e1bc9a0SAchim Leubner 
4042*4e1bc9a0SAchim Leubner   tdsaAllShared->SwConfig.param3 = (void *)QueueConfig;
4043*4e1bc9a0SAchim Leubner   tdsaAllShared->SwConfig.stallUsec = 10;
4044*4e1bc9a0SAchim Leubner 
4045*4e1bc9a0SAchim Leubner   /* finds a first high priority queue for SMP */
4046*4e1bc9a0SAchim Leubner   tdsaAllShared->SMPQNum = 0; /* default */
4047*4e1bc9a0SAchim Leubner   for(i=0;i<QueueConfig->numInboundQueues;i++)
4048*4e1bc9a0SAchim Leubner   {
4049*4e1bc9a0SAchim Leubner     if (QueueConfig->inboundQueues[i].priority != DEFAULT_INBOUND_QUEUE_PRIORITY) /* 0 */
4050*4e1bc9a0SAchim Leubner     {
4051*4e1bc9a0SAchim Leubner       tdsaAllShared->SMPQNum = i;
4052*4e1bc9a0SAchim Leubner       break;
4053*4e1bc9a0SAchim Leubner     }
4054*4e1bc9a0SAchim Leubner   }
4055*4e1bc9a0SAchim Leubner 
4056*4e1bc9a0SAchim Leubner   tdsaGetHwConfigParams(tiRoot);
4057*4e1bc9a0SAchim Leubner 
4058*4e1bc9a0SAchim Leubner   tdsaPrintHwConfig(&(tdsaAllShared->HwConfig));
4059*4e1bc9a0SAchim Leubner 
4060*4e1bc9a0SAchim Leubner #ifdef TARGET_DRIVER
4061*4e1bc9a0SAchim Leubner   /* target, not yet */
4062*4e1bc9a0SAchim Leubner   if (tdsaAllShared->currentOperation & TD_OPERATION_TARGET)
4063*4e1bc9a0SAchim Leubner   {
4064*4e1bc9a0SAchim Leubner     ttdssGetTargetParams(tiRoot);
4065*4e1bc9a0SAchim Leubner   }
4066*4e1bc9a0SAchim Leubner #endif
4067*4e1bc9a0SAchim Leubner 
4068*4e1bc9a0SAchim Leubner #if defined(FDS_DM) && defined(FDS_SM)
4069*4e1bc9a0SAchim Leubner   /*
4070*4e1bc9a0SAchim Leubner     needs to call saGetRequirements() to find out agMemoryRequirement.count requested by LL
4071*4e1bc9a0SAchim Leubner   */
4072*4e1bc9a0SAchim Leubner   osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4073*4e1bc9a0SAchim Leubner 
4074*4e1bc9a0SAchim Leubner   saGetRequirements(agRoot,
4075*4e1bc9a0SAchim Leubner                     &tmpLLSwConfig,
4076*4e1bc9a0SAchim Leubner                     &memRequirement,
4077*4e1bc9a0SAchim Leubner                     &usecsPerTick,
4078*4e1bc9a0SAchim Leubner                     &maxQueueSets
4079*4e1bc9a0SAchim Leubner                     );
4080*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: usecsPerTick %d\n", usecsPerTick));
4081*4e1bc9a0SAchim Leubner 
4082*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: LL memRequirement.count %d\n", memRequirement.count));
4083*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4084*4e1bc9a0SAchim Leubner   LLMemCount = memRequirement.count;
4085*4e1bc9a0SAchim Leubner 
4086*4e1bc9a0SAchim Leubner   /*
4087*4e1bc9a0SAchim Leubner     needs to call dmGetRequirements() to find out dmMemoryRequirement.count requested by DM
4088*4e1bc9a0SAchim Leubner   */
4089*4e1bc9a0SAchim Leubner 
4090*4e1bc9a0SAchim Leubner   dmGetRequirements(dmRoot,
4091*4e1bc9a0SAchim Leubner                     &dmSwConfig,
4092*4e1bc9a0SAchim Leubner                     &dmMemRequirement,
4093*4e1bc9a0SAchim Leubner                     &dmUsecsPerTick,
4094*4e1bc9a0SAchim Leubner                     &dmMaxNumLocks
4095*4e1bc9a0SAchim Leubner                     );
4096*4e1bc9a0SAchim Leubner 
4097*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: DM dmmemRequirement.count %d\n", dmMemRequirement.count));
4098*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4099*4e1bc9a0SAchim Leubner 
4100*4e1bc9a0SAchim Leubner   DMMemCount = dmMemRequirement.count;
4101*4e1bc9a0SAchim Leubner   SMMemCount = loResource->loLevelMem.count - LLMemCount - DMMemCount;
4102*4e1bc9a0SAchim Leubner   agMemoryRequirement.count =  LLMemCount;
4103*4e1bc9a0SAchim Leubner 
4104*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: SMMemCount %d\n", SMMemCount));
4105*4e1bc9a0SAchim Leubner 
4106*4e1bc9a0SAchim Leubner 
4107*4e1bc9a0SAchim Leubner #elif defined(FDS_DM)
4108*4e1bc9a0SAchim Leubner   /*
4109*4e1bc9a0SAchim Leubner     needs to call saGetRequirements() to find out agMemoryRequirement.count requested by LL
4110*4e1bc9a0SAchim Leubner   */
4111*4e1bc9a0SAchim Leubner   osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4112*4e1bc9a0SAchim Leubner 
4113*4e1bc9a0SAchim Leubner   saGetRequirements(agRoot,
4114*4e1bc9a0SAchim Leubner                     &tmpLLSwConfig,
4115*4e1bc9a0SAchim Leubner                     &memRequirement,
4116*4e1bc9a0SAchim Leubner                     &usecsPerTick,
4117*4e1bc9a0SAchim Leubner                     &maxQueueSets
4118*4e1bc9a0SAchim Leubner                     );
4119*4e1bc9a0SAchim Leubner 
4120*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
4121*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4122*4e1bc9a0SAchim Leubner 
4123*4e1bc9a0SAchim Leubner   LLMemCount = memRequirement.count;
4124*4e1bc9a0SAchim Leubner   DMMemCount = loResource->loLevelMem.count - LLMemCount;
4125*4e1bc9a0SAchim Leubner 
4126*4e1bc9a0SAchim Leubner   agMemoryRequirement.count =  LLMemCount;
4127*4e1bc9a0SAchim Leubner 
4128*4e1bc9a0SAchim Leubner #elif defined(FDS_SM)
4129*4e1bc9a0SAchim Leubner   osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4130*4e1bc9a0SAchim Leubner 
4131*4e1bc9a0SAchim Leubner   saGetRequirements(agRoot,
4132*4e1bc9a0SAchim Leubner                     &tmpLLSwConfig,
4133*4e1bc9a0SAchim Leubner                     &memRequirement,
4134*4e1bc9a0SAchim Leubner                     &usecsPerTick,
4135*4e1bc9a0SAchim Leubner                     &maxQueueSets
4136*4e1bc9a0SAchim Leubner                     );
4137*4e1bc9a0SAchim Leubner 
4138*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
4139*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4140*4e1bc9a0SAchim Leubner 
4141*4e1bc9a0SAchim Leubner   LLMemCount = memRequirement.count;
4142*4e1bc9a0SAchim Leubner   SMMemCount = loResource->loLevelMem.count - LLMemCount;
4143*4e1bc9a0SAchim Leubner 
4144*4e1bc9a0SAchim Leubner   agMemoryRequirement.count =  LLMemCount;
4145*4e1bc9a0SAchim Leubner 
4146*4e1bc9a0SAchim Leubner #else
4147*4e1bc9a0SAchim Leubner 
4148*4e1bc9a0SAchim Leubner   agMemoryRequirement.count = loResource->loLevelMem.count;
4149*4e1bc9a0SAchim Leubner 
4150*4e1bc9a0SAchim Leubner #endif
4151*4e1bc9a0SAchim Leubner 
4152*4e1bc9a0SAchim Leubner #if defined(FDS_DM) && defined(FDS_SM)
4153*4e1bc9a0SAchim Leubner   /* for debugging */
4154*4e1bc9a0SAchim Leubner   for(i=0;i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
4155*4e1bc9a0SAchim Leubner   {
4156*4e1bc9a0SAchim Leubner     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));
4157*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4158*4e1bc9a0SAchim Leubner   }
4159*4e1bc9a0SAchim Leubner #endif
4160*4e1bc9a0SAchim Leubner 
4161*4e1bc9a0SAchim Leubner   /* initialize */
4162*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortInit: AGSA_NUM_MEM_CHUNKS %d\n", AGSA_NUM_MEM_CHUNKS));
4163*4e1bc9a0SAchim Leubner   for(i=0;i<AGSA_NUM_MEM_CHUNKS;i++)
4164*4e1bc9a0SAchim Leubner   {
4165*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].virtPtr = agNULL;
4166*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].osHandle = agNULL;
4167*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].phyAddrUpper = 0;
4168*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].phyAddrLower = 0;
4169*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].totalLength = 0;
4170*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].numElements = 0;
4171*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].singleElementLength = 0;
4172*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].alignment = 0;
4173*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].type = 0;
4174*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].reserved = 0;
4175*4e1bc9a0SAchim Leubner   }
4176*4e1bc9a0SAchim Leubner 
4177*4e1bc9a0SAchim Leubner   for(i=0;i<(int)agMemoryRequirement.count;i++)
4178*4e1bc9a0SAchim Leubner   {
4179*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: LL copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4180*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4181*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].osHandle = loResource->loLevelMem.mem[i].osHandle;
4182*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].phyAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4183*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].phyAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4184*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].totalLength = loResource->loLevelMem.mem[i].totalLength;
4185*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].numElements = loResource->loLevelMem.mem[i].numElements;
4186*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4187*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].alignment = loResource->loLevelMem.mem[i].alignment;
4188*4e1bc9a0SAchim Leubner     if (loResource->loLevelMem.mem[i].type == TI_DMA_MEM)
4189*4e1bc9a0SAchim Leubner     {
4190*4e1bc9a0SAchim Leubner       agMemoryRequirement.agMemory[i].type = AGSA_DMA_MEM;
4191*4e1bc9a0SAchim Leubner     }
4192*4e1bc9a0SAchim Leubner     else if (loResource->loLevelMem.mem[i].type == TI_CACHED_MEM)
4193*4e1bc9a0SAchim Leubner     {
4194*4e1bc9a0SAchim Leubner       agMemoryRequirement.agMemory[i].type = AGSA_CACHED_MEM;
4195*4e1bc9a0SAchim Leubner 
4196*4e1bc9a0SAchim Leubner     }
4197*4e1bc9a0SAchim Leubner     else if (loResource->loLevelMem.mem[i].type == TI_CACHED_DMA_MEM)
4198*4e1bc9a0SAchim Leubner     {
4199*4e1bc9a0SAchim Leubner       agMemoryRequirement.agMemory[i].type = AGSA_CACHED_DMA_MEM;
4200*4e1bc9a0SAchim Leubner     }
4201*4e1bc9a0SAchim Leubner 
4202*4e1bc9a0SAchim Leubner     agMemoryRequirement.agMemory[i].reserved = loResource->loLevelMem.mem[i].reserved;
4203*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4204*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4205*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].physAddrUpper,
4206*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].physAddrLower,
4207*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].totalLength,
4208*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].numElements));
4209*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4210*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].singleElementLength,
4211*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].alignment,
4212*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].type,
4213*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].reserved));
4214*4e1bc9a0SAchim Leubner 
4215*4e1bc9a0SAchim Leubner   }
4216*4e1bc9a0SAchim Leubner   osti_memset(&(tdsaAllShared->tdFWControlEx), 0, sizeof(tdFWControlEx_t));
4217*4e1bc9a0SAchim Leubner 
4218*4e1bc9a0SAchim Leubner   /*
4219*4e1bc9a0SAchim Leubner    * Note: Be sure to call this only once since sallsdk does initialization only once
4220*4e1bc9a0SAchim Leubner    * saInitialize(IN, IN, IN, IN, IN);
4221*4e1bc9a0SAchim Leubner    */
4222*4e1bc9a0SAchim Leubner 
4223*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdDeviceIdVendId %x\n",tdsaAllShared->tdDeviceIdVendId));
4224*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdSubVendorId= SUB_VEN_ID %x\n",tdsaAllShared->tdSubVendorId));
4225*4e1bc9a0SAchim Leubner 
4226*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: swConfig->param1 hwDEVICE_ID_VENDID %x\n", tdsaAllShared->SwConfig.param1 ));
4227*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: swConfig->param2 hwSVID             %x\n", tdsaAllShared->SwConfig.param2));
4228*4e1bc9a0SAchim Leubner 
4229*4e1bc9a0SAchim Leubner   /*
4230*4e1bc9a0SAchim Leubner     1. Read hostDirectAccessSupport
4231*4e1bc9a0SAchim Leubner     2. If set, read HDA images based on chip ID
4232*4e1bc9a0SAchim Leubner  */
4233*4e1bc9a0SAchim Leubner 
4234*4e1bc9a0SAchim Leubner   t_MacroCheck(agRoot);
4235*4e1bc9a0SAchim Leubner 
4236*4e1bc9a0SAchim Leubner #ifndef TURN_OFF_HDA
4237*4e1bc9a0SAchim Leubner   if (tdsaAllShared->SwConfig.hostDirectAccessSupport != 0)
4238*4e1bc9a0SAchim Leubner   {
4239*4e1bc9a0SAchim Leubner     osti_memset(&HDAImg, 0, sizeof(HDAImg));
4240*4e1bc9a0SAchim Leubner     if (tiIS_SPC(agRoot))
4241*4e1bc9a0SAchim Leubner     {
4242*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMPortInit: SPC HDA\n"));
4243*4e1bc9a0SAchim Leubner       HDAImg.aap1Img = (bit8*)(&aap1array);
4244*4e1bc9a0SAchim Leubner       HDAImg.aap1Len = sizeof( aap1array);
4245*4e1bc9a0SAchim Leubner       HDAImg.iopImg  = (bit8*)(&ioparray);
4246*4e1bc9a0SAchim Leubner       HDAImg.iopLen  = sizeof(  ioparray);
4247*4e1bc9a0SAchim Leubner       HDAImg.istrImg = (bit8*)(&istrarray);
4248*4e1bc9a0SAchim Leubner       HDAImg.istrLen = sizeof( istrarray);
4249*4e1bc9a0SAchim Leubner 
4250*4e1bc9a0SAchim Leubner       HDAImg.ilaImg  = (bit8*)(&ilaarray);
4251*4e1bc9a0SAchim Leubner       HDAImg.ilaLen  = sizeof(ilaarray);
4252*4e1bc9a0SAchim Leubner     }
4253*4e1bc9a0SAchim Leubner     else if (tiIS_SPC6V(agRoot))
4254*4e1bc9a0SAchim Leubner     {
4255*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMPortInit: SPCv HDA\n"));
4256*4e1bc9a0SAchim Leubner       HDAImg.aap1Img = (bit8*)(&spcv_aap1array);
4257*4e1bc9a0SAchim Leubner       HDAImg.aap1Len =  sizeof( spcv_aap1array);
4258*4e1bc9a0SAchim Leubner       HDAImg.iopImg  = (bit8*)(&spcv_ioparray);
4259*4e1bc9a0SAchim Leubner       HDAImg.iopLen  = sizeof(  spcv_ioparray);
4260*4e1bc9a0SAchim Leubner 
4261*4e1bc9a0SAchim Leubner       HDAImg.ilaImg  = (bit8*)(&spcv_ilaarray);
4262*4e1bc9a0SAchim Leubner       HDAImg.ilaLen  = sizeof(spcv_ilaarray);
4263*4e1bc9a0SAchim Leubner     }
4264*4e1bc9a0SAchim Leubner     else if (tIsSPCV12G(agRoot))
4265*4e1bc9a0SAchim Leubner     {
4266*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMPortInit: SPCv12G HDA\n"));
4267*4e1bc9a0SAchim Leubner       HDAImg.aap1Img = (bit8*)(&spcv12g_raaearray);
4268*4e1bc9a0SAchim Leubner       HDAImg.aap1Len =  sizeof( spcv12g_raaearray);
4269*4e1bc9a0SAchim Leubner       HDAImg.iopImg  = (bit8*)(&spcv12g_ioparray);
4270*4e1bc9a0SAchim Leubner       HDAImg.iopLen  = sizeof(  spcv12g_ioparray);
4271*4e1bc9a0SAchim Leubner 
4272*4e1bc9a0SAchim Leubner       HDAImg.ilaImg  = (bit8*)(&spcv12g_ilaarray);
4273*4e1bc9a0SAchim Leubner       HDAImg.ilaLen  = sizeof(spcv12g_ilaarray);
4274*4e1bc9a0SAchim Leubner     }
4275*4e1bc9a0SAchim Leubner     else
4276*4e1bc9a0SAchim Leubner     {
4277*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMPortInit: HDA Mode Unknown chip type 0x%08x\n",ossaHwRegReadConfig32(agRoot,0 )));
4278*4e1bc9a0SAchim Leubner       return tiError;
4279*4e1bc9a0SAchim Leubner     }
4280*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: HDA aap1Len 0x%08x iopLen 0x%08x ilaLen 0x%08x\n",HDAImg.aap1Len,HDAImg.iopLen,HDAImg.ilaLen ));
4281*4e1bc9a0SAchim Leubner     tdsaAllShared->SwConfig.param4 = &(HDAImg);
4282*4e1bc9a0SAchim Leubner   }
4283*4e1bc9a0SAchim Leubner   else
4284*4e1bc9a0SAchim Leubner   {
4285*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: HDA off\n"));
4286*4e1bc9a0SAchim Leubner     tdsaAllShared->SwConfig.param4 = agNULL;
4287*4e1bc9a0SAchim Leubner   }
4288*4e1bc9a0SAchim Leubner #endif /*  TURN_OFF_HDA */
4289*4e1bc9a0SAchim Leubner 
4290*4e1bc9a0SAchim Leubner   if (tiIS_SPC(agRoot))
4291*4e1bc9a0SAchim Leubner   {
4292*4e1bc9a0SAchim Leubner     /* FW config is only for SPC */
4293*4e1bc9a0SAchim Leubner     tdsaAllShared->SwConfig.FWConfig = 0;
4294*4e1bc9a0SAchim Leubner     /* default port recovery timer 0x32 = 50 = 5000ms and port reset timer 3 (300 ms)*/
4295*4e1bc9a0SAchim Leubner     tdsaAllShared->SwConfig.PortRecoveryResetTimer = 0x30032;
4296*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit:only for SPC FWConfig set\n"));
4297*4e1bc9a0SAchim Leubner   }
4298*4e1bc9a0SAchim Leubner 
4299*4e1bc9a0SAchim Leubner   tdsaAllShared->SwConfig.fatalErrorInterruptVector = loResource->loLevelOption.maxInterruptVectors > 31 ? 31 : loResource->loLevelOption.maxInterruptVectors -1;
4300*4e1bc9a0SAchim Leubner 
4301*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: SwConfig->FWConfig 0x%x\n", tdsaAllShared->SwConfig.FWConfig));
4302*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: SwConfig->fatalErrorInterruptVector 0x%x\n", tdsaAllShared->SwConfig.fatalErrorInterruptVector));
4303*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d\n", loResource->loLevelOption.usecsPerTick));
4304*4e1bc9a0SAchim Leubner 
4305*4e1bc9a0SAchim Leubner   status = saInitialize(agRoot,
4306*4e1bc9a0SAchim Leubner                         &agMemoryRequirement,
4307*4e1bc9a0SAchim Leubner                         &(tdsaAllShared->HwConfig),
4308*4e1bc9a0SAchim Leubner                         /* &temp_HwConfig, */
4309*4e1bc9a0SAchim Leubner                         &(tdsaAllShared->SwConfig),
4310*4e1bc9a0SAchim Leubner                         loResource->loLevelOption.usecsPerTick);
4311*4e1bc9a0SAchim Leubner 
4312*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d 0x%x\n", loResource->loLevelOption.usecsPerTick, loResource->loLevelOption.usecsPerTick));
4313*4e1bc9a0SAchim Leubner 
4314*4e1bc9a0SAchim Leubner   /*TI_DBG6(("tiCOMPortInit: tdsaAllShared->SwConfig.enableDIF %d\n", tdsaAllShared->SwConfig.enableDIF)); */
4315*4e1bc9a0SAchim Leubner   /*TI_DBG6(("tiCOMPortInit: tdsaAllShared->SwConfig.enableEncryption %d\n", tdsaAllShared->SwConfig.enableEncryption)); */
4316*4e1bc9a0SAchim Leubner 
4317*4e1bc9a0SAchim Leubner   if(status == AGSA_RC_FAILURE )
4318*4e1bc9a0SAchim Leubner   {
4319*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_FAILURE, status 0x%x\n", status));
4320*4e1bc9a0SAchim Leubner     return tiError;
4321*4e1bc9a0SAchim Leubner   }
4322*4e1bc9a0SAchim Leubner 
4323*4e1bc9a0SAchim Leubner   if( status == AGSA_RC_VERSION_INCOMPATIBLE)
4324*4e1bc9a0SAchim Leubner   {
4325*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_VERSION_INCOMPATIBLE, status 0x%x\n", status));
4326*4e1bc9a0SAchim Leubner     return tiError;
4327*4e1bc9a0SAchim Leubner   }
4328*4e1bc9a0SAchim Leubner 
4329*4e1bc9a0SAchim Leubner   /* let's make sdkData same for Int and Non-int agRoots */
4330*4e1bc9a0SAchim Leubner   tdsaAllShared->agRootInt.sdkData = tdsaAllShared->agRootNonInt.sdkData;
4331*4e1bc9a0SAchim Leubner 
4332*4e1bc9a0SAchim Leubner 
4333*4e1bc9a0SAchim Leubner   /* mark the port as initialized */
4334*4e1bc9a0SAchim Leubner   for(i=0;i<TD_MAX_NUM_PHYS;i++)
4335*4e1bc9a0SAchim Leubner   {
4336*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[i].flags.portInitialized = agTRUE;
4337*4e1bc9a0SAchim Leubner   }
4338*4e1bc9a0SAchim Leubner 
4339*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER                 //ini. only in stsdkll spec (TP)
4340*4e1bc9a0SAchim Leubner   /* register device registration callback function */
4341*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device registration\n"));
4342*4e1bc9a0SAchim Leubner   status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_ADDED, (void *)ossaDeviceRegistrationCB);
4343*4e1bc9a0SAchim Leubner   if (status == AGSA_RC_FAILURE)
4344*4e1bc9a0SAchim Leubner   {
4345*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register failed\n"));
4346*4e1bc9a0SAchim Leubner   }
4347*4e1bc9a0SAchim Leubner   else
4348*4e1bc9a0SAchim Leubner   {
4349*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register succeeded\n"));
4350*4e1bc9a0SAchim Leubner   }
4351*4e1bc9a0SAchim Leubner #endif
4352*4e1bc9a0SAchim Leubner 
4353*4e1bc9a0SAchim Leubner   /* register device deregistration callback function */
4354*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device de-registration\n"));
4355*4e1bc9a0SAchim Leubner   status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_REMOVED, (void *)ossaDeregisterDeviceHandleCB);
4356*4e1bc9a0SAchim Leubner   if (status == AGSA_RC_FAILURE)
4357*4e1bc9a0SAchim Leubner   {
4358*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister failed\n"));
4359*4e1bc9a0SAchim Leubner   }
4360*4e1bc9a0SAchim Leubner   else
4361*4e1bc9a0SAchim Leubner   {
4362*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister succeeded\n"));
4363*4e1bc9a0SAchim Leubner   }
4364*4e1bc9a0SAchim Leubner 
4365*4e1bc9a0SAchim Leubner #ifdef ECHO_TESTING
4366*4e1bc9a0SAchim Leubner   /* temporary to test saEchoCommand() */
4367*4e1bc9a0SAchim Leubner   /*
4368*4e1bc9a0SAchim Leubner     send echo
4369*4e1bc9a0SAchim Leubner   */
4370*4e1bc9a0SAchim Leubner   payload[0] = gEcho;
4371*4e1bc9a0SAchim Leubner   payload[55] = gEcho;
4372*4e1bc9a0SAchim Leubner   TI_DBG2(("tiCOMPortInit: calling saEchoCommand gEcho %d\n", gEcho));
4373*4e1bc9a0SAchim Leubner   saEchoCommand(agRoot, agNULL, tdsaRotateQnumber(tiRoot, agNULL), (void *)&payload);
4374*4e1bc9a0SAchim Leubner   gEcho++;
4375*4e1bc9a0SAchim Leubner #endif
4376*4e1bc9a0SAchim Leubner 
4377*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_STATUS_TESTING
4378*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
4379*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
4380*4e1bc9a0SAchim Leubner 
4381*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_INFO_TESTING
4382*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
4383*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
4384*4e1bc9a0SAchim Leubner 
4385*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_ENCRYPT_TESTING
4386*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
4387*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
4388*4e1bc9a0SAchim Leubner 
4389*4e1bc9a0SAchim Leubner 
4390*4e1bc9a0SAchim Leubner #ifdef VPD_TESTING
4391*4e1bc9a0SAchim Leubner   /* temporary to test saSetVPDCommand() and saGetVPDCommand */
4392*4e1bc9a0SAchim Leubner   tdsaVPDSet(tiRoot);
4393*4e1bc9a0SAchim Leubner #endif /* VPD_TESTING */
4394*4e1bc9a0SAchim Leubner 
4395*4e1bc9a0SAchim Leubner #if defined(FDS_DM) && defined(FDS_SM)
4396*4e1bc9a0SAchim Leubner   /* initialize DM then SM */
4397*4e1bc9a0SAchim Leubner   /* DM */
4398*4e1bc9a0SAchim Leubner   dmRoot = &(tdsaAllShared->dmRoot);
4399*4e1bc9a0SAchim Leubner   osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
4400*4e1bc9a0SAchim Leubner 
4401*4e1bc9a0SAchim Leubner   dmMemRequirement.count = DMMemCount;
4402*4e1bc9a0SAchim Leubner 
4403*4e1bc9a0SAchim Leubner   for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
4404*4e1bc9a0SAchim Leubner   {
4405*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: DM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4406*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4407*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4408*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4409*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4410*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4411*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4412*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4413*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4414*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4415*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4416*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4417*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4418*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].physAddrUpper,
4419*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].physAddrLower,
4420*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].totalLength,
4421*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].numElements));
4422*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4423*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].singleElementLength,
4424*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].alignment,
4425*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].type,
4426*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].reserved));
4427*4e1bc9a0SAchim Leubner 
4428*4e1bc9a0SAchim Leubner   }
4429*4e1bc9a0SAchim Leubner 
4430*4e1bc9a0SAchim Leubner   status = dmInitialize(dmRoot,
4431*4e1bc9a0SAchim Leubner                         agRoot,
4432*4e1bc9a0SAchim Leubner                         &dmMemRequirement,
4433*4e1bc9a0SAchim Leubner                         &(tdsaAllShared->dmSwConfig), //&dmSwConfig, /* start here */
4434*4e1bc9a0SAchim Leubner                         loResource->loLevelOption.usecsPerTick);
4435*4e1bc9a0SAchim Leubner 
4436*4e1bc9a0SAchim Leubner   if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
4437*4e1bc9a0SAchim Leubner   {
4438*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
4439*4e1bc9a0SAchim Leubner     return tiError;
4440*4e1bc9a0SAchim Leubner   }
4441*4e1bc9a0SAchim Leubner 
4442*4e1bc9a0SAchim Leubner   /* SM */
4443*4e1bc9a0SAchim Leubner   smRoot = &(tdsaAllShared->smRoot);
4444*4e1bc9a0SAchim Leubner   osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
4445*4e1bc9a0SAchim Leubner 
4446*4e1bc9a0SAchim Leubner   smMemRequirement.count = SMMemCount;
4447*4e1bc9a0SAchim Leubner 
4448*4e1bc9a0SAchim Leubner   for(i=(LLMemCount + DMMemCount);i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
4449*4e1bc9a0SAchim Leubner   {
4450*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: SM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4451*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4452*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4453*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4454*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4455*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4456*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4457*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4458*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4459*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].type = loResource->loLevelMem.mem[i].type;
4460*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount-DMMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4461*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4462*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4463*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].physAddrUpper,
4464*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].physAddrLower,
4465*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].totalLength,
4466*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].numElements));
4467*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4468*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].singleElementLength,
4469*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].alignment,
4470*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].type,
4471*4e1bc9a0SAchim Leubner     loResource->loLevelMem.mem[i].reserved));
4472*4e1bc9a0SAchim Leubner 
4473*4e1bc9a0SAchim Leubner   }
4474*4e1bc9a0SAchim Leubner 
4475*4e1bc9a0SAchim Leubner   status = smInitialize(smRoot,
4476*4e1bc9a0SAchim Leubner                         agRoot,
4477*4e1bc9a0SAchim Leubner                         &smMemRequirement,
4478*4e1bc9a0SAchim Leubner                         &(tdsaAllShared->smSwConfig), //&smSwConfig, /* start here */
4479*4e1bc9a0SAchim Leubner                         loResource->loLevelOption.usecsPerTick);
4480*4e1bc9a0SAchim Leubner 
4481*4e1bc9a0SAchim Leubner   if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
4482*4e1bc9a0SAchim Leubner   {
4483*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
4484*4e1bc9a0SAchim Leubner     return tiError;
4485*4e1bc9a0SAchim Leubner   }
4486*4e1bc9a0SAchim Leubner 
4487*4e1bc9a0SAchim Leubner #elif defined(FDS_DM)
4488*4e1bc9a0SAchim Leubner   dmRoot = &(tdsaAllShared->dmRoot);
4489*4e1bc9a0SAchim Leubner   osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
4490*4e1bc9a0SAchim Leubner 
4491*4e1bc9a0SAchim Leubner   dmMemRequirement.count = DMMemCount;
4492*4e1bc9a0SAchim Leubner 
4493*4e1bc9a0SAchim Leubner   for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
4494*4e1bc9a0SAchim Leubner   {
4495*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4496*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4497*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4498*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4499*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4500*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4501*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4502*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4503*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4504*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4505*4e1bc9a0SAchim Leubner     dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4506*4e1bc9a0SAchim Leubner     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));
4507*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4508*4e1bc9a0SAchim Leubner 
4509*4e1bc9a0SAchim Leubner   }
4510*4e1bc9a0SAchim Leubner 
4511*4e1bc9a0SAchim Leubner   status = dmInitialize(dmRoot,
4512*4e1bc9a0SAchim Leubner                         agRoot,
4513*4e1bc9a0SAchim Leubner                         &dmMemRequirement,
4514*4e1bc9a0SAchim Leubner                         &(tdsaAllShared->dmSwConfig), //&dmSwConfig, /* start here */
4515*4e1bc9a0SAchim Leubner                         loResource->loLevelOption.usecsPerTick);
4516*4e1bc9a0SAchim Leubner 
4517*4e1bc9a0SAchim Leubner   if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
4518*4e1bc9a0SAchim Leubner   {
4519*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
4520*4e1bc9a0SAchim Leubner     return tiError;
4521*4e1bc9a0SAchim Leubner   }
4522*4e1bc9a0SAchim Leubner 
4523*4e1bc9a0SAchim Leubner #elif defined(FDS_SM)
4524*4e1bc9a0SAchim Leubner   smRoot = &(tdsaAllShared->smRoot);
4525*4e1bc9a0SAchim Leubner   osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
4526*4e1bc9a0SAchim Leubner 
4527*4e1bc9a0SAchim Leubner   smMemRequirement.count = SMMemCount;
4528*4e1bc9a0SAchim Leubner 
4529*4e1bc9a0SAchim Leubner   for(i=LLMemCount;i<(int)(LLMemCount + SMMemCount);i++)
4530*4e1bc9a0SAchim Leubner   {
4531*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4532*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4533*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4534*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4535*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4536*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4537*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4538*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4539*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4540*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4541*4e1bc9a0SAchim Leubner     smMemRequirement.smMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4542*4e1bc9a0SAchim Leubner     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));
4543*4e1bc9a0SAchim Leubner     TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4544*4e1bc9a0SAchim Leubner 
4545*4e1bc9a0SAchim Leubner   }
4546*4e1bc9a0SAchim Leubner 
4547*4e1bc9a0SAchim Leubner   status = smInitialize(smRoot,
4548*4e1bc9a0SAchim Leubner                         agRoot,
4549*4e1bc9a0SAchim Leubner                         &smMemRequirement,
4550*4e1bc9a0SAchim Leubner                         &(tdsaAllShared->smSwConfig), //&smSwConfig, /* start here */
4551*4e1bc9a0SAchim Leubner                         loResource->loLevelOption.usecsPerTick);
4552*4e1bc9a0SAchim Leubner 
4553*4e1bc9a0SAchim Leubner   if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
4554*4e1bc9a0SAchim Leubner   {
4555*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
4556*4e1bc9a0SAchim Leubner     return tiError;
4557*4e1bc9a0SAchim Leubner   }
4558*4e1bc9a0SAchim Leubner #else
4559*4e1bc9a0SAchim Leubner   /* nothing */
4560*4e1bc9a0SAchim Leubner #endif /* FDS_DM && FDS_SM */
4561*4e1bc9a0SAchim Leubner 
4562*4e1bc9a0SAchim Leubner   /* call these again after agroot is created  for testing */
4563*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_STATUS_TESTING
4564*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit:again saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
4565*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
4566*4e1bc9a0SAchim Leubner 
4567*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_INFO_TESTING
4568*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit:again saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
4569*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
4570*4e1bc9a0SAchim Leubner 
4571*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_ENCRYPT_TESTING
4572*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortInit:again saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
4573*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
4574*4e1bc9a0SAchim Leubner 
4575*4e1bc9a0SAchim Leubner /* Enable SGPIO */
4576*4e1bc9a0SAchim Leubner   if (tiSuccess == tiCOMConfigureSgpio(tiRoot, agTRUE))
4577*4e1bc9a0SAchim Leubner   {
4578*4e1bc9a0SAchim Leubner     TI_DBG2(("tiCOMPortInit: Successfully sent request to enable SGPIO\n"));
4579*4e1bc9a0SAchim Leubner   }
4580*4e1bc9a0SAchim Leubner   else
4581*4e1bc9a0SAchim Leubner   {
4582*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortInit: Failed to enable SGPIO\n"));
4583*4e1bc9a0SAchim Leubner   }
4584*4e1bc9a0SAchim Leubner 
4585*4e1bc9a0SAchim Leubner   return tiSuccess;
4586*4e1bc9a0SAchim Leubner }
4587*4e1bc9a0SAchim Leubner 
4588*4e1bc9a0SAchim Leubner /*****************************************************************************
4589*4e1bc9a0SAchim Leubner *! \brief SendSgpioRequest
4590*4e1bc9a0SAchim Leubner *
4591*4e1bc9a0SAchim Leubner *  Purpose: This function is used to send SGPIO request during initialization
4592*4e1bc9a0SAchim Leubner *
4593*4e1bc9a0SAchim Leubner *  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
4594*4e1bc9a0SAchim Leubner *                   instance.
4595*4e1bc9a0SAchim Leubner *  \param   regType: Register Type
4596*4e1bc9a0SAchim Leubner *  \param   regIndex: Register Index
4597*4e1bc9a0SAchim Leubner *  \param   regCount: Register Count
4598*4e1bc9a0SAchim Leubner *  \param   writeData: Part of the request
4599*4e1bc9a0SAchim Leubner *
4600*4e1bc9a0SAchim Leubner *  \return:
4601*4e1bc9a0SAchim Leubner *           tiSuccess on success
4602*4e1bc9a0SAchim Leubner *           Other status on failure
4603*4e1bc9a0SAchim Leubner *
4604*4e1bc9a0SAchim Leubner *****************************************************************************/
SendSgpioRequest(tiRoot_t * tiRoot,bit8 regType,bit8 regIndex,bit8 regCount,bit32 * writeData)4605*4e1bc9a0SAchim Leubner static bit32 SendSgpioRequest(
4606*4e1bc9a0SAchim Leubner                             tiRoot_t    *tiRoot,
4607*4e1bc9a0SAchim Leubner                             bit8        regType,
4608*4e1bc9a0SAchim Leubner                             bit8        regIndex,
4609*4e1bc9a0SAchim Leubner                             bit8        regCount,
4610*4e1bc9a0SAchim Leubner                             bit32       *writeData
4611*4e1bc9a0SAchim Leubner                             )
4612*4e1bc9a0SAchim Leubner {
4613*4e1bc9a0SAchim Leubner     static bit32            buffer[128] = {0};
4614*4e1bc9a0SAchim Leubner     bit32                   status = tiError;
4615*4e1bc9a0SAchim Leubner     bit32		    retVal = IOCTL_CALL_FAIL;
4616*4e1bc9a0SAchim Leubner     tiIOCTLPayload_t        *agIOCTLPayload = (tiIOCTLPayload_t *) buffer;
4617*4e1bc9a0SAchim Leubner     agsaSGpioReqResponse_t  *pSGpioReq = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
4618*4e1bc9a0SAchim Leubner     agsaSGpioReqResponse_t  *pSgpioResponse = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
4619*4e1bc9a0SAchim Leubner 
4620*4e1bc9a0SAchim Leubner     do{
4621*4e1bc9a0SAchim Leubner 
4622*4e1bc9a0SAchim Leubner     /* Frame the Ioctl payload */
4623*4e1bc9a0SAchim Leubner     agIOCTLPayload->MajorFunction = IOCTL_MJ_SGPIO;
4624*4e1bc9a0SAchim Leubner     agIOCTLPayload->Length = sizeof(agsaSGpioReqResponse_t);
4625*4e1bc9a0SAchim Leubner 
4626*4e1bc9a0SAchim Leubner     /* Frame the SGPIO request */
4627*4e1bc9a0SAchim Leubner     pSGpioReq->smpFrameType = SMP_REQUEST;
4628*4e1bc9a0SAchim Leubner     pSGpioReq->function = AGSA_WRITE_SGPIO_REGISTER;
4629*4e1bc9a0SAchim Leubner     pSGpioReq->registerType = regType;
4630*4e1bc9a0SAchim Leubner     pSGpioReq->registerIndex = regIndex;
4631*4e1bc9a0SAchim Leubner     pSGpioReq->registerCount = regCount;
4632*4e1bc9a0SAchim Leubner     memcpy(pSGpioReq->readWriteData, writeData, regCount * 4);
4633*4e1bc9a0SAchim Leubner 
4634*4e1bc9a0SAchim Leubner     /* Send the SGPIO request */
4635*4e1bc9a0SAchim Leubner     sgpioResponseSet = 0;
4636*4e1bc9a0SAchim Leubner     retVal = tdsaSGpioIoctlSetup(tiRoot, agNULL, agIOCTLPayload, agNULL, agNULL);
4637*4e1bc9a0SAchim Leubner     if (retVal != IOCTL_CALL_PENDING)
4638*4e1bc9a0SAchim Leubner     {
4639*4e1bc9a0SAchim Leubner 	break;
4640*4e1bc9a0SAchim Leubner     }
4641*4e1bc9a0SAchim Leubner     /* Waiting for SGPIO Response */
4642*4e1bc9a0SAchim Leubner     while(!sgpioResponseSet)
4643*4e1bc9a0SAchim Leubner     {
4644*4e1bc9a0SAchim Leubner 	tiCOMDelayedInterruptHandler(tiRoot, 0, 1, tiNonInterruptContext);
4645*4e1bc9a0SAchim Leubner     }
4646*4e1bc9a0SAchim Leubner     sgpioResponseSet = 0;
4647*4e1bc9a0SAchim Leubner     /* Check the ioctl result */
4648*4e1bc9a0SAchim Leubner     if(agIOCTLPayload->Status != IOCTL_ERR_STATUS_OK)
4649*4e1bc9a0SAchim Leubner     {
4650*4e1bc9a0SAchim Leubner 	break;
4651*4e1bc9a0SAchim Leubner     }
4652*4e1bc9a0SAchim Leubner     /* Check the sgpio function result */
4653*4e1bc9a0SAchim Leubner     if(pSgpioResponse->functionResult != 0x00)
4654*4e1bc9a0SAchim Leubner     {
4655*4e1bc9a0SAchim Leubner 	break;
4656*4e1bc9a0SAchim Leubner     }
4657*4e1bc9a0SAchim Leubner 
4658*4e1bc9a0SAchim Leubner     status = tiSuccess;
4659*4e1bc9a0SAchim Leubner 
4660*4e1bc9a0SAchim Leubner   }while(0);
4661*4e1bc9a0SAchim Leubner 
4662*4e1bc9a0SAchim Leubner     return status;
4663*4e1bc9a0SAchim Leubner }
4664*4e1bc9a0SAchim Leubner 
4665*4e1bc9a0SAchim Leubner /*****************************************************************************
4666*4e1bc9a0SAchim Leubner *! \brief tiCOMConfigureSgpio
4667*4e1bc9a0SAchim Leubner *
4668*4e1bc9a0SAchim Leubner *  Purpose: This function is used to configure SGPIO during initialization
4669*4e1bc9a0SAchim Leubner *
4670*4e1bc9a0SAchim Leubner *  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
4671*4e1bc9a0SAchim Leubner *                   instance.
4672*4e1bc9a0SAchim Leubner *  \param   enableSgpio: Enable / Disable SGPIO
4673*4e1bc9a0SAchim Leubner *
4674*4e1bc9a0SAchim Leubner *  \return:
4675*4e1bc9a0SAchim Leubner *           tiSuccess on success
4676*4e1bc9a0SAchim Leubner *           Other status on failure
4677*4e1bc9a0SAchim Leubner *
4678*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMConfigureSgpio(tiRoot_t * tiRoot,bit8 enableSgpio)4679*4e1bc9a0SAchim Leubner bit32 tiCOMConfigureSgpio(
4680*4e1bc9a0SAchim Leubner                         tiRoot_t    *tiRoot,
4681*4e1bc9a0SAchim Leubner                         bit8        enableSgpio
4682*4e1bc9a0SAchim Leubner                         )
4683*4e1bc9a0SAchim Leubner {
4684*4e1bc9a0SAchim Leubner     bit32	    status = tiError;
4685*4e1bc9a0SAchim Leubner     bit32	    i;
4686*4e1bc9a0SAchim Leubner     bit8            regCount;
4687*4e1bc9a0SAchim Leubner     bit32           writeData[OSSA_SGPIO_MAX_READ_DATA_COUNT] = {0};
4688*4e1bc9a0SAchim Leubner     agsaSGpioCfg0_t *pCfg0 = (agsaSGpioCfg0_t *) &writeData[0];
4689*4e1bc9a0SAchim Leubner     agsaSGpioCfg1_t *pCfg1 = (agsaSGpioCfg1_t *) &writeData[1];
4690*4e1bc9a0SAchim Leubner     tdsaRoot_t	    *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
4691*4e1bc9a0SAchim Leubner     tdsaContext_t   *tdsaAllShared = (tdsaContext_t *) &tdsaRoot->tdsaAllShared;
4692*4e1bc9a0SAchim Leubner     bit32	    phyCount = tdsaAllShared->phyCount;
4693*4e1bc9a0SAchim Leubner 
4694*4e1bc9a0SAchim Leubner     if (enableSgpio)
4695*4e1bc9a0SAchim Leubner     {
4696*4e1bc9a0SAchim Leubner         /* Configure both CFG[0] and CFG[1] */
4697*4e1bc9a0SAchim Leubner         regCount = 2;
4698*4e1bc9a0SAchim Leubner 
4699*4e1bc9a0SAchim Leubner         /* Enable SGPIO */
4700*4e1bc9a0SAchim Leubner         pCfg0->gpioEnable = 1;
4701*4e1bc9a0SAchim Leubner 
4702*4e1bc9a0SAchim Leubner         /* The following are the default values for CFG[1] suggested by SFF-8485 spec */
4703*4e1bc9a0SAchim Leubner         /* Maximum Activity ON: 2 */
4704*4e1bc9a0SAchim Leubner         /* Forced Activity OFF: 1 */
4705*4e1bc9a0SAchim Leubner         pCfg1->maxActOn = 2;
4706*4e1bc9a0SAchim Leubner         pCfg1->forceActOff = 1;
4707*4e1bc9a0SAchim Leubner     }
4708*4e1bc9a0SAchim Leubner     else
4709*4e1bc9a0SAchim Leubner     {
4710*4e1bc9a0SAchim Leubner         /* Configure CFG[0] only */
4711*4e1bc9a0SAchim Leubner         regCount = 1;
4712*4e1bc9a0SAchim Leubner 
4713*4e1bc9a0SAchim Leubner         /* Disable SGPIO */
4714*4e1bc9a0SAchim Leubner         pCfg0->gpioEnable = 0;
4715*4e1bc9a0SAchim Leubner     }
4716*4e1bc9a0SAchim Leubner 
4717*4e1bc9a0SAchim Leubner     status = SendSgpioRequest(tiRoot, AGSA_SGPIO_CONFIG_REG, 0, regCount, writeData);
4718*4e1bc9a0SAchim Leubner     if((tiSuccess == status) && (enableSgpio))
4719*4e1bc9a0SAchim Leubner     {
4720*4e1bc9a0SAchim Leubner 	 /* Write default values to transmit registers */
4721*4e1bc9a0SAchim Leubner 	 /* RegisterCount = Number of phys present in HBA / 4 */
4722*4e1bc9a0SAchim Leubner 	 regCount = phyCount / 4;
4723*4e1bc9a0SAchim Leubner          for(i = 0; i < regCount; i++)
4724*4e1bc9a0SAchim Leubner 	 {
4725*4e1bc9a0SAchim Leubner 	   /* Following are the default values specified in SFF-8485 spec */
4726*4e1bc9a0SAchim Leubner 	   /* Activity: 5 */
4727*4e1bc9a0SAchim Leubner 	   /* Locate: 0 */
4728*4e1bc9a0SAchim Leubner 	   /* Error: 0 */
4729*4e1bc9a0SAchim Leubner 	   writeData[i] = 0xA0A0A0A0;
4730*4e1bc9a0SAchim Leubner   	}
4731*4e1bc9a0SAchim Leubner 	status = SendSgpioRequest(tiRoot, AGSA_SGPIO_DRIVE_BY_DRIVE_TRANSMIT_REG, 0, regCount, writeData);
4732*4e1bc9a0SAchim Leubner    }
4733*4e1bc9a0SAchim Leubner 
4734*4e1bc9a0SAchim Leubner    return status;
4735*4e1bc9a0SAchim Leubner }
4736*4e1bc9a0SAchim Leubner 
4737*4e1bc9a0SAchim Leubner 
4738*4e1bc9a0SAchim Leubner /*****************************************************************************
4739*4e1bc9a0SAchim Leubner *! \brief  tiCOMPortStart
4740*4e1bc9a0SAchim Leubner *
4741*4e1bc9a0SAchim Leubner *  Purpose: This function is called to bring the port hardware online. This
4742*4e1bc9a0SAchim Leubner *           call could only be called until after the successful completion
4743*4e1bc9a0SAchim Leubner *           tiCOMPortInit().
4744*4e1bc9a0SAchim Leubner *
4745*4e1bc9a0SAchim Leubner *  \param  tiRoot:          Pointer to root data structure.
4746*4e1bc9a0SAchim Leubner *  \param  portID:          A ID for this portal to be used by the TD Layer
4747*4e1bc9a0SAchim Leubner *                           to get the portal configuration information.
4748*4e1bc9a0SAchim Leubner *  \param  portalContext:   Pointer to the context for this portal.
4749*4e1bc9a0SAchim Leubner *  \param  option:          An option for starting a port
4750*4e1bc9a0SAchim Leubner *
4751*4e1bc9a0SAchim Leubner *  \return:
4752*4e1bc9a0SAchim Leubner *          tiSuccess:      Successful.
4753*4e1bc9a0SAchim Leubner *          Others:             Fail.
4754*4e1bc9a0SAchim Leubner *
4755*4e1bc9a0SAchim Leubner *  \note -
4756*4e1bc9a0SAchim Leubner *   If sas or sata initiator, this will be called 8 (the number of phys) times.
4757*4e1bc9a0SAchim Leubner *   If both sas and sata initiator, this will be called 16 times
4758*4e1bc9a0SAchim Leubner *
4759*4e1bc9a0SAchim Leubner *****************************************************************************/
4760*4e1bc9a0SAchim Leubner /* portID is used as PhyID
4761*4e1bc9a0SAchim Leubner    Should return always tiSuccess. PortStarted is returned in ossaHwCB()
4762*4e1bc9a0SAchim Leubner */
4763*4e1bc9a0SAchim Leubner osGLOBAL bit32
tiCOMPortStart(tiRoot_t * tiRoot,bit32 portID,tiPortalContext_t * portalContext,bit32 option)4764*4e1bc9a0SAchim Leubner tiCOMPortStart(
4765*4e1bc9a0SAchim Leubner                tiRoot_t          * tiRoot,
4766*4e1bc9a0SAchim Leubner                bit32               portID,
4767*4e1bc9a0SAchim Leubner                tiPortalContext_t * portalContext,
4768*4e1bc9a0SAchim Leubner                bit32               option
4769*4e1bc9a0SAchim Leubner                )
4770*4e1bc9a0SAchim Leubner {
4771*4e1bc9a0SAchim Leubner   tdsaRoot_t    *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
4772*4e1bc9a0SAchim Leubner   tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
4773*4e1bc9a0SAchim Leubner   agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
4774*4e1bc9a0SAchim Leubner   agsaSASProtocolTimerConfigurationPage_t SASConfigPage;
4775*4e1bc9a0SAchim Leubner   bit32 status = AGSA_RC_FAILURE;
4776*4e1bc9a0SAchim Leubner   static bit32 IsSendSASConfigPage = agFALSE;
4777*4e1bc9a0SAchim Leubner 
4778*4e1bc9a0SAchim Leubner 
4779*4e1bc9a0SAchim Leubner   TI_DBG3(("tiCOMPortStart: start portID %d\n", portID));
4780*4e1bc9a0SAchim Leubner 
4781*4e1bc9a0SAchim Leubner   /*
4782*4e1bc9a0SAchim Leubner    * return error if reset is in progress
4783*4e1bc9a0SAchim Leubner    */
4784*4e1bc9a0SAchim Leubner   if (tdsaAllShared->flags.resetInProgress == agTRUE)
4785*4e1bc9a0SAchim Leubner   {
4786*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: reset error\n"));
4787*4e1bc9a0SAchim Leubner     return tiError;
4788*4e1bc9a0SAchim Leubner   }
4789*4e1bc9a0SAchim Leubner 
4790*4e1bc9a0SAchim Leubner   /*
4791*4e1bc9a0SAchim Leubner    *
4792*4e1bc9a0SAchim Leubner    * port is not initialized, return error
4793*4e1bc9a0SAchim Leubner    */
4794*4e1bc9a0SAchim Leubner   if (tdsaAllShared->Ports[portID].flags.portInitialized == agFALSE)
4795*4e1bc9a0SAchim Leubner   {
4796*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: not intialized error\n"));
4797*4e1bc9a0SAchim Leubner     return tiError;
4798*4e1bc9a0SAchim Leubner   }
4799*4e1bc9a0SAchim Leubner 
4800*4e1bc9a0SAchim Leubner   /* portal has been started. */
4801*4e1bc9a0SAchim Leubner   if (portalContext->tdData != NULL)
4802*4e1bc9a0SAchim Leubner   {
4803*4e1bc9a0SAchim Leubner     if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
4804*4e1bc9a0SAchim Leubner     {
4805*4e1bc9a0SAchim Leubner       TI_DBG3 (("tiCOMPortStart : Cannot start port again: Port has already been started\n"));
4806*4e1bc9a0SAchim Leubner       ostiPortEvent (
4807*4e1bc9a0SAchim Leubner                      tiRoot,
4808*4e1bc9a0SAchim Leubner                      tiPortStarted,
4809*4e1bc9a0SAchim Leubner                      tiSuccess,
4810*4e1bc9a0SAchim Leubner                      (void *) tdsaAllShared->Ports[portID].tiPortalContext
4811*4e1bc9a0SAchim Leubner                      );
4812*4e1bc9a0SAchim Leubner       return tiSuccess;
4813*4e1bc9a0SAchim Leubner     }
4814*4e1bc9a0SAchim Leubner   }
4815*4e1bc9a0SAchim Leubner 
4816*4e1bc9a0SAchim Leubner   portalContext->tdData =  &(tdsaAllShared->Ports[portID]);
4817*4e1bc9a0SAchim Leubner   TI_DBG4 (("tiCOMPortStart : saving portalconext portID %d tdsaAllShared %p\n", portID, tdsaAllShared));
4818*4e1bc9a0SAchim Leubner   /* saving tiportalContext_t */
4819*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].tiPortalContext = portalContext;
4820*4e1bc9a0SAchim Leubner   TI_DBG4(("tiCOMPortStart : portID/phyID %d tiPortalContext %p\n", portID, tdsaAllShared->Ports[portID].tiPortalContext));
4821*4e1bc9a0SAchim Leubner 
4822*4e1bc9a0SAchim Leubner   /*
4823*4e1bc9a0SAchim Leubner     where is "tdsaAllShared->Ports[0].portContext" set?
4824*4e1bc9a0SAchim Leubner     in ossaHWCB
4825*4e1bc9a0SAchim Leubner   */
4826*4e1bc9a0SAchim Leubner   if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
4827*4e1bc9a0SAchim Leubner   {
4828*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: port already has been started \n"));
4829*4e1bc9a0SAchim Leubner     return tiSuccess;
4830*4e1bc9a0SAchim Leubner   }
4831*4e1bc9a0SAchim Leubner 
4832*4e1bc9a0SAchim Leubner 
4833*4e1bc9a0SAchim Leubner   /*
4834*4e1bc9a0SAchim Leubner     hardcode sasID frame. It should be read by ostigettransportparams later from configuration file
4835*4e1bc9a0SAchim Leubner   */
4836*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
4837*4e1bc9a0SAchim Leubner 
4838*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = 0;
4839*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
4840*4e1bc9a0SAchim Leubner       = SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
4841*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4842*4e1bc9a0SAchim Leubner 
4843*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4844*4e1bc9a0SAchim Leubner 
4845*4e1bc9a0SAchim Leubner #endif
4846*4e1bc9a0SAchim Leubner 
4847*4e1bc9a0SAchim Leubner #ifdef TARGET_DRIVER
4848*4e1bc9a0SAchim Leubner 
4849*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
4850*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp = 0;
4851*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4852*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4853*4e1bc9a0SAchim Leubner 
4854*4e1bc9a0SAchim Leubner #endif
4855*4e1bc9a0SAchim Leubner 
4856*4e1bc9a0SAchim Leubner #if defined (INITIATOR_DRIVER) && defined (TARGET_DRIVER)
4857*4e1bc9a0SAchim Leubner 
4858*4e1bc9a0SAchim Leubner   /* for combo testing */
4859*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
4860*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
4861*4e1bc9a0SAchim Leubner       = SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
4862*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4863*4e1bc9a0SAchim Leubner 
4864*4e1bc9a0SAchim Leubner   tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4865*4e1bc9a0SAchim Leubner 
4866*4e1bc9a0SAchim Leubner #endif
4867*4e1bc9a0SAchim Leubner 
4868*4e1bc9a0SAchim Leubner 
4869*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortStart: before pid %d\n", portID));
4870*4e1bc9a0SAchim Leubner   tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
4871*4e1bc9a0SAchim Leubner 
4872*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortStart: sysIntsActive %s\n",
4873*4e1bc9a0SAchim Leubner            (tdsaAllShared->flags.sysIntsActive == agTRUE) ? "agTRUE" : "agFALSE"));
4874*4e1bc9a0SAchim Leubner 
4875*4e1bc9a0SAchim Leubner   /* Read global configuration first then card-specific configuration */
4876*4e1bc9a0SAchim Leubner 
4877*4e1bc9a0SAchim Leubner   /* the following must be processed only once */
4878*4e1bc9a0SAchim Leubner   if ( tdsaAllShared->first_process == agFALSE)
4879*4e1bc9a0SAchim Leubner   {
4880*4e1bc9a0SAchim Leubner     tdsaGetGlobalPhyParams(tiRoot);
4881*4e1bc9a0SAchim Leubner     tdsaGetCardPhyParams(tiRoot);
4882*4e1bc9a0SAchim Leubner     tdsaAllShared->first_process = agTRUE;
4883*4e1bc9a0SAchim Leubner   }
4884*4e1bc9a0SAchim Leubner 
4885*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortStart: after pid %d\n", portID));
4886*4e1bc9a0SAchim Leubner   tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
4887*4e1bc9a0SAchim Leubner 
4888*4e1bc9a0SAchim Leubner   /*
4889*4e1bc9a0SAchim Leubner      Phy Calibration
4890*4e1bc9a0SAchim Leubner   */
4891*4e1bc9a0SAchim Leubner   if (tdsaAllShared->phyCalibration)
4892*4e1bc9a0SAchim Leubner   {
4893*4e1bc9a0SAchim Leubner     /* Change default phy calibration */
4894*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
4895*4e1bc9a0SAchim Leubner       (tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | 0x80;
4896*4e1bc9a0SAchim Leubner     /* Setting index of phy calibration table index
4897*4e1bc9a0SAchim Leubner        portID is used as phy calibration table index
4898*4e1bc9a0SAchim Leubner     */
4899*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
4900*4e1bc9a0SAchim Leubner       (tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | (portID << 8);
4901*4e1bc9a0SAchim Leubner   }
4902*4e1bc9a0SAchim Leubner   TI_DBG2(("tiCOMPortStart: tdsaAllShared->Ports[0x%x].agPhyConfig.phyProperties 0x%x\n",
4903*4e1bc9a0SAchim Leubner     portID, tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
4904*4e1bc9a0SAchim Leubner 
4905*4e1bc9a0SAchim Leubner 
4906*4e1bc9a0SAchim Leubner   if(gSSC_Disable)
4907*4e1bc9a0SAchim Leubner   {
4908*4e1bc9a0SAchim Leubner     tdsaAllShared->Ports[portID].agPhyConfig.phyProperties = tdsaAllShared->Ports[portID].agPhyConfig.phyProperties | 0x40000;
4909*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart:gSSC_Disable tdsaAllShared->Ports[portID].agPhyConfig.phyProperties 0x%x\n", tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
4910*4e1bc9a0SAchim Leubner 
4911*4e1bc9a0SAchim Leubner   }
4912*4e1bc9a0SAchim Leubner 
4913*4e1bc9a0SAchim Leubner   if(tIsSPCV12or6G(agRoot) && !IsSendSASConfigPage) /* Not SPC */
4914*4e1bc9a0SAchim Leubner   {
4915*4e1bc9a0SAchim Leubner     /* call saSetControllerConfig() to set STP_IDLE_TIME; All others are the defaults */
4916*4e1bc9a0SAchim Leubner     osti_memset(&SASConfigPage, 0, sizeof(agsaSASProtocolTimerConfigurationPage_t));
4917*4e1bc9a0SAchim Leubner     SASConfigPage.pageCode        =  AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE;
4918*4e1bc9a0SAchim Leubner     SASConfigPage.MST_MSI         =  3 << 15; /* enables both MCT for SSP target and initiator */
4919*4e1bc9a0SAchim Leubner     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 */
4920*4e1bc9a0SAchim Leubner     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 */
4921*4e1bc9a0SAchim Leubner     SASConfigPage.STP_IDLE_TMO    =  tdsaAllShared->stp_idle_time;
4922*4e1bc9a0SAchim Leubner     if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF)
4923*4e1bc9a0SAchim Leubner     {
4924*4e1bc9a0SAchim Leubner       SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF;
4925*4e1bc9a0SAchim Leubner     }
4926*4e1bc9a0SAchim Leubner     SASConfigPage.OPNRJT_RTRY_INTVL =         (tdsaAllShared->MFD << 16)              | tdsaAllShared->OPNRJT_RTRY_INTVL; /* Multi Data Fetach enabled and 2 us for Open Reject Retry interval */
4927*4e1bc9a0SAchim Leubner     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 */
4928*4e1bc9a0SAchim Leubner     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 */
4929*4e1bc9a0SAchim Leubner     SASConfigPage.MAX_AIP =  tdsaAllShared->MAX_AIP; /* MAX AIP. Default is  0x200000 */
4930*4e1bc9a0SAchim Leubner 
4931*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.pageCode                 0x%08x\n",SASConfigPage.pageCode));
4932*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MST_MSI                  0x%08x\n",SASConfigPage.MST_MSI));
4933*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_SSP_MCT_TMO          0x%08x\n",SASConfigPage.STP_SSP_MCT_TMO));
4934*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_FRM_TMO              0x%08x\n",SASConfigPage.STP_FRM_TMO));
4935*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_IDLE_TMO             0x%08x\n",SASConfigPage.STP_IDLE_TMO));
4936*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.OPNRJT_RTRY_INTVL        0x%08x\n",SASConfigPage.OPNRJT_RTRY_INTVL));
4937*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO));
4938*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR));
4939*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MAX_AIP                  0x%08x\n",SASConfigPage.MAX_AIP));
4940*4e1bc9a0SAchim Leubner 
4941*4e1bc9a0SAchim Leubner     status = saSetControllerConfig(agRoot,
4942*4e1bc9a0SAchim Leubner                                     0,
4943*4e1bc9a0SAchim Leubner                                     AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE,
4944*4e1bc9a0SAchim Leubner                                     sizeof(agsaSASProtocolTimerConfigurationPage_t),
4945*4e1bc9a0SAchim Leubner                                     &SASConfigPage,
4946*4e1bc9a0SAchim Leubner                                     agNULL);
4947*4e1bc9a0SAchim Leubner     if (status != AGSA_RC_SUCCESS)
4948*4e1bc9a0SAchim Leubner     {
4949*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMPortStart: calling saSetControllerConfig() failed\n"));
4950*4e1bc9a0SAchim Leubner     }
4951*4e1bc9a0SAchim Leubner     else
4952*4e1bc9a0SAchim Leubner     {
4953*4e1bc9a0SAchim Leubner       TI_DBG2(("tiCOMPortStart: calling saSetControllerConfig() is OK\n"));
4954*4e1bc9a0SAchim Leubner     }
4955*4e1bc9a0SAchim Leubner     IsSendSASConfigPage = agTRUE;
4956*4e1bc9a0SAchim Leubner   }
4957*4e1bc9a0SAchim Leubner   else
4958*4e1bc9a0SAchim Leubner   {
4959*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStart: saSetControllerConfig not called tIsSPCV12or6G %d IsSendSASConfigPage %d\n",tIsSPCV12or6G(agRoot),IsSendSASConfigPage));
4960*4e1bc9a0SAchim Leubner   }
4961*4e1bc9a0SAchim Leubner 
4962*4e1bc9a0SAchim Leubner   /* maps portID to phyID */
4963*4e1bc9a0SAchim Leubner   status = saPhyStart(agRoot,
4964*4e1bc9a0SAchim Leubner                       agNULL,
4965*4e1bc9a0SAchim Leubner                       0,
4966*4e1bc9a0SAchim Leubner                       portID,
4967*4e1bc9a0SAchim Leubner                       &(tdsaAllShared->Ports[portID].agPhyConfig),
4968*4e1bc9a0SAchim Leubner                       &(tdsaAllShared->Ports[portID].SASID)
4969*4e1bc9a0SAchim Leubner                       );
4970*4e1bc9a0SAchim Leubner 
4971*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMPortStart: saPhyStart status %d\n", status));
4972*4e1bc9a0SAchim Leubner 
4973*4e1bc9a0SAchim Leubner   if (status == AGSA_RC_SUCCESS)
4974*4e1bc9a0SAchim Leubner   {
4975*4e1bc9a0SAchim Leubner     TI_DBG3(("tiCOMPortStart : calling portstarted\n"));
4976*4e1bc9a0SAchim Leubner     ostiPortEvent(
4977*4e1bc9a0SAchim Leubner                   tiRoot,
4978*4e1bc9a0SAchim Leubner                   tiPortStarted,
4979*4e1bc9a0SAchim Leubner                   tiSuccess,
4980*4e1bc9a0SAchim Leubner                   (void *) tdsaAllShared->Ports[portID].tiPortalContext
4981*4e1bc9a0SAchim Leubner                   );
4982*4e1bc9a0SAchim Leubner     return tiSuccess;
4983*4e1bc9a0SAchim Leubner   }
4984*4e1bc9a0SAchim Leubner   else
4985*4e1bc9a0SAchim Leubner   {
4986*4e1bc9a0SAchim Leubner     TI_DBG3(("tiCOMPortStart : cant' start port\n"));
4987*4e1bc9a0SAchim Leubner     return tiError;
4988*4e1bc9a0SAchim Leubner   }
4989*4e1bc9a0SAchim Leubner 
4990*4e1bc9a0SAchim Leubner }
4991*4e1bc9a0SAchim Leubner 
4992*4e1bc9a0SAchim Leubner /*****************************************************************************
4993*4e1bc9a0SAchim Leubner *! \brief  tiCOMPortStop
4994*4e1bc9a0SAchim Leubner *
4995*4e1bc9a0SAchim Leubner *  Purpose: This function is called to bring the port hardware down.
4996*4e1bc9a0SAchim Leubner *
4997*4e1bc9a0SAchim Leubner *  \param  tiRoot:          Pointer to root data structure.
4998*4e1bc9a0SAchim Leubner *  \param  portalContext:   Pointer to the context for this portal.
4999*4e1bc9a0SAchim Leubner *
5000*4e1bc9a0SAchim Leubner *  \return:
5001*4e1bc9a0SAchim Leubner *          tiSuccess:      Successful.
5002*4e1bc9a0SAchim Leubner *          Others:             Fail.
5003*4e1bc9a0SAchim Leubner *
5004*4e1bc9a0SAchim Leubner *  \note -
5005*4e1bc9a0SAchim Leubner *
5006*4e1bc9a0SAchim Leubner *****************************************************************************/
5007*4e1bc9a0SAchim Leubner osGLOBAL bit32
tiCOMPortStop(tiRoot_t * tiRoot,tiPortalContext_t * portalContext)5008*4e1bc9a0SAchim Leubner tiCOMPortStop (
5009*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot,
5010*4e1bc9a0SAchim Leubner   tiPortalContext_t *portalContext
5011*4e1bc9a0SAchim Leubner   )
5012*4e1bc9a0SAchim Leubner {
5013*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5014*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5015*4e1bc9a0SAchim Leubner   tdList_t          *PortContextList;
5016*4e1bc9a0SAchim Leubner   tdsaPortContext_t *onePortContext = agNULL;
5017*4e1bc9a0SAchim Leubner   agsaRoot_t        *agRoot = agNULL;
5018*4e1bc9a0SAchim Leubner   bit32             i;
5019*4e1bc9a0SAchim Leubner   bit32             found = agFALSE;
5020*4e1bc9a0SAchim Leubner 
5021*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_STATUS_TESTING
5022*4e1bc9a0SAchim Leubner   agsaControllerStatus_t  agcontrollerStatus;
5023*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_STATUS_TESTING */
5024*4e1bc9a0SAchim Leubner 
5025*4e1bc9a0SAchim Leubner 
5026*4e1bc9a0SAchim Leubner   TI_DBG3(("tiCOMPortStop: start\n"));
5027*4e1bc9a0SAchim Leubner   /*
5028*4e1bc9a0SAchim Leubner     find the portcontext
5029*4e1bc9a0SAchim Leubner     find phys belonging to that portcotext
5030*4e1bc9a0SAchim Leubner     call saPhyStop for all those phys
5031*4e1bc9a0SAchim Leubner     call saPhyStop()
5032*4e1bc9a0SAchim Leubner     remove the portcontext from the portcontext list
5033*4e1bc9a0SAchim Leubner   */
5034*4e1bc9a0SAchim Leubner 
5035*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5036*4e1bc9a0SAchim Leubner 
5037*4e1bc9a0SAchim Leubner #ifdef CONTROLLER_STATUS_TESTING
5038*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMPortStop: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
5039*4e1bc9a0SAchim Leubner #endif /* CONTROLLER_INFO_TESTING */
5040*4e1bc9a0SAchim Leubner 
5041*4e1bc9a0SAchim Leubner   if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
5042*4e1bc9a0SAchim Leubner   {
5043*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStop: empty tdsaPortContext\n"));
5044*4e1bc9a0SAchim Leubner     return tiError;
5045*4e1bc9a0SAchim Leubner   }
5046*4e1bc9a0SAchim Leubner 
5047*4e1bc9a0SAchim Leubner   /* find a right portcontext */
5048*4e1bc9a0SAchim Leubner   PortContextList = tdsaAllShared->MainPortContextList.flink;
5049*4e1bc9a0SAchim Leubner   while (PortContextList != &(tdsaAllShared->MainPortContextList))
5050*4e1bc9a0SAchim Leubner   {
5051*4e1bc9a0SAchim Leubner     onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
5052*4e1bc9a0SAchim Leubner     if (onePortContext == agNULL)
5053*4e1bc9a0SAchim Leubner     {
5054*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMPortStop: onePortContext is NULL!!!\n"));
5055*4e1bc9a0SAchim Leubner       return tiError;
5056*4e1bc9a0SAchim Leubner     }
5057*4e1bc9a0SAchim Leubner     if (onePortContext->tiPortalContext == portalContext)
5058*4e1bc9a0SAchim Leubner     {
5059*4e1bc9a0SAchim Leubner       TI_DBG6(("tiCOMPortStop: found; oneportContext ID %d\n", onePortContext->id));
5060*4e1bc9a0SAchim Leubner       found = agTRUE;
5061*4e1bc9a0SAchim Leubner       break;
5062*4e1bc9a0SAchim Leubner     }
5063*4e1bc9a0SAchim Leubner     PortContextList = PortContextList->flink;
5064*4e1bc9a0SAchim Leubner   }
5065*4e1bc9a0SAchim Leubner 
5066*4e1bc9a0SAchim Leubner   if (found == agFALSE)
5067*4e1bc9a0SAchim Leubner   {
5068*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMPortStop: No corressponding tdsaPortContext\n"));
5069*4e1bc9a0SAchim Leubner     return tiError;
5070*4e1bc9a0SAchim Leubner   }
5071*4e1bc9a0SAchim Leubner 
5072*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
5073*4e1bc9a0SAchim Leubner   /* reset the fields of portcontext */
5074*4e1bc9a0SAchim Leubner   onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED;
5075*4e1bc9a0SAchim Leubner   onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START;
5076*4e1bc9a0SAchim Leubner #endif /* INITIATOR_DRIVER */
5077*4e1bc9a0SAchim Leubner 
5078*4e1bc9a0SAchim Leubner   onePortContext->Count = 0;
5079*4e1bc9a0SAchim Leubner   onePortContext->agContext.osData = onePortContext;
5080*4e1bc9a0SAchim Leubner   for(i=0;i<TD_MAX_NUM_PHYS;i++)
5081*4e1bc9a0SAchim Leubner   {
5082*4e1bc9a0SAchim Leubner     if (onePortContext->PhyIDList[i] == agTRUE)
5083*4e1bc9a0SAchim Leubner     {
5084*4e1bc9a0SAchim Leubner       tdsaAllShared->Ports[i].portContext = agNULL;
5085*4e1bc9a0SAchim Leubner #ifdef CCFLAGS_PHYCONTROL_COUNTS
5086*4e1bc9a0SAchim Leubner       if( tiIS_SPC(agRoot) )
5087*4e1bc9a0SAchim Leubner       {
5088*4e1bc9a0SAchim Leubner 
5089*4e1bc9a0SAchim Leubner         saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_ERROR_COUNTS, agNULL);
5090*4e1bc9a0SAchim Leubner         saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_CLEAR_ERROR_COUNTS, agNULL);
5091*4e1bc9a0SAchim Leubner         saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_BW_COUNTS, agNULL);
5092*4e1bc9a0SAchim Leubner       }
5093*4e1bc9a0SAchim Leubner       else
5094*4e1bc9a0SAchim Leubner       {
5095*4e1bc9a0SAchim Leubner         TI_DBG1(("\ntiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
5096*4e1bc9a0SAchim Leubner         saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_PAGE, i);
5097*4e1bc9a0SAchim Leubner         saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_BW_COUNTERS_PAGE,i);
5098*4e1bc9a0SAchim Leubner         saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ANALOG_SETTINGS_PAGE,i);
5099*4e1bc9a0SAchim Leubner         saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_GENERAL_STATUS_PAGE,i);
5100*4e1bc9a0SAchim Leubner         saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_CLR_PAGE,i);
5101*4e1bc9a0SAchim Leubner 
5102*4e1bc9a0SAchim Leubner         TI_DBG1(("tiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
5103*4e1bc9a0SAchim Leubner 
5104*4e1bc9a0SAchim Leubner       }
5105*4e1bc9a0SAchim Leubner 
5106*4e1bc9a0SAchim Leubner #endif /* CCFLAGS_PHYCONTROL_COUNTS */
5107*4e1bc9a0SAchim Leubner       saPhyStop(agRoot, &onePortContext->agContext, 0, i);
5108*4e1bc9a0SAchim Leubner     }
5109*4e1bc9a0SAchim Leubner   }
5110*4e1bc9a0SAchim Leubner 
5111*4e1bc9a0SAchim Leubner   return tiSuccess;
5112*4e1bc9a0SAchim Leubner }
5113*4e1bc9a0SAchim Leubner 
5114*4e1bc9a0SAchim Leubner 
5115*4e1bc9a0SAchim Leubner /*****************************************************************************
5116*4e1bc9a0SAchim Leubner *! \brief tiCOMGetPortInfo
5117*4e1bc9a0SAchim Leubner *
5118*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to return information about the specific
5119*4e1bc9a0SAchim Leubner *            port instant
5120*4e1bc9a0SAchim Leubner *
5121*4e1bc9a0SAchim Leubner *
5122*4e1bc9a0SAchim Leubner *  \param   tiRoot:        Pointer to driver/port instance.
5123*4e1bc9a0SAchim Leubner *  \param   portalContext  Pointer to the context for this portal.
5124*4e1bc9a0SAchim Leubner *  \param   tiPortInfo:    Pointer to port information structure.
5125*4e1bc9a0SAchim Leubner *
5126*4e1bc9a0SAchim Leubner *  \Return: tiSuccess
5127*4e1bc9a0SAchim Leubner *
5128*4e1bc9a0SAchim Leubner *****************************************************************************/
5129*4e1bc9a0SAchim Leubner /*
5130*4e1bc9a0SAchim Leubner   can't find tdsaportcontext in this function
5131*4e1bc9a0SAchim Leubner   since discovery has not been called by OS layer yet
5132*4e1bc9a0SAchim Leubner   Therefore, hardcoded value are being returned for now
5133*4e1bc9a0SAchim Leubner */
tiCOMGetPortInfo(tiRoot_t * tiRoot,tiPortalContext_t * portalContext,tiPortInfo_t * tiPortInfo)5134*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMGetPortInfo(
5135*4e1bc9a0SAchim Leubner                                 tiRoot_t            *tiRoot,
5136*4e1bc9a0SAchim Leubner                                 tiPortalContext_t   *portalContext,
5137*4e1bc9a0SAchim Leubner                                 tiPortInfo_t        *tiPortInfo
5138*4e1bc9a0SAchim Leubner                                 )
5139*4e1bc9a0SAchim Leubner 
5140*4e1bc9a0SAchim Leubner {
5141*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5142*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5143*4e1bc9a0SAchim Leubner   tdList_t          *PortContextList;
5144*4e1bc9a0SAchim Leubner   tdsaPortContext_t *onePortContext = agNULL;
5145*4e1bc9a0SAchim Leubner   bit32             found = agFALSE;
5146*4e1bc9a0SAchim Leubner   static bit8       localname[68], remotename[68];
5147*4e1bc9a0SAchim Leubner 
5148*4e1bc9a0SAchim Leubner   TI_DBG6(("tiCOMGetPortInfo: start\n"));
5149*4e1bc9a0SAchim Leubner 
5150*4e1bc9a0SAchim Leubner 
5151*4e1bc9a0SAchim Leubner   tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
5152*4e1bc9a0SAchim Leubner   if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
5153*4e1bc9a0SAchim Leubner   {
5154*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
5155*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMGetPortInfo: No tdsaPortContext\n"));
5156*4e1bc9a0SAchim Leubner     return tiError;
5157*4e1bc9a0SAchim Leubner   }
5158*4e1bc9a0SAchim Leubner   else
5159*4e1bc9a0SAchim Leubner   {
5160*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
5161*4e1bc9a0SAchim Leubner   }
5162*4e1bc9a0SAchim Leubner 
5163*4e1bc9a0SAchim Leubner   /* find a corresponding portcontext */
5164*4e1bc9a0SAchim Leubner   PortContextList = tdsaAllShared->MainPortContextList.flink;
5165*4e1bc9a0SAchim Leubner   while (PortContextList != &(tdsaAllShared->MainPortContextList))
5166*4e1bc9a0SAchim Leubner   {
5167*4e1bc9a0SAchim Leubner     onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
5168*4e1bc9a0SAchim Leubner     TI_DBG3(("tiCOMGetPortInfo: oneportContext pid %d\n", onePortContext->id));
5169*4e1bc9a0SAchim Leubner     if (onePortContext->tiPortalContext == portalContext && onePortContext->valid == agTRUE)
5170*4e1bc9a0SAchim Leubner     {
5171*4e1bc9a0SAchim Leubner       TI_DBG3(("tiCOMGetPortInfo: found; oneportContext pid %d\n", onePortContext->id));
5172*4e1bc9a0SAchim Leubner       found = agTRUE;
5173*4e1bc9a0SAchim Leubner       break;
5174*4e1bc9a0SAchim Leubner     }
5175*4e1bc9a0SAchim Leubner     PortContextList = PortContextList->flink;
5176*4e1bc9a0SAchim Leubner   }
5177*4e1bc9a0SAchim Leubner 
5178*4e1bc9a0SAchim Leubner   if (found == agFALSE)
5179*4e1bc9a0SAchim Leubner   {
5180*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMGetPortInfo: First, No corresponding tdsaPortContext\n"));
5181*4e1bc9a0SAchim Leubner     return tiError;
5182*4e1bc9a0SAchim Leubner   }
5183*4e1bc9a0SAchim Leubner 
5184*4e1bc9a0SAchim Leubner   if (onePortContext == agNULL)
5185*4e1bc9a0SAchim Leubner   {
5186*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMGetPortInfo: Second, No corressponding tdsaPortContext\n"));
5187*4e1bc9a0SAchim Leubner     return tiError;
5188*4e1bc9a0SAchim Leubner   }
5189*4e1bc9a0SAchim Leubner 
5190*4e1bc9a0SAchim Leubner   osti_memset(localname, 0, sizeof(localname));
5191*4e1bc9a0SAchim Leubner   osti_memset(remotename, 0, sizeof(remotename));
5192*4e1bc9a0SAchim Leubner 
5193*4e1bc9a0SAchim Leubner   /*
5194*4e1bc9a0SAchim Leubner     Parse the type of port then fill in the information
5195*4e1bc9a0SAchim Leubner   */
5196*4e1bc9a0SAchim Leubner   if ( onePortContext->sasRemoteAddressHi == 0xFFFFFFFF && onePortContext->sasRemoteAddressLo == 0xFFFFFFFF)
5197*4e1bc9a0SAchim Leubner   {
5198*4e1bc9a0SAchim Leubner     /* directly attached SATA port */
5199*4e1bc9a0SAchim Leubner     osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
5200*4e1bc9a0SAchim Leubner     osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
5201*4e1bc9a0SAchim Leubner     tiPortInfo->localNameLen = 8;
5202*4e1bc9a0SAchim Leubner     /* information is from SATA ID device data. remoteName is serial number, firmware version, model number */
5203*4e1bc9a0SAchim Leubner     osti_memcpy(remotename, onePortContext->remoteName, 68);
5204*4e1bc9a0SAchim Leubner     tiPortInfo->remoteNameLen = 68;
5205*4e1bc9a0SAchim Leubner   }
5206*4e1bc9a0SAchim Leubner   else
5207*4e1bc9a0SAchim Leubner   {
5208*4e1bc9a0SAchim Leubner     /* copy hi address and low address */
5209*4e1bc9a0SAchim Leubner     osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
5210*4e1bc9a0SAchim Leubner     osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
5211*4e1bc9a0SAchim Leubner     tiPortInfo->localNameLen = 8;
5212*4e1bc9a0SAchim Leubner     osti_memcpy(remotename, &(onePortContext->sasRemoteAddressHi), 4);
5213*4e1bc9a0SAchim Leubner     osti_memcpy(&(remotename[4]), &(onePortContext->sasRemoteAddressLo), 4);
5214*4e1bc9a0SAchim Leubner     tiPortInfo->remoteNameLen = 8;
5215*4e1bc9a0SAchim Leubner   }
5216*4e1bc9a0SAchim Leubner 
5217*4e1bc9a0SAchim Leubner   tiPortInfo->localName = (char *)&localname;
5218*4e1bc9a0SAchim Leubner   tiPortInfo->remoteName = (char *)&remotename;
5219*4e1bc9a0SAchim Leubner 
5220*4e1bc9a0SAchim Leubner 
5221*4e1bc9a0SAchim Leubner   return tiSuccess;
5222*4e1bc9a0SAchim Leubner 
5223*4e1bc9a0SAchim Leubner }
5224*4e1bc9a0SAchim Leubner 
5225*4e1bc9a0SAchim Leubner /*****************************************************************************
5226*4e1bc9a0SAchim Leubner *
5227*4e1bc9a0SAchim Leubner * tiCOMSetControllerConfig
5228*4e1bc9a0SAchim Leubner *
5229*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to set the controller's advanced configuration.
5230*4e1bc9a0SAchim Leubner *            The status is reported via ostiPortEvent().
5231*4e1bc9a0SAchim Leubner *
5232*4e1bc9a0SAchim Leubner *  Parameters:
5233*4e1bc9a0SAchim Leubner *
5234*4e1bc9a0SAchim Leubner *    tiRoot:        Pointer to driver/port instance.
5235*4e1bc9a0SAchim Leubner *
5236*4e1bc9a0SAchim Leubner *  Return:
5237*4e1bc9a0SAchim Leubner *     tiSuccess:  The setting controller configuration was started.
5238*4e1bc9a0SAchim Leubner *     tiError:    The setting controller configuration was not started.
5239*4e1bc9a0SAchim Leubner *
5240*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMSetControllerConfig(tiRoot_t * tiRoot,bit32 modePage,bit32 length,void * buffer,void * context)5241*4e1bc9a0SAchim Leubner osGLOBAL bit32  tiCOMSetControllerConfig (
5242*4e1bc9a0SAchim Leubner          tiRoot_t    *tiRoot,
5243*4e1bc9a0SAchim Leubner          bit32       modePage,
5244*4e1bc9a0SAchim Leubner          bit32       length,
5245*4e1bc9a0SAchim Leubner          void        *buffer,
5246*4e1bc9a0SAchim Leubner          void        *context)
5247*4e1bc9a0SAchim Leubner {
5248*4e1bc9a0SAchim Leubner    agsaRoot_t      *agRoot;
5249*4e1bc9a0SAchim Leubner    bit32           returnCode = AGSA_RC_BUSY;
5250*4e1bc9a0SAchim Leubner    bit32           tiStatus = tiSuccess;
5251*4e1bc9a0SAchim Leubner    tdsaRoot_t      *tdsaRoot ;
5252*4e1bc9a0SAchim Leubner    tdsaContext_t   *tdsaAllShared ;
5253*4e1bc9a0SAchim Leubner 
5254*4e1bc9a0SAchim Leubner    TD_ASSERT(tiRoot, "tiRoot");
5255*4e1bc9a0SAchim Leubner    tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5256*4e1bc9a0SAchim Leubner    TD_ASSERT(tdsaRoot, "tdsaRoot");
5257*4e1bc9a0SAchim Leubner 
5258*4e1bc9a0SAchim Leubner    tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5259*4e1bc9a0SAchim Leubner    TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5260*4e1bc9a0SAchim Leubner    agRoot = &(tdsaAllShared->agRootNonInt);
5261*4e1bc9a0SAchim Leubner    TD_ASSERT(agRoot, "agRoot");
5262*4e1bc9a0SAchim Leubner 
5263*4e1bc9a0SAchim Leubner    agRoot = &(tdsaAllShared->agRootNonInt);
5264*4e1bc9a0SAchim Leubner 
5265*4e1bc9a0SAchim Leubner    TI_DBG1(("tiCOMSetControllerConfig:\n" ));
5266*4e1bc9a0SAchim Leubner 
5267*4e1bc9a0SAchim Leubner    /*do some sanity checking */
5268*4e1bc9a0SAchim Leubner    if ( ((modePage == TI_INTERRUPT_CONFIGURATION_PAGE)   && (length != sizeof(tiInterruptConfigPage_t )))   ||
5269*4e1bc9a0SAchim Leubner         ((modePage == TI_ENCRYPTION_GENERAL_CONFIG_PAGE) && (length != sizeof(tiEncryptGeneralPage_t  )))    ||
5270*4e1bc9a0SAchim Leubner         ((modePage == TI_ENCRYPTION_DEK_CONFIG_PAGE)     && (length != sizeof(tiEncryptDekConfigPage_t)))    ||
5271*4e1bc9a0SAchim Leubner         ((modePage == TI_ENCRYPTION_CONTROL_PARM_PAGE)  && (length != sizeof(tiEncryptControlParamPage_t ))) ||
5272*4e1bc9a0SAchim Leubner         ((modePage == TI_ENCRYPTION_HMAC_CONFIG_PAGE)  && (length != sizeof(tiEncryptHMACConfigPage_t )))    ||
5273*4e1bc9a0SAchim Leubner         ((modePage == TI_SAS_PROTOCOL_TIMER_CONFIG_PAGE) && (length != sizeof(tiSASProtocolTimerConfigurationPage_t )))  )
5274*4e1bc9a0SAchim Leubner    {
5275*4e1bc9a0SAchim Leubner        tiStatus = tiError;
5276*4e1bc9a0SAchim Leubner    }
5277*4e1bc9a0SAchim Leubner    else
5278*4e1bc9a0SAchim Leubner    {
5279*4e1bc9a0SAchim Leubner        returnCode = saSetControllerConfig(agRoot, 0, modePage, length, buffer, context);
5280*4e1bc9a0SAchim Leubner 
5281*4e1bc9a0SAchim Leubner        if (returnCode == AGSA_RC_SUCCESS)
5282*4e1bc9a0SAchim Leubner        {
5283*4e1bc9a0SAchim Leubner            tiStatus = tiSuccess;
5284*4e1bc9a0SAchim Leubner        }
5285*4e1bc9a0SAchim Leubner        else if (returnCode == AGSA_RC_BUSY)
5286*4e1bc9a0SAchim Leubner        {
5287*4e1bc9a0SAchim Leubner            tiStatus = tiBusy;
5288*4e1bc9a0SAchim Leubner        }
5289*4e1bc9a0SAchim Leubner        else
5290*4e1bc9a0SAchim Leubner        {
5291*4e1bc9a0SAchim Leubner            tiStatus = tiError;
5292*4e1bc9a0SAchim Leubner        }
5293*4e1bc9a0SAchim Leubner    }
5294*4e1bc9a0SAchim Leubner    return(tiStatus);
5295*4e1bc9a0SAchim Leubner }
5296*4e1bc9a0SAchim Leubner 
5297*4e1bc9a0SAchim Leubner /*****************************************************************************
5298*4e1bc9a0SAchim Leubner *
5299*4e1bc9a0SAchim Leubner * tiCOMGetControllerConfig
5300*4e1bc9a0SAchim Leubner *
5301*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to get the controller's advanced configuration.
5302*4e1bc9a0SAchim Leubner *            The status is reported via ostiPortEvent().
5303*4e1bc9a0SAchim Leubner *
5304*4e1bc9a0SAchim Leubner *  Parameters:
5305*4e1bc9a0SAchim Leubner *
5306*4e1bc9a0SAchim Leubner *    tiRoot:        Pointer to driver/port instance.
5307*4e1bc9a0SAchim Leubner *    flag:          Interrupt  Vector Mask
5308*4e1bc9a0SAchim Leubner *                   This parameter is valid only when modePage is set to TI_INTERRUPT_CONFIGURATION_PAGE.
5309*4e1bc9a0SAchim Leubner *                   When the modePage field is set to TI_INTERRUPT_CONFIGURATION_PAGE,
5310*4e1bc9a0SAchim Leubner *                   this field contains a bitmap of interrupt vectors for which interrupt coalescing parameters are retrieved.
5311*4e1bc9a0SAchim Leubner *  Return:
5312*4e1bc9a0SAchim Leubner *     tiSuccess:  The controller configuration retrival was started.
5313*4e1bc9a0SAchim Leubner *     tiError:    The controller configuration retrival was not started.
5314*4e1bc9a0SAchim Leubner *
5315*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMGetControllerConfig(tiRoot_t * tiRoot,bit32 modePage,bit32 flag,void * context)5316*4e1bc9a0SAchim Leubner osGLOBAL bit32  tiCOMGetControllerConfig (
5317*4e1bc9a0SAchim Leubner          tiRoot_t    *tiRoot,
5318*4e1bc9a0SAchim Leubner          bit32       modePage,
5319*4e1bc9a0SAchim Leubner          bit32       flag,
5320*4e1bc9a0SAchim Leubner          void        *context)
5321*4e1bc9a0SAchim Leubner 
5322*4e1bc9a0SAchim Leubner {
5323*4e1bc9a0SAchim Leubner   agsaRoot_t      *agRoot;
5324*4e1bc9a0SAchim Leubner   bit32           returnCode = AGSA_RC_BUSY;
5325*4e1bc9a0SAchim Leubner   bit32           tiStatus = tiSuccess;
5326*4e1bc9a0SAchim Leubner   tdsaRoot_t      *tdsaRoot ;
5327*4e1bc9a0SAchim Leubner   tdsaContext_t   *tdsaAllShared ;
5328*4e1bc9a0SAchim Leubner 
5329*4e1bc9a0SAchim Leubner   TD_ASSERT(tiRoot, "tiRoot");
5330*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5331*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaRoot, "tdsaRoot");
5332*4e1bc9a0SAchim Leubner 
5333*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5334*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5335*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5336*4e1bc9a0SAchim Leubner   TD_ASSERT(agRoot, "agRoot");
5337*4e1bc9a0SAchim Leubner 
5338*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5339*4e1bc9a0SAchim Leubner 
5340*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMGetControllerConfig: modePage 0x%x context %p\n",modePage,context ));
5341*4e1bc9a0SAchim Leubner 
5342*4e1bc9a0SAchim Leubner   returnCode = saGetControllerConfig(agRoot, 0, modePage, flag, 0, context);
5343*4e1bc9a0SAchim Leubner 
5344*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
5345*4e1bc9a0SAchim Leubner   {
5346*4e1bc9a0SAchim Leubner     tiStatus = tiSuccess;
5347*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiSuccess\n",modePage ));
5348*4e1bc9a0SAchim Leubner   }
5349*4e1bc9a0SAchim Leubner   else if (returnCode == AGSA_RC_BUSY)
5350*4e1bc9a0SAchim Leubner   {
5351*4e1bc9a0SAchim Leubner     tiStatus = tiBusy;
5352*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiBusy\n",modePage ));
5353*4e1bc9a0SAchim Leubner   }
5354*4e1bc9a0SAchim Leubner   else
5355*4e1bc9a0SAchim Leubner   {
5356*4e1bc9a0SAchim Leubner     tiStatus = tiError;
5357*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiError\n",modePage ));
5358*4e1bc9a0SAchim Leubner   }
5359*4e1bc9a0SAchim Leubner 
5360*4e1bc9a0SAchim Leubner    return(tiStatus);
5361*4e1bc9a0SAchim Leubner }
5362*4e1bc9a0SAchim Leubner 
5363*4e1bc9a0SAchim Leubner /*****************************************************************************
5364*4e1bc9a0SAchim Leubner *
5365*4e1bc9a0SAchim Leubner * tiCOMEncryptGetInfo
5366*4e1bc9a0SAchim Leubner *
5367*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to return information about the encryption
5368*4e1bc9a0SAchim Leubner *            engine for the specified port.
5369*4e1bc9a0SAchim Leubner *
5370*4e1bc9a0SAchim Leubner *  Parameters:
5371*4e1bc9a0SAchim Leubner *
5372*4e1bc9a0SAchim Leubner *    tiRoot:        Pointer to driver/port instance.
5373*4e1bc9a0SAchim Leubner *
5374*4e1bc9a0SAchim Leubner *  Return:
5375*4e1bc9a0SAchim Leubner *   tiSuccess       The request is being processed
5376*4e1bc9a0SAchim Leubner *   tiNotSupported  Encryption is not supported
5377*4e1bc9a0SAchim Leubner *
5378*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMEncryptGetInfo(tiRoot_t * tiRoot)5379*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptGetInfo(tiRoot_t *tiRoot)
5380*4e1bc9a0SAchim Leubner {
5381*4e1bc9a0SAchim Leubner   tiEncryptInfo_t tiEncryptInfo;
5382*4e1bc9a0SAchim Leubner   agsaEncryptInfo_t agsaEncryptInfo;
5383*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5384*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5385*4e1bc9a0SAchim Leubner   agsaRoot_t      *agRoot;
5386*4e1bc9a0SAchim Leubner   tiEncryptPort_t tiEncryptPort;
5387*4e1bc9a0SAchim Leubner   bit32           returnCode;
5388*4e1bc9a0SAchim Leubner   bit32           tiStatus;
5389*4e1bc9a0SAchim Leubner 
5390*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5391*4e1bc9a0SAchim Leubner 
5392*4e1bc9a0SAchim Leubner   returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
5393*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMEncryptGetInfo: returnCode 0x%x\n", returnCode));
5394*4e1bc9a0SAchim Leubner 
5395*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
5396*4e1bc9a0SAchim Leubner   {
5397*4e1bc9a0SAchim Leubner       tiStatus = tiSuccess;
5398*4e1bc9a0SAchim Leubner 
5399*4e1bc9a0SAchim Leubner       /*
5400*4e1bc9a0SAchim Leubner        * The data encoded in the agsaEncryptInfo must be converted
5401*4e1bc9a0SAchim Leubner        * to match the fields of the tiEncryptInfo structure.
5402*4e1bc9a0SAchim Leubner        *
5403*4e1bc9a0SAchim Leubner        * No sector information is currently available.
5404*4e1bc9a0SAchim Leubner        */
5405*4e1bc9a0SAchim Leubner       osti_memset(&tiEncryptInfo, 0x0, sizeof(tiEncryptInfo_t));
5406*4e1bc9a0SAchim Leubner 
5407*4e1bc9a0SAchim Leubner       /* cipher mode */
5408*4e1bc9a0SAchim Leubner       if (agsaEncryptInfo.encryptionCipherMode == agsaEncryptCipherModeXTS)
5409*4e1bc9a0SAchim Leubner       {
5410*4e1bc9a0SAchim Leubner          tiEncryptInfo.securityCipherMode = TI_ENCRYPT_ATTRIB_CIPHER_XTS;
5411*4e1bc9a0SAchim Leubner       }
5412*4e1bc9a0SAchim Leubner       /* security mode */
5413*4e1bc9a0SAchim Leubner       if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMF)
5414*4e1bc9a0SAchim Leubner       {
5415*4e1bc9a0SAchim Leubner          tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_FACT_INIT;
5416*4e1bc9a0SAchim Leubner       }
5417*4e1bc9a0SAchim Leubner       else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMA)
5418*4e1bc9a0SAchim Leubner       {
5419*4e1bc9a0SAchim Leubner          tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_A;
5420*4e1bc9a0SAchim Leubner       }
5421*4e1bc9a0SAchim Leubner       else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMB)
5422*4e1bc9a0SAchim Leubner       {
5423*4e1bc9a0SAchim Leubner          tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_B;
5424*4e1bc9a0SAchim Leubner       }
5425*4e1bc9a0SAchim Leubner 
5426*4e1bc9a0SAchim Leubner       tiEncryptInfo.status = agsaEncryptInfo.status;
5427*4e1bc9a0SAchim Leubner 
5428*4e1bc9a0SAchim Leubner       tiEncryptPort.pData = &tiEncryptInfo;
5429*4e1bc9a0SAchim Leubner 
5430*4e1bc9a0SAchim Leubner       /* The low level returns synchronously, so fake a port event now.*/
5431*4e1bc9a0SAchim Leubner       tiEncryptPort.encryptEvent = tiEncryptGetInfo;
5432*4e1bc9a0SAchim Leubner       tiEncryptPort.subEvent = 0;
5433*4e1bc9a0SAchim Leubner 
5434*4e1bc9a0SAchim Leubner       ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
5435*4e1bc9a0SAchim Leubner   }
5436*4e1bc9a0SAchim Leubner   else
5437*4e1bc9a0SAchim Leubner   {
5438*4e1bc9a0SAchim Leubner     if (returnCode == AGSA_RC_NOT_SUPPORTED)
5439*4e1bc9a0SAchim Leubner     {
5440*4e1bc9a0SAchim Leubner       tiStatus = tiNotSupported;
5441*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMEncryptGetInfo: tiNotSupported\n"));
5442*4e1bc9a0SAchim Leubner     }
5443*4e1bc9a0SAchim Leubner     else
5444*4e1bc9a0SAchim Leubner     {
5445*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMEncryptGetInfo: tiError returnCode 0x%x\n",returnCode));
5446*4e1bc9a0SAchim Leubner       tiStatus = tiError;
5447*4e1bc9a0SAchim Leubner     }
5448*4e1bc9a0SAchim Leubner 
5449*4e1bc9a0SAchim Leubner     tiEncryptPort.pData = NULL;
5450*4e1bc9a0SAchim Leubner   }
5451*4e1bc9a0SAchim Leubner 
5452*4e1bc9a0SAchim Leubner   return(tiStatus);
5453*4e1bc9a0SAchim Leubner }
5454*4e1bc9a0SAchim Leubner 
5455*4e1bc9a0SAchim Leubner /*****************************************************************************
5456*4e1bc9a0SAchim Leubner *
5457*4e1bc9a0SAchim Leubner * tiCOMEncryptSetMode
5458*4e1bc9a0SAchim Leubner *
5459*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to set the encryption security and cipher modes
5460*4e1bc9a0SAchim Leubner *            for the encryption engine.
5461*4e1bc9a0SAchim Leubner *
5462*4e1bc9a0SAchim Leubner *  Parameters:
5463*4e1bc9a0SAchim Leubner *
5464*4e1bc9a0SAchim Leubner *    tiRoot:        Pointer to driver/port instance.
5465*4e1bc9a0SAchim Leubner *
5466*4e1bc9a0SAchim Leubner *  Return:
5467*4e1bc9a0SAchim Leubner *   tiSuccess       The request is being processed
5468*4e1bc9a0SAchim Leubner *   tiError         The encryption engine is not in factory init mode or multiple
5469*4e1bc9a0SAchim Leubner *                   security modes were specified.
5470*4e1bc9a0SAchim Leubner *
5471*4e1bc9a0SAchim Leubner *****************************************************************************/
5472*4e1bc9a0SAchim Leubner 
tiCOMEncryptSetMode(tiRoot_t * tiRoot,bit32 securityCipherMode)5473*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptSetMode(tiRoot_t            *tiRoot,
5474*4e1bc9a0SAchim Leubner                                    bit32               securityCipherMode)
5475*4e1bc9a0SAchim Leubner {
5476*4e1bc9a0SAchim Leubner   bit32                         returnCode;
5477*4e1bc9a0SAchim Leubner   bit32                         tiStatus;
5478*4e1bc9a0SAchim Leubner   agsaEncryptInfo_t mode;
5479*4e1bc9a0SAchim Leubner   agsaEncryptInfo_t *pmode = &mode;
5480*4e1bc9a0SAchim Leubner 
5481*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot ;
5482*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared;
5483*4e1bc9a0SAchim Leubner   agsaRoot_t        *agRoot;
5484*4e1bc9a0SAchim Leubner 
5485*4e1bc9a0SAchim Leubner   TD_ASSERT(tiRoot, "tiRoot");
5486*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5487*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaRoot, "tdsaRoot");
5488*4e1bc9a0SAchim Leubner 
5489*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5490*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5491*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5492*4e1bc9a0SAchim Leubner   TD_ASSERT(agRoot, "agRoot");
5493*4e1bc9a0SAchim Leubner 
5494*4e1bc9a0SAchim Leubner   pmode->encryptionSecurityMode = 0;
5495*4e1bc9a0SAchim Leubner   pmode->encryptionCipherMode = 0;
5496*4e1bc9a0SAchim Leubner   pmode->status = 0;
5497*4e1bc9a0SAchim Leubner 
5498*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMEncryptSetMode:\n"));
5499*4e1bc9a0SAchim Leubner 
5500*4e1bc9a0SAchim Leubner 
5501*4e1bc9a0SAchim Leubner   if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_A ) == TI_ENCRYPT_SEC_MODE_A)
5502*4e1bc9a0SAchim Leubner   {
5503*4e1bc9a0SAchim Leubner     pmode->encryptionSecurityMode = agsaEncryptSMA;
5504*4e1bc9a0SAchim Leubner   }
5505*4e1bc9a0SAchim Leubner 
5506*4e1bc9a0SAchim Leubner   if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_B ) == TI_ENCRYPT_SEC_MODE_B)
5507*4e1bc9a0SAchim Leubner   {
5508*4e1bc9a0SAchim Leubner     pmode->encryptionSecurityMode = agsaEncryptSMB;
5509*4e1bc9a0SAchim Leubner   }
5510*4e1bc9a0SAchim Leubner 
5511*4e1bc9a0SAchim Leubner   if( (securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_XTS)  == TI_ENCRYPT_ATTRIB_CIPHER_XTS)
5512*4e1bc9a0SAchim Leubner   {
5513*4e1bc9a0SAchim Leubner     pmode->encryptionCipherMode |= agsaEncryptCipherModeXTS;
5514*4e1bc9a0SAchim Leubner   }
5515*4e1bc9a0SAchim Leubner 
5516*4e1bc9a0SAchim Leubner   /* ECB is not supported in SPCv */
5517*4e1bc9a0SAchim Leubner   if(( securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_ECB)  == TI_ENCRYPT_ATTRIB_CIPHER_ECB)
5518*4e1bc9a0SAchim Leubner   {
5519*4e1bc9a0SAchim Leubner     return tiError;
5520*4e1bc9a0SAchim Leubner   }
5521*4e1bc9a0SAchim Leubner 
5522*4e1bc9a0SAchim Leubner   returnCode = saEncryptSetMode(agRoot,agNULL, 0, pmode );
5523*4e1bc9a0SAchim Leubner 
5524*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
5525*4e1bc9a0SAchim Leubner   {
5526*4e1bc9a0SAchim Leubner     tiStatus = tiSuccess;
5527*4e1bc9a0SAchim Leubner   }
5528*4e1bc9a0SAchim Leubner   else if (returnCode == AGSA_RC_BUSY)
5529*4e1bc9a0SAchim Leubner   {
5530*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptSetMode:tiBusy\n"));
5531*4e1bc9a0SAchim Leubner     tiStatus = tiBusy;
5532*4e1bc9a0SAchim Leubner   }
5533*4e1bc9a0SAchim Leubner   else
5534*4e1bc9a0SAchim Leubner   {
5535*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptSetMode:tiError\n"));
5536*4e1bc9a0SAchim Leubner     tiStatus = tiError;
5537*4e1bc9a0SAchim Leubner   }
5538*4e1bc9a0SAchim Leubner 
5539*4e1bc9a0SAchim Leubner   return(tiStatus);
5540*4e1bc9a0SAchim Leubner }
5541*4e1bc9a0SAchim Leubner 
5542*4e1bc9a0SAchim Leubner /*****************************************************************************
5543*4e1bc9a0SAchim Leubner *
5544*4e1bc9a0SAchim Leubner * tiCOMEncryptDekAdd
5545*4e1bc9a0SAchim Leubner *
5546*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to add a DEK to the controller cache.
5547*4e1bc9a0SAchim Leubner *
5548*4e1bc9a0SAchim Leubner *  Parameters:
5549*4e1bc9a0SAchim Leubner *
5550*4e1bc9a0SAchim Leubner *    tiRoot:          Pointer to driver/port instance.
5551*4e1bc9a0SAchim Leubner *    kekIndext:         Index of the KEK table
5552*4e1bc9a0SAchim Leubner *    dekTableSelect:  Number of the DEK table receiving a new entry
5553*4e1bc9a0SAchim Leubner *    dekAddrHi:       Upper 32-bits of the DEK table physical address
5554*4e1bc9a0SAchim Leubner *    dekAddrLo:       Lower 32-bits of the DEK table physical address
5555*4e1bc9a0SAchim Leubner *    dekIndex:        Number of the first entry in the DEK table that will inserted in the cache
5556*4e1bc9a0SAchim Leubner *    dekNumberOfEntries: Number of entries to be inserted in the cache
5557*4e1bc9a0SAchim Leubner *    dekBlobFormat:     Specifies the DEK blob format
5558*4e1bc9a0SAchim Leubner *    dekTableKeyEntrySize: Encoded value for DEK Entry Size in the DEK Table
5559*4e1bc9a0SAchim Leubner *
5560*4e1bc9a0SAchim Leubner *  Return:
5561*4e1bc9a0SAchim Leubner *   tiSuccess       The request is being processed
5562*4e1bc9a0SAchim Leubner *   tiError         An invalid parameter was specified
5563*4e1bc9a0SAchim Leubner *
5564*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMEncryptDekAdd(tiRoot_t * tiRoot,bit32 kekIndex,bit32 dekTableSelect,bit32 dekAddrHi,bit32 dekAddrLo,bit32 dekIndex,bit32 dekNumberOfEntries,bit32 dekBlobFormat,bit32 dekTableKeyEntrySize)5565*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptDekAdd(tiRoot_t            *tiRoot,
5566*4e1bc9a0SAchim Leubner                                   bit32               kekIndex,
5567*4e1bc9a0SAchim Leubner                                   bit32               dekTableSelect,
5568*4e1bc9a0SAchim Leubner                                   bit32               dekAddrHi,
5569*4e1bc9a0SAchim Leubner                                   bit32               dekAddrLo,
5570*4e1bc9a0SAchim Leubner                                   bit32               dekIndex,
5571*4e1bc9a0SAchim Leubner                                   bit32               dekNumberOfEntries,
5572*4e1bc9a0SAchim Leubner                                   bit32               dekBlobFormat,
5573*4e1bc9a0SAchim Leubner                                   bit32               dekTableKeyEntrySize
5574*4e1bc9a0SAchim Leubner 
5575*4e1bc9a0SAchim Leubner                                   )
5576*4e1bc9a0SAchim Leubner {
5577*4e1bc9a0SAchim Leubner     agsaRoot_t        *agRoot;
5578*4e1bc9a0SAchim Leubner     bit32           returnCode;
5579*4e1bc9a0SAchim Leubner     bit32           tiStatus;
5580*4e1bc9a0SAchim Leubner     tdsaRoot_t        *tdsaRoot ;
5581*4e1bc9a0SAchim Leubner     tdsaContext_t     *tdsaAllShared ;
5582*4e1bc9a0SAchim Leubner 
5583*4e1bc9a0SAchim Leubner     TD_ASSERT(tiRoot, "tiRoot");
5584*4e1bc9a0SAchim Leubner     tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5585*4e1bc9a0SAchim Leubner     TD_ASSERT(tdsaRoot, "tdsaRoot");
5586*4e1bc9a0SAchim Leubner 
5587*4e1bc9a0SAchim Leubner     tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5588*4e1bc9a0SAchim Leubner     TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5589*4e1bc9a0SAchim Leubner     agRoot = &(tdsaAllShared->agRootNonInt);
5590*4e1bc9a0SAchim Leubner     TD_ASSERT(agRoot, "agRoot");
5591*4e1bc9a0SAchim Leubner 
5592*4e1bc9a0SAchim Leubner 
5593*4e1bc9a0SAchim Leubner     agRoot = &(tdsaAllShared->agRootNonInt);
5594*4e1bc9a0SAchim Leubner 
5595*4e1bc9a0SAchim Leubner 
5596*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptDekAdd:\n" ));
5597*4e1bc9a0SAchim Leubner 
5598*4e1bc9a0SAchim Leubner     returnCode = saEncryptDekCacheUpdate(agRoot,
5599*4e1bc9a0SAchim Leubner                                     agNULL,
5600*4e1bc9a0SAchim Leubner                                     0,
5601*4e1bc9a0SAchim Leubner                                     kekIndex,
5602*4e1bc9a0SAchim Leubner                                     dekTableSelect,
5603*4e1bc9a0SAchim Leubner                                     dekAddrHi,
5604*4e1bc9a0SAchim Leubner                                     dekAddrLo,
5605*4e1bc9a0SAchim Leubner                                     dekIndex,
5606*4e1bc9a0SAchim Leubner                                     dekNumberOfEntries,
5607*4e1bc9a0SAchim Leubner                                     dekBlobFormat,
5608*4e1bc9a0SAchim Leubner                                     dekTableKeyEntrySize
5609*4e1bc9a0SAchim Leubner                                     );
5610*4e1bc9a0SAchim Leubner 
5611*4e1bc9a0SAchim Leubner     if (returnCode == AGSA_RC_SUCCESS)
5612*4e1bc9a0SAchim Leubner     {
5613*4e1bc9a0SAchim Leubner         tiStatus = tiSuccess;
5614*4e1bc9a0SAchim Leubner     }
5615*4e1bc9a0SAchim Leubner     else if (returnCode == AGSA_RC_BUSY)
5616*4e1bc9a0SAchim Leubner     {
5617*4e1bc9a0SAchim Leubner         tiStatus = tiBusy;
5618*4e1bc9a0SAchim Leubner     }
5619*4e1bc9a0SAchim Leubner     else
5620*4e1bc9a0SAchim Leubner     {
5621*4e1bc9a0SAchim Leubner         tiStatus = tiError;
5622*4e1bc9a0SAchim Leubner     }
5623*4e1bc9a0SAchim Leubner 
5624*4e1bc9a0SAchim Leubner     return(tiStatus);
5625*4e1bc9a0SAchim Leubner }
5626*4e1bc9a0SAchim Leubner 
5627*4e1bc9a0SAchim Leubner /*****************************************************************************
5628*4e1bc9a0SAchim Leubner *
5629*4e1bc9a0SAchim Leubner * tiCOMEncryptDekInvalidate
5630*4e1bc9a0SAchim Leubner *
5631*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to remove a DEK entry from the hardware cache.
5632*4e1bc9a0SAchim Leubner *
5633*4e1bc9a0SAchim Leubner *  Parameters:
5634*4e1bc9a0SAchim Leubner *
5635*4e1bc9a0SAchim Leubner *    tiRoot:        Pointer to driver/port instance.
5636*4e1bc9a0SAchim Leubner *    dekTable       DEK table that will be affected
5637*4e1bc9a0SAchim Leubner *    dekIndex:      DEK table entry that will be affected. The value 0xfffffff clears the cache.
5638*4e1bc9a0SAchim Leubner *
5639*4e1bc9a0SAchim Leubner *  Return:
5640*4e1bc9a0SAchim Leubner *   tiSuccess       The request is being processed
5641*4e1bc9a0SAchim Leubner *   tiError         An invalid parameter was specified
5642*4e1bc9a0SAchim Leubner *   tiBusy          An operation is already in progress
5643*4e1bc9a0SAchim Leubner *
5644*4e1bc9a0SAchim Leubner *****************************************************************************/
5645*4e1bc9a0SAchim Leubner 
tiCOMEncryptDekInvalidate(tiRoot_t * tiRoot,bit32 dekTable,bit32 dekIndex)5646*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptDekInvalidate(tiRoot_t            *tiRoot,
5647*4e1bc9a0SAchim Leubner                                          bit32               dekTable,
5648*4e1bc9a0SAchim Leubner                                          bit32               dekIndex)
5649*4e1bc9a0SAchim Leubner {
5650*4e1bc9a0SAchim Leubner 
5651*4e1bc9a0SAchim Leubner     tdsaRoot_t        *tdsaRoot;
5652*4e1bc9a0SAchim Leubner     tdsaContext_t     *tdsaAllShared;
5653*4e1bc9a0SAchim Leubner 
5654*4e1bc9a0SAchim Leubner     agsaRoot_t        *agRoot;
5655*4e1bc9a0SAchim Leubner     tiEncryptPort_t tiEncryptPort;
5656*4e1bc9a0SAchim Leubner     tiEncryptDek_t  tiEncryptDek;
5657*4e1bc9a0SAchim Leubner     bit32           returnCode;
5658*4e1bc9a0SAchim Leubner     bit32           tiStatus;
5659*4e1bc9a0SAchim Leubner 
5660*4e1bc9a0SAchim Leubner     TD_ASSERT(tiRoot, "tiRoot");
5661*4e1bc9a0SAchim Leubner     tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5662*4e1bc9a0SAchim Leubner     TD_ASSERT(tdsaRoot, "tdsaRoot");
5663*4e1bc9a0SAchim Leubner 
5664*4e1bc9a0SAchim Leubner     tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5665*4e1bc9a0SAchim Leubner     TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5666*4e1bc9a0SAchim Leubner     agRoot = &(tdsaAllShared->agRootNonInt);
5667*4e1bc9a0SAchim Leubner     TD_ASSERT(agRoot, "agRoot");
5668*4e1bc9a0SAchim Leubner 
5669*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptDekInvalidate:dekTable 0x%x dekIndex 0x%x\n", dekTable, dekIndex));
5670*4e1bc9a0SAchim Leubner 
5671*4e1bc9a0SAchim Leubner     returnCode = saEncryptDekCacheInvalidate(agRoot, agNULL, 0, dekTable, dekIndex);
5672*4e1bc9a0SAchim Leubner 
5673*4e1bc9a0SAchim Leubner     if (returnCode == AGSA_RC_SUCCESS)
5674*4e1bc9a0SAchim Leubner     {
5675*4e1bc9a0SAchim Leubner         tiStatus = tiSuccess;
5676*4e1bc9a0SAchim Leubner     }
5677*4e1bc9a0SAchim Leubner     else
5678*4e1bc9a0SAchim Leubner     {
5679*4e1bc9a0SAchim Leubner         if (returnCode == AGSA_RC_NOT_SUPPORTED)
5680*4e1bc9a0SAchim Leubner         {
5681*4e1bc9a0SAchim Leubner             tiStatus = tiNotSupported;
5682*4e1bc9a0SAchim Leubner         }
5683*4e1bc9a0SAchim Leubner         else if (returnCode == AGSA_RC_BUSY)
5684*4e1bc9a0SAchim Leubner         {
5685*4e1bc9a0SAchim Leubner             tiStatus = tiBusy;
5686*4e1bc9a0SAchim Leubner         }
5687*4e1bc9a0SAchim Leubner         else
5688*4e1bc9a0SAchim Leubner         {
5689*4e1bc9a0SAchim Leubner             tiStatus = tiError;
5690*4e1bc9a0SAchim Leubner         }
5691*4e1bc9a0SAchim Leubner 
5692*4e1bc9a0SAchim Leubner         tiEncryptDek.dekTable = dekTable;
5693*4e1bc9a0SAchim Leubner         tiEncryptDek.dekIndex = dekIndex;
5694*4e1bc9a0SAchim Leubner 
5695*4e1bc9a0SAchim Leubner         tiEncryptPort.encryptEvent = tiEncryptDekInvalidate;
5696*4e1bc9a0SAchim Leubner         tiEncryptPort.subEvent = 0;
5697*4e1bc9a0SAchim Leubner         tiEncryptPort.pData = (void *) &tiEncryptDek;
5698*4e1bc9a0SAchim Leubner 
5699*4e1bc9a0SAchim Leubner         ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
5700*4e1bc9a0SAchim Leubner     }
5701*4e1bc9a0SAchim Leubner 
5702*4e1bc9a0SAchim Leubner     return(tiStatus);
5703*4e1bc9a0SAchim Leubner }
5704*4e1bc9a0SAchim Leubner 
5705*4e1bc9a0SAchim Leubner /*****************************************************************************
5706*4e1bc9a0SAchim Leubner *
5707*4e1bc9a0SAchim Leubner * tiCOMEncryptKekAdd
5708*4e1bc9a0SAchim Leubner *
5709*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to add a KEK in the register specified by
5710*4e1bc9a0SAchim Leubner *            the index parameter.
5711*4e1bc9a0SAchim Leubner *
5712*4e1bc9a0SAchim Leubner *  Parameters:
5713*4e1bc9a0SAchim Leubner *
5714*4e1bc9a0SAchim Leubner *    tiRoot:           Pointer to driver/port instance.
5715*4e1bc9a0SAchim Leubner *    kekIndex:         KEK table entry that will be affected
5716*4e1bc9a0SAchim Leubner *    wrapperKekIndex   KEK table entry that encrypt the KEK blob
5717*4e1bc9a0SAchim Leubner *    encryptKekBlob    KEK blob that will be added
5718*4e1bc9a0SAchim Leubner *
5719*4e1bc9a0SAchim Leubner *  Return:
5720*4e1bc9a0SAchim Leubner *   tiSuccess       The request is being processed
5721*4e1bc9a0SAchim Leubner *   tiError         An invalid parameter was specified
5722*4e1bc9a0SAchim Leubner *   tiBusy          A KEK operation is already in progress
5723*4e1bc9a0SAchim Leubner *
5724*4e1bc9a0SAchim Leubner *****************************************************************************/
5725*4e1bc9a0SAchim Leubner 
tiCOMEncryptKekAdd(tiRoot_t * tiRoot,bit32 kekIndex,bit32 wrapperKekIndex,bit32 blobFormat,tiEncryptKekBlob_t * encryptKekBlob)5726*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptKekAdd(tiRoot_t            *tiRoot,
5727*4e1bc9a0SAchim Leubner                                   bit32               kekIndex,
5728*4e1bc9a0SAchim Leubner                                   bit32               wrapperKekIndex,
5729*4e1bc9a0SAchim Leubner                                   bit32               blobFormat,
5730*4e1bc9a0SAchim Leubner                                   tiEncryptKekBlob_t *encryptKekBlob)
5731*4e1bc9a0SAchim Leubner {
5732*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot;
5733*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared;
5734*4e1bc9a0SAchim Leubner   agsaRoot_t        *agRoot;
5735*4e1bc9a0SAchim Leubner 
5736*4e1bc9a0SAchim Leubner   bit32           returnCode= AGSA_RC_BUSY;
5737*4e1bc9a0SAchim Leubner   bit32           tiStatus= tiError;
5738*4e1bc9a0SAchim Leubner 
5739*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5740*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5741*4e1bc9a0SAchim Leubner 
5742*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5743*4e1bc9a0SAchim Leubner 
5744*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMEncryptDekInvalidate: kekIndex 0x%x wrapperKekIndex 0x%x\n", kekIndex , wrapperKekIndex));
5745*4e1bc9a0SAchim Leubner 
5746*4e1bc9a0SAchim Leubner   returnCode = saEncryptKekUpdate(agRoot,
5747*4e1bc9a0SAchim Leubner                                   agNULL,
5748*4e1bc9a0SAchim Leubner                                   0,
5749*4e1bc9a0SAchim Leubner                                   AGSA_ENCRYPT_STORE_NVRAM,
5750*4e1bc9a0SAchim Leubner                                   kekIndex,
5751*4e1bc9a0SAchim Leubner                                   wrapperKekIndex,
5752*4e1bc9a0SAchim Leubner                                   blobFormat,
5753*4e1bc9a0SAchim Leubner                                   (agsaEncryptKekBlob_t *) encryptKekBlob);
5754*4e1bc9a0SAchim Leubner 
5755*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
5756*4e1bc9a0SAchim Leubner   {
5757*4e1bc9a0SAchim Leubner     tiStatus = tiSuccess;
5758*4e1bc9a0SAchim Leubner   }
5759*4e1bc9a0SAchim Leubner   else if (returnCode == AGSA_RC_BUSY)
5760*4e1bc9a0SAchim Leubner   {
5761*4e1bc9a0SAchim Leubner     tiStatus = tiBusy;
5762*4e1bc9a0SAchim Leubner   }
5763*4e1bc9a0SAchim Leubner   else
5764*4e1bc9a0SAchim Leubner   {
5765*4e1bc9a0SAchim Leubner     tiStatus = tiError;
5766*4e1bc9a0SAchim Leubner   }
5767*4e1bc9a0SAchim Leubner 
5768*4e1bc9a0SAchim Leubner   return(tiStatus);
5769*4e1bc9a0SAchim Leubner }
5770*4e1bc9a0SAchim Leubner #ifdef HIALEAH_ENCRYPTION
5771*4e1bc9a0SAchim Leubner 
tiCOMEncryptHilSet(tiRoot_t * tiRoot)5772*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptHilSet(tiRoot_t            *tiRoot )
5773*4e1bc9a0SAchim Leubner {
5774*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot;
5775*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared;
5776*4e1bc9a0SAchim Leubner   agsaRoot_t        *agRoot;
5777*4e1bc9a0SAchim Leubner   agsaEncryptInfo_t agsaEncryptInfo;
5778*4e1bc9a0SAchim Leubner 
5779*4e1bc9a0SAchim Leubner   bit32           returnCode= tiBusy;
5780*4e1bc9a0SAchim Leubner   bit32           tiStatus= tiError;
5781*4e1bc9a0SAchim Leubner 
5782*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5783*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5784*4e1bc9a0SAchim Leubner 
5785*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5786*4e1bc9a0SAchim Leubner 
5787*4e1bc9a0SAchim Leubner 
5788*4e1bc9a0SAchim Leubner   returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
5789*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMEncryptHilSet: saEncryptGetMode returnCode 0x%x agsaEncryptInfo status 0x%x Smode 0x%x CMode 0x%x\n",
5790*4e1bc9a0SAchim Leubner           returnCode,
5791*4e1bc9a0SAchim Leubner           agsaEncryptInfo.status,
5792*4e1bc9a0SAchim Leubner           agsaEncryptInfo.encryptionSecurityMode,
5793*4e1bc9a0SAchim Leubner           agsaEncryptInfo.encryptionCipherMode ));
5794*4e1bc9a0SAchim Leubner 
5795*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_FAILURE)
5796*4e1bc9a0SAchim Leubner   {
5797*4e1bc9a0SAchim Leubner    TI_DBG1(("tiCOMEncryptHilSet:agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5798*4e1bc9a0SAchim Leubner     if(agsaEncryptInfo.status == 0x81)
5799*4e1bc9a0SAchim Leubner     {
5800*4e1bc9a0SAchim Leubner    	  TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISMATCH agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5801*4e1bc9a0SAchim Leubner       returnCode = saEncryptHilUpdate(agRoot,
5802*4e1bc9a0SAchim Leubner                                       agNULL,
5803*4e1bc9a0SAchim Leubner                                       0 );
5804*4e1bc9a0SAchim Leubner       if (returnCode == AGSA_RC_SUCCESS)
5805*4e1bc9a0SAchim Leubner       {
5806*4e1bc9a0SAchim Leubner         TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_SUCCESS\n"));
5807*4e1bc9a0SAchim Leubner       }
5808*4e1bc9a0SAchim Leubner     }
5809*4e1bc9a0SAchim Leubner 	else if(agsaEncryptInfo.status == 0x80)
5810*4e1bc9a0SAchim Leubner     {
5811*4e1bc9a0SAchim Leubner    		ostidisableEncryption(tiRoot);
5812*4e1bc9a0SAchim Leubner 		TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISSING agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5813*4e1bc9a0SAchim Leubner     	returnCode = AGSA_RC_SUCCESS;
5814*4e1bc9a0SAchim Leubner 	}
5815*4e1bc9a0SAchim Leubner     else
5816*4e1bc9a0SAchim Leubner     {
5817*4e1bc9a0SAchim Leubner       TI_DBG1(("tiCOMEncryptHilSet: not status 0x81 agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5818*4e1bc9a0SAchim Leubner       returnCode = AGSA_RC_FAILURE;
5819*4e1bc9a0SAchim Leubner     }
5820*4e1bc9a0SAchim Leubner   }
5821*4e1bc9a0SAchim Leubner 
5822*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
5823*4e1bc9a0SAchim Leubner   {
5824*4e1bc9a0SAchim Leubner     tiStatus = tiSuccess;
5825*4e1bc9a0SAchim Leubner   }
5826*4e1bc9a0SAchim Leubner   else if (returnCode == AGSA_RC_BUSY)
5827*4e1bc9a0SAchim Leubner   {
5828*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_BUSY\n"));
5829*4e1bc9a0SAchim Leubner     tiStatus = tiBusy;
5830*4e1bc9a0SAchim Leubner   }
5831*4e1bc9a0SAchim Leubner   else
5832*4e1bc9a0SAchim Leubner   {
5833*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptHilSet:tiError\n"));
5834*4e1bc9a0SAchim Leubner     tiStatus = tiError;
5835*4e1bc9a0SAchim Leubner   }
5836*4e1bc9a0SAchim Leubner 
5837*4e1bc9a0SAchim Leubner   return(tiStatus);
5838*4e1bc9a0SAchim Leubner }
5839*4e1bc9a0SAchim Leubner #endif /* HIALEAH_ENCRYPTION */
5840*4e1bc9a0SAchim Leubner 
5841*4e1bc9a0SAchim Leubner /*****************************************************************************
5842*4e1bc9a0SAchim Leubner *
5843*4e1bc9a0SAchim Leubner * tiCOMEncryptKekStore
5844*4e1bc9a0SAchim Leubner *
5845*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to store a KEK in NVRAM. If -1 is specified
5846*4e1bc9a0SAchim Leubner *            as the KEK index, then all KEKs will be stored.
5847*4e1bc9a0SAchim Leubner *
5848*4e1bc9a0SAchim Leubner *  Parameters:
5849*4e1bc9a0SAchim Leubner *
5850*4e1bc9a0SAchim Leubner *    tiRoot:        Pointer to driver/port instance.
5851*4e1bc9a0SAchim Leubner *    kekIndex:      The KEK to be stored in NVRAM
5852*4e1bc9a0SAchim Leubner *
5853*4e1bc9a0SAchim Leubner *  Return:
5854*4e1bc9a0SAchim Leubner *   tiSuccess       The request is being processed
5855*4e1bc9a0SAchim Leubner *   tiError         An invalid parameter was specified
5856*4e1bc9a0SAchim Leubner *   tiBusy          A KEK operation is already in progress
5857*4e1bc9a0SAchim Leubner *
5858*4e1bc9a0SAchim Leubner *****************************************************************************/
5859*4e1bc9a0SAchim Leubner 
tiCOMEncryptKekStore(tiRoot_t * tiRoot,bit32 kekIndex)5860*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptKekStore(tiRoot_t  *tiRoot,
5861*4e1bc9a0SAchim Leubner                                     bit32      kekIndex)
5862*4e1bc9a0SAchim Leubner {
5863*4e1bc9a0SAchim Leubner #ifdef NOT_YET
5864*4e1bc9a0SAchim Leubner     tdsaRoot_t        *tdsaRoot;
5865*4e1bc9a0SAchim Leubner     tdsaContext_t     *tdsaAllShared;
5866*4e1bc9a0SAchim Leubner     agsaRoot_t        *agRoot;
5867*4e1bc9a0SAchim Leubner #endif
5868*4e1bc9a0SAchim Leubner /*
5869*4e1bc9a0SAchim Leubner     bit32           returnCode= AGSA_RC_BUSY;
5870*4e1bc9a0SAchim Leubner */
5871*4e1bc9a0SAchim Leubner     bit32           tiStatus = tiError;
5872*4e1bc9a0SAchim Leubner 
5873*4e1bc9a0SAchim Leubner #ifdef NOT_YET
5874*4e1bc9a0SAchim Leubner     tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5875*4e1bc9a0SAchim Leubner     tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5876*4e1bc9a0SAchim Leubner 
5877*4e1bc9a0SAchim Leubner     agRoot = &(tdsaAllShared->agRootNonInt);
5878*4e1bc9a0SAchim Leubner #endif
5879*4e1bc9a0SAchim Leubner 
5880*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptKekStore: Needs code !!!! kekIndex 0x%x\n", kekIndex ));
5881*4e1bc9a0SAchim Leubner /*
5882*4e1bc9a0SAchim Leubner     returnCode = fcEncryptKekStore(agRoot, kekIndex);
5883*4e1bc9a0SAchim Leubner 
5884*4e1bc9a0SAchim Leubner     if (returnCode == AGSA_RC_SUCCESS)
5885*4e1bc9a0SAchim Leubner     {
5886*4e1bc9a0SAchim Leubner         tiStatus = tiSuccess;
5887*4e1bc9a0SAchim Leubner     }
5888*4e1bc9a0SAchim Leubner     else if (returnCode == AGSA_RC_BUSY)
5889*4e1bc9a0SAchim Leubner     {
5890*4e1bc9a0SAchim Leubner         tiStatus = tiBusy;
5891*4e1bc9a0SAchim Leubner     }
5892*4e1bc9a0SAchim Leubner     else
5893*4e1bc9a0SAchim Leubner     {
5894*4e1bc9a0SAchim Leubner         tiStatus;
5895*4e1bc9a0SAchim Leubner     }
5896*4e1bc9a0SAchim Leubner */
5897*4e1bc9a0SAchim Leubner     return(tiStatus);
5898*4e1bc9a0SAchim Leubner }
5899*4e1bc9a0SAchim Leubner 
5900*4e1bc9a0SAchim Leubner /*****************************************************************************
5901*4e1bc9a0SAchim Leubner *
5902*4e1bc9a0SAchim Leubner * tiCOMEncryptKekLoad
5903*4e1bc9a0SAchim Leubner *
5904*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to load a KEK from NVRAM. If -1 is specified
5905*4e1bc9a0SAchim Leubner *            as the KEK index, then all KEKs will be loaded.
5906*4e1bc9a0SAchim Leubner *
5907*4e1bc9a0SAchim Leubner *  Parameters:
5908*4e1bc9a0SAchim Leubner *
5909*4e1bc9a0SAchim Leubner *    tiRoot:        Pointer to driver/port instance.
5910*4e1bc9a0SAchim Leubner *    kekIndex:      The KEK to be loaded in NVRAM
5911*4e1bc9a0SAchim Leubner *
5912*4e1bc9a0SAchim Leubner *  Return:
5913*4e1bc9a0SAchim Leubner *   tiSuccess       The request is being processed
5914*4e1bc9a0SAchim Leubner *   tiError         An invalid parameter was specified
5915*4e1bc9a0SAchim Leubner *   tiBusy          A KEK operation is already in progress
5916*4e1bc9a0SAchim Leubner *
5917*4e1bc9a0SAchim Leubner *****************************************************************************/
5918*4e1bc9a0SAchim Leubner 
tiCOMEncryptKekLoad(tiRoot_t * tiRoot,bit32 kekIndex)5919*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptKekLoad(tiRoot_t            *tiRoot,
5920*4e1bc9a0SAchim Leubner                                    bit32               kekIndex)
5921*4e1bc9a0SAchim Leubner {
5922*4e1bc9a0SAchim Leubner #ifdef NOT_YET
5923*4e1bc9a0SAchim Leubner     tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5924*4e1bc9a0SAchim Leubner     tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5925*4e1bc9a0SAchim Leubner     agsaRoot_t      *agRoot;
5926*4e1bc9a0SAchim Leubner     //bit32           returnCode;
5927*4e1bc9a0SAchim Leubner #endif
5928*4e1bc9a0SAchim Leubner     bit32           tiStatus = tiError;
5929*4e1bc9a0SAchim Leubner 
5930*4e1bc9a0SAchim Leubner #ifdef NOT_YET
5931*4e1bc9a0SAchim Leubner     agRoot = &(tdsaAllShared->agRootNonInt);
5932*4e1bc9a0SAchim Leubner #endif
5933*4e1bc9a0SAchim Leubner /*
5934*4e1bc9a0SAchim Leubner     returnCode = fcEncryptKekLoad(agRoot, kekIndex);
5935*4e1bc9a0SAchim Leubner 
5936*4e1bc9a0SAchim Leubner     if (returnCode == AGSA_RC_SUCCESS)
5937*4e1bc9a0SAchim Leubner     {
5938*4e1bc9a0SAchim Leubner         tiStatus = tiSuccess;
5939*4e1bc9a0SAchim Leubner     }
5940*4e1bc9a0SAchim Leubner     else if (returnCode == AGSA_RC_BUSY)
5941*4e1bc9a0SAchim Leubner     {
5942*4e1bc9a0SAchim Leubner         tiStatus = tiBusy;
5943*4e1bc9a0SAchim Leubner     }
5944*4e1bc9a0SAchim Leubner     else
5945*4e1bc9a0SAchim Leubner     {
5946*4e1bc9a0SAchim Leubner         tiStatus = tiError;
5947*4e1bc9a0SAchim Leubner     }
5948*4e1bc9a0SAchim Leubner */
5949*4e1bc9a0SAchim Leubner     return(tiStatus);
5950*4e1bc9a0SAchim Leubner }
5951*4e1bc9a0SAchim Leubner 
5952*4e1bc9a0SAchim Leubner /*****************************************************************************
5953*4e1bc9a0SAchim Leubner *
5954*4e1bc9a0SAchim Leubner * tiCOMEncryptSelfTest
5955*4e1bc9a0SAchim Leubner *
5956*4e1bc9a0SAchim Leubner *  Purpose:  This function starts the encryption self test. For the encryption self test, IOs must be quiesced.
5957*4e1bc9a0SAchim Leubner *                The completion of this function is via ostiPortEvent().
5958*4e1bc9a0SAchim Leubner *
5959*4e1bc9a0SAchim Leubner *  Parameters:
5960*4e1bc9a0SAchim Leubner *
5961*4e1bc9a0SAchim Leubner *    tiRoot:      Pointer to driver/port instance.
5962*4e1bc9a0SAchim Leubner *    type:        Types of test
5963*4e1bc9a0SAchim Leubner                       0x1: tiBISTTest
5964*4e1bc9a0SAchim Leubner                       0x2: tiHMACTest
5965*4e1bc9a0SAchim Leubner                       Others are reserved.
5966*4e1bc9a0SAchim Leubner *    length:
5967*4e1bc9a0SAchim Leubner                    Size of the test descriptor in bytes, e.g.,
5968*4e1bc9a0SAchim Leubner                    Sizeof(tiEncryptSelfTestDescriptor_t)
5969*4e1bc9a0SAchim Leubner                    Sizeof(tiEncryptHMACTestDescriptor_t)
5970*4e1bc9a0SAchim Leubner *    TestDescriptor       address of the test descriptor structure.
5971*4e1bc9a0SAchim Leubner *
5972*4e1bc9a0SAchim Leubner *  Return:
5973*4e1bc9a0SAchim Leubner *   tiSuccess     The request is being processed
5974*4e1bc9a0SAchim Leubner *   tiError          An invalid parameter was specified
5975*4e1bc9a0SAchim Leubner *   tiBusy          A encrytion operation is already in progress
5976*4e1bc9a0SAchim Leubner *
5977*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMEncryptSelfTest(tiRoot_t * tiRoot,bit32 type,bit32 length,void * TestDescriptor)5978*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMEncryptSelfTest(
5979*4e1bc9a0SAchim Leubner                         tiRoot_t  *tiRoot,
5980*4e1bc9a0SAchim Leubner                         bit32      type,
5981*4e1bc9a0SAchim Leubner                         bit32      length,
5982*4e1bc9a0SAchim Leubner                         void      *TestDescriptor
5983*4e1bc9a0SAchim Leubner                         )
5984*4e1bc9a0SAchim Leubner {
5985*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot       = agNULL;
5986*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared  = agNULL;
5987*4e1bc9a0SAchim Leubner   agsaRoot_t     *agRoot         = agNULL;
5988*4e1bc9a0SAchim Leubner 
5989*4e1bc9a0SAchim Leubner   bit32           returnCode     = AGSA_RC_BUSY;
5990*4e1bc9a0SAchim Leubner   bit32           tiStatus       = tiError;
5991*4e1bc9a0SAchim Leubner 
5992*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5993*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
5994*4e1bc9a0SAchim Leubner 
5995*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5996*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
5997*4e1bc9a0SAchim Leubner 
5998*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
5999*4e1bc9a0SAchim Leubner   TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6000*4e1bc9a0SAchim Leubner 
6001*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMEncryptSelfTest: type =  0x%x length = 0x%x\n", type, length));
6002*4e1bc9a0SAchim Leubner 
6003*4e1bc9a0SAchim Leubner   /*do some sanity checking */
6004*4e1bc9a0SAchim Leubner   if ( ((type == TI_ENCRYPTION_TEST_TYPE_BIST) && (length != sizeof(tiEncryptSelfTestDescriptor_t )))  ||
6005*4e1bc9a0SAchim Leubner        ((type == TI_ENCRYPTION_TEST_TYPE_HMAC) && (length != sizeof(tiEncryptHMACTestDescriptor_t))) )
6006*4e1bc9a0SAchim Leubner   {
6007*4e1bc9a0SAchim Leubner     TI_DBG1(("tiCOMEncryptSelfTest: type or length error, type 0x%x length 0x%x\n", type, length));
6008*4e1bc9a0SAchim Leubner     tiStatus = tiError;
6009*4e1bc9a0SAchim Leubner   }
6010*4e1bc9a0SAchim Leubner   else
6011*4e1bc9a0SAchim Leubner   {
6012*4e1bc9a0SAchim Leubner     returnCode = saEncryptSelftestExecute(agRoot,
6013*4e1bc9a0SAchim Leubner                                       agNULL,
6014*4e1bc9a0SAchim Leubner                                       0,
6015*4e1bc9a0SAchim Leubner                                       type,
6016*4e1bc9a0SAchim Leubner                                       length,
6017*4e1bc9a0SAchim Leubner                                       TestDescriptor
6018*4e1bc9a0SAchim Leubner                                       );
6019*4e1bc9a0SAchim Leubner 
6020*4e1bc9a0SAchim Leubner     if (returnCode == AGSA_RC_SUCCESS)
6021*4e1bc9a0SAchim Leubner     {
6022*4e1bc9a0SAchim Leubner       tiStatus = tiSuccess;
6023*4e1bc9a0SAchim Leubner     }
6024*4e1bc9a0SAchim Leubner     else if (returnCode == AGSA_RC_BUSY)
6025*4e1bc9a0SAchim Leubner     {
6026*4e1bc9a0SAchim Leubner       tiStatus = tiBusy;
6027*4e1bc9a0SAchim Leubner     }
6028*4e1bc9a0SAchim Leubner     else
6029*4e1bc9a0SAchim Leubner     {
6030*4e1bc9a0SAchim Leubner       tiStatus = tiError;
6031*4e1bc9a0SAchim Leubner     }
6032*4e1bc9a0SAchim Leubner   }
6033*4e1bc9a0SAchim Leubner 
6034*4e1bc9a0SAchim Leubner   return(tiStatus);
6035*4e1bc9a0SAchim Leubner }
6036*4e1bc9a0SAchim Leubner 
6037*4e1bc9a0SAchim Leubner /*****************************************************************************
6038*4e1bc9a0SAchim Leubner *
6039*4e1bc9a0SAchim Leubner * tiCOMSetOperator
6040*4e1bc9a0SAchim Leubner *
6041*4e1bc9a0SAchim Leubner *  Purpose:  This function is called to login to or logout out from the controller by an operator.
6042*4e1bc9a0SAchim Leubner                   The status is reported via ostiPortEvent().
6043*4e1bc9a0SAchim Leubner *
6044*4e1bc9a0SAchim Leubner *  Parameters:
6045*4e1bc9a0SAchim Leubner *
6046*4e1bc9a0SAchim Leubner *    tiRoot:      Pointer to driver/port instance.
6047*4e1bc9a0SAchim Leubner *    flag:         operator flag.
6048*4e1bc9a0SAchim Leubner                      Bits 0-3: Access type (ACS)
6049*4e1bc9a0SAchim Leubner                        0x1: Login
6050*4e1bc9a0SAchim Leubner                        0x2: Logout
6051*4e1bc9a0SAchim Leubner                        All others are reserved.
6052*4e1bc9a0SAchim Leubner                      Bit 4: KEYopr pinned in the KEK table (PIN)
6053*4e1bc9a0SAchim Leubner                        0: Not pinned. Operator ID table will be searched during authentication.
6054*4e1bc9a0SAchim Leubner                        1: Pinned. OPRIDX is referenced to unwrap the certificate.
6055*4e1bc9a0SAchim Leubner                      Bits 5-7: Reserved
6056*4e1bc9a0SAchim Leubner                      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
6057*4e1bc9a0SAchim Leubner                      Bits 16-31: Reserved.
6058*4e1bc9a0SAchim Leubner 
6059*4e1bc9a0SAchim Leubner      cert:         The pointer to the operator's certificate. The size of the certificate is 40 bytes.
6060*4e1bc9a0SAchim Leubner *
6061*4e1bc9a0SAchim Leubner *  Return:
6062*4e1bc9a0SAchim Leubner *   tiSuccess     Log in or log out was started.
6063*4e1bc9a0SAchim Leubner *   tiError          Log in or log out was not started.
6064*4e1bc9a0SAchim Leubner *   tiBusy          A operator management operation is already in progress
6065*4e1bc9a0SAchim Leubner *
6066*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMSetOperator(tiRoot_t * tiRoot,bit32 flag,void * cert)6067*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMSetOperator(
6068*4e1bc9a0SAchim Leubner                         tiRoot_t      *tiRoot,
6069*4e1bc9a0SAchim Leubner                         bit32          flag,
6070*4e1bc9a0SAchim Leubner                         void          *cert
6071*4e1bc9a0SAchim Leubner                         )
6072*4e1bc9a0SAchim Leubner {
6073*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot       = agNULL;
6074*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared  = agNULL;
6075*4e1bc9a0SAchim Leubner   agsaRoot_t     *agRoot         = agNULL;
6076*4e1bc9a0SAchim Leubner 
6077*4e1bc9a0SAchim Leubner   bit32           returnCode     = AGSA_RC_FAILURE;
6078*4e1bc9a0SAchim Leubner   bit32           tiStatus       = tiError;
6079*4e1bc9a0SAchim Leubner 
6080*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
6081*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6082*4e1bc9a0SAchim Leubner 
6083*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6084*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6085*4e1bc9a0SAchim Leubner 
6086*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
6087*4e1bc9a0SAchim Leubner   TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6088*4e1bc9a0SAchim Leubner 
6089*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMSetOperator: flag =  0x%x \n", flag));
6090*4e1bc9a0SAchim Leubner 
6091*4e1bc9a0SAchim Leubner   returnCode = saSetOperator(agRoot,
6092*4e1bc9a0SAchim Leubner                              agNULL,
6093*4e1bc9a0SAchim Leubner                              0,
6094*4e1bc9a0SAchim Leubner                              flag,
6095*4e1bc9a0SAchim Leubner                              cert);
6096*4e1bc9a0SAchim Leubner 
6097*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
6098*4e1bc9a0SAchim Leubner   {
6099*4e1bc9a0SAchim Leubner     tiStatus = tiSuccess;
6100*4e1bc9a0SAchim Leubner   }
6101*4e1bc9a0SAchim Leubner   else if (returnCode == AGSA_RC_BUSY)
6102*4e1bc9a0SAchim Leubner   {
6103*4e1bc9a0SAchim Leubner     tiStatus = tiBusy;
6104*4e1bc9a0SAchim Leubner   }
6105*4e1bc9a0SAchim Leubner   else
6106*4e1bc9a0SAchim Leubner   {
6107*4e1bc9a0SAchim Leubner     tiStatus = tiError;
6108*4e1bc9a0SAchim Leubner   }
6109*4e1bc9a0SAchim Leubner 
6110*4e1bc9a0SAchim Leubner   return(tiStatus);
6111*4e1bc9a0SAchim Leubner }
6112*4e1bc9a0SAchim Leubner 
6113*4e1bc9a0SAchim Leubner /*****************************************************************************
6114*4e1bc9a0SAchim Leubner *
6115*4e1bc9a0SAchim Leubner * tiCOMGetOperator
6116*4e1bc9a0SAchim Leubner *
6117*4e1bc9a0SAchim Leubner *  Purpose:  This function is used to retrieve the role and ID of the current operator or all operators.
6118*4e1bc9a0SAchim Leubner                   The status is reported via ostiPortEvent().
6119*4e1bc9a0SAchim Leubner *
6120*4e1bc9a0SAchim Leubner *  Parameters:
6121*4e1bc9a0SAchim Leubner *
6122*4e1bc9a0SAchim Leubner *    tiRoot:      Pointer to driver/port instance.
6123*4e1bc9a0SAchim Leubner *    option:     Types of get operations
6124*4e1bc9a0SAchim Leubner                        0x1: Current operator only
6125*4e1bc9a0SAchim Leubner                        0x2: All operators
6126*4e1bc9a0SAchim Leubner                        All others are reserved.
6127*4e1bc9a0SAchim Leubner       AddrHi      Upper 32-bit host physical address to store operator certificates.
6128*4e1bc9a0SAchim Leubner                     This field is used only when option is 0x2
6129*4e1bc9a0SAchim Leubner       AddrLo     Lower 32-bit host physical address to store operator certificates.
6130*4e1bc9a0SAchim Leubner                     This field is used only when option is 0x2
6131*4e1bc9a0SAchim Leubner *
6132*4e1bc9a0SAchim Leubner *  Return:
6133*4e1bc9a0SAchim Leubner *   tiSuccess     The operation was started..
6134*4e1bc9a0SAchim Leubner *   tiError          The operation was not started.
6135*4e1bc9a0SAchim Leubner *   tiBusy          A operator management operation is already in progress
6136*4e1bc9a0SAchim Leubner *
6137*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMGetOperator(tiRoot_t * tiRoot,bit32 option,bit32 AddrHi,bit32 AddrLo)6138*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMGetOperator(
6139*4e1bc9a0SAchim Leubner                            tiRoot_t   *tiRoot,
6140*4e1bc9a0SAchim Leubner                            bit32       option,
6141*4e1bc9a0SAchim Leubner                            bit32       AddrHi,
6142*4e1bc9a0SAchim Leubner                            bit32       AddrLo
6143*4e1bc9a0SAchim Leubner                            )
6144*4e1bc9a0SAchim Leubner {
6145*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot       = agNULL;
6146*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared  = agNULL;
6147*4e1bc9a0SAchim Leubner   agsaRoot_t     *agRoot         = agNULL;
6148*4e1bc9a0SAchim Leubner 
6149*4e1bc9a0SAchim Leubner   bit32           returnCode     = AGSA_RC_FAILURE;
6150*4e1bc9a0SAchim Leubner   bit32           tiStatus       = tiError;
6151*4e1bc9a0SAchim Leubner 
6152*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
6153*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6154*4e1bc9a0SAchim Leubner 
6155*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6156*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6157*4e1bc9a0SAchim Leubner 
6158*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
6159*4e1bc9a0SAchim Leubner   TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6160*4e1bc9a0SAchim Leubner 
6161*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMGetOperator: option = 0x%x \n", option));
6162*4e1bc9a0SAchim Leubner 
6163*4e1bc9a0SAchim Leubner   returnCode = saGetOperator(agRoot,
6164*4e1bc9a0SAchim Leubner                              agNULL,
6165*4e1bc9a0SAchim Leubner                              0,
6166*4e1bc9a0SAchim Leubner                              option,
6167*4e1bc9a0SAchim Leubner                              AddrHi,
6168*4e1bc9a0SAchim Leubner                              AddrLo);
6169*4e1bc9a0SAchim Leubner 
6170*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
6171*4e1bc9a0SAchim Leubner   {
6172*4e1bc9a0SAchim Leubner     tiStatus = tiSuccess;
6173*4e1bc9a0SAchim Leubner   }
6174*4e1bc9a0SAchim Leubner   else if (returnCode == AGSA_RC_BUSY)
6175*4e1bc9a0SAchim Leubner   {
6176*4e1bc9a0SAchim Leubner     tiStatus = tiBusy;
6177*4e1bc9a0SAchim Leubner   }
6178*4e1bc9a0SAchim Leubner   else
6179*4e1bc9a0SAchim Leubner   {
6180*4e1bc9a0SAchim Leubner     tiStatus = tiError;
6181*4e1bc9a0SAchim Leubner   }
6182*4e1bc9a0SAchim Leubner 
6183*4e1bc9a0SAchim Leubner   return(tiStatus);
6184*4e1bc9a0SAchim Leubner }
6185*4e1bc9a0SAchim Leubner 
6186*4e1bc9a0SAchim Leubner /*****************************************************************************
6187*4e1bc9a0SAchim Leubner *
6188*4e1bc9a0SAchim Leubner * tiCOMOperationManagement
6189*4e1bc9a0SAchim Leubner *
6190*4e1bc9a0SAchim Leubner *  Purpose:  this function is used to manage operators,  e.g. adding or deleting an operator..
6191*4e1bc9a0SAchim Leubner *
6192*4e1bc9a0SAchim Leubner *  Parameters:
6193*4e1bc9a0SAchim Leubner *
6194*4e1bc9a0SAchim Leubner *   tiRoot:      Pointer to driver/port instance.
6195*4e1bc9a0SAchim Leubner *   flag:         operation flag.
6196*4e1bc9a0SAchim Leubner                     Bits 0-7: Operator Management Operation(OMO)
6197*4e1bc9a0SAchim Leubner                        0: Add an operator.
6198*4e1bc9a0SAchim Leubner                        1: Delete an operator.
6199*4e1bc9a0SAchim Leubner                        2: Delete all operators.
6200*4e1bc9a0SAchim Leubner                        Others are reserved.
6201*4e1bc9a0SAchim Leubner                     Bit 8: Pinned to KEK RAM (PKR)
6202*4e1bc9a0SAchim Leubner                       0: Operator's KEK is stored in the operator ID table(OID_TLB) only.
6203*4e1bc9a0SAchim Leubner                       1: Operator's KEK is pinned to the internal KEK RAM (1 of the 16 entries) and is also stored in OID_TLB.
6204*4e1bc9a0SAchim Leubner                     Bits 9-10: KEKopr blob format (KBF)
6205*4e1bc9a0SAchim Leubner                       00b: Reserved.
6206*4e1bc9a0SAchim Leubner                       01b: AGSA_ENCRYPTED_KEK_PMCA.
6207*4e1bc9a0SAchim Leubner                       10b: AGSA_ENCRYPTED_KEK_PMCB.
6208*4e1bc9a0SAchim Leubner                       11b: Reserved.
6209*4e1bc9a0SAchim Leubner                     Bits 11-15: Reserved
6210*4e1bc9a0SAchim Leubner                     Bits 16-23: KEKauth Index in the KEK Table (AUTIDX)
6211*4e1bc9a0SAchim Leubner                     Bits 24-31: KEKopr Index in the KEK Table (OPRIDX). This field is valid only when PKR is 1.
6212*4e1bc9a0SAchim Leubner 
6213*4e1bc9a0SAchim Leubner        role        Role
6214*4e1bc9a0SAchim Leubner                        01b: Crypto officer role.
6215*4e1bc9a0SAchim Leubner                        10b: User role.
6216*4e1bc9a0SAchim Leubner                        All others are reserved.
6217*4e1bc9a0SAchim Leubner 
6218*4e1bc9a0SAchim Leubner *    idString:         Pointer to the tiID_t structure describing the ID string
6219*4e1bc9a0SAchim Leubner *    kekBlob          Pointer to the tiEncryptKekBlob_t structure describing KBLOB.
6220*4e1bc9a0SAchim Leubner *
6221*4e1bc9a0SAchim Leubner *  Return:
6222*4e1bc9a0SAchim Leubner *   tiSuccess     The request is being processed
6223*4e1bc9a0SAchim Leubner *   tiError          An invalid parameter was specified
6224*4e1bc9a0SAchim Leubner *   tiBusy          A operator management operation is already in progress
6225*4e1bc9a0SAchim Leubner *
6226*4e1bc9a0SAchim Leubner *****************************************************************************/
tiCOMOperatorManagement(tiRoot_t * tiRoot,bit32 flag,bit8 role,tiID_t * idString,tiEncryptKekBlob_t * kekBlob)6227*4e1bc9a0SAchim Leubner osGLOBAL bit32 tiCOMOperatorManagement(
6228*4e1bc9a0SAchim Leubner                         tiRoot_t            *tiRoot,
6229*4e1bc9a0SAchim Leubner                         bit32                flag,
6230*4e1bc9a0SAchim Leubner                         bit8                 role,
6231*4e1bc9a0SAchim Leubner                         tiID_t              *idString,
6232*4e1bc9a0SAchim Leubner                         tiEncryptKekBlob_t  *kekBlob
6233*4e1bc9a0SAchim Leubner                         )
6234*4e1bc9a0SAchim Leubner {
6235*4e1bc9a0SAchim Leubner   tdsaRoot_t     *tdsaRoot       = agNULL;
6236*4e1bc9a0SAchim Leubner   tdsaContext_t  *tdsaAllShared  = agNULL;
6237*4e1bc9a0SAchim Leubner   agsaRoot_t     *agRoot         = agNULL;
6238*4e1bc9a0SAchim Leubner 
6239*4e1bc9a0SAchim Leubner   bit32           returnCode     = AGSA_RC_BUSY;
6240*4e1bc9a0SAchim Leubner   bit32           tiStatus       = tiError;
6241*4e1bc9a0SAchim Leubner 
6242*4e1bc9a0SAchim Leubner   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
6243*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6244*4e1bc9a0SAchim Leubner 
6245*4e1bc9a0SAchim Leubner   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6246*4e1bc9a0SAchim Leubner   TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6247*4e1bc9a0SAchim Leubner 
6248*4e1bc9a0SAchim Leubner   agRoot = &(tdsaAllShared->agRootNonInt);
6249*4e1bc9a0SAchim Leubner   TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6250*4e1bc9a0SAchim Leubner 
6251*4e1bc9a0SAchim Leubner   TI_DBG1(("tiCOMOperatorManagement: flag =  0x%x role = 0x%x\n", flag, role));
6252*4e1bc9a0SAchim Leubner 
6253*4e1bc9a0SAchim Leubner   returnCode = saOperatorManagement(agRoot,
6254*4e1bc9a0SAchim Leubner                                     agNULL,
6255*4e1bc9a0SAchim Leubner                                     0,
6256*4e1bc9a0SAchim Leubner                                     flag,
6257*4e1bc9a0SAchim Leubner                                     role,
6258*4e1bc9a0SAchim Leubner                                     (agsaID_t*)idString,
6259*4e1bc9a0SAchim Leubner                                     (agsaEncryptKekBlob_t *)kekBlob
6260*4e1bc9a0SAchim Leubner                                     );
6261*4e1bc9a0SAchim Leubner 
6262*4e1bc9a0SAchim Leubner   if (returnCode == AGSA_RC_SUCCESS)
6263*4e1bc9a0SAchim Leubner   {
6264*4e1bc9a0SAchim Leubner     tiStatus = tiSuccess;
6265*4e1bc9a0SAchim Leubner   }
6266*4e1bc9a0SAchim Leubner   else if (returnCode == AGSA_RC_BUSY)
6267*4e1bc9a0SAchim Leubner   {
6268*4e1bc9a0SAchim Leubner     tiStatus = tiBusy;
6269*4e1bc9a0SAchim Leubner   }
6270*4e1bc9a0SAchim Leubner   else
6271*4e1bc9a0SAchim Leubner   {
6272*4e1bc9a0SAchim Leubner     tiStatus = tiError;
6273*4e1bc9a0SAchim Leubner   }
6274*4e1bc9a0SAchim Leubner 
6275*4e1bc9a0SAchim Leubner   return(tiStatus);
6276*4e1bc9a0SAchim Leubner }
6277*4e1bc9a0SAchim Leubner 
6278*4e1bc9a0SAchim Leubner /*****************************************************************************
6279*4e1bc9a0SAchim Leubner *! \brief tdssRemoveSASSATAFromSharedcontext
6280*4e1bc9a0SAchim Leubner *
6281*4e1bc9a0SAchim Leubner *  Purpose:  This function removes all discovered devices belonging to
6282*4e1bc9a0SAchim Leubner *            a given portcontext from device list
6283*4e1bc9a0SAchim Leubner *
6284*4e1bc9a0SAchim Leubner *
6285*4e1bc9a0SAchim Leubner *  \param   agRoot                   Pointer to the root data structure of
6286*4e1bc9a0SAchim Leubner *                                    TD and Lower layer
6287*4e1bc9a0SAchim Leubner *  \param   tsddPortContext_Instance Pointer to the target port context
6288*4e1bc9a0SAchim Leubner *
6289*4e1bc9a0SAchim Leubner *  \Return: none
6290*4e1bc9a0SAchim Leubner *
6291*4e1bc9a0SAchim Leubner *****************************************************************************/
6292*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER                     /*TBD: added to compile tgt_drv. (TP)*/
6293*4e1bc9a0SAchim Leubner osGLOBAL void
tdssRemoveSASSATAFromSharedcontext(agsaRoot_t * agRoot,tdsaPortContext_t * PortContext_Instance)6294*4e1bc9a0SAchim Leubner tdssRemoveSASSATAFromSharedcontext(
6295*4e1bc9a0SAchim Leubner                           agsaRoot_t           *agRoot,
6296*4e1bc9a0SAchim Leubner                           tdsaPortContext_t    *PortContext_Instance
6297*4e1bc9a0SAchim Leubner                           )
6298*4e1bc9a0SAchim Leubner {
6299*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
6300*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
6301*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6302*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6303*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6304*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6305*4e1bc9a0SAchim Leubner 
6306*4e1bc9a0SAchim Leubner   TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: start\n"));
6307*4e1bc9a0SAchim Leubner   TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d\n", PortContext_Instance->id));
6308*4e1bc9a0SAchim Leubner 
6309*4e1bc9a0SAchim Leubner   /* find oneDeviceData belonging to the portcontext */
6310*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
6311*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6312*4e1bc9a0SAchim Leubner   {
6313*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6314*4e1bc9a0SAchim Leubner     if (oneDeviceData == agNULL)
6315*4e1bc9a0SAchim Leubner     {
6316*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: oneDeviceData is NULL!!!\n"));
6317*4e1bc9a0SAchim Leubner       return;
6318*4e1bc9a0SAchim Leubner     }
6319*4e1bc9a0SAchim Leubner     if (oneDeviceData->tdPortContext == PortContext_Instance)
6320*4e1bc9a0SAchim Leubner     {
6321*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d did %d\n", PortContext_Instance->id, oneDeviceData->id));
6322*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
6323*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
6324*4e1bc9a0SAchim Leubner 
6325*4e1bc9a0SAchim Leubner       /* reset valid bit */
6326*4e1bc9a0SAchim Leubner       oneDeviceData->valid = agFALSE;
6327*4e1bc9a0SAchim Leubner       oneDeviceData->valid2 = agFALSE;
6328*4e1bc9a0SAchim Leubner       oneDeviceData->registered = agFALSE;
6329*4e1bc9a0SAchim Leubner       /* notify only reported devices to OS layer*/
6330*4e1bc9a0SAchim Leubner       if ( DEVICE_IS_SSP_TARGET(oneDeviceData) ||
6331*4e1bc9a0SAchim Leubner            DEVICE_IS_STP_TARGET(oneDeviceData) ||
6332*4e1bc9a0SAchim Leubner            DEVICE_IS_SATA_DEVICE(oneDeviceData)
6333*4e1bc9a0SAchim Leubner         )
6334*4e1bc9a0SAchim Leubner       {
6335*4e1bc9a0SAchim Leubner         ostiInitiatorEvent(
6336*4e1bc9a0SAchim Leubner                          tiRoot,
6337*4e1bc9a0SAchim Leubner                          PortContext_Instance->tiPortalContext,
6338*4e1bc9a0SAchim Leubner                          &(oneDeviceData->tiDeviceHandle),
6339*4e1bc9a0SAchim Leubner                          tiIntrEventTypeDeviceChange,
6340*4e1bc9a0SAchim Leubner                          tiDeviceRemoval,
6341*4e1bc9a0SAchim Leubner                          agNULL
6342*4e1bc9a0SAchim Leubner                          );
6343*4e1bc9a0SAchim Leubner       }
6344*4e1bc9a0SAchim Leubner       DeviceListList = DeviceListList->flink;
6345*4e1bc9a0SAchim Leubner     /* to-do: deregister */
6346*4e1bc9a0SAchim Leubner #ifdef REMOVED  /* don't remove device from the device list. May screw up ordering */
6347*4e1bc9a0SAchim Leubner       TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
6348*4e1bc9a0SAchim Leubner       TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
6349*4e1bc9a0SAchim Leubner #endif
6350*4e1bc9a0SAchim Leubner     }
6351*4e1bc9a0SAchim Leubner     else
6352*4e1bc9a0SAchim Leubner     {
6353*4e1bc9a0SAchim Leubner       TI_DBG6(("tdssRemoveSASSATAFromSharedcontext: move to the next\n"));
6354*4e1bc9a0SAchim Leubner       DeviceListList = DeviceListList->flink;
6355*4e1bc9a0SAchim Leubner     }
6356*4e1bc9a0SAchim Leubner   } /* while */
6357*4e1bc9a0SAchim Leubner 
6358*4e1bc9a0SAchim Leubner   return;
6359*4e1bc9a0SAchim Leubner }
6360*4e1bc9a0SAchim Leubner 
6361*4e1bc9a0SAchim Leubner /*****************************************************************************
6362*4e1bc9a0SAchim Leubner *! \brief tdssRemoveSASSATAFromSharedcontextByReset
6363*4e1bc9a0SAchim Leubner *
6364*4e1bc9a0SAchim Leubner *  Purpose:  This function removes all ports and discovered devices
6365*4e1bc9a0SAchim Leubner *
6366*4e1bc9a0SAchim Leubner *
6367*4e1bc9a0SAchim Leubner *  \param   agRoot                   Pointer to the root data structure of
6368*4e1bc9a0SAchim Leubner *                                    TD and Lower layer
6369*4e1bc9a0SAchim Leubner *
6370*4e1bc9a0SAchim Leubner *  \Return: none
6371*4e1bc9a0SAchim Leubner *
6372*4e1bc9a0SAchim Leubner *****************************************************************************/
6373*4e1bc9a0SAchim Leubner osGLOBAL void
tdssRemoveSASSATAFromSharedcontextByReset(agsaRoot_t * agRoot)6374*4e1bc9a0SAchim Leubner tdssRemoveSASSATAFromSharedcontextByReset(
6375*4e1bc9a0SAchim Leubner                                           agsaRoot_t           *agRoot
6376*4e1bc9a0SAchim Leubner                                           )
6377*4e1bc9a0SAchim Leubner {
6378*4e1bc9a0SAchim Leubner   tdsaPortContext_t *onePortContext = agNULL;
6379*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
6380*4e1bc9a0SAchim Leubner   tdList_t          *PortContextList;
6381*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
6382*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6383*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6384*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6385*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6386*4e1bc9a0SAchim Leubner #ifdef FDS_DM
6387*4e1bc9a0SAchim Leubner   dmRoot_t          *dmRoot = agNULL;
6388*4e1bc9a0SAchim Leubner   dmPortContext_t   *dmPortContext = agNULL;
6389*4e1bc9a0SAchim Leubner   dmPortInfo_t      dmPortInfo;
6390*4e1bc9a0SAchim Leubner #endif
6391*4e1bc9a0SAchim Leubner #ifdef FDS_SM
6392*4e1bc9a0SAchim Leubner   smRoot_t          *smRoot = &(tdsaAllShared->smRoot);
6393*4e1bc9a0SAchim Leubner   smDeviceHandle_t  *smDeviceHandle = agNULL;
6394*4e1bc9a0SAchim Leubner   agsaDevHandle_t   *agDevHandle = agNULL;
6395*4e1bc9a0SAchim Leubner #endif
6396*4e1bc9a0SAchim Leubner 
6397*4e1bc9a0SAchim Leubner   TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: start\n"));
6398*4e1bc9a0SAchim Leubner 
6399*4e1bc9a0SAchim Leubner #ifdef FDS_DM
6400*4e1bc9a0SAchim Leubner   dmRoot = &(tdsaAllShared->dmRoot);
6401*4e1bc9a0SAchim Leubner #endif
6402*4e1bc9a0SAchim Leubner   /* looping throuhg all portcontext */
6403*4e1bc9a0SAchim Leubner   PortContextList = tdsaAllShared->MainPortContextList.flink;
6404*4e1bc9a0SAchim Leubner   while (PortContextList != &(tdsaAllShared->MainPortContextList))
6405*4e1bc9a0SAchim Leubner   {
6406*4e1bc9a0SAchim Leubner     onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6407*4e1bc9a0SAchim Leubner     if (onePortContext == agNULL)
6408*4e1bc9a0SAchim Leubner     {
6409*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: onePortContext is NULL!!!\n"));
6410*4e1bc9a0SAchim Leubner       return;
6411*4e1bc9a0SAchim Leubner     }
6412*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneportContext pid %d\n", onePortContext->id));
6413*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", onePortContext->sasLocalAddressHi));
6414*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", onePortContext->sasLocalAddressLo));
6415*4e1bc9a0SAchim Leubner #ifdef FDS_DM
6416*4e1bc9a0SAchim Leubner     if (onePortContext->UseDM == agTRUE)
6417*4e1bc9a0SAchim Leubner     {
6418*4e1bc9a0SAchim Leubner       dmPortContext = &(onePortContext->dmPortContext);
6419*4e1bc9a0SAchim Leubner       dmDestroyPort(dmRoot, dmPortContext, &dmPortInfo);
6420*4e1bc9a0SAchim Leubner     }
6421*4e1bc9a0SAchim Leubner #endif
6422*4e1bc9a0SAchim Leubner 
6423*4e1bc9a0SAchim Leubner     tdsaPortContextReInit(tiRoot, onePortContext);
6424*4e1bc9a0SAchim Leubner 
6425*4e1bc9a0SAchim Leubner     PortContextList = PortContextList->flink;
6426*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
6427*4e1bc9a0SAchim Leubner     TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
6428*4e1bc9a0SAchim Leubner     TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
6429*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
6430*4e1bc9a0SAchim Leubner   }
6431*4e1bc9a0SAchim Leubner 
6432*4e1bc9a0SAchim Leubner   /* reinitialize the device data belonging to this portcontext */
6433*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
6434*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6435*4e1bc9a0SAchim Leubner   {
6436*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6437*4e1bc9a0SAchim Leubner     if (oneDeviceData == agNULL)
6438*4e1bc9a0SAchim Leubner     {
6439*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneDeviceData is NULL!!!\n"));
6440*4e1bc9a0SAchim Leubner       return;
6441*4e1bc9a0SAchim Leubner     }
6442*4e1bc9a0SAchim Leubner 
6443*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: did %d\n", oneDeviceData->id));
6444*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
6445*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
6446*4e1bc9a0SAchim Leubner 
6447*4e1bc9a0SAchim Leubner #ifdef FDS_SM
6448*4e1bc9a0SAchim Leubner     agDevHandle = oneDeviceData->agDevHandle;
6449*4e1bc9a0SAchim Leubner     smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle);
6450*4e1bc9a0SAchim Leubner     smDeregisterDevice(smRoot, agDevHandle, smDeviceHandle);
6451*4e1bc9a0SAchim Leubner #endif
6452*4e1bc9a0SAchim Leubner 
6453*4e1bc9a0SAchim Leubner     tdsaDeviceDataReInit(tiRoot, oneDeviceData);
6454*4e1bc9a0SAchim Leubner 
6455*4e1bc9a0SAchim Leubner     DeviceListList = DeviceListList->flink;
6456*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6457*4e1bc9a0SAchim Leubner     osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t));
6458*4e1bc9a0SAchim Leubner     TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
6459*4e1bc9a0SAchim Leubner     TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
6460*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6461*4e1bc9a0SAchim Leubner     /* no dequeue from Mainlink for consistant ordering of devices */
6462*4e1bc9a0SAchim Leubner   }
6463*4e1bc9a0SAchim Leubner 
6464*4e1bc9a0SAchim Leubner 
6465*4e1bc9a0SAchim Leubner   return;
6466*4e1bc9a0SAchim Leubner }
6467*4e1bc9a0SAchim Leubner 
6468*4e1bc9a0SAchim Leubner #endif
6469*4e1bc9a0SAchim Leubner 
6470*4e1bc9a0SAchim Leubner 
6471*4e1bc9a0SAchim Leubner /*****************************************************************************
6472*4e1bc9a0SAchim Leubner *! \brief tdssAddSASToSharedcontext
6473*4e1bc9a0SAchim Leubner *
6474*4e1bc9a0SAchim Leubner *  Purpose:  This function adds a discovered device to a device list of
6475*4e1bc9a0SAchim Leubner *            a shared context
6476*4e1bc9a0SAchim Leubner *
6477*4e1bc9a0SAchim Leubner *  \param   tsddPortContext_Instance Pointer to the target port context
6478*4e1bc9a0SAchim Leubner *  \param   agRoot                   Pointer to the root data structure of
6479*4e1bc9a0SAchim Leubner *                                    TD and Lower layer
6480*4e1bc9a0SAchim Leubner *  \param   agDevHandle              Pointer to a device handle
6481*4e1bc9a0SAchim Leubner *
6482*4e1bc9a0SAchim Leubner *  \Return: none
6483*4e1bc9a0SAchim Leubner *
6484*4e1bc9a0SAchim Leubner *****************************************************************************/
6485*4e1bc9a0SAchim Leubner osGLOBAL void
tdssAddSASToSharedcontext(tdsaPortContext_t * tdsaPortContext_Instance,agsaRoot_t * agRoot,agsaDevHandle_t * agDevHandle,tdsaSASSubID_t * agSASSubID,bit32 registered,bit8 phyID,bit32 flag)6486*4e1bc9a0SAchim Leubner tdssAddSASToSharedcontext(
6487*4e1bc9a0SAchim Leubner                           tdsaPortContext_t    *tdsaPortContext_Instance,
6488*4e1bc9a0SAchim Leubner                           agsaRoot_t           *agRoot,
6489*4e1bc9a0SAchim Leubner                           agsaDevHandle_t      *agDevHandle, /* this is NULL */
6490*4e1bc9a0SAchim Leubner                           tdsaSASSubID_t       *agSASSubID,
6491*4e1bc9a0SAchim Leubner                           bit32                 registered, /* no longer in use */
6492*4e1bc9a0SAchim Leubner                           bit8                  phyID,
6493*4e1bc9a0SAchim Leubner                           bit32                 flag
6494*4e1bc9a0SAchim Leubner                           )
6495*4e1bc9a0SAchim Leubner {
6496*4e1bc9a0SAchim Leubner 
6497*4e1bc9a0SAchim Leubner   tdsaPortContext_t *onePortContext = agNULL;
6498*4e1bc9a0SAchim Leubner   tdList_t          *PortContextList;
6499*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
6500*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
6501*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6502*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6503*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6504*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6505*4e1bc9a0SAchim Leubner   bit32             new_device = agTRUE;
6506*4e1bc9a0SAchim Leubner   bit32             Indenom = tdsaAllShared->QueueConfig.numInboundQueues;
6507*4e1bc9a0SAchim Leubner   bit32             Outdenom = tdsaAllShared->QueueConfig.numOutboundQueues;
6508*4e1bc9a0SAchim Leubner   bit8              dev_s_rate = 0;
6509*4e1bc9a0SAchim Leubner   bit8              sasorsata = 1;
6510*4e1bc9a0SAchim Leubner   bit8              connectionRate;
6511*4e1bc9a0SAchim Leubner   bit32             found = agFALSE;
6512*4e1bc9a0SAchim Leubner 
6513*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssAddSASToSharedcontext: start\n"));
6514*4e1bc9a0SAchim Leubner   /*
6515*4e1bc9a0SAchim Leubner     find a right portcontext
6516*4e1bc9a0SAchim Leubner     then, get devicedata from FreeLink in DeviceList
6517*4e1bc9a0SAchim Leubner     then, do pointer operations
6518*4e1bc9a0SAchim Leubner     then, add the devicedata to the portcontext
6519*4e1bc9a0SAchim Leubner   */
6520*4e1bc9a0SAchim Leubner 
6521*4e1bc9a0SAchim Leubner   /* find a right portcontext */
6522*4e1bc9a0SAchim Leubner   PortContextList = tdsaAllShared->MainPortContextList.flink;
6523*4e1bc9a0SAchim Leubner   while (PortContextList != &(tdsaAllShared->MainPortContextList))
6524*4e1bc9a0SAchim Leubner   {
6525*4e1bc9a0SAchim Leubner     onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6526*4e1bc9a0SAchim Leubner     if (onePortContext == tdsaPortContext_Instance)
6527*4e1bc9a0SAchim Leubner     {
6528*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssAddSASToSharedContext: found; oneportContext ID %d\n", onePortContext->id));
6529*4e1bc9a0SAchim Leubner       found = agTRUE;
6530*4e1bc9a0SAchim Leubner       break;
6531*4e1bc9a0SAchim Leubner     }
6532*4e1bc9a0SAchim Leubner     PortContextList = PortContextList->flink;
6533*4e1bc9a0SAchim Leubner   }
6534*4e1bc9a0SAchim Leubner 
6535*4e1bc9a0SAchim Leubner   if (found == agTRUE)
6536*4e1bc9a0SAchim Leubner   {
6537*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssAddSASToSharedcontext: found pid %d\n", onePortContext->id));
6538*4e1bc9a0SAchim Leubner   }
6539*4e1bc9a0SAchim Leubner   else
6540*4e1bc9a0SAchim Leubner   {
6541*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssAddSASToSharedcontext: Error!!! no portcontext found!!!\n"));
6542*4e1bc9a0SAchim Leubner     return;
6543*4e1bc9a0SAchim Leubner   }
6544*4e1bc9a0SAchim Leubner 
6545*4e1bc9a0SAchim Leubner   /* find a device's existence */
6546*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
6547*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6548*4e1bc9a0SAchim Leubner   {
6549*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6550*4e1bc9a0SAchim Leubner     if (oneDeviceData == agNULL)
6551*4e1bc9a0SAchim Leubner     {
6552*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
6553*4e1bc9a0SAchim Leubner       return;
6554*4e1bc9a0SAchim Leubner     }
6555*4e1bc9a0SAchim Leubner     if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
6556*4e1bc9a0SAchim Leubner         (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
6557*4e1bc9a0SAchim Leubner         (oneDeviceData->tdPortContext == onePortContext)
6558*4e1bc9a0SAchim Leubner          )
6559*4e1bc9a0SAchim Leubner     {
6560*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6561*4e1bc9a0SAchim Leubner       new_device = agFALSE;
6562*4e1bc9a0SAchim Leubner       break;
6563*4e1bc9a0SAchim Leubner     }
6564*4e1bc9a0SAchim Leubner     DeviceListList = DeviceListList->flink;
6565*4e1bc9a0SAchim Leubner   }
6566*4e1bc9a0SAchim Leubner 
6567*4e1bc9a0SAchim Leubner   /* new device */
6568*4e1bc9a0SAchim Leubner   if (new_device == agTRUE)
6569*4e1bc9a0SAchim Leubner   {
6570*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssAddSASToSharedcontext: new device\n"));
6571*4e1bc9a0SAchim Leubner 
6572*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6573*4e1bc9a0SAchim Leubner     if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
6574*4e1bc9a0SAchim Leubner     {
6575*4e1bc9a0SAchim Leubner       tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6576*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssAddSASToSharedContext: empty DeviceData FreeLink\n"));
6577*4e1bc9a0SAchim Leubner       return;
6578*4e1bc9a0SAchim Leubner     }
6579*4e1bc9a0SAchim Leubner 
6580*4e1bc9a0SAchim Leubner     TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
6581*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6582*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
6583*4e1bc9a0SAchim Leubner 
6584*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
6585*4e1bc9a0SAchim Leubner 
6586*4e1bc9a0SAchim Leubner     onePortContext->Count++;
6587*4e1bc9a0SAchim Leubner     oneDeviceData->DeviceType = TD_SAS_DEVICE;
6588*4e1bc9a0SAchim Leubner     oneDeviceData->agRoot = agRoot;
6589*4e1bc9a0SAchim Leubner 
6590*4e1bc9a0SAchim Leubner     if (flag == TD_OPERATION_TARGET)
6591*4e1bc9a0SAchim Leubner     {
6592*4e1bc9a0SAchim Leubner       oneDeviceData->agDevHandle = agDevHandle;
6593*4e1bc9a0SAchim Leubner       agDevHandle->osData = oneDeviceData; /* TD layer */
6594*4e1bc9a0SAchim Leubner     }
6595*4e1bc9a0SAchim Leubner 
6596*4e1bc9a0SAchim Leubner     /* saving sas address */
6597*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
6598*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
6599*4e1bc9a0SAchim Leubner     oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
6600*4e1bc9a0SAchim Leubner     oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
6601*4e1bc9a0SAchim Leubner 
6602*4e1bc9a0SAchim Leubner     oneDeviceData->tdPortContext = onePortContext;
6603*4e1bc9a0SAchim Leubner     oneDeviceData->valid = agTRUE;
6604*4e1bc9a0SAchim Leubner 
6605*4e1bc9a0SAchim Leubner     /* new */
6606*4e1bc9a0SAchim Leubner     oneDeviceData->directlyAttached = agTRUE;
6607*4e1bc9a0SAchim Leubner     /* parse sasIDframe to fill in agDeviceInfo */
6608*4e1bc9a0SAchim Leubner     DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
6609*4e1bc9a0SAchim Leubner     DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
6610*4e1bc9a0SAchim Leubner     DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
6611*4e1bc9a0SAchim Leubner     /* enable TLR */
6612*4e1bc9a0SAchim Leubner     DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
6613*4e1bc9a0SAchim Leubner 
6614*4e1bc9a0SAchim Leubner     sasorsata = SAS_DEVICE_TYPE; /* SAS target (SAS disk or expander) */
6615*4e1bc9a0SAchim Leubner     connectionRate = onePortContext->LinkRate;
6616*4e1bc9a0SAchim Leubner     dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
6617*4e1bc9a0SAchim Leubner     dev_s_rate = (bit8)(dev_s_rate | connectionRate);
6618*4e1bc9a0SAchim Leubner     DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
6619*4e1bc9a0SAchim Leubner 
6620*4e1bc9a0SAchim Leubner 
6621*4e1bc9a0SAchim Leubner     DEVINFO_PUT_SAS_ADDRESSLO(
6622*4e1bc9a0SAchim Leubner                               &oneDeviceData->agDeviceInfo,
6623*4e1bc9a0SAchim Leubner                               agSASSubID->sasAddressLo
6624*4e1bc9a0SAchim Leubner                               );
6625*4e1bc9a0SAchim Leubner     DEVINFO_PUT_SAS_ADDRESSHI(
6626*4e1bc9a0SAchim Leubner                               &oneDeviceData->agDeviceInfo,
6627*4e1bc9a0SAchim Leubner                               agSASSubID->sasAddressHi
6628*4e1bc9a0SAchim Leubner                               );
6629*4e1bc9a0SAchim Leubner 
6630*4e1bc9a0SAchim Leubner     oneDeviceData->agContext.osData = oneDeviceData;
6631*4e1bc9a0SAchim Leubner     oneDeviceData->agContext.sdkData = agNULL;
6632*4e1bc9a0SAchim Leubner 
6633*4e1bc9a0SAchim Leubner     if (flag == TD_OPERATION_INITIATOR)
6634*4e1bc9a0SAchim Leubner     {
6635*4e1bc9a0SAchim Leubner       if (oneDeviceData->registered == agFALSE )
6636*4e1bc9a0SAchim Leubner       {
6637*4e1bc9a0SAchim Leubner         if( tdsaAllShared->sflag )
6638*4e1bc9a0SAchim Leubner         {
6639*4e1bc9a0SAchim Leubner           if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
6640*4e1bc9a0SAchim Leubner           {
6641*4e1bc9a0SAchim Leubner             TI_DBG1(("tdssAddSASToSharedcontext: First, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
6642*4e1bc9a0SAchim Leubner             oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
6643*4e1bc9a0SAchim Leubner           }
6644*4e1bc9a0SAchim Leubner         }
6645*4e1bc9a0SAchim Leubner 
6646*4e1bc9a0SAchim Leubner         saRegisterNewDevice( /* tdssAddSASToSharedcontext */
6647*4e1bc9a0SAchim Leubner                             agRoot,
6648*4e1bc9a0SAchim Leubner                             &oneDeviceData->agContext,
6649*4e1bc9a0SAchim Leubner                             0,
6650*4e1bc9a0SAchim Leubner                             &oneDeviceData->agDeviceInfo,
6651*4e1bc9a0SAchim Leubner                             onePortContext->agPortContext,
6652*4e1bc9a0SAchim Leubner                             0
6653*4e1bc9a0SAchim Leubner                            );
6654*4e1bc9a0SAchim Leubner       }
6655*4e1bc9a0SAchim Leubner     }
6656*4e1bc9a0SAchim Leubner     oneDeviceData->phyID = phyID;
6657*4e1bc9a0SAchim Leubner     oneDeviceData->InQID = oneDeviceData->id % Indenom;
6658*4e1bc9a0SAchim Leubner 
6659*4e1bc9a0SAchim Leubner #ifdef TARGET_DRIVER
6660*4e1bc9a0SAchim Leubner     {
6661*4e1bc9a0SAchim Leubner       bit32 localId = oneDeviceData->id;
6662*4e1bc9a0SAchim Leubner       localId += 1;
6663*4e1bc9a0SAchim Leubner       oneDeviceData->OutQID = localId % Outdenom;
6664*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssAddSASToSharedcontext: OutQID %d\n", oneDeviceData->OutQID)); /* tdsaRotateQnumber for tgt*/
6665*4e1bc9a0SAchim Leubner 
6666*4e1bc9a0SAchim Leubner     }
6667*4e1bc9a0SAchim Leubner #endif /* TARGET_DRIVER */
6668*4e1bc9a0SAchim Leubner 
6669*4e1bc9a0SAchim Leubner     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)));
6670*4e1bc9a0SAchim Leubner     /* add the devicedata to the portcontext */
6671*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6672*4e1bc9a0SAchim Leubner     TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
6673*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6674*4e1bc9a0SAchim Leubner     TI_DBG4(("tdssAddSASToSharedContext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
6675*4e1bc9a0SAchim Leubner     TI_DBG4(("tdssAddSASToSharedContext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
6676*4e1bc9a0SAchim Leubner 
6677*4e1bc9a0SAchim Leubner   }
6678*4e1bc9a0SAchim Leubner   else /* old device */
6679*4e1bc9a0SAchim Leubner   {
6680*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssAddSASToSharedcontext: old device\n"));
6681*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
6682*4e1bc9a0SAchim Leubner 
6683*4e1bc9a0SAchim Leubner     oneDeviceData->DeviceType = TD_SAS_DEVICE;
6684*4e1bc9a0SAchim Leubner     oneDeviceData->agRoot = agRoot;
6685*4e1bc9a0SAchim Leubner 
6686*4e1bc9a0SAchim Leubner     if (flag == TD_OPERATION_TARGET)
6687*4e1bc9a0SAchim Leubner     {
6688*4e1bc9a0SAchim Leubner       oneDeviceData->agDevHandle = agDevHandle;
6689*4e1bc9a0SAchim Leubner       agDevHandle->osData = oneDeviceData; /* TD layer */
6690*4e1bc9a0SAchim Leubner     }
6691*4e1bc9a0SAchim Leubner 
6692*4e1bc9a0SAchim Leubner     /* saving sas address */
6693*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
6694*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
6695*4e1bc9a0SAchim Leubner     oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
6696*4e1bc9a0SAchim Leubner     oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
6697*4e1bc9a0SAchim Leubner 
6698*4e1bc9a0SAchim Leubner 
6699*4e1bc9a0SAchim Leubner     oneDeviceData->tdPortContext = onePortContext;
6700*4e1bc9a0SAchim Leubner     oneDeviceData->valid = agTRUE;
6701*4e1bc9a0SAchim Leubner 
6702*4e1bc9a0SAchim Leubner     oneDeviceData->directlyAttached = agTRUE;
6703*4e1bc9a0SAchim Leubner     /* new */
6704*4e1bc9a0SAchim Leubner     if (oneDeviceData->registered == agFALSE)
6705*4e1bc9a0SAchim Leubner     {
6706*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssAddSASToSharedcontext: registering\n"));
6707*4e1bc9a0SAchim Leubner       /* parse sasIDframe to fill in agDeviceInfo */
6708*4e1bc9a0SAchim Leubner       DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
6709*4e1bc9a0SAchim Leubner       DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
6710*4e1bc9a0SAchim Leubner       DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
6711*4e1bc9a0SAchim Leubner       DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
6712*4e1bc9a0SAchim Leubner 
6713*4e1bc9a0SAchim Leubner       sasorsata = SAS_DEVICE_TYPE; /* SAS target (SAS disk or expander) */
6714*4e1bc9a0SAchim Leubner       connectionRate = onePortContext->LinkRate;
6715*4e1bc9a0SAchim Leubner       dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
6716*4e1bc9a0SAchim Leubner       dev_s_rate = (bit8)(dev_s_rate | connectionRate);
6717*4e1bc9a0SAchim Leubner       DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
6718*4e1bc9a0SAchim Leubner 
6719*4e1bc9a0SAchim Leubner 
6720*4e1bc9a0SAchim Leubner       DEVINFO_PUT_SAS_ADDRESSLO(
6721*4e1bc9a0SAchim Leubner                                 &oneDeviceData->agDeviceInfo,
6722*4e1bc9a0SAchim Leubner                                 agSASSubID->sasAddressLo
6723*4e1bc9a0SAchim Leubner                                 );
6724*4e1bc9a0SAchim Leubner       DEVINFO_PUT_SAS_ADDRESSHI(
6725*4e1bc9a0SAchim Leubner                                 &oneDeviceData->agDeviceInfo,
6726*4e1bc9a0SAchim Leubner                                 agSASSubID->sasAddressHi
6727*4e1bc9a0SAchim Leubner                                 );
6728*4e1bc9a0SAchim Leubner 
6729*4e1bc9a0SAchim Leubner       oneDeviceData->agContext.osData = oneDeviceData;
6730*4e1bc9a0SAchim Leubner       oneDeviceData->agContext.sdkData = agNULL;
6731*4e1bc9a0SAchim Leubner 
6732*4e1bc9a0SAchim Leubner       if (flag == TD_OPERATION_INITIATOR)
6733*4e1bc9a0SAchim Leubner       {
6734*4e1bc9a0SAchim Leubner         if( tdsaAllShared->sflag )
6735*4e1bc9a0SAchim Leubner         {
6736*4e1bc9a0SAchim Leubner           if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
6737*4e1bc9a0SAchim Leubner           {
6738*4e1bc9a0SAchim Leubner             TI_DBG1(("tdssAddSASToSharedcontext: Second, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
6739*4e1bc9a0SAchim Leubner             oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
6740*4e1bc9a0SAchim Leubner           }
6741*4e1bc9a0SAchim Leubner         }
6742*4e1bc9a0SAchim Leubner         saRegisterNewDevice( /* tdssAddSASToSharedcontext */
6743*4e1bc9a0SAchim Leubner                             agRoot,
6744*4e1bc9a0SAchim Leubner                             &oneDeviceData->agContext,
6745*4e1bc9a0SAchim Leubner                             0,
6746*4e1bc9a0SAchim Leubner                             &oneDeviceData->agDeviceInfo,
6747*4e1bc9a0SAchim Leubner                             onePortContext->agPortContext,
6748*4e1bc9a0SAchim Leubner                             0
6749*4e1bc9a0SAchim Leubner                             );
6750*4e1bc9a0SAchim Leubner       }
6751*4e1bc9a0SAchim Leubner     }
6752*4e1bc9a0SAchim Leubner 
6753*4e1bc9a0SAchim Leubner 
6754*4e1bc9a0SAchim Leubner 
6755*4e1bc9a0SAchim Leubner 
6756*4e1bc9a0SAchim Leubner 
6757*4e1bc9a0SAchim Leubner 
6758*4e1bc9a0SAchim Leubner     oneDeviceData->phyID = phyID;
6759*4e1bc9a0SAchim Leubner     oneDeviceData->InQID = oneDeviceData->id % Indenom;
6760*4e1bc9a0SAchim Leubner     oneDeviceData->OutQID = oneDeviceData->id % Outdenom;
6761*4e1bc9a0SAchim Leubner 
6762*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssAddSASToSharedcontext: A OutQID %d\n", oneDeviceData->OutQID));
6763*4e1bc9a0SAchim Leubner     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)));
6764*4e1bc9a0SAchim Leubner     TI_DBG4(("tdssAddSASToSharedContext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
6765*4e1bc9a0SAchim Leubner   }
6766*4e1bc9a0SAchim Leubner 
6767*4e1bc9a0SAchim Leubner   return;
6768*4e1bc9a0SAchim Leubner }
6769*4e1bc9a0SAchim Leubner 
6770*4e1bc9a0SAchim Leubner 
6771*4e1bc9a0SAchim Leubner 
6772*4e1bc9a0SAchim Leubner 
6773*4e1bc9a0SAchim Leubner /*****************************************************************************
6774*4e1bc9a0SAchim Leubner *! \brief tdssRemoveDevicedataFromSharedcontext
6775*4e1bc9a0SAchim Leubner *
6776*4e1bc9a0SAchim Leubner *  Purpose:  This function removes a discovered device from a device list of
6777*4e1bc9a0SAchim Leubner *            a port context
6778*4e1bc9a0SAchim Leubner *
6779*4e1bc9a0SAchim Leubner *  \param   tsddPortContext_Ins      Pointer to the target port context
6780*4e1bc9a0SAchim Leubner *  \param   tdsaDeviceData_Ins       Pointer to the target device
6781*4e1bc9a0SAchim Leubner *  \param   agRoot                   Pointer to the root data structure of
6782*4e1bc9a0SAchim Leubner *                                    TD and Lower layer
6783*4e1bc9a0SAchim Leubner 
6784*4e1bc9a0SAchim Leubner *
6785*4e1bc9a0SAchim Leubner *  \Return: none
6786*4e1bc9a0SAchim Leubner *
6787*4e1bc9a0SAchim Leubner *****************************************************************************/
6788*4e1bc9a0SAchim Leubner osGLOBAL void
tdssRemoveSASFromSharedcontext(tdsaPortContext_t * tdsaPortContext_Ins,tdsaDeviceData_t * tdsaDeviceData_Ins,agsaRoot_t * agRoot)6789*4e1bc9a0SAchim Leubner tdssRemoveSASFromSharedcontext(
6790*4e1bc9a0SAchim Leubner                                tdsaPortContext_t *tdsaPortContext_Ins,
6791*4e1bc9a0SAchim Leubner                                tdsaDeviceData_t  *tdsaDeviceData_Ins,
6792*4e1bc9a0SAchim Leubner                                agsaRoot_t        *agRoot
6793*4e1bc9a0SAchim Leubner                                )
6794*4e1bc9a0SAchim Leubner {
6795*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6796*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6797*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6798*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6799*4e1bc9a0SAchim Leubner   tdsaPortContext_t *onePortContext = agNULL;
6800*4e1bc9a0SAchim Leubner   tdList_t          *PortContextList;
6801*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
6802*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
6803*4e1bc9a0SAchim Leubner   bit32             found = agTRUE;
6804*4e1bc9a0SAchim Leubner 
6805*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssRemoveSASFromSharedcontext: start\n"));
6806*4e1bc9a0SAchim Leubner   /* find a right portcontext */
6807*4e1bc9a0SAchim Leubner   PortContextList = tdsaAllShared->MainPortContextList.flink;
6808*4e1bc9a0SAchim Leubner   while (PortContextList != &(tdsaAllShared->MainPortContextList))
6809*4e1bc9a0SAchim Leubner   {
6810*4e1bc9a0SAchim Leubner     onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6811*4e1bc9a0SAchim Leubner     if (onePortContext == agNULL)
6812*4e1bc9a0SAchim Leubner     {
6813*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: onePortContext is NULL!!!\n"));
6814*4e1bc9a0SAchim Leubner       return;
6815*4e1bc9a0SAchim Leubner     }
6816*4e1bc9a0SAchim Leubner     if (onePortContext == tdsaPortContext_Ins)
6817*4e1bc9a0SAchim Leubner     {
6818*4e1bc9a0SAchim Leubner       TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: found; oneportContext ID %d\n", onePortContext->id));
6819*4e1bc9a0SAchim Leubner       break;
6820*4e1bc9a0SAchim Leubner     }
6821*4e1bc9a0SAchim Leubner     PortContextList = PortContextList->flink;
6822*4e1bc9a0SAchim Leubner   }
6823*4e1bc9a0SAchim Leubner 
6824*4e1bc9a0SAchim Leubner   /* find a device's existence */
6825*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
6826*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6827*4e1bc9a0SAchim Leubner   {
6828*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6829*4e1bc9a0SAchim Leubner     if (oneDeviceData == agNULL)
6830*4e1bc9a0SAchim Leubner     {
6831*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: oneDeviceData is NULL!!!\n"));
6832*4e1bc9a0SAchim Leubner       return;
6833*4e1bc9a0SAchim Leubner     }
6834*4e1bc9a0SAchim Leubner     if ((oneDeviceData->SASAddressID.sasAddressHi
6835*4e1bc9a0SAchim Leubner          == SA_DEVINFO_GET_SAS_ADDRESSHI(&tdsaDeviceData_Ins->agDeviceInfo))
6836*4e1bc9a0SAchim Leubner         &&
6837*4e1bc9a0SAchim Leubner         (oneDeviceData->SASAddressID.sasAddressLo ==
6838*4e1bc9a0SAchim Leubner          SA_DEVINFO_GET_SAS_ADDRESSLO(&tdsaDeviceData_Ins->agDeviceInfo)))
6839*4e1bc9a0SAchim Leubner     {
6840*4e1bc9a0SAchim Leubner       TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6841*4e1bc9a0SAchim Leubner       found = agFALSE;
6842*4e1bc9a0SAchim Leubner       break;
6843*4e1bc9a0SAchim Leubner     }
6844*4e1bc9a0SAchim Leubner     DeviceListList = DeviceListList->flink;
6845*4e1bc9a0SAchim Leubner   }
6846*4e1bc9a0SAchim Leubner 
6847*4e1bc9a0SAchim Leubner   if (found == agFALSE)
6848*4e1bc9a0SAchim Leubner   {
6849*4e1bc9a0SAchim Leubner     TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: can't find the right devicedata in MainLink\n"));
6850*4e1bc9a0SAchim Leubner     return;
6851*4e1bc9a0SAchim Leubner   }
6852*4e1bc9a0SAchim Leubner 
6853*4e1bc9a0SAchim Leubner   /* remove it and put it back to FreeLink of Devicedata */
6854*4e1bc9a0SAchim Leubner   TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: removing ... pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6855*4e1bc9a0SAchim Leubner 
6856*4e1bc9a0SAchim Leubner   /* invalidate the device but keep it on the list for persistency */
6857*4e1bc9a0SAchim Leubner   oneDeviceData->valid = agFALSE;
6858*4e1bc9a0SAchim Leubner 
6859*4e1bc9a0SAchim Leubner   return;
6860*4e1bc9a0SAchim Leubner }
6861*4e1bc9a0SAchim Leubner 
6862*4e1bc9a0SAchim Leubner /*****************************************************************************
6863*4e1bc9a0SAchim Leubner *! \brief tdssRemoveAllDevicedataFromPortcontext
6864*4e1bc9a0SAchim Leubner *
6865*4e1bc9a0SAchim Leubner *  Purpose:  This function removes all discovered devices from a device list of
6866*4e1bc9a0SAchim Leubner *            a port context
6867*4e1bc9a0SAchim Leubner *
6868*4e1bc9a0SAchim Leubner *  \param   tdsaDeviceData           Pointer to a device header
6869*4e1bc9a0SAchim Leubner *
6870*4e1bc9a0SAchim Leubner *  \Return: none
6871*4e1bc9a0SAchim Leubner *
6872*4e1bc9a0SAchim Leubner *****************************************************************************/
6873*4e1bc9a0SAchim Leubner osGLOBAL void
tdssRemoveAllDevicelistFromPortcontext(tdsaPortContext_t * PortContext_Ins,agsaRoot_t * agRoot)6874*4e1bc9a0SAchim Leubner tdssRemoveAllDevicelistFromPortcontext(
6875*4e1bc9a0SAchim Leubner                                        tdsaPortContext_t *PortContext_Ins,
6876*4e1bc9a0SAchim Leubner                                        agsaRoot_t        *agRoot
6877*4e1bc9a0SAchim Leubner                                        )
6878*4e1bc9a0SAchim Leubner {
6879*4e1bc9a0SAchim Leubner 
6880*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6881*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6882*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6883*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6884*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
6885*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
6886*4e1bc9a0SAchim Leubner 
6887*4e1bc9a0SAchim Leubner   TI_DBG6(("tdssRemoveAllDevicedataFromPortcontext: start\n"));
6888*4e1bc9a0SAchim Leubner 
6889*4e1bc9a0SAchim Leubner   /*
6890*4e1bc9a0SAchim Leubner     loop through device list and find the matching portcontext. Then invalidate the
6891*4e1bc9a0SAchim Leubner     matching devices
6892*4e1bc9a0SAchim Leubner   */
6893*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
6894*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6895*4e1bc9a0SAchim Leubner   {
6896*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6897*4e1bc9a0SAchim Leubner     if (oneDeviceData == agNULL)
6898*4e1bc9a0SAchim Leubner     {
6899*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssRemoveAllDevicelistFromPortcontext: oneDeviceData is NULL!!!\n"));
6900*4e1bc9a0SAchim Leubner       return;
6901*4e1bc9a0SAchim Leubner     }
6902*4e1bc9a0SAchim Leubner     if (oneDeviceData->tdPortContext == PortContext_Ins)
6903*4e1bc9a0SAchim Leubner     {
6904*4e1bc9a0SAchim Leubner       TI_DBG4(("tdssRemoveAllDevicelistFromPortcontext: pid %d did %d\n", PortContext_Ins->id, oneDeviceData->id));
6905*4e1bc9a0SAchim Leubner       PortContext_Ins->Count--;
6906*4e1bc9a0SAchim Leubner       oneDeviceData->valid = agFALSE;
6907*4e1bc9a0SAchim Leubner     }
6908*4e1bc9a0SAchim Leubner     DeviceListList = DeviceListList->flink;
6909*4e1bc9a0SAchim Leubner   }
6910*4e1bc9a0SAchim Leubner 
6911*4e1bc9a0SAchim Leubner   return;
6912*4e1bc9a0SAchim Leubner }
6913*4e1bc9a0SAchim Leubner 
6914*4e1bc9a0SAchim Leubner 
6915*4e1bc9a0SAchim Leubner #ifdef INITIATOR_DRIVER
6916*4e1bc9a0SAchim Leubner #ifdef TD_DISCOVER
6917*4e1bc9a0SAchim Leubner /*****************************************************************************
6918*4e1bc9a0SAchim Leubner *! \brief tdssNewAddSASToSharedcontext
6919*4e1bc9a0SAchim Leubner *
6920*4e1bc9a0SAchim Leubner *  Purpose:  This function adds a discovered SAS device to a device list of
6921*4e1bc9a0SAchim Leubner *            a shared context. Used only in discovery.
6922*4e1bc9a0SAchim Leubner *
6923*4e1bc9a0SAchim Leubner *  \param   agRoot          Pointer to chip/driver Instance.
6924*4e1bc9a0SAchim Leubner *  \param   onePortContext  Pointer to the target port context
6925*4e1bc9a0SAchim Leubner *  \param   agSASSubID      Pointer to the SAS identification.
6926*4e1bc9a0SAchim Leubner *
6927*4e1bc9a0SAchim Leubner *  \Return:
6928*4e1bc9a0SAchim Leubner *           Pointer to the device data
6929*4e1bc9a0SAchim Leubner *
6930*4e1bc9a0SAchim Leubner *****************************************************************************/
6931*4e1bc9a0SAchim Leubner osGLOBAL tdsaDeviceData_t *
tdssNewAddSASToSharedcontext(agsaRoot_t * agRoot,tdsaPortContext_t * onePortContext,tdsaSASSubID_t * agSASSubID,tdsaDeviceData_t * oneExpDeviceData,bit8 phyID)6932*4e1bc9a0SAchim Leubner tdssNewAddSASToSharedcontext(
6933*4e1bc9a0SAchim Leubner                              agsaRoot_t           *agRoot,
6934*4e1bc9a0SAchim Leubner                              tdsaPortContext_t    *onePortContext,
6935*4e1bc9a0SAchim Leubner                              tdsaSASSubID_t       *agSASSubID,
6936*4e1bc9a0SAchim Leubner                              tdsaDeviceData_t     *oneExpDeviceData,
6937*4e1bc9a0SAchim Leubner                              bit8                 phyID
6938*4e1bc9a0SAchim Leubner                              )
6939*4e1bc9a0SAchim Leubner {
6940*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
6941*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
6942*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6943*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6944*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6945*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6946*4e1bc9a0SAchim Leubner   bit32             new_device = agTRUE;
6947*4e1bc9a0SAchim Leubner 
6948*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssNewAddSASToSharedcontext: start\n"));
6949*4e1bc9a0SAchim Leubner   /*
6950*4e1bc9a0SAchim Leubner     find a right portcontext
6951*4e1bc9a0SAchim Leubner     then, get devicedata from FreeLink in DeviceList
6952*4e1bc9a0SAchim Leubner     then, do pointer operations
6953*4e1bc9a0SAchim Leubner     then, add the devicedata to the portcontext
6954*4e1bc9a0SAchim Leubner   */
6955*4e1bc9a0SAchim Leubner 
6956*4e1bc9a0SAchim Leubner 
6957*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssNewAddSASToSharedcontext: oneportContext ID %d\n", onePortContext->id));
6958*4e1bc9a0SAchim Leubner   /* find a device's existence */
6959*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
6960*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6961*4e1bc9a0SAchim Leubner   {
6962*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6963*4e1bc9a0SAchim Leubner     if (oneDeviceData == agNULL)
6964*4e1bc9a0SAchim Leubner     {
6965*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssNewAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
6966*4e1bc9a0SAchim Leubner       return agNULL;
6967*4e1bc9a0SAchim Leubner     }
6968*4e1bc9a0SAchim Leubner     if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
6969*4e1bc9a0SAchim Leubner         (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
6970*4e1bc9a0SAchim Leubner         (oneDeviceData->tdPortContext == onePortContext)
6971*4e1bc9a0SAchim Leubner         )
6972*4e1bc9a0SAchim Leubner     {
6973*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6974*4e1bc9a0SAchim Leubner       new_device = agFALSE;
6975*4e1bc9a0SAchim Leubner       break;
6976*4e1bc9a0SAchim Leubner     }
6977*4e1bc9a0SAchim Leubner     DeviceListList = DeviceListList->flink;
6978*4e1bc9a0SAchim Leubner   }
6979*4e1bc9a0SAchim Leubner 
6980*4e1bc9a0SAchim Leubner   /* new device */
6981*4e1bc9a0SAchim Leubner   if (new_device == agTRUE)
6982*4e1bc9a0SAchim Leubner   {
6983*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssNewAddSASToSharedcontext: new device\n"));
6984*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6985*4e1bc9a0SAchim Leubner     if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
6986*4e1bc9a0SAchim Leubner     {
6987*4e1bc9a0SAchim Leubner       tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6988*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssNewAddSASToSharedcontext: empty DeviceData FreeLink\n"));
6989*4e1bc9a0SAchim Leubner       return agNULL;
6990*4e1bc9a0SAchim Leubner     }
6991*4e1bc9a0SAchim Leubner 
6992*4e1bc9a0SAchim Leubner     TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
6993*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6994*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
6995*4e1bc9a0SAchim Leubner 
6996*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
6997*4e1bc9a0SAchim Leubner 
6998*4e1bc9a0SAchim Leubner     onePortContext->Count++;
6999*4e1bc9a0SAchim Leubner     oneDeviceData->agRoot = agRoot;
7000*4e1bc9a0SAchim Leubner     /* saving sas address */
7001*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
7002*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
7003*4e1bc9a0SAchim Leubner     oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
7004*4e1bc9a0SAchim Leubner     oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
7005*4e1bc9a0SAchim Leubner     oneDeviceData->tdPortContext = onePortContext;
7006*4e1bc9a0SAchim Leubner     /* handles both SAS target and STP-target, SATA-device */
7007*4e1bc9a0SAchim Leubner     if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
7008*4e1bc9a0SAchim Leubner     {
7009*4e1bc9a0SAchim Leubner       oneDeviceData->DeviceType = TD_SAS_DEVICE;
7010*4e1bc9a0SAchim Leubner     }
7011*4e1bc9a0SAchim Leubner     else
7012*4e1bc9a0SAchim Leubner     {
7013*4e1bc9a0SAchim Leubner       oneDeviceData->DeviceType = TD_SATA_DEVICE;
7014*4e1bc9a0SAchim Leubner     }
7015*4e1bc9a0SAchim Leubner 
7016*4e1bc9a0SAchim Leubner     oneDeviceData->ExpDevice = oneExpDeviceData;
7017*4e1bc9a0SAchim Leubner     /* set phyID only when it has initial value of 0xFF */
7018*4e1bc9a0SAchim Leubner     if (oneDeviceData->phyID == 0xFF)
7019*4e1bc9a0SAchim Leubner     {
7020*4e1bc9a0SAchim Leubner       oneDeviceData->phyID = phyID;
7021*4e1bc9a0SAchim Leubner     }
7022*4e1bc9a0SAchim Leubner #ifdef FDS_DM
7023*4e1bc9a0SAchim Leubner     oneDeviceData->valid = agTRUE;
7024*4e1bc9a0SAchim Leubner #else
7025*4e1bc9a0SAchim Leubner 
7026*4e1bc9a0SAchim Leubner     /* incremental discovery */
7027*4e1bc9a0SAchim Leubner     /* add device to incremental-related link. Report using this link
7028*4e1bc9a0SAchim Leubner        when incremental discovery is done */
7029*4e1bc9a0SAchim Leubner     if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
7030*4e1bc9a0SAchim Leubner     {
7031*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
7032*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7033*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7034*4e1bc9a0SAchim Leubner       oneDeviceData->valid2 = agTRUE;
7035*4e1bc9a0SAchim Leubner     }
7036*4e1bc9a0SAchim Leubner     else
7037*4e1bc9a0SAchim Leubner     {
7038*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
7039*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7040*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7041*4e1bc9a0SAchim Leubner       oneDeviceData->valid = agTRUE;
7042*4e1bc9a0SAchim Leubner     }
7043*4e1bc9a0SAchim Leubner #endif
7044*4e1bc9a0SAchim Leubner     /* add the devicedata to the portcontext */
7045*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7046*4e1bc9a0SAchim Leubner     TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
7047*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7048*4e1bc9a0SAchim Leubner     TI_DBG4(("tdssNewAddSASToSharedcontext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
7049*4e1bc9a0SAchim Leubner     TI_DBG4(("tdssNewAddSASToSharedcontext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
7050*4e1bc9a0SAchim Leubner   }
7051*4e1bc9a0SAchim Leubner   else /* old device */
7052*4e1bc9a0SAchim Leubner   {
7053*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssNewAddSASToSharedcontext: old device\n"));
7054*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
7055*4e1bc9a0SAchim Leubner 
7056*4e1bc9a0SAchim Leubner     oneDeviceData->agRoot = agRoot;
7057*4e1bc9a0SAchim Leubner     /* saving sas address */
7058*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
7059*4e1bc9a0SAchim Leubner     oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
7060*4e1bc9a0SAchim Leubner     oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
7061*4e1bc9a0SAchim Leubner     oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
7062*4e1bc9a0SAchim Leubner     oneDeviceData->tdPortContext = onePortContext;
7063*4e1bc9a0SAchim Leubner     /* handles both SAS target and STP-target, SATA-device */
7064*4e1bc9a0SAchim Leubner     if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
7065*4e1bc9a0SAchim Leubner     {
7066*4e1bc9a0SAchim Leubner       oneDeviceData->DeviceType = TD_SAS_DEVICE;
7067*4e1bc9a0SAchim Leubner     }
7068*4e1bc9a0SAchim Leubner     else
7069*4e1bc9a0SAchim Leubner     {
7070*4e1bc9a0SAchim Leubner       oneDeviceData->DeviceType = TD_SATA_DEVICE;
7071*4e1bc9a0SAchim Leubner     }
7072*4e1bc9a0SAchim Leubner 
7073*4e1bc9a0SAchim Leubner     oneDeviceData->ExpDevice = oneExpDeviceData;
7074*4e1bc9a0SAchim Leubner     /* set phyID only when it has initial value of 0xFF */
7075*4e1bc9a0SAchim Leubner     if (oneDeviceData->phyID == 0xFF)
7076*4e1bc9a0SAchim Leubner     {
7077*4e1bc9a0SAchim Leubner       oneDeviceData->phyID = phyID;
7078*4e1bc9a0SAchim Leubner     }
7079*4e1bc9a0SAchim Leubner 
7080*4e1bc9a0SAchim Leubner #ifdef FDS_DM
7081*4e1bc9a0SAchim Leubner     oneDeviceData->valid = agTRUE;
7082*4e1bc9a0SAchim Leubner #else
7083*4e1bc9a0SAchim Leubner     if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
7084*4e1bc9a0SAchim Leubner     {
7085*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
7086*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7087*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7088*4e1bc9a0SAchim Leubner       oneDeviceData->valid2 = agTRUE;
7089*4e1bc9a0SAchim Leubner     }
7090*4e1bc9a0SAchim Leubner     else
7091*4e1bc9a0SAchim Leubner     {
7092*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
7093*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7094*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7095*4e1bc9a0SAchim Leubner       oneDeviceData->valid = agTRUE;
7096*4e1bc9a0SAchim Leubner     }
7097*4e1bc9a0SAchim Leubner #endif
7098*4e1bc9a0SAchim Leubner     TI_DBG4(("tdssNewAddSASToSharedcontext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
7099*4e1bc9a0SAchim Leubner 
7100*4e1bc9a0SAchim Leubner   }
7101*4e1bc9a0SAchim Leubner   return oneDeviceData;
7102*4e1bc9a0SAchim Leubner }
7103*4e1bc9a0SAchim Leubner 
7104*4e1bc9a0SAchim Leubner /*****************************************************************************
7105*4e1bc9a0SAchim Leubner *! \brief tdsaFindRegNValid
7106*4e1bc9a0SAchim Leubner *
7107*4e1bc9a0SAchim Leubner *  Purpose:  This function finds a device which is registered and valid in
7108*4e1bc9a0SAchim Leubner *            the device list. Used only in incremental discovery.
7109*4e1bc9a0SAchim Leubner *
7110*4e1bc9a0SAchim Leubner *  \param   agRoot          Pointer to chip/driver Instance.
7111*4e1bc9a0SAchim Leubner *  \param   onePortContext  Pointer to the target port context
7112*4e1bc9a0SAchim Leubner *  \param   tdsaDeviceData  Pointer to a device list header
7113*4e1bc9a0SAchim Leubner *  \param   agSASSubID      Pointer to the SAS identification.
7114*4e1bc9a0SAchim Leubner *
7115*4e1bc9a0SAchim Leubner *  \Return:
7116*4e1bc9a0SAchim Leubner *           Pointer to the device data
7117*4e1bc9a0SAchim Leubner *
7118*4e1bc9a0SAchim Leubner *****************************************************************************/
7119*4e1bc9a0SAchim Leubner osGLOBAL tdsaDeviceData_t *
tdsaFindRegNValid(agsaRoot_t * agRoot,tdsaPortContext_t * onePortContext,tdsaSASSubID_t * agSASSubID)7120*4e1bc9a0SAchim Leubner tdsaFindRegNValid(
7121*4e1bc9a0SAchim Leubner                   agsaRoot_t           *agRoot,
7122*4e1bc9a0SAchim Leubner                   tdsaPortContext_t    *onePortContext,
7123*4e1bc9a0SAchim Leubner                   tdsaSASSubID_t       *agSASSubID
7124*4e1bc9a0SAchim Leubner                   )
7125*4e1bc9a0SAchim Leubner {
7126*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
7127*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
7128*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7129*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7130*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
7131*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
7132*4e1bc9a0SAchim Leubner   bit32             found = agFALSE;
7133*4e1bc9a0SAchim Leubner 
7134*4e1bc9a0SAchim Leubner   TI_DBG3(("tdsaFindRegNValid: start\n"));
7135*4e1bc9a0SAchim Leubner 
7136*4e1bc9a0SAchim Leubner   /* find a device's existence */
7137*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
7138*4e1bc9a0SAchim Leubner   if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_FULL_START)
7139*4e1bc9a0SAchim Leubner   {
7140*4e1bc9a0SAchim Leubner     TI_DBG3(("tdsaFindRegNValid: Full discovery\n"));
7141*4e1bc9a0SAchim Leubner     while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7142*4e1bc9a0SAchim Leubner     {
7143*4e1bc9a0SAchim Leubner       oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7144*4e1bc9a0SAchim Leubner       if (oneDeviceData == agNULL)
7145*4e1bc9a0SAchim Leubner       {
7146*4e1bc9a0SAchim Leubner         TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
7147*4e1bc9a0SAchim Leubner         return agNULL;
7148*4e1bc9a0SAchim Leubner       }
7149*4e1bc9a0SAchim Leubner       if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7150*4e1bc9a0SAchim Leubner           (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7151*4e1bc9a0SAchim Leubner           (oneDeviceData->registered == agTRUE) &&
7152*4e1bc9a0SAchim Leubner           (oneDeviceData->valid == agTRUE) &&
7153*4e1bc9a0SAchim Leubner           (oneDeviceData->tdPortContext == onePortContext)
7154*4e1bc9a0SAchim Leubner           )
7155*4e1bc9a0SAchim Leubner       {
7156*4e1bc9a0SAchim Leubner         TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7157*4e1bc9a0SAchim Leubner         TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7158*4e1bc9a0SAchim Leubner         TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7159*4e1bc9a0SAchim Leubner         found = agTRUE;
7160*4e1bc9a0SAchim Leubner         break;
7161*4e1bc9a0SAchim Leubner       }
7162*4e1bc9a0SAchim Leubner       DeviceListList = DeviceListList->flink;
7163*4e1bc9a0SAchim Leubner     }
7164*4e1bc9a0SAchim Leubner   }
7165*4e1bc9a0SAchim Leubner   else
7166*4e1bc9a0SAchim Leubner   {
7167*4e1bc9a0SAchim Leubner     /* incremental discovery */
7168*4e1bc9a0SAchim Leubner     TI_DBG3(("tdsaFindRegNValid: Incremental discovery\n"));
7169*4e1bc9a0SAchim Leubner     while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7170*4e1bc9a0SAchim Leubner     {
7171*4e1bc9a0SAchim Leubner       oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7172*4e1bc9a0SAchim Leubner       if (oneDeviceData == agNULL)
7173*4e1bc9a0SAchim Leubner       {
7174*4e1bc9a0SAchim Leubner         TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
7175*4e1bc9a0SAchim Leubner         return agNULL;
7176*4e1bc9a0SAchim Leubner       }
7177*4e1bc9a0SAchim Leubner       if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7178*4e1bc9a0SAchim Leubner           (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7179*4e1bc9a0SAchim Leubner           (oneDeviceData->registered == agTRUE) &&
7180*4e1bc9a0SAchim Leubner           (oneDeviceData->valid2 == agTRUE) &&
7181*4e1bc9a0SAchim Leubner           (oneDeviceData->tdPortContext == onePortContext)
7182*4e1bc9a0SAchim Leubner           )
7183*4e1bc9a0SAchim Leubner       {
7184*4e1bc9a0SAchim Leubner         TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7185*4e1bc9a0SAchim Leubner         TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7186*4e1bc9a0SAchim Leubner         TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7187*4e1bc9a0SAchim Leubner         found = agTRUE;
7188*4e1bc9a0SAchim Leubner         break;
7189*4e1bc9a0SAchim Leubner       }
7190*4e1bc9a0SAchim Leubner       DeviceListList = DeviceListList->flink;
7191*4e1bc9a0SAchim Leubner     }
7192*4e1bc9a0SAchim Leubner   }
7193*4e1bc9a0SAchim Leubner 
7194*4e1bc9a0SAchim Leubner 
7195*4e1bc9a0SAchim Leubner 
7196*4e1bc9a0SAchim Leubner   if (found == agFALSE)
7197*4e1bc9a0SAchim Leubner   {
7198*4e1bc9a0SAchim Leubner     TI_DBG3(("tdsaFindRegNValid: end returning NULL\n"));
7199*4e1bc9a0SAchim Leubner     return agNULL;
7200*4e1bc9a0SAchim Leubner   }
7201*4e1bc9a0SAchim Leubner   else
7202*4e1bc9a0SAchim Leubner   {
7203*4e1bc9a0SAchim Leubner     TI_DBG3(("tdsaFindRegNValid: end returning NOT NULL\n"));
7204*4e1bc9a0SAchim Leubner     return oneDeviceData;
7205*4e1bc9a0SAchim Leubner   }
7206*4e1bc9a0SAchim Leubner 
7207*4e1bc9a0SAchim Leubner }
7208*4e1bc9a0SAchim Leubner 
7209*4e1bc9a0SAchim Leubner //registered to LL or not
7210*4e1bc9a0SAchim Leubner /*****************************************************************************
7211*4e1bc9a0SAchim Leubner *! \brief tdssNewSASorNot
7212*4e1bc9a0SAchim Leubner *
7213*4e1bc9a0SAchim Leubner *  Purpose:  This function finds whether a device is registered or not
7214*4e1bc9a0SAchim Leubner *
7215*4e1bc9a0SAchim Leubner *  \param   agRoot          Pointer to chip/driver Instance.
7216*4e1bc9a0SAchim Leubner *  \param   onePortContext  Pointer to the target port context
7217*4e1bc9a0SAchim Leubner *  \param   agSASSubID      Pointer to the SAS identification.
7218*4e1bc9a0SAchim Leubner *
7219*4e1bc9a0SAchim Leubner *  \Return:
7220*4e1bc9a0SAchim Leubner *           agTRUE   Device is not registered (New device).
7221*4e1bc9a0SAchim Leubner *           agFALSE  Device is registered (Old device).
7222*4e1bc9a0SAchim Leubner *
7223*4e1bc9a0SAchim Leubner *****************************************************************************/
7224*4e1bc9a0SAchim Leubner bit32
tdssNewSASorNot(agsaRoot_t * agRoot,tdsaPortContext_t * onePortContext,tdsaSASSubID_t * agSASSubID)7225*4e1bc9a0SAchim Leubner tdssNewSASorNot(
7226*4e1bc9a0SAchim Leubner                                  agsaRoot_t           *agRoot,
7227*4e1bc9a0SAchim Leubner                                  tdsaPortContext_t    *onePortContext,
7228*4e1bc9a0SAchim Leubner                                  tdsaSASSubID_t       *agSASSubID
7229*4e1bc9a0SAchim Leubner                                  )
7230*4e1bc9a0SAchim Leubner {
7231*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
7232*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
7233*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7234*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7235*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
7236*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
7237*4e1bc9a0SAchim Leubner   bit32             ret = agTRUE;
7238*4e1bc9a0SAchim Leubner 
7239*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssNewSASorNot: start\n"));
7240*4e1bc9a0SAchim Leubner 
7241*4e1bc9a0SAchim Leubner   /* find a device's existence */
7242*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
7243*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7244*4e1bc9a0SAchim Leubner   {
7245*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7246*4e1bc9a0SAchim Leubner     if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7247*4e1bc9a0SAchim Leubner         (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7248*4e1bc9a0SAchim Leubner         (oneDeviceData->registered == agTRUE) &&
7249*4e1bc9a0SAchim Leubner         (oneDeviceData->tdPortContext == onePortContext)
7250*4e1bc9a0SAchim Leubner         )
7251*4e1bc9a0SAchim Leubner     {
7252*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssNewSASorNot: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7253*4e1bc9a0SAchim Leubner       ret = agFALSE;
7254*4e1bc9a0SAchim Leubner       break;
7255*4e1bc9a0SAchim Leubner     }
7256*4e1bc9a0SAchim Leubner     DeviceListList = DeviceListList->flink;
7257*4e1bc9a0SAchim Leubner   }
7258*4e1bc9a0SAchim Leubner 
7259*4e1bc9a0SAchim Leubner 
7260*4e1bc9a0SAchim Leubner 
7261*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssNewSASorNot: end\n"));
7262*4e1bc9a0SAchim Leubner 
7263*4e1bc9a0SAchim Leubner   return ret;
7264*4e1bc9a0SAchim Leubner }
7265*4e1bc9a0SAchim Leubner 
7266*4e1bc9a0SAchim Leubner 
7267*4e1bc9a0SAchim Leubner 
7268*4e1bc9a0SAchim Leubner /*****************************************************************************
7269*4e1bc9a0SAchim Leubner *! \brief  tdssSASDiscoveringExpanderAlloc
7270*4e1bc9a0SAchim Leubner *
7271*4e1bc9a0SAchim Leubner *  Purpose:  This function allocates an expander from the pre-allocated memory
7272*4e1bc9a0SAchim Leubner *            pool.
7273*4e1bc9a0SAchim Leubner *
7274*4e1bc9a0SAchim Leubner *  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7275*4e1bc9a0SAchim Leubner *                   instance.
7276*4e1bc9a0SAchim Leubner *  \param   onePortContext: Pointer to the portal context instance.
7277*4e1bc9a0SAchim Leubner *  \param   oneDeviceData:  Pointer to the device data.
7278*4e1bc9a0SAchim Leubner *
7279*4e1bc9a0SAchim Leubner *  \return:
7280*4e1bc9a0SAchim Leubner *           Pointer to expander on success
7281*4e1bc9a0SAchim Leubner *           agNULL              on failure
7282*4e1bc9a0SAchim Leubner *
7283*4e1bc9a0SAchim Leubner *   \note:
7284*4e1bc9a0SAchim Leubner *
7285*4e1bc9a0SAchim Leubner *****************************************************************************/
7286*4e1bc9a0SAchim Leubner osGLOBAL tdsaExpander_t *
tdssSASDiscoveringExpanderAlloc(tiRoot_t * tiRoot,tdsaPortContext_t * onePortContext,tdsaDeviceData_t * oneDeviceData)7287*4e1bc9a0SAchim Leubner tdssSASDiscoveringExpanderAlloc(
7288*4e1bc9a0SAchim Leubner                                 tiRoot_t                 *tiRoot,
7289*4e1bc9a0SAchim Leubner                                 tdsaPortContext_t        *onePortContext,
7290*4e1bc9a0SAchim Leubner                                 tdsaDeviceData_t         *oneDeviceData
7291*4e1bc9a0SAchim Leubner                                 )
7292*4e1bc9a0SAchim Leubner {
7293*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7294*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared   = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7295*4e1bc9a0SAchim Leubner   tdsaExpander_t    *oneExpander = agNULL;
7296*4e1bc9a0SAchim Leubner   tdList_t          *ExpanderList;
7297*4e1bc9a0SAchim Leubner 
7298*4e1bc9a0SAchim Leubner   /*
7299*4e1bc9a0SAchim Leubner     move the expander from freeExpanderList
7300*4e1bc9a0SAchim Leubner     and ground the expander by TDLIST_DEQUEUE_THIS
7301*4e1bc9a0SAchim Leubner   */
7302*4e1bc9a0SAchim Leubner 
7303*4e1bc9a0SAchim Leubner 
7304*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAlloc: start\n"));
7305*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAlloc: did %d\n", oneDeviceData->id));
7306*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7307*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7308*4e1bc9a0SAchim Leubner 
7309*4e1bc9a0SAchim Leubner   if (onePortContext->valid == agFALSE)
7310*4e1bc9a0SAchim Leubner   {
7311*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssSASDiscoveringExpanderAlloc: aborting discovery\n"));
7312*4e1bc9a0SAchim Leubner     tdsaSASDiscoverAbort(tiRoot, onePortContext);
7313*4e1bc9a0SAchim Leubner     return agNULL;
7314*4e1bc9a0SAchim Leubner   }
7315*4e1bc9a0SAchim Leubner 
7316*4e1bc9a0SAchim Leubner   tdsaDumpAllFreeExp(tiRoot);
7317*4e1bc9a0SAchim Leubner 
7318*4e1bc9a0SAchim Leubner   if (TDLIST_EMPTY(&(tdsaAllShared->freeExpanderList)))
7319*4e1bc9a0SAchim Leubner   {
7320*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssSASDiscoveringExpanderAlloc: no free expanders\n"));
7321*4e1bc9a0SAchim Leubner     return agNULL;
7322*4e1bc9a0SAchim Leubner   }
7323*4e1bc9a0SAchim Leubner 
7324*4e1bc9a0SAchim Leubner   tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7325*4e1bc9a0SAchim Leubner   TDLIST_DEQUEUE_FROM_HEAD(&ExpanderList, &(tdsaAllShared->freeExpanderList));
7326*4e1bc9a0SAchim Leubner   tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7327*4e1bc9a0SAchim Leubner   //  oneExpander = TDLIST_OBJECT_BASE(tdsaContext_t, freeExpanderList, ExpanderList);
7328*4e1bc9a0SAchim Leubner   oneExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7329*4e1bc9a0SAchim Leubner 
7330*4e1bc9a0SAchim Leubner   if (oneExpander != agNULL)
7331*4e1bc9a0SAchim Leubner   {
7332*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderAlloc: expander id %d\n", oneExpander->id));
7333*4e1bc9a0SAchim Leubner 
7334*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7335*4e1bc9a0SAchim Leubner     TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
7336*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7337*4e1bc9a0SAchim Leubner 
7338*4e1bc9a0SAchim Leubner     oneExpander->tdDevice = oneDeviceData;
7339*4e1bc9a0SAchim Leubner     oneExpander->tdUpStreamExpander = agNULL;
7340*4e1bc9a0SAchim Leubner     oneExpander->tdCurrentDownStreamExpander = agNULL;
7341*4e1bc9a0SAchim Leubner     oneExpander->tdReturnginExpander = agNULL;
7342*4e1bc9a0SAchim Leubner     oneExpander->hasUpStreamDevice = agFALSE;
7343*4e1bc9a0SAchim Leubner     oneExpander->numOfUpStreamPhys = 0;
7344*4e1bc9a0SAchim Leubner     oneExpander->currentUpStreamPhyIndex = 0;
7345*4e1bc9a0SAchim Leubner     oneExpander->discoveringPhyId = 0;
7346*4e1bc9a0SAchim Leubner     oneExpander->underDiscovering = agFALSE;
7347*4e1bc9a0SAchim Leubner     osti_memset( &(oneExpander->currentIndex), 0, sizeof(oneExpander->currentIndex));
7348*4e1bc9a0SAchim Leubner 
7349*4e1bc9a0SAchim Leubner     oneDeviceData->tdExpander = oneExpander;
7350*4e1bc9a0SAchim Leubner   }
7351*4e1bc9a0SAchim Leubner 
7352*4e1bc9a0SAchim Leubner   return oneExpander;
7353*4e1bc9a0SAchim Leubner }
7354*4e1bc9a0SAchim Leubner 
7355*4e1bc9a0SAchim Leubner /*****************************************************************************
7356*4e1bc9a0SAchim Leubner *! \brief  tdssSASDiscoveringExpanderAdd
7357*4e1bc9a0SAchim Leubner *
7358*4e1bc9a0SAchim Leubner *  Purpose:  This function adds an expander to the expander list.
7359*4e1bc9a0SAchim Leubner *
7360*4e1bc9a0SAchim Leubner *  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7361*4e1bc9a0SAchim Leubner *                   instance.
7362*4e1bc9a0SAchim Leubner *  \param   onePortContext: Pointer to the portal context instance.
7363*4e1bc9a0SAchim Leubner *  \param   oneExpander: Pointer to the expander data.
7364*4e1bc9a0SAchim Leubner *
7365*4e1bc9a0SAchim Leubner *  \return:
7366*4e1bc9a0SAchim Leubner *           None
7367*4e1bc9a0SAchim Leubner *
7368*4e1bc9a0SAchim Leubner *   \note:
7369*4e1bc9a0SAchim Leubner *
7370*4e1bc9a0SAchim Leubner *****************************************************************************/
7371*4e1bc9a0SAchim Leubner osGLOBAL void
tdssSASDiscoveringExpanderAdd(tiRoot_t * tiRoot,tdsaPortContext_t * onePortContext,tdsaExpander_t * oneExpander)7372*4e1bc9a0SAchim Leubner tdssSASDiscoveringExpanderAdd(
7373*4e1bc9a0SAchim Leubner                               tiRoot_t                 *tiRoot,
7374*4e1bc9a0SAchim Leubner                               tdsaPortContext_t        *onePortContext,
7375*4e1bc9a0SAchim Leubner                               tdsaExpander_t           *oneExpander
7376*4e1bc9a0SAchim Leubner                               )
7377*4e1bc9a0SAchim Leubner {
7378*4e1bc9a0SAchim Leubner #ifdef TD_INTERNAL_DEBUG
7379*4e1bc9a0SAchim Leubner   tdList_t          *ExpanderList;
7380*4e1bc9a0SAchim Leubner   tdsaExpander_t    *tempExpander;
7381*4e1bc9a0SAchim Leubner #endif
7382*4e1bc9a0SAchim Leubner 
7383*4e1bc9a0SAchim Leubner   /* move the expander to discoveringExpanderList */
7384*4e1bc9a0SAchim Leubner 
7385*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAdd: start\n"));
7386*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", oneExpander->id));
7387*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7388*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7389*4e1bc9a0SAchim Leubner 
7390*4e1bc9a0SAchim Leubner   if (onePortContext->valid == agFALSE)
7391*4e1bc9a0SAchim Leubner   {
7392*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssSASDiscoveringExpanderAdd: aborting discovery\n"));
7393*4e1bc9a0SAchim Leubner     tdsaSASDiscoverAbort(tiRoot, onePortContext);
7394*4e1bc9a0SAchim Leubner     return;
7395*4e1bc9a0SAchim Leubner   }
7396*4e1bc9a0SAchim Leubner 
7397*4e1bc9a0SAchim Leubner 
7398*4e1bc9a0SAchim Leubner   if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
7399*4e1bc9a0SAchim Leubner   {
7400*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderAdd: UPSTREAM\n"));
7401*4e1bc9a0SAchim Leubner   }
7402*4e1bc9a0SAchim Leubner   else if (onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
7403*4e1bc9a0SAchim Leubner   {
7404*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderAdd: DOWNSTREAM\n"));
7405*4e1bc9a0SAchim Leubner   }
7406*4e1bc9a0SAchim Leubner   else
7407*4e1bc9a0SAchim Leubner   {
7408*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderAdd: status %d\n", onePortContext->discovery.status));
7409*4e1bc9a0SAchim Leubner   }
7410*4e1bc9a0SAchim Leubner 
7411*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAdd: BEFORE\n"));
7412*4e1bc9a0SAchim Leubner   tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7413*4e1bc9a0SAchim Leubner 
7414*4e1bc9a0SAchim Leubner 
7415*4e1bc9a0SAchim Leubner   if ( oneExpander->underDiscovering == agFALSE)
7416*4e1bc9a0SAchim Leubner   {
7417*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderAdd: ADDED \n"));
7418*4e1bc9a0SAchim Leubner 
7419*4e1bc9a0SAchim Leubner     oneExpander->underDiscovering = agTRUE;
7420*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7421*4e1bc9a0SAchim Leubner     TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(onePortContext->discovery.discoveringExpanderList));
7422*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7423*4e1bc9a0SAchim Leubner   }
7424*4e1bc9a0SAchim Leubner 
7425*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderAdd: AFTER\n"));
7426*4e1bc9a0SAchim Leubner   tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7427*4e1bc9a0SAchim Leubner 
7428*4e1bc9a0SAchim Leubner #ifdef TD_INTERNAL_DEBUG
7429*4e1bc9a0SAchim Leubner   /* debugging */
7430*4e1bc9a0SAchim Leubner   if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7431*4e1bc9a0SAchim Leubner   {
7432*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderAdd: empty discoveringExpanderList\n"));
7433*4e1bc9a0SAchim Leubner     return;
7434*4e1bc9a0SAchim Leubner   }
7435*4e1bc9a0SAchim Leubner   ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7436*4e1bc9a0SAchim Leubner   while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7437*4e1bc9a0SAchim Leubner   {
7438*4e1bc9a0SAchim Leubner     tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7439*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", tempExpander->id));
7440*4e1bc9a0SAchim Leubner     ExpanderList = ExpanderList->flink;
7441*4e1bc9a0SAchim Leubner   }
7442*4e1bc9a0SAchim Leubner #endif
7443*4e1bc9a0SAchim Leubner 
7444*4e1bc9a0SAchim Leubner   return;
7445*4e1bc9a0SAchim Leubner }
7446*4e1bc9a0SAchim Leubner 
7447*4e1bc9a0SAchim Leubner /* temp */
7448*4e1bc9a0SAchim Leubner osGLOBAL bit32
tdssSASFindDiscoveringExpander(tiRoot_t * tiRoot,tdsaPortContext_t * onePortContext,tdsaExpander_t * oneExpander)7449*4e1bc9a0SAchim Leubner tdssSASFindDiscoveringExpander(
7450*4e1bc9a0SAchim Leubner                tiRoot_t                 *tiRoot,
7451*4e1bc9a0SAchim Leubner                tdsaPortContext_t        *onePortContext,
7452*4e1bc9a0SAchim Leubner                tdsaExpander_t           *oneExpander
7453*4e1bc9a0SAchim Leubner               )
7454*4e1bc9a0SAchim Leubner {
7455*4e1bc9a0SAchim Leubner   tdList_t          *ExpanderList;
7456*4e1bc9a0SAchim Leubner   tdsaExpander_t    *tempExpander;
7457*4e1bc9a0SAchim Leubner   tdsaPortContext_t *tmpOnePortContext = onePortContext;
7458*4e1bc9a0SAchim Leubner   bit32             ret = agFALSE;
7459*4e1bc9a0SAchim Leubner 
7460*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7461*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7462*4e1bc9a0SAchim Leubner 
7463*4e1bc9a0SAchim Leubner   if (TDLIST_EMPTY(&(tmpOnePortContext->discovery.discoveringExpanderList)))
7464*4e1bc9a0SAchim Leubner   {
7465*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssSASFindDiscoveringExpander: empty discoveringExpanderList\n"));
7466*4e1bc9a0SAchim Leubner     return ret;
7467*4e1bc9a0SAchim Leubner   }
7468*4e1bc9a0SAchim Leubner   ExpanderList = tmpOnePortContext->discovery.discoveringExpanderList.flink;
7469*4e1bc9a0SAchim Leubner   while (ExpanderList != &(tmpOnePortContext->discovery.discoveringExpanderList))
7470*4e1bc9a0SAchim Leubner   {
7471*4e1bc9a0SAchim Leubner     tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7472*4e1bc9a0SAchim Leubner     if (tempExpander == oneExpander)
7473*4e1bc9a0SAchim Leubner     {
7474*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssSASFindDiscoveringExpander: match!!! expander id %d\n", tempExpander->id));
7475*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressHi));
7476*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressLo));
7477*4e1bc9a0SAchim Leubner       ret = agTRUE;
7478*4e1bc9a0SAchim Leubner       break;
7479*4e1bc9a0SAchim Leubner     }
7480*4e1bc9a0SAchim Leubner 
7481*4e1bc9a0SAchim Leubner     ExpanderList = ExpanderList->flink;
7482*4e1bc9a0SAchim Leubner   }
7483*4e1bc9a0SAchim Leubner 
7484*4e1bc9a0SAchim Leubner 
7485*4e1bc9a0SAchim Leubner   return ret;
7486*4e1bc9a0SAchim Leubner 
7487*4e1bc9a0SAchim Leubner }
7488*4e1bc9a0SAchim Leubner /* to be tested */
7489*4e1bc9a0SAchim Leubner /* move the expander to freeExpanderList */
7490*4e1bc9a0SAchim Leubner /*****************************************************************************
7491*4e1bc9a0SAchim Leubner *! \brief  tdssSASDiscoveringExpanderRemove
7492*4e1bc9a0SAchim Leubner *
7493*4e1bc9a0SAchim Leubner *  Purpose:  This function removes an expander from the expander list.
7494*4e1bc9a0SAchim Leubner *
7495*4e1bc9a0SAchim Leubner *  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7496*4e1bc9a0SAchim Leubner *                   instance.
7497*4e1bc9a0SAchim Leubner *  \param   onePortContext: Pointer to the portal context instance.
7498*4e1bc9a0SAchim Leubner *  \param   oneExpander: Pointer to the expander data.
7499*4e1bc9a0SAchim Leubner *
7500*4e1bc9a0SAchim Leubner *  \return:
7501*4e1bc9a0SAchim Leubner *           None
7502*4e1bc9a0SAchim Leubner *
7503*4e1bc9a0SAchim Leubner *   \note:
7504*4e1bc9a0SAchim Leubner *
7505*4e1bc9a0SAchim Leubner *****************************************************************************/
7506*4e1bc9a0SAchim Leubner osGLOBAL void
tdssSASDiscoveringExpanderRemove(tiRoot_t * tiRoot,tdsaPortContext_t * onePortContext,tdsaExpander_t * oneExpander)7507*4e1bc9a0SAchim Leubner tdssSASDiscoveringExpanderRemove(
7508*4e1bc9a0SAchim Leubner                                  tiRoot_t                 *tiRoot,
7509*4e1bc9a0SAchim Leubner                                  tdsaPortContext_t        *onePortContext,
7510*4e1bc9a0SAchim Leubner                                  tdsaExpander_t           *oneExpander
7511*4e1bc9a0SAchim Leubner                                  )
7512*4e1bc9a0SAchim Leubner {
7513*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7514*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared   = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7515*4e1bc9a0SAchim Leubner #ifdef TD_INTERNAL_DEBUG
7516*4e1bc9a0SAchim Leubner   tdList_t          *ExpanderList;
7517*4e1bc9a0SAchim Leubner   tdsaExpander_t    *tempExpander;
7518*4e1bc9a0SAchim Leubner #endif
7519*4e1bc9a0SAchim Leubner 
7520*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: start\n"));
7521*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", oneExpander->id));
7522*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7523*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7524*4e1bc9a0SAchim Leubner 
7525*4e1bc9a0SAchim Leubner 
7526*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
7527*4e1bc9a0SAchim Leubner   tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7528*4e1bc9a0SAchim Leubner   tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
7529*4e1bc9a0SAchim Leubner   tdsaDumpAllFreeExp(tiRoot);
7530*4e1bc9a0SAchim Leubner 
7531*4e1bc9a0SAchim Leubner #ifdef TD_INTERNAL_DEBUG
7532*4e1bc9a0SAchim Leubner   /* debugging */
7533*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
7534*4e1bc9a0SAchim Leubner   if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7535*4e1bc9a0SAchim Leubner   {
7536*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
7537*4e1bc9a0SAchim Leubner   }
7538*4e1bc9a0SAchim Leubner   ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7539*4e1bc9a0SAchim Leubner   while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7540*4e1bc9a0SAchim Leubner   {
7541*4e1bc9a0SAchim Leubner     tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7542*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
7543*4e1bc9a0SAchim Leubner     ExpanderList = ExpanderList->flink;
7544*4e1bc9a0SAchim Leubner   }
7545*4e1bc9a0SAchim Leubner #endif
7546*4e1bc9a0SAchim Leubner 
7547*4e1bc9a0SAchim Leubner   // if is temporary till smp problem is fixed
7548*4e1bc9a0SAchim Leubner   if (tdssSASFindDiscoveringExpander(tiRoot, onePortContext, oneExpander) == agTRUE)
7549*4e1bc9a0SAchim Leubner   {
7550*4e1bc9a0SAchim Leubner     oneExpander->underDiscovering = agFALSE;
7551*4e1bc9a0SAchim Leubner     oneExpander->discoveringPhyId = 0;
7552*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7553*4e1bc9a0SAchim Leubner     TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
7554*4e1bc9a0SAchim Leubner 
7555*4e1bc9a0SAchim Leubner     if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
7556*4e1bc9a0SAchim Leubner     {
7557*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssSASDiscoveringExpanderRemove: DISCOVERY_UP_STREAM\n"));
7558*4e1bc9a0SAchim Leubner       TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->upNode), &(onePortContext->discovery.UpdiscoveringExpanderList));
7559*4e1bc9a0SAchim Leubner       onePortContext->discovery.NumOfUpExp++;
7560*4e1bc9a0SAchim Leubner     }
7561*4e1bc9a0SAchim Leubner     else
7562*4e1bc9a0SAchim Leubner     {
7563*4e1bc9a0SAchim Leubner       TI_DBG3(("tdssSASDiscoveringExpanderRemove: Status %d\n", onePortContext->discovery.status));
7564*4e1bc9a0SAchim Leubner       TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(tdsaAllShared->freeExpanderList));
7565*4e1bc9a0SAchim Leubner     }
7566*4e1bc9a0SAchim Leubner 
7567*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7568*4e1bc9a0SAchim Leubner   } //end temp if
7569*4e1bc9a0SAchim Leubner   else
7570*4e1bc9a0SAchim Leubner   {
7571*4e1bc9a0SAchim Leubner     TI_DBG1(("tdssSASDiscoveringExpanderRemove: !!! problem !!!\n"));
7572*4e1bc9a0SAchim Leubner   }
7573*4e1bc9a0SAchim Leubner 
7574*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
7575*4e1bc9a0SAchim Leubner   tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7576*4e1bc9a0SAchim Leubner   tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
7577*4e1bc9a0SAchim Leubner 
7578*4e1bc9a0SAchim Leubner   tdsaDumpAllFreeExp(tiRoot);
7579*4e1bc9a0SAchim Leubner 
7580*4e1bc9a0SAchim Leubner #ifdef TD_INTERNAL_DEBUG
7581*4e1bc9a0SAchim Leubner   /* debugging */
7582*4e1bc9a0SAchim Leubner   TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
7583*4e1bc9a0SAchim Leubner   if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7584*4e1bc9a0SAchim Leubner   {
7585*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
7586*4e1bc9a0SAchim Leubner   }
7587*4e1bc9a0SAchim Leubner   ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7588*4e1bc9a0SAchim Leubner   while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7589*4e1bc9a0SAchim Leubner   {
7590*4e1bc9a0SAchim Leubner     tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7591*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
7592*4e1bc9a0SAchim Leubner     ExpanderList = ExpanderList->flink;
7593*4e1bc9a0SAchim Leubner   }
7594*4e1bc9a0SAchim Leubner #endif
7595*4e1bc9a0SAchim Leubner 
7596*4e1bc9a0SAchim Leubner   return;
7597*4e1bc9a0SAchim Leubner }
7598*4e1bc9a0SAchim Leubner 
7599*4e1bc9a0SAchim Leubner #ifdef SATA_ENABLE
7600*4e1bc9a0SAchim Leubner 
7601*4e1bc9a0SAchim Leubner /*****************************************************************************
7602*4e1bc9a0SAchim Leubner *! \brief tdssNewAddSATAToSharedcontext
7603*4e1bc9a0SAchim Leubner *
7604*4e1bc9a0SAchim Leubner *  Purpose:  This function adds a discovered SATA device to a device list of
7605*4e1bc9a0SAchim Leubner *            a shared context. Used only in discovery.
7606*4e1bc9a0SAchim Leubner *
7607*4e1bc9a0SAchim Leubner *  \param   tiRoot  Pointer to the OS Specific module allocated tiRoot_t
7608*4e1bc9a0SAchim Leubner *                   instance.
7609*4e1bc9a0SAchim Leubner *  \param   agRoot          Pointer to chip/driver Instance.
7610*4e1bc9a0SAchim Leubner *  \param   onePortContext  Pointer to the target port context
7611*4e1bc9a0SAchim Leubner *  \param   tdsaDeviceData  Pointer to a device list header
7612*4e1bc9a0SAchim Leubner *  \param   agSATADeviceInfo      Pointer to the SATA device information.
7613*4e1bc9a0SAchim Leubner *  \param   Signature       Pointer to SATA signature
7614*4e1bc9a0SAchim Leubner *  \param   pm              Port multiplier
7615*4e1bc9a0SAchim Leubner *  \param   pmField         Port multiplier field
7616*4e1bc9a0SAchim Leubner *  \param   connectionRate  Connection rate
7617*4e1bc9a0SAchim Leubner *
7618*4e1bc9a0SAchim Leubner *  \Return:
7619*4e1bc9a0SAchim Leubner *           Pointer to the device data
7620*4e1bc9a0SAchim Leubner *
7621*4e1bc9a0SAchim Leubner *****************************************************************************/
7622*4e1bc9a0SAchim Leubner osGLOBAL tdsaDeviceData_t *
tdssNewAddSATAToSharedcontext(tiRoot_t * tiRoot,agsaRoot_t * agRoot,tdsaPortContext_t * onePortContext,agsaSATADeviceInfo_t * agSATADeviceInfo,bit8 * Signature,bit8 pm,bit8 pmField,bit32 connectionRate,tdsaDeviceData_t * oneExpDeviceData,bit8 phyID)7623*4e1bc9a0SAchim Leubner tdssNewAddSATAToSharedcontext(tiRoot_t             *tiRoot,
7624*4e1bc9a0SAchim Leubner                               agsaRoot_t           *agRoot,
7625*4e1bc9a0SAchim Leubner                               tdsaPortContext_t    *onePortContext,
7626*4e1bc9a0SAchim Leubner                               agsaSATADeviceInfo_t *agSATADeviceInfo,
7627*4e1bc9a0SAchim Leubner                               bit8                    *Signature,
7628*4e1bc9a0SAchim Leubner                               bit8                    pm,
7629*4e1bc9a0SAchim Leubner                               bit8                    pmField,
7630*4e1bc9a0SAchim Leubner                               bit32                   connectionRate,
7631*4e1bc9a0SAchim Leubner                               tdsaDeviceData_t        *oneExpDeviceData,
7632*4e1bc9a0SAchim Leubner                               bit8                    phyID
7633*4e1bc9a0SAchim Leubner                               )
7634*4e1bc9a0SAchim Leubner {
7635*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
7636*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
7637*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7638*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7639*4e1bc9a0SAchim Leubner   int               new_device = agTRUE;
7640*4e1bc9a0SAchim Leubner 
7641*4e1bc9a0SAchim Leubner   TI_DBG5(("tdssNewAddSATAToSharedcontext: start\n"));
7642*4e1bc9a0SAchim Leubner 
7643*4e1bc9a0SAchim Leubner 
7644*4e1bc9a0SAchim Leubner 
7645*4e1bc9a0SAchim Leubner   TI_DBG5(("tdssNewAddSATAToSharedcontext: oneportContext ID %d\n", onePortContext->id));
7646*4e1bc9a0SAchim Leubner 
7647*4e1bc9a0SAchim Leubner 
7648*4e1bc9a0SAchim Leubner #ifdef RPM_SOC
7649*4e1bc9a0SAchim Leubner   /* Find a device's existence */
7650*4e1bc9a0SAchim Leubner   DeviceListList = tdsaAllShared->MainDeviceList.flink;
7651*4e1bc9a0SAchim Leubner   while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7652*4e1bc9a0SAchim Leubner   {
7653*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7654*4e1bc9a0SAchim Leubner 
7655*4e1bc9a0SAchim Leubner     if ((osti_memcmp (((char *)&oneDeviceData->satDevData.satIdentifyData),
7656*4e1bc9a0SAchim Leubner                       ((char *)&agSATADeviceInfo->sataIdentifyData),
7657*4e1bc9a0SAchim Leubner                       sizeof(agsaSATAIdentifyData_t)) == 0))
7658*4e1bc9a0SAchim Leubner     {
7659*4e1bc9a0SAchim Leubner       TI_DBG5(("tdssNewAddSATAToSharedcontext: pid %d did %d\n",
7660*4e1bc9a0SAchim Leubner         onePortContext->id, oneDeviceData->id));
7661*4e1bc9a0SAchim Leubner       new_device = agFALSE;
7662*4e1bc9a0SAchim Leubner       break;
7663*4e1bc9a0SAchim Leubner     }
7664*4e1bc9a0SAchim Leubner     DeviceListList = DeviceListList->flink;
7665*4e1bc9a0SAchim Leubner   }
7666*4e1bc9a0SAchim Leubner #else
7667*4e1bc9a0SAchim Leubner 
7668*4e1bc9a0SAchim Leubner 
7669*4e1bc9a0SAchim Leubner #endif
7670*4e1bc9a0SAchim Leubner 
7671*4e1bc9a0SAchim Leubner   /* New device */
7672*4e1bc9a0SAchim Leubner   if (new_device == agTRUE)
7673*4e1bc9a0SAchim Leubner   {
7674*4e1bc9a0SAchim Leubner     TI_DBG5(("tdssNewAddSATAToSharedcontext: new device\n"));
7675*4e1bc9a0SAchim Leubner 
7676*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7677*4e1bc9a0SAchim Leubner     if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
7678*4e1bc9a0SAchim Leubner     {
7679*4e1bc9a0SAchim Leubner       tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7680*4e1bc9a0SAchim Leubner       TI_DBG1(("tdssNewAddSATAToSharedcontext: ERROR empty DeviceData FreeLink\n"));
7681*4e1bc9a0SAchim Leubner       return oneDeviceData;
7682*4e1bc9a0SAchim Leubner     }
7683*4e1bc9a0SAchim Leubner 
7684*4e1bc9a0SAchim Leubner     TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
7685*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7686*4e1bc9a0SAchim Leubner     oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
7687*4e1bc9a0SAchim Leubner 
7688*4e1bc9a0SAchim Leubner     onePortContext->Count++;
7689*4e1bc9a0SAchim Leubner     oneDeviceData->DeviceType = TD_SATA_DEVICE;
7690*4e1bc9a0SAchim Leubner     oneDeviceData->agRoot = agRoot;
7691*4e1bc9a0SAchim Leubner     TI_DBG5(("tdssNewAddSATAToSharedcontext: oneDeviceData %p\n", oneDeviceData));
7692*4e1bc9a0SAchim Leubner     TI_DBG5(("tdssNewAddSATAToSharedcontext: pSatDevData=%p\n", &oneDeviceData->satDevData));
7693*4e1bc9a0SAchim Leubner 
7694*4e1bc9a0SAchim Leubner 
7695*4e1bc9a0SAchim Leubner     /* saving PortMultiplier(PM) field */
7696*4e1bc9a0SAchim Leubner     oneDeviceData->satDevData.satPMField = pmField;
7697*4e1bc9a0SAchim Leubner 
7698*4e1bc9a0SAchim Leubner     /* saving signature */
7699*4e1bc9a0SAchim Leubner     osti_memcpy(&(oneDeviceData->satDevData.satSignature), Signature, 8);
7700*4e1bc9a0SAchim Leubner 
7701*4e1bc9a0SAchim Leubner     /*
7702*4e1bc9a0SAchim Leubner       saving device type
7703*4e1bc9a0SAchim Leubner       ATA device type; here should be either ATA_ATA_DEVICE or ATA_ATAPI_DEVICE
7704*4e1bc9a0SAchim Leubner     */
7705*4e1bc9a0SAchim Leubner      oneDeviceData->satDevData.satDeviceType = tdssSATADeviceTypeDecode(agSATADeviceInfo->signature);
7706*4e1bc9a0SAchim Leubner      TI_DBG3(("tdssNewAddSATAToSharedcontext: device type %d\n",  oneDeviceData->satDevData.satDeviceType));
7707*4e1bc9a0SAchim Leubner 
7708*4e1bc9a0SAchim Leubner #ifdef RPM_SOC_REMOVED
7709*4e1bc9a0SAchim Leubner     /* print device signature - Word8 */
7710*4e1bc9a0SAchim Leubner     TI_DBG3(("tdssNewAddSATAToSharedcontext: Word8 %x signature: %x %x %x %x %x %x %x %x\n",
7711*4e1bc9a0SAchim Leubner              agSATADeviceInfo->sataIdentifyData.word1_9[7],
7712*4e1bc9a0SAchim Leubner              agSATADeviceInfo->signature[0], agSATADeviceInfo->signature[1],
7713*4e1bc9a0SAchim Leubner              agSATADeviceInfo->signature[2], agSATADeviceInfo->signature[3],
7714*4e1bc9a0SAchim Leubner              agSATADeviceInfo->signature[4], agSATADeviceInfo->signature[5],
7715*4e1bc9a0SAchim Leubner              agSATADeviceInfo->signature[6], agSATADeviceInfo->signature[7] ));
7716*4e1bc9a0SAchim Leubner #endif
7717*4e1bc9a0SAchim Leubner 
7718*4e1bc9a0SAchim Leubner 
7719*4e1bc9a0SAchim Leubner 
7720*4e1bc9a0SAchim Leubner     oneDeviceData->tdPortContext = onePortContext;
7721*4e1bc9a0SAchim Leubner     oneDeviceData->valid = agTRUE;
7722*4e1bc9a0SAchim Leubner 
7723*4e1bc9a0SAchim Leubner     oneDeviceData->ExpDevice = oneExpDeviceData;
7724*4e1bc9a0SAchim Leubner     oneDeviceData->phyID = phyID;
7725*4e1bc9a0SAchim Leubner 
7726*4e1bc9a0SAchim Leubner     /* Add the devicedata to the portcontext */
7727*4e1bc9a0SAchim Leubner     tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7728*4e1bc9a0SAchim Leubner     TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
7729*4e1bc9a0SAchim Leubner     tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7730*4e1bc9a0SAchim Leubner     TI_DBG5(("tdssNewAddSATAToSharedcontext: one case pid %d did %d \n",
7731*4e1bc9a0SAchim Leubner       onePortContext->id, oneDeviceData->id));
7732*4e1bc9a0SAchim Leubner   }
7733*4e1bc9a0SAchim Leubner   else /* old device */
7734*4e1bc9a0SAchim Leubner   {
7735*4e1bc9a0SAchim Leubner     TI_DBG5(("tdssNewAddSATAToSharedcontext: old device\n"));
7736*4e1bc9a0SAchim Leubner 
7737*4e1bc9a0SAchim Leubner     onePortContext->Count++;
7738*4e1bc9a0SAchim Leubner 
7739*4e1bc9a0SAchim Leubner     oneDeviceData->DeviceType = TD_SATA_DEVICE;
7740*4e1bc9a0SAchim Leubner     oneDeviceData->agRoot = agRoot;
7741*4e1bc9a0SAchim Leubner 
7742*4e1bc9a0SAchim Leubner     oneDeviceData->tdPortContext = onePortContext;
7743*4e1bc9a0SAchim Leubner     oneDeviceData->valid = agTRUE;
7744*4e1bc9a0SAchim Leubner 
7745*4e1bc9a0SAchim Leubner     oneDeviceData->ExpDevice = oneExpDeviceData;
7746*4e1bc9a0SAchim Leubner     oneDeviceData->phyID = phyID;
7747*4e1bc9a0SAchim Leubner 
7748*4e1bc9a0SAchim Leubner   }
7749*4e1bc9a0SAchim Leubner 
7750*4e1bc9a0SAchim Leubner   return oneDeviceData;
7751*4e1bc9a0SAchim Leubner 
7752*4e1bc9a0SAchim Leubner }
7753*4e1bc9a0SAchim Leubner #endif /* SATA_ENABLE */
7754*4e1bc9a0SAchim Leubner #endif /* TD_DISCOVER */
7755*4e1bc9a0SAchim Leubner #endif /* INITIATOR_DRIVER */
7756*4e1bc9a0SAchim Leubner 
7757*4e1bc9a0SAchim Leubner #ifdef TARGET_DRIVER
7758*4e1bc9a0SAchim Leubner /*****************************************************************************
7759*4e1bc9a0SAchim Leubner *! \brief  tdssReportRemovals
7760*4e1bc9a0SAchim Leubner *
7761*4e1bc9a0SAchim Leubner *  Purpose:  This function goes through device list and removes all devices
7762*4e1bc9a0SAchim Leubner *            belong to the portcontext. This function also deregiters those
7763*4e1bc9a0SAchim Leubner *            devices. This function is called in case of incremental discovery
7764*4e1bc9a0SAchim Leubner *            failure.
7765*4e1bc9a0SAchim Leubner *
7766*4e1bc9a0SAchim Leubner *  \param   agRoot        :  Pointer to chip/driver Instance.
7767*4e1bc9a0SAchim Leubner *  \param   onePortContext: Pointer to the portal context instance.
7768*4e1bc9a0SAchim Leubner *  \param   oneDeviceData: Pointer to the device data.
7769*4e1bc9a0SAchim Leubner *
7770*4e1bc9a0SAchim Leubner *  \return:
7771*4e1bc9a0SAchim Leubner *           None
7772*4e1bc9a0SAchim Leubner *
7773*4e1bc9a0SAchim Leubner *   \note:
7774*4e1bc9a0SAchim Leubner *
7775*4e1bc9a0SAchim Leubner *****************************************************************************/
7776*4e1bc9a0SAchim Leubner osGLOBAL void
ttdssReportRemovals(agsaRoot_t * agRoot,tdsaPortContext_t * onePortContext,bit32 flag)7777*4e1bc9a0SAchim Leubner ttdssReportRemovals(
7778*4e1bc9a0SAchim Leubner                   agsaRoot_t           *agRoot,
7779*4e1bc9a0SAchim Leubner                   tdsaPortContext_t    *onePortContext,
7780*4e1bc9a0SAchim Leubner                   bit32                flag
7781*4e1bc9a0SAchim Leubner                   )
7782*4e1bc9a0SAchim Leubner {
7783*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *oneDeviceData = agNULL;
7784*4e1bc9a0SAchim Leubner   tdList_t          *DeviceListList;
7785*4e1bc9a0SAchim Leubner   tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
7786*4e1bc9a0SAchim Leubner   tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
7787*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7788*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7789*4e1bc9a0SAchim Leubner   bit32             removed = agFALSE;
7790*4e1bc9a0SAchim Leubner   agsaEventSource_t *eventSource;
7791*4e1bc9a0SAchim Leubner   bit32             PhyID;
7792*4e1bc9a0SAchim Leubner   bit32             HwAckSatus;
7793*4e1bc9a0SAchim Leubner   tdsaDeviceData_t  *tmpDeviceData = agNULL;
7794*4e1bc9a0SAchim Leubner 
7795*4e1bc9a0SAchim Leubner   TI_DBG1(("ttdssReportRemovals: start\n"));
7796*4e1bc9a0SAchim Leubner   /* in case nothing was registered */
7797*4e1bc9a0SAchim Leubner   PhyID = onePortContext->eventPhyID;
7798*4e1bc9a0SAchim Leubner   if (tdsaAllShared->eventSource[PhyID].EventValid == agTRUE &&
7799*4e1bc9a0SAchim Leubner       onePortContext->RegisteredDevNums == 0 &&
7800*4e1bc9a0SAchim Leubner       PhyID != 0xFF
7801*4e1bc9a0SAchim Leubner       )
7802*4e1bc9a0SAchim Leubner   {
7803*4e1bc9a0SAchim Leubner     TI_DBG1(("ttdssReportRemovals: calling saHwEventAck\n"));
7804*4e1bc9a0SAchim Leubner     eventSource = &(tdsaAllShared->eventSource[PhyID].Source);
7805*4e1bc9a0SAchim Leubner     HwAckSatus = saHwEventAck(
7806*4e1bc9a0SAchim Leubner                               agRoot,
7807*4e1bc9a0SAchim Leubner                               agNULL, /* agContext */
7808*4e1bc9a0SAchim Leubner                               0,
7809*4e1bc9a0SAchim Leubner                               eventSource, /* agsaEventSource_t */
7810*4e1bc9a0SAchim Leubner                               0,
7811*4e1bc9a0SAchim Leubner                               0
7812*4e1bc9a0SAchim Leubner                               );
7813*4e1bc9a0SAchim Leubner     if ( HwAckSatus != AGSA_RC_SUCCESS)
7814*4e1bc9a0SAchim Leubner     {
7815*4e1bc9a0SAchim Leubner       TI_DBG1(("ttdssReportRemovals: failing in saHwEventAck; status %d\n", HwAckSatus));
7816*4e1bc9a0SAchim Leubner     }
7817*4e1bc9a0SAchim Leubner 
7818*4e1bc9a0SAchim Leubner     /* toggle */
7819*4e1bc9a0SAchim Leubner     tdsaAllShared->eventSource[PhyID].EventValid = agFALSE;
7820*4e1bc9a0SAchim Leubner     if (onePortContext->valid == agFALSE)
7821*4e1bc9a0SAchim Leubner     {
7822*4e1bc9a0SAchim Leubner       tdsaPortContextReInit(tiRoot, onePortContext);
7823*4e1bc9a0SAchim Leubner       /*
7824*4e1bc9a0SAchim Leubner         put all devices belonging to the onePortContext
7825*4e1bc9a0SAchim Leubner         back to the free link
7826*4e1bc9a0SAchim Leubner        */
7827*4e1bc9a0SAchim Leubner       tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
7828*4e1bc9a0SAchim Leubner       TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
7829*4e1bc9a0SAchim Leubner       TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
7830*4e1bc9a0SAchim Leubner       tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
7831*4e1bc9a0SAchim Leubner     }
7832*4e1bc9a0SAchim Leubner   }
7833*4e1bc9a0SAchim Leubner   else
7834*4e1bc9a0SAchim Leubner   {
7835*4e1bc9a0SAchim Leubner     if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
7836*4e1bc9a0SAchim Leubner     {
7837*4e1bc9a0SAchim Leubner       TI_DBG1(("ttdssReportRemovals: empty device list\n"));
7838*4e1bc9a0SAchim Leubner       return;
7839*4e1bc9a0SAchim Leubner     }
7840*4e1bc9a0SAchim Leubner 
7841*4e1bc9a0SAchim Leubner     DeviceListList = tdsaAllShared->MainDeviceList.flink;
7842*4e1bc9a0SAchim Leubner     while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7843*4e1bc9a0SAchim Leubner     {
7844*4e1bc9a0SAchim Leubner       oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7845*4e1bc9a0SAchim Leubner       if( oneDeviceData == agNULL )
7846*4e1bc9a0SAchim Leubner       {
7847*4e1bc9a0SAchim Leubner         break;
7848*4e1bc9a0SAchim Leubner       }
7849*4e1bc9a0SAchim Leubner       TI_DBG1(("ttdssReportRemovals: loop did %d\n", oneDeviceData->id));
7850*4e1bc9a0SAchim Leubner       TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
7851*4e1bc9a0SAchim Leubner       TI_DBG1(("ttdssReportRemovals: valid %d valid2 %d\n", oneDeviceData->valid, oneDeviceData->valid2));
7852*4e1bc9a0SAchim Leubner       TI_DBG1(("ttdssReportRemovals: directlyAttached %d registered %d\n", oneDeviceData->directlyAttached, oneDeviceData->registered));
7853*4e1bc9a0SAchim Leubner       if ( oneDeviceData->tdPortContext == onePortContext)
7854*4e1bc9a0SAchim Leubner       {
7855*4e1bc9a0SAchim Leubner         TI_DBG1(("ttdssReportRemovals: right portcontext pid %d\n", onePortContext->id));
7856*4e1bc9a0SAchim Leubner         if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE)
7857*4e1bc9a0SAchim Leubner         {
7858*4e1bc9a0SAchim Leubner           TI_DBG1(("ttdssReportRemovals: removing\n"));
7859*4e1bc9a0SAchim Leubner 
7860*4e1bc9a0SAchim Leubner           /* notify only reported devices to OS layer*/
7861*4e1bc9a0SAchim Leubner           removed = agTRUE;
7862*4e1bc9a0SAchim Leubner 
7863*4e1bc9a0SAchim Leubner           /* all targets except expanders */
7864*4e1bc9a0SAchim Leubner           TI_DBG1(("ttdssReportRemovals: calling tdsaAbortAll\n"));
7865*4e1bc9a0SAchim Leubner           TI_DBG1(("ttdssReportRemovals: did %d\n", oneDeviceData->id));
7866*4e1bc9a0SAchim Leubner           TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
7867*4e1bc9a0SAchim Leubner           tmpDeviceData = oneDeviceData;
7868*4e1bc9a0SAchim Leubner           ttdsaAbortAll(tiRoot, agRoot, oneDeviceData);
7869*4e1bc9a0SAchim Leubner 
7870*4e1bc9a0SAchim Leubner 
7871*4e1bc9a0SAchim Leubner           /* reset valid bit */
7872*4e1bc9a0SAchim Leubner           oneDeviceData->valid = agFALSE;
7873*4e1bc9a0SAchim Leubner           oneDeviceData->valid2 = agFALSE;
7874*4e1bc9a0SAchim Leubner           oneDeviceData->registered = agFALSE;
7875*4e1bc9a0SAchim Leubner         }
7876*4e1bc9a0SAchim Leubner         /* called by port invalid case */
7877*4e1bc9a0SAchim Leubner         if (flag == agTRUE)
7878*4e1bc9a0SAchim Leubner         {
7879*4e1bc9a0SAchim Leubner           oneDeviceData->tdPortContext = agNULL;
7880*4e1bc9a0SAchim Leubner         }
7881*4e1bc9a0SAchim Leubner #ifdef REMOVED /* removed */
7882*4e1bc9a0SAchim Leubner         /* directly attached SATA -> always remove it */
7883*4e1bc9a0SAchim Leubner         if (oneDeviceData->DeviceType == TD_SATA_DEVICE &&
7884*4e1bc9a0SAchim Leubner             oneDeviceData->directlyAttached == agTRUE)
7885*4e1bc9a0SAchim Leubner         {
7886*4e1bc9a0SAchim Leubner           TI_DBG1(("ttdssReportRemovals: device did %d\n", oneDeviceData->id));
7887*4e1bc9a0SAchim Leubner           tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7888*4e1bc9a0SAchim Leubner           TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
7889*4e1bc9a0SAchim Leubner           TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceLis));
7890*4e1bc9a0SAchim Leubner           DeviceListList = tdsaAllShared->MainDeviceList.flink;
7891*4e1bc9a0SAchim Leubner           if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
7892*4e1bc9a0SAchim Leubner           {
7893*4e1bc9a0SAchim Leubner             tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7894*4e1bc9a0SAchim Leubner             break;
7895*4e1bc9a0SAchim Leubner           }
7896*4e1bc9a0SAchim Leubner           else
7897*4e1bc9a0SAchim Leubner           {
7898*4e1bc9a0SAchim Leubner             tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7899*4e1bc9a0SAchim Leubner           }
7900*4e1bc9a0SAchim Leubner         }
7901*4e1bc9a0SAchim Leubner         else
7902*4e1bc9a0SAchim Leubner         {
7903*4e1bc9a0SAchim Leubner           DeviceListList = DeviceListList->flink;
7904*4e1bc9a0SAchim Leubner         }
7905*4e1bc9a0SAchim Leubner #endif /* REMOVED */
7906*4e1bc9a0SAchim Leubner         DeviceListList = DeviceListList->flink;
7907*4e1bc9a0SAchim Leubner       }
7908*4e1bc9a0SAchim Leubner       else
7909*4e1bc9a0SAchim Leubner       {
7910*4e1bc9a0SAchim Leubner         if (oneDeviceData->tdPortContext != agNULL)
7911*4e1bc9a0SAchim Leubner         {
7912*4e1bc9a0SAchim Leubner           TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid %d oneportcontext pid %d\n", oneDeviceData->tdPortContext->id, onePortContext->id));
7913*4e1bc9a0SAchim Leubner         }
7914*4e1bc9a0SAchim Leubner         else
7915*4e1bc9a0SAchim Leubner         {
7916*4e1bc9a0SAchim Leubner           TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid NULL oneportcontext pid %d\n", onePortContext->id));
7917*4e1bc9a0SAchim Leubner         }
7918*4e1bc9a0SAchim Leubner         DeviceListList = DeviceListList->flink;
7919*4e1bc9a0SAchim Leubner       }
7920*4e1bc9a0SAchim Leubner     }
7921*4e1bc9a0SAchim Leubner 
7922*4e1bc9a0SAchim Leubner     if (removed == agTRUE)
7923*4e1bc9a0SAchim Leubner     {
7924*4e1bc9a0SAchim Leubner       TI_DBG1(("ttdssReportRemovals: removed at the end\n"));
7925*4e1bc9a0SAchim Leubner       ostiTargetEvent(
7926*4e1bc9a0SAchim Leubner                       tiRoot,
7927*4e1bc9a0SAchim Leubner                       onePortContext->tiPortalContext,
7928*4e1bc9a0SAchim Leubner                       &(tmpDeviceData->tiDeviceHandle),
7929*4e1bc9a0SAchim Leubner                       tiTgtEventTypeDeviceChange,
7930*4e1bc9a0SAchim Leubner                       tiDeviceRemoval,
7931*4e1bc9a0SAchim Leubner                       agNULL
7932*4e1bc9a0SAchim Leubner                       );
7933*4e1bc9a0SAchim Leubner     }
7934*4e1bc9a0SAchim Leubner   } /* big else */
7935*4e1bc9a0SAchim Leubner   return;
7936*4e1bc9a0SAchim Leubner }
7937*4e1bc9a0SAchim Leubner #endif /* TARGET_DRIVER */
7938*4e1bc9a0SAchim Leubner 
7939*4e1bc9a0SAchim Leubner 
7940*4e1bc9a0SAchim Leubner /*****************************************************************************
7941*4e1bc9a0SAchim Leubner *! \brief  tdsaRotateQnumber
7942*4e1bc9a0SAchim Leubner *
7943*4e1bc9a0SAchim Leubner *  Purpose:  This function generates inbound queue number.
7944*4e1bc9a0SAchim Leubner *
7945*4e1bc9a0SAchim Leubner *  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7946*4e1bc9a0SAchim Leubner *                   instance.
7947*4e1bc9a0SAchim Leubner *
7948*4e1bc9a0SAchim Leubner *  \return:
7949*4e1bc9a0SAchim Leubner *           Queue number
7950*4e1bc9a0SAchim Leubner *
7951*4e1bc9a0SAchim Leubner *   \note:
7952*4e1bc9a0SAchim Leubner *
7953*4e1bc9a0SAchim Leubner *****************************************************************************/
7954*4e1bc9a0SAchim Leubner FORCEINLINE bit32
tdsaRotateQnumber(tiRoot_t * tiRoot,tdsaDeviceData_t * oneDeviceData)7955*4e1bc9a0SAchim Leubner tdsaRotateQnumber(tiRoot_t                *tiRoot,
7956*4e1bc9a0SAchim Leubner                   tdsaDeviceData_t        *oneDeviceData )
7957*4e1bc9a0SAchim Leubner {
7958*4e1bc9a0SAchim Leubner   bit32             ret = 0;
7959*4e1bc9a0SAchim Leubner 
7960*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaRotateQnumber: start\n"));
7961*4e1bc9a0SAchim Leubner   if (oneDeviceData == agNULL)
7962*4e1bc9a0SAchim Leubner   {
7963*4e1bc9a0SAchim Leubner     return 0;
7964*4e1bc9a0SAchim Leubner   }
7965*4e1bc9a0SAchim Leubner   ret = (oneDeviceData->OutQID << 16) | oneDeviceData->InQID;
7966*4e1bc9a0SAchim Leubner   return ret;
7967*4e1bc9a0SAchim Leubner }
7968*4e1bc9a0SAchim Leubner 
7969*4e1bc9a0SAchim Leubner osGLOBAL bit32
tdsaRotateQnumber1(tiRoot_t * tiRoot,tdsaDeviceData_t * oneDeviceData)7970*4e1bc9a0SAchim Leubner tdsaRotateQnumber1(tiRoot_t                *tiRoot,
7971*4e1bc9a0SAchim Leubner                   tdsaDeviceData_t        *oneDeviceData )
7972*4e1bc9a0SAchim Leubner {
7973*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
7974*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7975*4e1bc9a0SAchim Leubner //  static int Last_Q;
7976*4e1bc9a0SAchim Leubner //  bit32             denom = tdsaAllShared->QueueConfig.numOutboundQueues;
7977*4e1bc9a0SAchim Leubner   bit32             ret = 0;
7978*4e1bc9a0SAchim Leubner   if (oneDeviceData == agNULL)
7979*4e1bc9a0SAchim Leubner   {
7980*4e1bc9a0SAchim Leubner //    Last_Q= 0;
7981*4e1bc9a0SAchim Leubner     return 0;
7982*4e1bc9a0SAchim Leubner   }
7983*4e1bc9a0SAchim Leubner 
7984*4e1bc9a0SAchim Leubner /* alway use highest Q number */
7985*4e1bc9a0SAchim Leubner   ret = ((tdsaAllShared->QueueConfig.numOutboundQueues-1) << 16) | (tdsaAllShared->QueueConfig.numInboundQueues-1);
7986*4e1bc9a0SAchim Leubner 
7987*4e1bc9a0SAchim Leubner   return(ret);
7988*4e1bc9a0SAchim Leubner }
7989*4e1bc9a0SAchim Leubner 
7990*4e1bc9a0SAchim Leubner #ifdef REMOVED
7991*4e1bc9a0SAchim Leubner osGLOBAL bit32
tdsaRotateQnumber(tiRoot_t * tiRoot,tdsaDeviceData_t * oneDeviceData)7992*4e1bc9a0SAchim Leubner tdsaRotateQnumber(tiRoot_t                *tiRoot,
7993*4e1bc9a0SAchim Leubner                   tdsaDeviceData_t        *oneDeviceData )
7994*4e1bc9a0SAchim Leubner {
7995*4e1bc9a0SAchim Leubner   tdsaRoot_t        *tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
7996*4e1bc9a0SAchim Leubner   tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7997*4e1bc9a0SAchim Leubner   bit32             denom = tdsaAllShared->QueueConfig.numInboundQueues;
7998*4e1bc9a0SAchim Leubner   bit32             ret = 0;
7999*4e1bc9a0SAchim Leubner 
8000*4e1bc9a0SAchim Leubner   /* inbound queue number */
8001*4e1bc9a0SAchim Leubner   tdsaAllShared->IBQnumber++;
8002*4e1bc9a0SAchim Leubner   if (tdsaAllShared->IBQnumber % denom == 0) /* % Qnumber*/
8003*4e1bc9a0SAchim Leubner   {
8004*4e1bc9a0SAchim Leubner     tdsaAllShared->IBQnumber = 0;
8005*4e1bc9a0SAchim Leubner   }
8006*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaRotateQnumber: IBQnumber %d\n", tdsaAllShared->IBQnumber));
8007*4e1bc9a0SAchim Leubner 
8008*4e1bc9a0SAchim Leubner 
8009*4e1bc9a0SAchim Leubner   /* outbound queue number */
8010*4e1bc9a0SAchim Leubner   tdsaAllShared->OBQnumber++;
8011*4e1bc9a0SAchim Leubner   denom = tdsaAllShared->QueueConfig.numOutboundQueues;
8012*4e1bc9a0SAchim Leubner   if (tdsaAllShared->OBQnumber % denom == 0) /* % Qnumber*/
8013*4e1bc9a0SAchim Leubner   {
8014*4e1bc9a0SAchim Leubner     tdsaAllShared->OBQnumber = 0;
8015*4e1bc9a0SAchim Leubner   }
8016*4e1bc9a0SAchim Leubner   TI_DBG6(("tdsaRotateQnumber: OBQnumber %d\n", tdsaAllShared->OBQnumber));
8017*4e1bc9a0SAchim Leubner 
8018*4e1bc9a0SAchim Leubner   ret = (tdsaAllShared->OBQnumber << 16) | tdsaAllShared->IBQnumber;
8019*4e1bc9a0SAchim Leubner   return ret;
8020*4e1bc9a0SAchim Leubner }
8021*4e1bc9a0SAchim Leubner #endif
8022*4e1bc9a0SAchim Leubner 
8023*4e1bc9a0SAchim Leubner 
t_MacroCheck(agsaRoot_t * agRoot)8024*4e1bc9a0SAchim Leubner void t_MacroCheck(  agsaRoot_t       *agRoot)
8025*4e1bc9a0SAchim Leubner {
8026*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPC           %d\n",tIsSPC(agRoot)));
8027*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCHIL        %d\n",tIsSPCHIL(agRoot)));
8028*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCv          %d\n",tIsSPCv(agRoot)));
8029*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCve         %d\n",tIsSPCve(agRoot)));
8030*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCvplus      %d\n",tIsSPCvplus(agRoot)));
8031*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCveplus     %d\n",tIsSPCveplus(agRoot)));
8032*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCADAPvplus  %d\n",tIsSPCADAPvplus(agRoot)));
8033*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCADAPveplus %d\n",tIsSPCADAPveplus(agRoot)));
8034*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPC12Gv       %d\n",tIsSPC12Gv(agRoot)));
8035*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPC12Gve      %d\n",tIsSPC12Gve(agRoot)));
8036*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPC12Gvplus   %d\n",tIsSPC12Gvplus(agRoot)));
8037*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPC12Gveplus  %d\n",tIsSPC12Gveplus(agRoot)));
8038*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tiIS_SPC         %d\n",tiIS_SPC(agRoot)   ));
8039*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tiIS_HIL         %d\n",tiIS_HIL(agRoot)   ));
8040*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tiIS_SPC6V       %d\n",tiIS_SPC6V(agRoot) ));
8041*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tiIS_SPC_ENC     %d\n",tiIS_SPC_ENC(agRoot) ));
8042*4e1bc9a0SAchim Leubner   TI_DBG1(("t_MacroCheck:tIsSPCV12G       %d\n",tIsSPCV12G(agRoot) ));
8043*4e1bc9a0SAchim Leubner }
8044