1285809Sscottl/*******************************************************************************
2285809Sscottl*Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3285809Sscottl*
4285809Sscottl*Redistribution and use in source and binary forms, with or without modification, are permitted provided
5285809Sscottl*that the following conditions are met:
6285809Sscottl*1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7285809Sscottl*following disclaimer.
8285809Sscottl*2. Redistributions in binary form must reproduce the above copyright notice,
9285809Sscottl*this list of conditions and the following disclaimer in the documentation and/or other materials provided
10285809Sscottl*with the distribution.
11285809Sscottl*
12285809Sscottl*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13285809Sscottl*WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14285809Sscottl*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15285809Sscottl*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16285809Sscottl*NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17285809Sscottl*BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18285809Sscottl*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19285809Sscottl*SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20285809Sscottl
21285809Sscottl********************************************************************************/
22285809Sscottl/*******************************************************************************/
23285809Sscottl/** \file
24285809Sscottl *
25285809Sscottl * tdport.c
26285809Sscottl * This file contains port realted functions such as tiCOMPortStart()
27285809Sscottl *
28285809Sscottl */
29285809Sscottl#include <sys/cdefs.h>
30285809Sscottl__FBSDID("$FreeBSD$");
31285809Sscottl#include <dev/pms/config.h>
32285809Sscottl
33285809Sscottl#include <dev/pms/freebsd/driver/common/osenv.h>
34285809Sscottl#include <dev/pms/freebsd/driver/common/ostypes.h>
35285809Sscottl#include <dev/pms/freebsd/driver/common/osdebug.h>
36285809Sscottl
37285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/sa.h>
38285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/saapi.h>
39285809Sscottl#include <dev/pms/RefTisa/sallsdk/spc/sadefs.h>
40285809Sscottl#include <dev/pms/RefTisa/sallsdk/api/saosapi.h>
41285809Sscottl
42285809Sscottl#include <dev/pms/RefTisa/tisa/api/titypes.h>
43285809Sscottl#include <dev/pms/RefTisa/tisa/api/ostiapi.h>
44285809Sscottl#include <dev/pms/RefTisa/tisa/api/tiapi.h>
45285809Sscottl#include <dev/pms/RefTisa/tisa/api/tiglobal.h>
46285809Sscottl
47285809Sscottl#ifdef FDS_SM
48285809Sscottl#include <dev/pms/RefTisa/sat/api/sm.h>
49285809Sscottl#include <dev/pms/RefTisa/sat/api/smapi.h>
50285809Sscottl#include <dev/pms/RefTisa/sat/api/tdsmapi.h>
51285809Sscottl#endif
52285809Sscottl
53285809Sscottl#ifdef FDS_DM
54285809Sscottl#include <dev/pms/RefTisa/discovery/api/dm.h>
55285809Sscottl#include <dev/pms/RefTisa/discovery/api/dmapi.h>
56285809Sscottl#include <dev/pms/RefTisa/discovery/api/tddmapi.h>
57285809Sscottl#endif
58285809Sscottl
59285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/common/tdtypes.h>
60285809Sscottl#include <dev/pms/freebsd/driver/common/osstring.h>
61285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdutil.h>
62285809Sscottl
63285809Sscottl#ifdef INITIATOR_DRIVER
64285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdtypes.h>
65285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itddefs.h>
66285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/ini/itdglobl.h>
67285809Sscottl#endif
68285809Sscottl
69285809Sscottl#ifdef TARGET_DRIVER
70285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdglobl.h>
71285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdxchg.h>
72285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/sas/tgt/ttdtypes.h>
73285809Sscottl#endif
74285809Sscottl
75285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h>
76285809Sscottl#include <dev/pms/RefTisa/tisa/sassata/common/tdproto.h>
77285809Sscottl
78285809Sscottl#ifndef TURN_OFF_HDA
79285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/aap1img.h> /* SPC HDA */
80285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/ilaimg.h>
81285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/iopimg.h>
82285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/istrimg.h>
83285809Sscottl
84285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/aap18008.h>	/* SPCv HDA */
85285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/iop8008.h>
86285809Sscottl
87285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/ila8008.h> /* Ila common to SPCv SPCvp versions */
88285809Sscottl
89285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/raae8070.h>	/* SPCv 12g HDA */
90285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/iop8070.h>
91285809Sscottl#include <dev/pms/RefTisa/sallsdk/hda/64k/ila8070.h> /* Ila 12g  SPCv SPCvp versions */
92285809Sscottl
93285809Sscottl#endif /* TURN_OFF_HDA */
94285809Sscottl
95285809Sscottl
96285809Sscottlbit32 gSSC_Disable = 0;
97285809Sscottlbit32 volatile sgpioResponseSet = 0;
98285809Sscottl
99285809Sscottl#ifdef ECHO_TESTING
100285809Sscottl/* temporary to test saEchoCommand() */
101285809Sscottlbit8 gEcho;
102285809Sscottl#endif
103285809Sscottlbit32 tiCOMConfigureSgpio(
104285809Sscottl                        tiRoot_t    *tiRoot,
105285809Sscottl                        bit8        enableSgpio
106285809Sscottl                        );
107285809Sscottl
108285809Sscottl
109285809Sscottl/*****************************************************************************
110285809Sscottl*! \brief tdsaGetSwConfigParams
111285809Sscottl*
112285809Sscottl*  Purpose:  This function reads software configuration parameters from the
113285809Sscottl*            configuration file
114285809Sscottl*
115285809Sscottl*  \param  tiRoot:            Pointer to driver/port instance.
116285809Sscottl*
117285809Sscottl*  \return: None
118285809Sscottl*
119285809Sscottl*  \note -
120285809Sscottl*
121285809Sscottl*****************************************************************************/
122285809SscottlosGLOBAL void
123285809SscottltdsaGetSwConfigParams(
124285809Sscottl                      tiRoot_t *tiRoot
125285809Sscottl                      )
126285809Sscottl{
127285809Sscottl  tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
128285809Sscottl  tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
129285809Sscottl  agsaSwConfig_t *SwConfig;
130285809Sscottl  agsaQueueConfig_t   *QueueConfig;
131285809Sscottl  char           *buffer;
132285809Sscottl  bit32          buffLen;
133285809Sscottl  bit32          lenRecv = 0;
134285809Sscottl  char           *pLastUsedChar = agNULL;
135285809Sscottl  char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
136285809Sscottl  char           globalStr[]     = "Global";
137285809Sscottl  char           iniParmsStr[]   = "InitiatorParms";
138285809Sscottl  char           SwParmsStr[]   = "SWParms";
139285809Sscottl  char           OBQueueProps[] = "OBQueueProps";
140285809Sscottl  char           IBQueueProps[] = "IBQueueProps";
141285809Sscottl  char           IBQueueSize[40];
142285809Sscottl  char           OBQueueSize[40];
143285809Sscottl  char           IBQueueEleSize[40];
144285809Sscottl  char           OBQueueEleSize[40];
145285809Sscottl  char           OBQueueInterruptCount[40];
146285809Sscottl  char           OBQueueInterruptDelay[40];
147285809Sscottl  char           OBQueueInterruptEnable[40];
148285809Sscottl  char           IBQueuePriority[40];
149285809Sscottl  char           *cardNum = tdsaAllShared->CardIDString;
150285809Sscottl  bit32          i;
151285809Sscottl  bit32          enableDIF;
152285809Sscottl  bit32          enableEncryption;
153285809Sscottl#ifdef SA_CONFIG_MDFD_REGISTRY
154285809Sscottl  bit32          disableMDF;
155285809Sscottl#endif
156285809Sscottl
157285809Sscottl#ifdef FDS_DM
158285809Sscottl  dmSwConfig_t   *dmSwConfig;
159285809Sscottl#endif
160285809Sscottl#ifdef FDS_SM
161285809Sscottl  smSwConfig_t   *smSwConfig;
162285809Sscottl#endif
163285809Sscottl
164285809Sscottl  TI_DBG6(("tdsaGetSwConfigParams: start\n"));
165285809Sscottl  TI_DBG6(("tdsaGetSwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
166285809Sscottl
167285809Sscottl  buffer = tmpBuffer;
168285809Sscottl  buffLen = sizeof(tmpBuffer);
169285809Sscottl
170285809Sscottl  osti_memset(buffer, 0, buffLen);
171285809Sscottl
172285809Sscottl  /* the followings are the default values */
173285809Sscottl  SwConfig = (agsaSwConfig_t *)&(tdsaAllShared->SwConfig);
174285809Sscottl  QueueConfig = (agsaQueueConfig_t *)&(tdsaAllShared->QueueConfig);
175285809Sscottl
176285809Sscottl#ifdef FDS_DM
177285809Sscottl  dmSwConfig = (dmSwConfig_t *)&(tdsaAllShared->dmSwConfig);
178285809Sscottl#endif
179285809Sscottl#ifdef FDS_SM
180285809Sscottl  smSwConfig = (smSwConfig_t *)&(tdsaAllShared->smSwConfig);
181285809Sscottl#endif
182285809Sscottl
183285809Sscottl  /*
184285809Sscottl    just default values
185285809Sscottl    and are overwritten later by the configuration file contents
186285809Sscottl  */
187285809Sscottl  SwConfig->numDevHandles = DEFAULT_MAX_DEV;
188285809Sscottl
189285809Sscottl  SwConfig->maxActiveIOs = DEFAULT_MAX_ACTIVE_IOS;
190285809Sscottl  SwConfig->smpReqTimeout = DEFAULT_SMP_TIMEOUT; /* DEFAULT_VALUE; */
191285809Sscottl  SwConfig->numberOfEventRegClients = DEFAULT_NUM_REG_CLIENTS;
192285809Sscottl  SwConfig->sizefEventLog1 = HOST_EVENT_LOG_SIZE;
193285809Sscottl  SwConfig->sizefEventLog2 = HOST_EVENT_LOG_SIZE;
194285809Sscottl  SwConfig->eventLog1Option = DEFAULT_EVENT_LOG_OPTION;
195285809Sscottl  SwConfig->eventLog2Option = DEFAULT_EVENT_LOG_OPTION;
196285809Sscottl  SwConfig->fatalErrorInterruptEnable = 1;
197285809Sscottl  SwConfig->fatalErrorInterruptVector = 0; /* Was 1 */
198285809Sscottl  SwConfig->hostDirectAccessSupport = 0;
199285809Sscottl  SwConfig->hostDirectAccessMode = 0;
200285809Sscottl  SwConfig->FWConfig = 0;
201285809Sscottl  SwConfig->enableDIF = agFALSE;
202285809Sscottl  SwConfig->enableEncryption = agFALSE;
203285809Sscottl
204285809Sscottl#ifdef SA_CONFIG_MDFD_REGISTRY
205285809Sscottl  SwConfig->disableMDF = agFALSE;
206285809Sscottl#endif
207285809Sscottl
208285809Sscottl  SwConfig->param1 = tdsaAllShared->tdDeviceIdVendId;
209285809Sscottl  SwConfig->param2 = tdsaAllShared->tdSubVendorId;
210285809Sscottl
211285809Sscottl
212285809Sscottl#if defined(SALLSDK_DEBUG)
213285809Sscottl  SwConfig->sallDebugLevel = 1; /* DEFAULT_VALUE; */
214285809Sscottl#endif
215285809Sscottl#if defined(DM_DEBUG)
216285809Sscottl  dmSwConfig->DMDebugLevel = 1; /* DEFAULT_VALUE; */
217285809Sscottl#endif
218285809Sscottl#if defined(SM_DEBUG)
219285809Sscottl  smSwConfig->SMDebugLevel = 1; /* DEFAULT_VALUE; */
220285809Sscottl#endif
221285809Sscottl
222285809Sscottl  tdsaAllShared->portTMO = PORT_RECOVERY_TIMEOUT;   /* default 5 sec */
223285809Sscottl  tdsaAllShared->stp_idle_time = STP_IDLE_TIME;     /* default 5 us */
224285809Sscottl  tdsaAllShared->itNexusTimeout = IT_NEXUS_TIMEOUT; /* default 2000 ms */
225285809Sscottl
226285809Sscottl  osti_memset(buffer, 0, buffLen);
227285809Sscottl  lenRecv = 0;
228285809Sscottl
229285809Sscottl  if ((ostiGetTransportParam(
230285809Sscottl                             tiRoot,
231285809Sscottl                             globalStr,
232285809Sscottl                             iniParmsStr,
233285809Sscottl                             agNULL,
234285809Sscottl                             agNULL,
235285809Sscottl                             agNULL,
236285809Sscottl                             agNULL,
237285809Sscottl                             "MaxTargets",
238285809Sscottl                             buffer,
239285809Sscottl                             buffLen,
240285809Sscottl                             &lenRecv
241285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
242285809Sscottl  {
243285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
244285809Sscottl    {
245285809Sscottl      SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 0);
246285809Sscottl    }
247285809Sscottl    else
248285809Sscottl    {
249285809Sscottl      SwConfig->numDevHandles = osti_strtoul (buffer, &pLastUsedChar, 10);
250285809Sscottl    }
251285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: MaxTargets  %d\n",SwConfig->numDevHandles  ));
252285809Sscottl  }
253285809Sscottl
254285809Sscottl  /*
255285809Sscottl   * read the NumInboundQueue parameter
256285809Sscottl   */
257285809Sscottl  osti_memset(buffer, 0, buffLen);
258285809Sscottl  lenRecv = 0;
259285809Sscottl
260285809Sscottl  QueueConfig->numInboundQueues = DEFAULT_NUM_INBOUND_QUEUE;  /* default 1 Inbound queue */
261285809Sscottl
262285809Sscottl  if ((ostiGetTransportParam(
263285809Sscottl                             tiRoot,
264285809Sscottl                             globalStr,   /* key */
265285809Sscottl                             SwParmsStr,  /* subkey1 */
266285809Sscottl                             agNULL,      /* subkey2 */
267285809Sscottl                             agNULL,
268285809Sscottl                             agNULL,
269285809Sscottl                             agNULL,      /* subkey5 */
270285809Sscottl                             "NumInboundQueues", /* valueName */
271285809Sscottl                             buffer,
272285809Sscottl                             buffLen,
273285809Sscottl                             &lenRecv
274285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
275285809Sscottl  {
276285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
277285809Sscottl    {
278285809Sscottl      QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
279285809Sscottl    }
280285809Sscottl    else
281285809Sscottl    {
282285809Sscottl      QueueConfig->numInboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
283285809Sscottl    }
284285809Sscottl
285285809Sscottl    if (QueueConfig->numInboundQueues > AGSA_MAX_INBOUND_Q)
286285809Sscottl    {
287285809Sscottl      QueueConfig->numInboundQueues = AGSA_MAX_INBOUND_Q;
288285809Sscottl    }
289285809Sscottl  }
290285809Sscottl
291285809Sscottl  /*
292285809Sscottl   * read the NumOutboundQueue parameter
293285809Sscottl   */
294285809Sscottl  osti_memset(buffer, 0, buffLen);
295285809Sscottl  lenRecv = 0;
296285809Sscottl
297285809Sscottl  QueueConfig->numOutboundQueues = DEFAULT_NUM_OUTBOUND_QUEUE;  /* default 1 Outbound queue */
298285809Sscottl
299285809Sscottl  if ((ostiGetTransportParam(
300285809Sscottl                             tiRoot,
301285809Sscottl                             globalStr,   /* key */
302285809Sscottl                             SwParmsStr,  /* subkey1 */
303285809Sscottl                             agNULL,      /* subkey2 */
304285809Sscottl                             agNULL,
305285809Sscottl                             agNULL,
306285809Sscottl                             agNULL,      /* subkey5 */
307285809Sscottl                             "NumOutboundQueues", /* valueName */
308285809Sscottl                             buffer,
309285809Sscottl                             buffLen,
310285809Sscottl                             &lenRecv
311285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
312285809Sscottl  {
313285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
314285809Sscottl    {
315285809Sscottl      QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
316285809Sscottl    }
317285809Sscottl    else
318285809Sscottl    {
319285809Sscottl      QueueConfig->numOutboundQueues = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
320285809Sscottl    }
321285809Sscottl
322285809Sscottl    if (QueueConfig->numOutboundQueues > AGSA_MAX_OUTBOUND_Q)
323285809Sscottl    {
324285809Sscottl      QueueConfig->numOutboundQueues = AGSA_MAX_OUTBOUND_Q;
325285809Sscottl    }
326285809Sscottl  }
327285809Sscottl
328285809Sscottl  /*
329285809Sscottl   * read the outbound queue option
330285809Sscottl   */
331285809Sscottl
332285809Sscottl  osti_memset(buffer, 0, buffLen);
333285809Sscottl  lenRecv = 0;
334285809Sscottl
335285809Sscottl  tdsaAllShared->QueueOption = DEFAULT_QUEUE_OPTION;  /* default 0 Outbound queue element */
336285809Sscottl
337285809Sscottl  if ((ostiGetTransportParam(
338285809Sscottl                             tiRoot,
339285809Sscottl                             globalStr,   /* key */
340285809Sscottl                             SwParmsStr,  /* subkey1 */
341285809Sscottl                             agNULL,      /* subkey2 */
342285809Sscottl                             agNULL,
343285809Sscottl                             agNULL,
344285809Sscottl                             agNULL,      /* subkey5 */
345285809Sscottl                             "QueueOption", /* valueName */
346285809Sscottl                             buffer,
347285809Sscottl                             buffLen,
348285809Sscottl                             &lenRecv
349285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
350285809Sscottl  {
351285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
352285809Sscottl    {
353285809Sscottl      tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
354285809Sscottl    }
355285809Sscottl    else
356285809Sscottl    {
357285809Sscottl      tdsaAllShared->QueueOption = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
358285809Sscottl    }
359285809Sscottl  }
360285809Sscottl
361285809Sscottl  /*
362285809Sscottl   * read the MaxActiveIO parameter
363285809Sscottl   */
364285809Sscottl
365285809Sscottl  osti_memset(buffer, 0, buffLen);
366285809Sscottl  lenRecv = 0;
367285809Sscottl
368285809Sscottl  if ((ostiGetTransportParam(
369285809Sscottl                             tiRoot,
370285809Sscottl                             globalStr,   /* key */
371285809Sscottl                             SwParmsStr,  /* subkey1 */
372285809Sscottl                             agNULL,      /* subkey2 */
373285809Sscottl                             agNULL,
374285809Sscottl                             agNULL,
375285809Sscottl                             agNULL,      /* subkey5 */
376285809Sscottl                             "MaxActiveIO", /* valueName */
377285809Sscottl                             buffer,
378285809Sscottl                             buffLen,
379285809Sscottl                             &lenRecv
380285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
381285809Sscottl  {
382285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
383285809Sscottl    {
384285809Sscottl      SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 0);
385285809Sscottl      TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 1 !!!\n"));
386285809Sscottl    }
387285809Sscottl    else
388285809Sscottl    {
389285809Sscottl      SwConfig->maxActiveIOs = osti_strtoul (buffer, &pLastUsedChar, 10);
390285809Sscottl      TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 2 !!!\n"));
391285809Sscottl    }
392285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: maxactiveio 3 !!!\n"));
393285809Sscottl  }
394285809Sscottl
395285809Sscottl
396285809Sscottl
397285809Sscottl  /*
398285809Sscottl   * read the SMPTO parameter (SMP Timeout)
399285809Sscottl   */
400285809Sscottl  osti_memset(buffer, 0, buffLen);
401285809Sscottl  lenRecv = 0;
402285809Sscottl
403285809Sscottl  if ((ostiGetTransportParam(
404285809Sscottl                             tiRoot,
405285809Sscottl                             globalStr,   /* key */
406285809Sscottl                             SwParmsStr,  /* subkey1 */
407285809Sscottl                             agNULL,      /* subkey2 */
408285809Sscottl                             agNULL,
409285809Sscottl                             agNULL,
410285809Sscottl                             agNULL,      /* subkey5 */
411285809Sscottl                             "SMPTO", /* valueName */
412285809Sscottl                             buffer,
413285809Sscottl                             buffLen,
414285809Sscottl                             &lenRecv
415285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
416285809Sscottl  {
417285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
418285809Sscottl    {
419285809Sscottl      SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
420285809Sscottl    }
421285809Sscottl    else
422285809Sscottl    {
423285809Sscottl      SwConfig->smpReqTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
424285809Sscottl    }
425285809Sscottl  }
426285809Sscottl
427285809Sscottl
428285809Sscottl  /*
429285809Sscottl   * read the NumRegClients parameter (SMP Timeout)
430285809Sscottl   */
431285809Sscottl  osti_memset(buffer, 0, buffLen);
432285809Sscottl  lenRecv = 0;
433285809Sscottl
434285809Sscottl  if ((ostiGetTransportParam(
435285809Sscottl                             tiRoot,
436285809Sscottl                             globalStr,   /* key */
437285809Sscottl                             SwParmsStr,  /* subkey1 */
438285809Sscottl                             agNULL,      /* subkey2 */
439285809Sscottl                             agNULL,
440285809Sscottl                             agNULL,
441285809Sscottl                             agNULL,      /* subkey5 */
442285809Sscottl                             "NumRegClients", /* valueName */
443285809Sscottl                             buffer,
444285809Sscottl                             buffLen,
445285809Sscottl                             &lenRecv
446285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
447285809Sscottl  {
448285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
449285809Sscottl    {
450285809Sscottl      SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 0);
451285809Sscottl    }
452285809Sscottl    else
453285809Sscottl    {
454285809Sscottl      SwConfig->numberOfEventRegClients = osti_strtoul (buffer, &pLastUsedChar, 10);
455285809Sscottl    }
456285809Sscottl  }
457285809Sscottl
458285809Sscottl#if defined(SALLSDK_DEBUG)
459285809Sscottl  osti_memset(buffer, 0, buffLen);
460285809Sscottl  lenRecv = 0;
461285809Sscottl
462285809Sscottl  if ((ostiGetTransportParam(
463285809Sscottl                             tiRoot,
464285809Sscottl                             globalStr,   /* key */
465285809Sscottl                             SwParmsStr,  /* subkey1 */
466285809Sscottl                             agNULL,      /* subkey2 */
467285809Sscottl                             agNULL,
468285809Sscottl                             agNULL,
469285809Sscottl                             agNULL,      /* subkey5 */
470285809Sscottl                             "LLDebugLevel", /* valueName */
471285809Sscottl                             buffer,
472285809Sscottl                             buffLen,
473285809Sscottl                             &lenRecv
474285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
475285809Sscottl  {
476285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
477285809Sscottl    {
478285809Sscottl      SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
479285809Sscottl    }
480285809Sscottl    else
481285809Sscottl    {
482285809Sscottl      SwConfig->sallDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
483285809Sscottl    }
484285809Sscottl  }
485285809Sscottl#endif
486285809Sscottl
487285809Sscottl#if defined(DM_DEBUG)
488285809Sscottl  osti_memset(buffer, 0, buffLen);
489285809Sscottl  lenRecv = 0;
490285809Sscottl
491285809Sscottl  if ((ostiGetTransportParam(
492285809Sscottl                             tiRoot,
493285809Sscottl                             globalStr,   /* key */
494285809Sscottl                             SwParmsStr,  /* subkey1 */
495285809Sscottl                             agNULL,      /* subkey2 */
496285809Sscottl                             agNULL,
497285809Sscottl                             agNULL,
498285809Sscottl                             agNULL,      /* subkey5 */
499285809Sscottl                             "DMDebugLevel", /* valueName */
500285809Sscottl                             buffer,
501285809Sscottl                             buffLen,
502285809Sscottl                             &lenRecv
503285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
504285809Sscottl  {
505285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
506285809Sscottl    {
507285809Sscottl      dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
508285809Sscottl    }
509285809Sscottl    else
510285809Sscottl    {
511285809Sscottl      dmSwConfig->DMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
512285809Sscottl    }
513285809Sscottl  }
514285809Sscottl#endif
515285809Sscottl
516285809Sscottl#if defined(SM_DEBUG)
517285809Sscottl  osti_memset(buffer, 0, buffLen);
518285809Sscottl  lenRecv = 0;
519285809Sscottl
520285809Sscottl  if ((ostiGetTransportParam(
521285809Sscottl                             tiRoot,
522285809Sscottl                             globalStr,   /* key */
523285809Sscottl                             SwParmsStr,  /* subkey1 */
524285809Sscottl                             agNULL,      /* subkey2 */
525285809Sscottl                             agNULL,
526285809Sscottl                             agNULL,
527285809Sscottl                             agNULL,      /* subkey5 */
528285809Sscottl                             "SMDebugLevel", /* valueName */
529285809Sscottl                             buffer,
530285809Sscottl                             buffLen,
531285809Sscottl                             &lenRecv
532285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
533285809Sscottl  {
534285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
535285809Sscottl    {
536285809Sscottl      smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 0);
537285809Sscottl    }
538285809Sscottl    else
539285809Sscottl    {
540285809Sscottl      smSwConfig->SMDebugLevel = osti_strtoul (buffer, &pLastUsedChar, 10);
541285809Sscottl    }
542285809Sscottl  }
543285809Sscottl#endif
544285809Sscottl
545285809Sscottl  osti_memset(buffer, 0, buffLen);
546285809Sscottl  lenRecv = 0;
547285809Sscottl
548285809Sscottl  for (i=0;i<QueueConfig->numInboundQueues;i++)
549285809Sscottl  {
550285809Sscottl    osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
551285809Sscottl    osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
552285809Sscottl    osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
553285809Sscottl
554285809Sscottl    /*
555285809Sscottl     * read the IBQueueSize
556285809Sscottl     */
557285809Sscottl
558285809Sscottl    osti_memset(buffer, 0, buffLen);
559285809Sscottl    lenRecv = 0;
560285809Sscottl
561285809Sscottl    tdsaAllShared->InboundQueueSize[i] = DEFAULT_INBOUND_QUEUE_SIZE;  /* default 256 Inbound queue size */
562285809Sscottl
563285809Sscottl    if ((ostiGetTransportParam(
564285809Sscottl                             tiRoot,
565285809Sscottl                             globalStr,   /* key */
566285809Sscottl                             SwParmsStr,  /* subkey1 */
567285809Sscottl                             IBQueueProps,/* subkey2 */
568285809Sscottl                             agNULL,
569285809Sscottl                             agNULL,
570285809Sscottl                             agNULL,      /* subkey5 */
571285809Sscottl                             IBQueueSize, /* valueName */
572285809Sscottl                             buffer,
573285809Sscottl                             buffLen,
574285809Sscottl                             &lenRecv
575285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
576285809Sscottl    {
577285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
578285809Sscottl      {
579285809Sscottl        tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
580285809Sscottl      }
581285809Sscottl      else
582285809Sscottl      {
583285809Sscottl        tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
584285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
585285809Sscottl      }
586285809Sscottl    }
587285809Sscottl
588285809Sscottl
589285809Sscottl    /*
590285809Sscottl     * read the IBQueueEleSize
591285809Sscottl     */
592285809Sscottl
593285809Sscottl    osti_memset(buffer, 0, buffLen);
594285809Sscottl    lenRecv = 0;
595285809Sscottl
596285809Sscottl    tdsaAllShared->InboundQueueEleSize[i] = DEFAULT_INBOUND_QUEUE_ELE_SIZE;  /* default 128 Inbound queue element */
597285809Sscottl
598285809Sscottl    if ((ostiGetTransportParam(
599285809Sscottl                             tiRoot,
600285809Sscottl                             globalStr,   /* key */
601285809Sscottl                             SwParmsStr,  /* subkey1 */
602285809Sscottl                             IBQueueProps,/* subkey2 */
603285809Sscottl                             agNULL,
604285809Sscottl                             agNULL,
605285809Sscottl                             agNULL,      /* subkey5 */
606285809Sscottl                             IBQueueEleSize, /* valueName */
607285809Sscottl                             buffer,
608285809Sscottl                             buffLen,
609285809Sscottl                             &lenRecv
610285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
611285809Sscottl    {
612285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
613285809Sscottl      {
614285809Sscottl        tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
615285809Sscottl      }
616285809Sscottl      else
617285809Sscottl      {
618285809Sscottl        tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
619285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
620285809Sscottl      }
621285809Sscottl    }
622285809Sscottl
623285809Sscottl    /*
624285809Sscottl     * read the IBQueuePriority
625285809Sscottl     */
626285809Sscottl
627285809Sscottl    osti_memset(buffer, 0, buffLen);
628285809Sscottl    lenRecv = 0;
629285809Sscottl
630285809Sscottl    tdsaAllShared->InboundQueuePriority[i] = DEFAULT_INBOUND_QUEUE_PRIORITY; /* default 0 Inbound queue priority */
631285809Sscottl
632285809Sscottl    if ((ostiGetTransportParam(
633285809Sscottl                             tiRoot,
634285809Sscottl                             globalStr,   /* key */
635285809Sscottl                             SwParmsStr,  /* subkey1 */
636285809Sscottl                             IBQueueProps,/* subkey2 */
637285809Sscottl                             agNULL,
638285809Sscottl                             agNULL,
639285809Sscottl                             agNULL,      /* subkey5 */
640285809Sscottl                             IBQueuePriority, /* valueName */
641285809Sscottl                             buffer,
642285809Sscottl                             buffLen,
643285809Sscottl                             &lenRecv
644285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
645285809Sscottl    {
646285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
647285809Sscottl      {
648285809Sscottl        tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
649285809Sscottl      }
650285809Sscottl      else
651285809Sscottl      {
652285809Sscottl        tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
653285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d priority %d\n", i, tdsaAllShared->InboundQueuePriority[i]));
654285809Sscottl      }
655285809Sscottl    }
656285809Sscottl
657285809Sscottl    /**********************************************/
658285809Sscottl    osti_memset(buffer, 0, buffLen);
659285809Sscottl    lenRecv = 0;
660285809Sscottl  }/* end of loop */
661285809Sscottl
662285809Sscottl
663285809Sscottl
664285809Sscottl  osti_memset(buffer, 0, buffLen);
665285809Sscottl  lenRecv = 0;
666285809Sscottl
667285809Sscottl  for (i=0;i<QueueConfig->numOutboundQueues;i++)
668285809Sscottl  {
669285809Sscottl    osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
670285809Sscottl    osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
671285809Sscottl    osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
672285809Sscottl    osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
673285809Sscottl    osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
674285809Sscottl
675285809Sscottl    /*
676285809Sscottl     * read the OBQueueSize
677285809Sscottl     */
678285809Sscottl    osti_memset(buffer, 0, buffLen);
679285809Sscottl    lenRecv = 0;
680285809Sscottl
681285809Sscottl
682285809Sscottl    tdsaAllShared->OutboundQueueSize[i] = DEFAULT_OUTBOUND_QUEUE_SIZE;  /* default 256 Outbound queue size */
683285809Sscottl
684285809Sscottl    if ((ostiGetTransportParam(
685285809Sscottl                             tiRoot,
686285809Sscottl                             globalStr,   /* key */
687285809Sscottl                             SwParmsStr,  /* subkey1 */
688285809Sscottl                             OBQueueProps,      /* subkey2 */
689285809Sscottl                             agNULL,
690285809Sscottl                             agNULL,
691285809Sscottl                             agNULL,      /* subkey5 */
692285809Sscottl                             OBQueueSize, /* valueName */
693285809Sscottl                             buffer,
694285809Sscottl                             buffLen,
695285809Sscottl                             &lenRecv
696285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
697285809Sscottl    {
698285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
699285809Sscottl      {
700285809Sscottl        tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
701285809Sscottl      }
702285809Sscottl      else
703285809Sscottl      {
704285809Sscottl        tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
705285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
706285809Sscottl
707285809Sscottl      }
708285809Sscottl    }
709285809Sscottl
710285809Sscottl
711285809Sscottl    /*
712285809Sscottl     * read the OBQueueEleSize
713285809Sscottl     */
714285809Sscottl    osti_memset(buffer, 0, buffLen);
715285809Sscottl    lenRecv = 0;
716285809Sscottl
717285809Sscottl
718285809Sscottl    tdsaAllShared->OutboundQueueEleSize[i] = DEFAULT_OUTBOUND_QUEUE_ELE_SIZE;  /* default 128 Outbound queue element */
719285809Sscottl
720285809Sscottl    if ((ostiGetTransportParam(
721285809Sscottl                             tiRoot,
722285809Sscottl                             globalStr,   /* key */
723285809Sscottl                             SwParmsStr,  /* subkey1 */
724285809Sscottl                             OBQueueProps,      /* subkey2 */
725285809Sscottl                             agNULL,
726285809Sscottl                             agNULL,
727285809Sscottl                             agNULL,      /* subkey5 */
728285809Sscottl                             OBQueueEleSize, /* valueName */
729285809Sscottl                             buffer,
730285809Sscottl                             buffLen,
731285809Sscottl                             &lenRecv
732285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
733285809Sscottl    {
734285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
735285809Sscottl      {
736285809Sscottl        tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
737285809Sscottl      }
738285809Sscottl      else
739285809Sscottl      {
740285809Sscottl        tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
741285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
742285809Sscottl
743285809Sscottl      }
744285809Sscottl    }
745285809Sscottl
746285809Sscottl
747285809Sscottl    /*
748285809Sscottl     * read the OBQueueInterruptDelay
749285809Sscottl     */
750285809Sscottl    osti_memset(buffer, 0, buffLen);
751285809Sscottl    lenRecv = 0;
752285809Sscottl
753285809Sscottl
754285809Sscottl    tdsaAllShared->OutboundQueueInterruptDelay[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_DELAY;  /* default 1 Outbound interrupt delay */
755285809Sscottl
756285809Sscottl    if ((ostiGetTransportParam(
757285809Sscottl                             tiRoot,
758285809Sscottl                             globalStr,   /* key */
759285809Sscottl                             SwParmsStr,  /* subkey1 */
760285809Sscottl                             OBQueueProps,      /* subkey2 */
761285809Sscottl                             agNULL,
762285809Sscottl                             agNULL,
763285809Sscottl                             agNULL,      /* subkey5 */
764285809Sscottl                             OBQueueInterruptDelay, /* valueName */
765285809Sscottl                             buffer,
766285809Sscottl                             buffLen,
767285809Sscottl                             &lenRecv
768285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
769285809Sscottl    {
770285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
771285809Sscottl      {
772285809Sscottl        tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
773285809Sscottl      }
774285809Sscottl      else
775285809Sscottl      {
776285809Sscottl        tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
777285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt delay %d\n", i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
778285809Sscottl
779285809Sscottl      }
780285809Sscottl    }
781285809Sscottl
782285809Sscottl    /*
783285809Sscottl     * read the OBQueueInterruptCount
784285809Sscottl     */
785285809Sscottl
786285809Sscottl    osti_memset(buffer, 0, buffLen);
787285809Sscottl    lenRecv = 0;
788285809Sscottl
789285809Sscottl    tdsaAllShared->OutboundQueueInterruptCount[i] = DEFAULT_OUTBOUND_QUEUE_INTERRUPT_COUNT;  /* default 1 Outbound interrupt count */
790285809Sscottl
791285809Sscottl    if ((ostiGetTransportParam(
792285809Sscottl                             tiRoot,
793285809Sscottl                             globalStr,   /* key */
794285809Sscottl                             SwParmsStr,  /* subkey1 */
795285809Sscottl                             OBQueueProps,      /* subkey2 */
796285809Sscottl                             agNULL,
797285809Sscottl                             agNULL,
798285809Sscottl                             agNULL,      /* subkey5 */
799285809Sscottl                             OBQueueInterruptCount, /* valueName */
800285809Sscottl                             buffer,
801285809Sscottl                             buffLen,
802285809Sscottl                             &lenRecv
803285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
804285809Sscottl    {
805285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
806285809Sscottl      {
807285809Sscottl        tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
808285809Sscottl      }
809285809Sscottl      else
810285809Sscottl      {
811285809Sscottl        tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
812285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt count %d\n", i, tdsaAllShared->OutboundQueueInterruptCount[i]));
813285809Sscottl      }
814285809Sscottl    }
815285809Sscottl
816285809Sscottl
817285809Sscottl    /*
818285809Sscottl     * read the OBQueueInterruptEnable
819285809Sscottl     */
820285809Sscottl
821285809Sscottl    osti_memset(buffer, 0, buffLen);
822285809Sscottl    lenRecv = 0;
823285809Sscottl
824285809Sscottl    tdsaAllShared->OutboundQueueInterruptEnable[i] = DEFAULT_OUTBOUND_INTERRUPT_ENABLE;  /* default 1 Outbound interrupt is enabled */
825285809Sscottl
826285809Sscottl    if ((ostiGetTransportParam(
827285809Sscottl                             tiRoot,
828285809Sscottl                             globalStr,   /* key */
829285809Sscottl                             SwParmsStr,  /* subkey1 */
830285809Sscottl                             OBQueueProps,      /* subkey2 */
831285809Sscottl                             agNULL,
832285809Sscottl                             agNULL,
833285809Sscottl                             agNULL,      /* subkey5 */
834285809Sscottl                             OBQueueInterruptEnable, /* valueName */
835285809Sscottl                             buffer,
836285809Sscottl                             buffLen,
837285809Sscottl                             &lenRecv
838285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
839285809Sscottl    {
840285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
841285809Sscottl      {
842285809Sscottl        tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
843285809Sscottl      }
844285809Sscottl      else
845285809Sscottl      {
846285809Sscottl        tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
847285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d interrupt enable %d\n", i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
848285809Sscottl      }
849285809Sscottl    }
850285809Sscottl
851285809Sscottl    /**********************************************/
852285809Sscottl    osti_memset(buffer, 0, buffLen);
853285809Sscottl    lenRecv = 0;
854285809Sscottl
855285809Sscottl  }/* end of loop */
856285809Sscottl
857285809Sscottl
858285809Sscottl
859285809Sscottl  /********************READ CARD SPECIFIC *******************************************************/
860285809Sscottl
861285809Sscottl  osti_memset(buffer, 0, buffLen);
862285809Sscottl  lenRecv = 0;
863285809Sscottl
864285809Sscottl  for (i=0;i<QueueConfig->numInboundQueues;i++)
865285809Sscottl  {
866285809Sscottl    osti_sprintf(IBQueueSize,"IBQueueNumElements%d", i);
867285809Sscottl    osti_sprintf(IBQueueEleSize,"IBQueueElementSize%d", i);
868285809Sscottl    osti_sprintf(IBQueuePriority,"IBQueuePriority%d", i);
869285809Sscottl
870285809Sscottl    /*
871285809Sscottl     * read the IBQueueSize
872285809Sscottl     */
873285809Sscottl
874285809Sscottl    osti_memset(buffer, 0, buffLen);
875285809Sscottl    lenRecv = 0;
876285809Sscottl
877285809Sscottl    if ((ostiGetTransportParam(
878285809Sscottl                             tiRoot,
879285809Sscottl                             cardNum,   /* key */
880285809Sscottl                             SwParmsStr,  /* subkey1 */
881285809Sscottl                             IBQueueProps,/* subkey2 */
882285809Sscottl                             agNULL,
883285809Sscottl                             agNULL,
884285809Sscottl                             agNULL,      /* subkey5 */
885285809Sscottl                             IBQueueSize, /* valueName */
886285809Sscottl                             buffer,
887285809Sscottl                             buffLen,
888285809Sscottl                             &lenRecv
889285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
890285809Sscottl    {
891285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
892285809Sscottl      {
893285809Sscottl        tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
894285809Sscottl      }
895285809Sscottl      else
896285809Sscottl      {
897285809Sscottl        tdsaAllShared->InboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
898285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue size %d\n", i, tdsaAllShared->InboundQueueSize[i]));
899285809Sscottl      }
900285809Sscottl    }
901285809Sscottl
902285809Sscottl    /*
903285809Sscottl     * read the IBQueueEleSize
904285809Sscottl     */
905285809Sscottl
906285809Sscottl    osti_memset(buffer, 0, buffLen);
907285809Sscottl    lenRecv = 0;
908285809Sscottl
909285809Sscottl    if ((ostiGetTransportParam(
910285809Sscottl                             tiRoot,
911285809Sscottl                             cardNum,   /* key */
912285809Sscottl                             SwParmsStr,  /* subkey1 */
913285809Sscottl                             IBQueueProps,/* subkey2 */
914285809Sscottl                             agNULL,
915285809Sscottl                             agNULL,
916285809Sscottl                             agNULL,      /* subkey5 */
917285809Sscottl                             IBQueueEleSize, /* valueName */
918285809Sscottl                             buffer,
919285809Sscottl                             buffLen,
920285809Sscottl                             &lenRecv
921285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
922285809Sscottl    {
923285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
924285809Sscottl      {
925285809Sscottl        tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
926285809Sscottl      }
927285809Sscottl      else
928285809Sscottl      {
929285809Sscottl        tdsaAllShared->InboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
930285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d IB queue ele size %d\n", i, tdsaAllShared->InboundQueueEleSize[i]));
931285809Sscottl      }
932285809Sscottl    }
933285809Sscottl
934285809Sscottl    /*
935285809Sscottl     * read the IBQueuePriority
936285809Sscottl     */
937285809Sscottl
938285809Sscottl    osti_memset(buffer, 0, buffLen);
939285809Sscottl    lenRecv = 0;
940285809Sscottl
941285809Sscottl    if ((ostiGetTransportParam(
942285809Sscottl                             tiRoot,
943285809Sscottl                             cardNum,   /* key */
944285809Sscottl                             SwParmsStr,  /* subkey1 */
945285809Sscottl                             IBQueueProps,/* subkey2 */
946285809Sscottl                             agNULL,
947285809Sscottl                             agNULL,
948285809Sscottl                             agNULL,      /* subkey5 */
949285809Sscottl                             IBQueuePriority, /* valueName */
950285809Sscottl                             buffer,
951285809Sscottl                             buffLen,
952285809Sscottl                             &lenRecv
953285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
954285809Sscottl    {
955285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
956285809Sscottl      {
957285809Sscottl        tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
958285809Sscottl      }
959285809Sscottl      else
960285809Sscottl      {
961285809Sscottl        tdsaAllShared->InboundQueuePriority[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
962285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d priority %d\n", cardNum, i, tdsaAllShared->InboundQueuePriority[i]));
963285809Sscottl      }
964285809Sscottl    }
965285809Sscottl
966285809Sscottl    /**********************************************/
967285809Sscottl    osti_memset(buffer, 0, buffLen);
968285809Sscottl    lenRecv = 0;
969285809Sscottl  }/* end of loop */
970285809Sscottl
971285809Sscottl
972285809Sscottl
973285809Sscottl  osti_memset(buffer, 0, buffLen);
974285809Sscottl  lenRecv = 0;
975285809Sscottl
976285809Sscottl  for (i=0;i<QueueConfig->numOutboundQueues;i++)
977285809Sscottl  {
978285809Sscottl    osti_sprintf(OBQueueSize,"OBQueueNumElements%d", i);
979285809Sscottl    osti_sprintf(OBQueueEleSize,"OBQueueElementSize%d", i);
980285809Sscottl    osti_sprintf(OBQueueInterruptDelay,"OBQueueInterruptDelay%d", i);
981285809Sscottl    osti_sprintf(OBQueueInterruptCount,"OBQueueInterruptCount%d", i);
982285809Sscottl    osti_sprintf(OBQueueInterruptEnable,"OBQueueInterruptEnable%d", i);
983285809Sscottl
984285809Sscottl    /*
985285809Sscottl     * read the OBQueueSize
986285809Sscottl     */
987285809Sscottl    osti_memset(buffer, 0, buffLen);
988285809Sscottl    lenRecv = 0;
989285809Sscottl
990285809Sscottl    if ((ostiGetTransportParam(
991285809Sscottl                             tiRoot,
992285809Sscottl                             cardNum,   /* key */
993285809Sscottl                             SwParmsStr,  /* subkey1 */
994285809Sscottl                             OBQueueProps,      /* subkey2 */
995285809Sscottl                             agNULL,
996285809Sscottl                             agNULL,
997285809Sscottl                             agNULL,      /* subkey5 */
998285809Sscottl                             OBQueueSize, /* valueName */
999285809Sscottl                             buffer,
1000285809Sscottl                             buffLen,
1001285809Sscottl                             &lenRecv
1002285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1003285809Sscottl    {
1004285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1005285809Sscottl      {
1006285809Sscottl        tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1007285809Sscottl      }
1008285809Sscottl      else
1009285809Sscottl      {
1010285809Sscottl        tdsaAllShared->OutboundQueueSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1011285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue size %d\n", i, tdsaAllShared->OutboundQueueSize[i]));
1012285809Sscottl
1013285809Sscottl      }
1014285809Sscottl    }
1015285809Sscottl
1016285809Sscottl    /*
1017285809Sscottl     * read the OBQueueEleSize
1018285809Sscottl     */
1019285809Sscottl    osti_memset(buffer, 0, buffLen);
1020285809Sscottl    lenRecv = 0;
1021285809Sscottl
1022285809Sscottl
1023285809Sscottl    if ((ostiGetTransportParam(
1024285809Sscottl                             tiRoot,
1025285809Sscottl                             cardNum,   /* key */
1026285809Sscottl                             SwParmsStr,  /* subkey1 */
1027285809Sscottl                             OBQueueProps,      /* subkey2 */
1028285809Sscottl                             agNULL,
1029285809Sscottl                             agNULL,
1030285809Sscottl                             agNULL,      /* subkey5 */
1031285809Sscottl                             OBQueueEleSize, /* valueName */
1032285809Sscottl                             buffer,
1033285809Sscottl                             buffLen,
1034285809Sscottl                             &lenRecv
1035285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1036285809Sscottl    {
1037285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1038285809Sscottl      {
1039285809Sscottl        tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1040285809Sscottl      }
1041285809Sscottl      else
1042285809Sscottl      {
1043285809Sscottl        tdsaAllShared->OutboundQueueEleSize[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1044285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: queue number %d OB queue ele size %d\n", i, tdsaAllShared->OutboundQueueEleSize[i]));
1045285809Sscottl
1046285809Sscottl      }
1047285809Sscottl    }
1048285809Sscottl
1049285809Sscottl    /*
1050285809Sscottl     * read the OBQueueInterruptDelay
1051285809Sscottl     */
1052285809Sscottl    osti_memset(buffer, 0, buffLen);
1053285809Sscottl    lenRecv = 0;
1054285809Sscottl
1055285809Sscottl
1056285809Sscottl    if ((ostiGetTransportParam(
1057285809Sscottl                             tiRoot,
1058285809Sscottl                             cardNum,   /* key */
1059285809Sscottl                             SwParmsStr,  /* subkey1 */
1060285809Sscottl                             OBQueueProps,      /* subkey2 */
1061285809Sscottl                             agNULL,
1062285809Sscottl                             agNULL,
1063285809Sscottl                             agNULL,      /* subkey5 */
1064285809Sscottl                             OBQueueInterruptDelay, /* valueName */
1065285809Sscottl                             buffer,
1066285809Sscottl                             buffLen,
1067285809Sscottl                             &lenRecv
1068285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1069285809Sscottl    {
1070285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1071285809Sscottl      {
1072285809Sscottl        tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1073285809Sscottl      }
1074285809Sscottl      else
1075285809Sscottl      {
1076285809Sscottl        tdsaAllShared->OutboundQueueInterruptDelay[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1077285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt delay %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptDelay[i]));
1078285809Sscottl
1079285809Sscottl      }
1080285809Sscottl    }
1081285809Sscottl
1082285809Sscottl    /*
1083285809Sscottl     * read the OBQueueInterruptCount
1084285809Sscottl     */
1085285809Sscottl
1086285809Sscottl    osti_memset(buffer, 0, buffLen);
1087285809Sscottl    lenRecv = 0;
1088285809Sscottl
1089285809Sscottl    if ((ostiGetTransportParam(
1090285809Sscottl                             tiRoot,
1091285809Sscottl                             cardNum,   /* key */
1092285809Sscottl                             SwParmsStr,  /* subkey1 */
1093285809Sscottl                             OBQueueProps,      /* subkey2 */
1094285809Sscottl                             agNULL,
1095285809Sscottl                             agNULL,
1096285809Sscottl                             agNULL,      /* subkey5 */
1097285809Sscottl                             OBQueueInterruptCount, /* valueName */
1098285809Sscottl                             buffer,
1099285809Sscottl                             buffLen,
1100285809Sscottl                             &lenRecv
1101285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1102285809Sscottl    {
1103285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1104285809Sscottl      {
1105285809Sscottl        tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1106285809Sscottl      }
1107285809Sscottl      else
1108285809Sscottl      {
1109285809Sscottl        tdsaAllShared->OutboundQueueInterruptCount[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1110285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt count %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptCount[i]));
1111285809Sscottl      }
1112285809Sscottl    }
1113285809Sscottl
1114285809Sscottl
1115285809Sscottl    /*
1116285809Sscottl     * read the OBQueueInterruptEnable
1117285809Sscottl     */
1118285809Sscottl
1119285809Sscottl    osti_memset(buffer, 0, buffLen);
1120285809Sscottl    lenRecv = 0;
1121285809Sscottl
1122285809Sscottl    if ((ostiGetTransportParam(
1123285809Sscottl                             tiRoot,
1124285809Sscottl                             cardNum,   /* key */
1125285809Sscottl                             SwParmsStr,  /* subkey1 */
1126285809Sscottl                             OBQueueProps,      /* subkey2 */
1127285809Sscottl                             agNULL,
1128285809Sscottl                             agNULL,
1129285809Sscottl                             agNULL,      /* subkey5 */
1130285809Sscottl                             OBQueueInterruptEnable, /* valueName */
1131285809Sscottl                             buffer,
1132285809Sscottl                             buffLen,
1133285809Sscottl                             &lenRecv
1134285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1135285809Sscottl    {
1136285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1137285809Sscottl      {
1138285809Sscottl        tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 0);
1139285809Sscottl      }
1140285809Sscottl      else
1141285809Sscottl      {
1142285809Sscottl        tdsaAllShared->OutboundQueueInterruptEnable[i] = (bit16) osti_strtoul (buffer, &pLastUsedChar, 10);
1143285809Sscottl        TI_DBG6(("tdsaGetSwConfigParams: card number %s queue number %d interrupt enable %d\n", cardNum, i, tdsaAllShared->OutboundQueueInterruptEnable[i]));
1144285809Sscottl      }
1145285809Sscottl    }
1146285809Sscottl
1147285809Sscottl
1148285809Sscottl    /**********************************************/
1149285809Sscottl    osti_memset(buffer, 0, buffLen);
1150285809Sscottl    lenRecv = 0;
1151285809Sscottl
1152285809Sscottl  }/* end of loop */
1153285809Sscottl
1154285809Sscottl  /* process event log related parameters */
1155285809Sscottl  osti_memset(buffer, 0, buffLen);
1156285809Sscottl  lenRecv = 0;
1157285809Sscottl
1158285809Sscottl  if ((ostiGetTransportParam(
1159285809Sscottl                             tiRoot,
1160285809Sscottl                             globalStr,   /* key */
1161285809Sscottl                             SwParmsStr,  /* subkey1 */
1162285809Sscottl                             agNULL,      /* subkey2 */
1163285809Sscottl                             agNULL,
1164285809Sscottl                             agNULL,
1165285809Sscottl                             agNULL,      /* subkey5 */
1166285809Sscottl                             "EventLogSize1", /* valueName */
1167285809Sscottl                             buffer,
1168285809Sscottl                             buffLen,
1169285809Sscottl                             &lenRecv
1170285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1171285809Sscottl  {
1172285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1173285809Sscottl    {
1174285809Sscottl      SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 0);
1175285809Sscottl    }
1176285809Sscottl    else
1177285809Sscottl    {
1178285809Sscottl      SwConfig->sizefEventLog1 = osti_strtoul (buffer, &pLastUsedChar, 10);
1179285809Sscottl    }
1180285809Sscottl  }
1181285809Sscottl
1182285809Sscottl  osti_memset(buffer, 0, buffLen);
1183285809Sscottl  lenRecv = 0;
1184285809Sscottl
1185285809Sscottl  if ((ostiGetTransportParam(
1186285809Sscottl                             tiRoot,
1187285809Sscottl                             globalStr,   /* key */
1188285809Sscottl                             SwParmsStr,  /* subkey1 */
1189285809Sscottl                             agNULL,      /* subkey2 */
1190285809Sscottl                             agNULL,
1191285809Sscottl                             agNULL,
1192285809Sscottl                             agNULL,      /* subkey5 */
1193285809Sscottl                             "EventLogOption1", /* valueName */
1194285809Sscottl                             buffer,
1195285809Sscottl                             buffLen,
1196285809Sscottl                             &lenRecv
1197285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1198285809Sscottl  {
1199285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1200285809Sscottl    {
1201285809Sscottl      SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1202285809Sscottl    }
1203285809Sscottl    else
1204285809Sscottl    {
1205285809Sscottl      SwConfig->eventLog1Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1206285809Sscottl    }
1207285809Sscottl  }
1208285809Sscottl
1209285809Sscottl  osti_memset(buffer, 0, buffLen);
1210285809Sscottl  lenRecv = 0;
1211285809Sscottl
1212285809Sscottl  if ((ostiGetTransportParam(
1213285809Sscottl                             tiRoot,
1214285809Sscottl                             globalStr,   /* key */
1215285809Sscottl                             SwParmsStr,  /* subkey1 */
1216285809Sscottl                             agNULL,      /* subkey2 */
1217285809Sscottl                             agNULL,
1218285809Sscottl                             agNULL,
1219285809Sscottl                             agNULL,      /* subkey5 */
1220285809Sscottl                             "EventLogSize2", /* valueName *//* IOP size in K dWords   */
1221285809Sscottl                             buffer,
1222285809Sscottl                             buffLen,
1223285809Sscottl                             &lenRecv
1224285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1225285809Sscottl  {
1226285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1227285809Sscottl    {
1228285809Sscottl      SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 0);
1229285809Sscottl    }
1230285809Sscottl    else
1231285809Sscottl    {
1232285809Sscottl      SwConfig->sizefEventLog2 = osti_strtoul (buffer, &pLastUsedChar, 10);
1233285809Sscottl    }
1234285809Sscottl  }
1235285809Sscottl
1236285809Sscottl  osti_memset(buffer, 0, buffLen);
1237285809Sscottl  lenRecv = 0;
1238285809Sscottl
1239285809Sscottl  if ((ostiGetTransportParam(
1240285809Sscottl                             tiRoot,
1241285809Sscottl                             globalStr,   /* key */
1242285809Sscottl                             SwParmsStr,  /* subkey1 */
1243285809Sscottl                             agNULL,      /* subkey2 */
1244285809Sscottl                             agNULL,
1245285809Sscottl                             agNULL,
1246285809Sscottl                             agNULL,      /* subkey5 */
1247285809Sscottl                             "EventLogOption2", /* valueName */
1248285809Sscottl                             buffer,
1249285809Sscottl                             buffLen,
1250285809Sscottl                             &lenRecv
1251285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1252285809Sscottl  {
1253285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1254285809Sscottl    {
1255285809Sscottl      SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 0);
1256285809Sscottl    }
1257285809Sscottl    else
1258285809Sscottl    {
1259285809Sscottl      SwConfig->eventLog2Option = osti_strtoul (buffer, &pLastUsedChar, 10);
1260285809Sscottl    }
1261285809Sscottl  }
1262285809Sscottl  /* end of event log related parameters */
1263285809Sscottl
1264285809Sscottl  /*
1265285809Sscottl    HDA parameters
1266285809Sscottl  */
1267285809Sscottl  osti_memset(buffer, 0, buffLen);
1268285809Sscottl  lenRecv = 0;
1269285809Sscottl
1270285809Sscottl  if ((ostiGetTransportParam(
1271285809Sscottl                             tiRoot,
1272285809Sscottl                             globalStr,   /* key */
1273285809Sscottl                             SwParmsStr,  /* subkey1 */
1274285809Sscottl                             agNULL,      /* subkey2 */
1275285809Sscottl                             agNULL,
1276285809Sscottl                             agNULL,
1277285809Sscottl                             agNULL,      /* subkey5 */
1278285809Sscottl                             "HDASupport", /* valueName */
1279285809Sscottl                             buffer,
1280285809Sscottl                             buffLen,
1281285809Sscottl                             &lenRecv
1282285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1283285809Sscottl  {
1284285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1285285809Sscottl    {
1286285809Sscottl      SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 0);
1287285809Sscottl    }
1288285809Sscottl    else
1289285809Sscottl    {
1290285809Sscottl      SwConfig->hostDirectAccessSupport = osti_strtoul (buffer, &pLastUsedChar, 10);
1291285809Sscottl    }
1292285809Sscottl  }
1293285809Sscottl
1294285809Sscottl  osti_memset(buffer, 0, buffLen);
1295285809Sscottl  lenRecv = 0;
1296285809Sscottl
1297285809Sscottl  if ((ostiGetTransportParam(
1298285809Sscottl                             tiRoot,
1299285809Sscottl                             globalStr,   /* key */
1300285809Sscottl                             SwParmsStr,  /* subkey1 */
1301285809Sscottl                             agNULL,      /* subkey2 */
1302285809Sscottl                             agNULL,
1303285809Sscottl                             agNULL,
1304285809Sscottl                             agNULL,      /* subkey5 */
1305285809Sscottl                             "HDAMode", /* valueName */
1306285809Sscottl                             buffer,
1307285809Sscottl                             buffLen,
1308285809Sscottl                             &lenRecv
1309285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1310285809Sscottl  {
1311285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1312285809Sscottl    {
1313285809Sscottl      SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 0);
1314285809Sscottl    }
1315285809Sscottl    else
1316285809Sscottl    {
1317285809Sscottl      SwConfig->hostDirectAccessMode = osti_strtoul (buffer, &pLastUsedChar, 10);
1318285809Sscottl    }
1319285809Sscottl  }
1320285809Sscottl  /* the end of HDA parameters */
1321285809Sscottl
1322285809Sscottl  /* FW configuration */
1323285809Sscottl  osti_memset(buffer, 0, buffLen);
1324285809Sscottl  lenRecv = 0;
1325285809Sscottl
1326285809Sscottl  if ((ostiGetTransportParam(
1327285809Sscottl                             tiRoot,
1328285809Sscottl                             globalStr,   /* key */
1329285809Sscottl                             SwParmsStr,  /* subkey1 */
1330285809Sscottl                             agNULL,      /* subkey2 */
1331285809Sscottl                             agNULL,
1332285809Sscottl                             agNULL,
1333285809Sscottl                             agNULL,      /* subkey5 */
1334285809Sscottl                             "FWConfig", /* valueName */
1335285809Sscottl                             buffer,
1336285809Sscottl                             buffLen,
1337285809Sscottl                             &lenRecv
1338285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1339285809Sscottl  {
1340285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1341285809Sscottl    {
1342285809Sscottl      SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 0);
1343285809Sscottl    }
1344285809Sscottl    else
1345285809Sscottl    {
1346285809Sscottl      SwConfig->FWConfig = osti_strtoul (buffer, &pLastUsedChar, 10);
1347285809Sscottl    }
1348285809Sscottl  }
1349285809Sscottl  /* The end of FW configuration */
1350285809Sscottl
1351285809Sscottl  /* IQ Normal priority and High priority */
1352285809Sscottl  osti_memset(buffer, 0, buffLen);
1353285809Sscottl  lenRecv = 0;
1354285809Sscottl
1355285809Sscottl  if ((ostiGetTransportParam(
1356285809Sscottl                             tiRoot,
1357285809Sscottl                             globalStr,   /* key */
1358285809Sscottl                             SwParmsStr,  /* subkey1 */
1359285809Sscottl                             IBQueueProps,/* subkey2 */
1360285809Sscottl                             agNULL,
1361285809Sscottl                             agNULL,
1362285809Sscottl                             agNULL,      /* subkey5 */
1363285809Sscottl                             "IQNQDepth", /* valueName */
1364285809Sscottl                             buffer,
1365285809Sscottl                             buffLen,
1366285809Sscottl                             &lenRecv
1367285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1368285809Sscottl    {
1369285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1370285809Sscottl      {
1371285809Sscottl        QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
1372285809Sscottl      }
1373285809Sscottl      else
1374285809Sscottl      {
1375285809Sscottl        QueueConfig->iqNormalPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
1376285809Sscottl      }
1377285809Sscottl    }
1378285809Sscottl
1379285809Sscottl  osti_memset(buffer, 0, buffLen);
1380285809Sscottl  lenRecv = 0;
1381285809Sscottl
1382285809Sscottl  if ((ostiGetTransportParam(
1383285809Sscottl                             tiRoot,
1384285809Sscottl                             globalStr,   /* key */
1385285809Sscottl                             SwParmsStr,  /* subkey1 */
1386285809Sscottl                             IBQueueProps,/* subkey2 */
1387285809Sscottl                             agNULL,
1388285809Sscottl                             agNULL,
1389285809Sscottl                             agNULL,      /* subkey5 */
1390285809Sscottl                             "IQHQDepth", /* valueName */
1391285809Sscottl                             buffer,
1392285809Sscottl                             buffLen,
1393285809Sscottl                             &lenRecv
1394285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1395285809Sscottl    {
1396285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1397285809Sscottl      {
1398285809Sscottl        QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 0);
1399285809Sscottl      }
1400285809Sscottl      else
1401285809Sscottl      {
1402285809Sscottl        QueueConfig->iqHighPriorityProcessingDepth = (bit8) osti_strtoul (buffer, &pLastUsedChar, 10);
1403285809Sscottl      }
1404285809Sscottl    }
1405285809Sscottl  /* End IQ Normal priority and High priority */
1406285809Sscottl
1407285809Sscottl  /* Start port timeout value */
1408285809Sscottl  osti_memset(buffer, 0, buffLen);
1409285809Sscottl  lenRecv = 0;
1410285809Sscottl
1411285809Sscottl  if ((ostiGetTransportParam(
1412285809Sscottl                             tiRoot,
1413285809Sscottl                             globalStr,   /* key */
1414285809Sscottl                             SwParmsStr,  /* subkey1 */
1415285809Sscottl                             agNULL,/* subkey2 */
1416285809Sscottl                             agNULL,
1417285809Sscottl                             agNULL,
1418285809Sscottl                             agNULL,      /* subkey5 */
1419285809Sscottl                             "PortTMO", /* valueName */
1420285809Sscottl                             buffer,
1421285809Sscottl                             buffLen,
1422285809Sscottl                             &lenRecv
1423285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1424285809Sscottl    {
1425285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1426285809Sscottl      {
1427285809Sscottl        tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1428285809Sscottl      }
1429285809Sscottl      else
1430285809Sscottl      {
1431285809Sscottl        tdsaAllShared->portTMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1432285809Sscottl      }
1433285809Sscottl    }
1434285809Sscottl  /* End port timeout value */
1435285809Sscottl
1436285809Sscottl#ifdef SA_ENABLE_TRACE_FUNCTIONS
1437285809Sscottl  osti_memset(buffer, 0, buffLen);
1438285809Sscottl  lenRecv = 0;
1439285809Sscottl  if ((ostiGetTransportParam(
1440285809Sscottl                             tiRoot,
1441285809Sscottl                             globalStr,   /* key */
1442285809Sscottl                             SwParmsStr,  /* subkey1 */
1443285809Sscottl                             agNULL,      /* subkey2 */
1444285809Sscottl                             agNULL,
1445285809Sscottl                             agNULL,
1446285809Sscottl                             agNULL,      /* subkey5 */
1447285809Sscottl                             "TraceDestination", /* valueName */
1448285809Sscottl                             buffer,
1449285809Sscottl                             buffLen,
1450285809Sscottl                             &lenRecv
1451285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1452285809Sscottl  {
1453285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1454285809Sscottl    {
1455285809Sscottl      SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 0);
1456285809Sscottl    }
1457285809Sscottl    else
1458285809Sscottl    {
1459285809Sscottl      SwConfig->TraceDestination = osti_strtoul (buffer, &pLastUsedChar, 10);
1460285809Sscottl    }
1461285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceDestination %d\n",SwConfig->TraceDestination));
1462285809Sscottl  }
1463285809Sscottl
1464285809Sscottl  osti_memset(buffer, 0, buffLen);
1465285809Sscottl  lenRecv = 0;
1466285809Sscottl  if ((ostiGetTransportParam(
1467285809Sscottl                             tiRoot,
1468285809Sscottl                             globalStr,   /* key */
1469285809Sscottl                             SwParmsStr,  /* subkey1 */
1470285809Sscottl                             agNULL,      /* subkey2 */
1471285809Sscottl                             agNULL,
1472285809Sscottl                             agNULL,
1473285809Sscottl                             agNULL,      /* subkey5 */
1474285809Sscottl                             "TraceMask", /* valueName */
1475285809Sscottl                             buffer,
1476285809Sscottl                             buffLen,
1477285809Sscottl                             &lenRecv
1478285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1479285809Sscottl  {
1480285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1481285809Sscottl    {
1482285809Sscottl      SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 0);
1483285809Sscottl    }
1484285809Sscottl    else
1485285809Sscottl    {
1486285809Sscottl      SwConfig->TraceMask = osti_strtoul (buffer, &pLastUsedChar, 10);
1487285809Sscottl    }
1488285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: SwConfig->TraceMask %d %X\n",SwConfig->TraceMask,SwConfig->TraceMask));
1489285809Sscottl  }
1490285809Sscottl#endif /*# SA_ENABLE_TRACE_FUNCTIONS */
1491285809Sscottl
1492285809Sscottl#ifdef AGTIAPI_CTL
1493285809Sscottl  /*
1494285809Sscottl   * read the SAS Connection Time Limit parameter
1495285809Sscottl   */
1496285809Sscottl  osti_memset(buffer, 0, buffLen);
1497285809Sscottl  lenRecv = 0;
1498285809Sscottl  tdsaAllShared->SASConnectTimeLimit = 0;
1499285809Sscottl
1500285809Sscottl  if ((ostiGetTransportParam(
1501285809Sscottl                             tiRoot,
1502285809Sscottl                             globalStr,   /* key */
1503285809Sscottl                             SwParmsStr,  /* subkey1 */
1504285809Sscottl                             agNULL,      /* subkey2 */
1505285809Sscottl                             agNULL,
1506285809Sscottl                             agNULL,
1507285809Sscottl                             agNULL,      /* subkey5 */
1508285809Sscottl                             "SASCTL",    /* valueName */
1509285809Sscottl                             buffer,
1510285809Sscottl                             buffLen,
1511285809Sscottl                             &lenRecv
1512285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1513285809Sscottl  {
1514285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1515285809Sscottl      tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 0);
1516285809Sscottl    else
1517285809Sscottl      tdsaAllShared->SASConnectTimeLimit = osti_strtoul (buffer, &pLastUsedChar, 10);
1518285809Sscottl  }
1519285809Sscottl#endif
1520285809Sscottl
1521285809Sscottl  /* Start FCA value */
1522285809Sscottl  osti_memset(buffer, 0, buffLen);
1523285809Sscottl  lenRecv = 0;
1524285809Sscottl
1525285809Sscottl  tdsaAllShared->FCA = 1; /* No FCA by default */
1526285809Sscottl
1527285809Sscottl  if ((ostiGetTransportParam(
1528285809Sscottl                             tiRoot,
1529285809Sscottl                             globalStr,   /* key */
1530285809Sscottl                             "InitiatorParms",  /* subkey1 */
1531285809Sscottl                             agNULL,/* subkey2 */
1532285809Sscottl                             agNULL,
1533285809Sscottl                             agNULL,
1534285809Sscottl                             agNULL,      /* subkey5 */
1535285809Sscottl                             "FCA", /* valueName */
1536285809Sscottl                             buffer,
1537285809Sscottl                             buffLen,
1538285809Sscottl                             &lenRecv
1539285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1540285809Sscottl    {
1541285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1542285809Sscottl      {
1543285809Sscottl        tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 0);
1544285809Sscottl      }
1545285809Sscottl      else
1546285809Sscottl      {
1547285809Sscottl        tdsaAllShared->FCA = osti_strtoul (buffer, &pLastUsedChar, 10);
1548285809Sscottl      }
1549285809Sscottl    }
1550285809Sscottl  /* End FCA value */
1551285809Sscottl
1552285809Sscottl  /* Start ResetInDiscovery value */
1553285809Sscottl  osti_memset(buffer, 0, buffLen);
1554285809Sscottl  lenRecv = 0;
1555285809Sscottl
1556285809Sscottl  tdsaAllShared->ResetInDiscovery = 0; /* No ResetInDiscovery by default */
1557285809Sscottl
1558285809Sscottl  if ((ostiGetTransportParam(
1559285809Sscottl                             tiRoot,
1560285809Sscottl                             globalStr,   /* key */
1561285809Sscottl                             "InitiatorParms",  /* subkey1 */
1562285809Sscottl                             agNULL,/* subkey2 */
1563285809Sscottl                             agNULL,
1564285809Sscottl                             agNULL,
1565285809Sscottl                             agNULL,      /* subkey5 */
1566285809Sscottl                             "ResetInDiscovery", /* valueName */
1567285809Sscottl                             buffer,
1568285809Sscottl                             buffLen,
1569285809Sscottl                             &lenRecv
1570285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1571285809Sscottl    {
1572285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
1573285809Sscottl      {
1574285809Sscottl        tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 0);
1575285809Sscottl      }
1576285809Sscottl      else
1577285809Sscottl      {
1578285809Sscottl        tdsaAllShared->ResetInDiscovery = osti_strtoul (buffer, &pLastUsedChar, 10);
1579285809Sscottl      }
1580285809Sscottl    }
1581285809Sscottl  /* End ResetInDiscovery value */
1582285809Sscottl
1583285809Sscottl  /* Start MCN value */
1584285809Sscottl  osti_memset(buffer, 0, buffLen);
1585285809Sscottl  lenRecv = 0;
1586285809Sscottl
1587285809Sscottl  tdsaAllShared->MCN = 1; /* default MCN */
1588285809Sscottl
1589285809Sscottl  if ((ostiGetTransportParam(
1590285809Sscottl                             tiRoot,
1591285809Sscottl                             globalStr,   /* key */
1592285809Sscottl                             SwParmsStr,  /* subkey1 */
1593285809Sscottl                             agNULL,/* subkey2 */
1594285809Sscottl                             agNULL,
1595285809Sscottl                             agNULL,
1596285809Sscottl                             agNULL,      /* subkey5 */
1597285809Sscottl                             "MCN", /* valueName */
1598285809Sscottl                             buffer,
1599285809Sscottl                             buffLen,
1600285809Sscottl                             &lenRecv
1601285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1602285809Sscottl  {
1603285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1604285809Sscottl    {
1605285809Sscottl      tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 0);
1606285809Sscottl    }
1607285809Sscottl    else
1608285809Sscottl    {
1609285809Sscottl      tdsaAllShared->MCN = osti_strtoul (buffer, &pLastUsedChar, 10);
1610285809Sscottl    }
1611285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: MCN %d\n", tdsaAllShared->MCN));
1612285809Sscottl  }
1613285809Sscottl  /* End MCN value */
1614285809Sscottl
1615285809Sscottl  /* Start sflag value */
1616285809Sscottl  osti_memset(buffer, 0, buffLen);
1617285809Sscottl  lenRecv = 0;
1618285809Sscottl
1619285809Sscottl  tdsaAllShared->sflag = 0; /* default sflag */
1620285809Sscottl
1621285809Sscottl  if ((ostiGetTransportParam(
1622285809Sscottl                             tiRoot,
1623285809Sscottl                             globalStr,   /* key */
1624285809Sscottl                             SwParmsStr,  /* subkey1 */
1625285809Sscottl                             agNULL,      /* subkey2 */
1626285809Sscottl                             agNULL,
1627285809Sscottl                             agNULL,
1628285809Sscottl                             agNULL,      /* subkey5 */
1629285809Sscottl                             "Sflag",     /* valueName */
1630285809Sscottl                             buffer,
1631285809Sscottl                             buffLen,
1632285809Sscottl                             &lenRecv
1633285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1634285809Sscottl  {
1635285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1636285809Sscottl    {
1637285809Sscottl      tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 0);
1638285809Sscottl    }
1639285809Sscottl    else
1640285809Sscottl    {
1641285809Sscottl      tdsaAllShared->sflag = osti_strtoul (buffer, &pLastUsedChar, 10);
1642285809Sscottl    }
1643285809Sscottl    TI_DBG1(("tdsaGetSwConfigParams: sflag %d\n", tdsaAllShared->sflag));
1644285809Sscottl  }
1645285809Sscottl  /* End sflag value */
1646285809Sscottl
1647285809Sscottl  /* Start enable DIF */
1648285809Sscottl  osti_memset(buffer, 0, buffLen);
1649285809Sscottl  lenRecv = 0;
1650285809Sscottl
1651285809Sscottl  if ((ostiGetTransportParam(
1652285809Sscottl                             tiRoot,
1653285809Sscottl                             globalStr,   /* key */
1654285809Sscottl                             SwParmsStr,  /* subkey1 */
1655285809Sscottl                             agNULL,/* subkey2 */
1656285809Sscottl                             agNULL,
1657285809Sscottl                             agNULL,
1658285809Sscottl                             agNULL,      /* subkey5 */
1659285809Sscottl                             "enableDIF", /* valueName */
1660285809Sscottl                             buffer,
1661285809Sscottl                             buffLen,
1662285809Sscottl                             &lenRecv
1663285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1664285809Sscottl  {
1665285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1666285809Sscottl    {
1667285809Sscottl      enableDIF = osti_strtoul (buffer, &pLastUsedChar, 0);
1668285809Sscottl    }
1669285809Sscottl    else
1670285809Sscottl    {
1671285809Sscottl      enableDIF = osti_strtoul (buffer, &pLastUsedChar, 10);
1672285809Sscottl    }
1673285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: enableDIF %d\n", enableDIF));
1674285809Sscottl    if (enableDIF)
1675285809Sscottl    {
1676285809Sscottl      SwConfig->enableDIF = agTRUE;
1677285809Sscottl    }
1678285809Sscottl    else
1679285809Sscottl    {
1680285809Sscottl      SwConfig->enableDIF = agFALSE;
1681285809Sscottl    }
1682285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableDIF %d\n", SwConfig->enableDIF));
1683285809Sscottl  }
1684285809Sscottl  /* End enable DIF */
1685285809Sscottl
1686285809Sscottl
1687285809Sscottl  /* Start enable Encryption */
1688285809Sscottl  osti_memset(buffer, 0, buffLen);
1689285809Sscottl  lenRecv = 0;
1690285809Sscottl
1691285809Sscottl  if ((ostiGetTransportParam(
1692285809Sscottl                             tiRoot,
1693285809Sscottl                             globalStr,   /* key */
1694285809Sscottl                             SwParmsStr,  /* subkey1 */
1695285809Sscottl                             agNULL,/* subkey2 */
1696285809Sscottl                             agNULL,
1697285809Sscottl                             agNULL,
1698285809Sscottl                             agNULL,      /* subkey5 */
1699285809Sscottl                             "enableEncryption", /* valueName */
1700285809Sscottl                             buffer,
1701285809Sscottl                             buffLen,
1702285809Sscottl                             &lenRecv
1703285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1704285809Sscottl  {
1705285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1706285809Sscottl    {
1707285809Sscottl      enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 0);
1708285809Sscottl    }
1709285809Sscottl    else
1710285809Sscottl    {
1711285809Sscottl      enableEncryption = osti_strtoul (buffer, &pLastUsedChar, 10);
1712285809Sscottl    }
1713285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: enableEncryption %d\n", enableEncryption));
1714285809Sscottl    if (enableEncryption)
1715285809Sscottl    {
1716285809Sscottl      SwConfig->enableEncryption = agTRUE;
1717285809Sscottl    }
1718285809Sscottl    else
1719285809Sscottl    {
1720285809Sscottl      SwConfig->enableEncryption = agFALSE;
1721285809Sscottl    }
1722285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: SwConfig->enableEncryption %d\n", SwConfig->enableEncryption));
1723285809Sscottl  }
1724285809Sscottl  /* End enable Encryption */
1725285809Sscottl
1726285809Sscottl  /* Start allow connection rate change */
1727285809Sscottl  osti_memset(buffer, 0, buffLen);
1728285809Sscottl  lenRecv = 0;
1729285809Sscottl  tdsaAllShared->RateAdjust = 0; /* No rate adjust by default */
1730285809Sscottl  if ((ostiGetTransportParam(
1731285809Sscottl                             tiRoot,
1732285809Sscottl                             globalStr,   /* key */
1733285809Sscottl                             SwParmsStr,  /* subkey1 */
1734285809Sscottl                             agNULL,/* subkey2 */
1735285809Sscottl                             agNULL,
1736285809Sscottl                             agNULL,
1737285809Sscottl                             agNULL,      /* subkey5 */
1738285809Sscottl                             "RateAdjust", /* valueName */
1739285809Sscottl                             buffer,
1740285809Sscottl                             buffLen,
1741285809Sscottl                             &lenRecv
1742285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1743285809Sscottl  {
1744285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1745285809Sscottl    {
1746285809Sscottl      tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 0);
1747285809Sscottl    }
1748285809Sscottl    else
1749285809Sscottl    {
1750285809Sscottl      tdsaAllShared->RateAdjust = osti_strtoul (buffer, &pLastUsedChar, 10);
1751285809Sscottl    }
1752285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: tdsaAllShared->RateAdjust %d\n", tdsaAllShared->RateAdjust));
1753285809Sscottl  }
1754285809Sscottl  /* End allow connection rate change */
1755285809Sscottl
1756285809Sscottl
1757285809Sscottl#ifdef SA_CONFIG_MDFD_REGISTRY
1758285809Sscottl  /* Start disable MDF */
1759285809Sscottl  osti_memset(buffer, 0, buffLen);
1760285809Sscottl  lenRecv = 0;
1761285809Sscottl
1762285809Sscottl  if ((ostiGetTransportParam(
1763285809Sscottl                             tiRoot,
1764285809Sscottl                             globalStr,   /* key */
1765285809Sscottl                             SwParmsStr,  /* subkey1 */
1766285809Sscottl                             agNULL,/* subkey2 */
1767285809Sscottl                             agNULL,
1768285809Sscottl                             agNULL,
1769285809Sscottl                             agNULL,      /* subkey5 */
1770285809Sscottl                             "disableMDF", /* valueName */
1771285809Sscottl                             buffer,
1772285809Sscottl                             buffLen,
1773285809Sscottl                             &lenRecv
1774285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1775285809Sscottl  {
1776285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1777285809Sscottl    {
1778285809Sscottl      disableMDF = osti_strtoul (buffer, &pLastUsedChar, 0);
1779285809Sscottl    }
1780285809Sscottl    else
1781285809Sscottl    {
1782285809Sscottl      disableMDF = osti_strtoul (buffer, &pLastUsedChar, 10);
1783285809Sscottl    }
1784285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: disableMDF %d\n", disableMDF));
1785285809Sscottl    if (disableMDF)
1786285809Sscottl    {
1787285809Sscottl      SwConfig->disableMDF = agTRUE;
1788285809Sscottl    }
1789285809Sscottl    else
1790285809Sscottl    {
1791285809Sscottl      SwConfig->disableMDF = agFALSE;
1792285809Sscottl    }
1793285809Sscottl    TI_DBG6(("tdsaGetSwConfigParams: SwConfig->disableMDF %d\n", SwConfig->disableMDF));
1794285809Sscottl  }
1795285809Sscottl  /* End disable MDF */
1796285809Sscottl#endif /*SA_CONFIG_MDFD_REGISTRY*/
1797285809Sscottl
1798285809Sscottl  /* Start IT_NEXUS_TIMEOUT */
1799285809Sscottl  osti_memset(buffer, 0, buffLen);
1800285809Sscottl  lenRecv = 0;
1801285809Sscottl
1802285809Sscottl  if ((ostiGetTransportParam(
1803285809Sscottl                             tiRoot,
1804285809Sscottl                             globalStr,   /* key */
1805285809Sscottl                             SwParmsStr,  /* subkey1 */
1806285809Sscottl                             agNULL,/* subkey2 */
1807285809Sscottl                             agNULL,
1808285809Sscottl                             agNULL,
1809285809Sscottl                             agNULL,      /* subkey5 */
1810285809Sscottl                             "IT_NEXUS_TIMEOUT", /* valueName */
1811285809Sscottl                             buffer,
1812285809Sscottl                             buffLen,
1813285809Sscottl                             &lenRecv
1814285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1815285809Sscottl  {
1816285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1817285809Sscottl    {
1818285809Sscottl      tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 0);
1819285809Sscottl    }
1820285809Sscottl    else
1821285809Sscottl    {
1822285809Sscottl      tdsaAllShared->itNexusTimeout = osti_strtoul (buffer, &pLastUsedChar, 10);
1823285809Sscottl    }
1824285809Sscottl    TI_DBG1(("tdsaGetSwConfigParams: tdsaAllShared->itNexusTimeout %d\n", tdsaAllShared->itNexusTimeout));
1825285809Sscottl  }
1826285809Sscottl  /* End IT_NEXUS_TIMEOUT */
1827285809Sscottl
1828285809Sscottl  /* Start stp idle time */
1829285809Sscottl  osti_memset(buffer, 0, buffLen);
1830285809Sscottl  lenRecv = 0;
1831285809Sscottl
1832285809Sscottl  if ((ostiGetTransportParam(
1833285809Sscottl                             tiRoot,
1834285809Sscottl                             globalStr,   /* key */
1835285809Sscottl                             SwParmsStr,  /* subkey1 */
1836285809Sscottl                             agNULL,/* subkey2 */
1837285809Sscottl                             agNULL,
1838285809Sscottl                             agNULL,
1839285809Sscottl                             agNULL,      /* subkey5 */
1840285809Sscottl                             "STPIdleTime", /* valueName */
1841285809Sscottl                             buffer,
1842285809Sscottl                             buffLen,
1843285809Sscottl                             &lenRecv
1844285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1845285809Sscottl  {
1846285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1847285809Sscottl    {
1848285809Sscottl      tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 0);
1849285809Sscottl    }
1850285809Sscottl    else
1851285809Sscottl    {
1852285809Sscottl      tdsaAllShared->stp_idle_time = osti_strtoul (buffer, &pLastUsedChar, 10);
1853285809Sscottl    }
1854285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: STPIdleTime %d\n", tdsaAllShared->stp_idle_time));
1855285809Sscottl  }
1856285809Sscottl  /* End stp idle time */
1857285809Sscottl
1858285809Sscottl  /* Start STP_MCT_TMO */
1859285809Sscottl  osti_memset(buffer, 0, buffLen);
1860285809Sscottl  lenRecv = 0;
1861285809Sscottl
1862285809Sscottl  tdsaAllShared->STP_MCT_TMO = 32;
1863285809Sscottl  if ((ostiGetTransportParam(
1864285809Sscottl                             tiRoot,
1865285809Sscottl                             globalStr,   /* key */
1866285809Sscottl                             SwParmsStr,  /* subkey1 */
1867285809Sscottl                             agNULL,/* subkey2 */
1868285809Sscottl                             agNULL,
1869285809Sscottl                             agNULL,
1870285809Sscottl                             agNULL,      /* subkey5 */
1871285809Sscottl                             "SAS_STP_MCT_TMO", /* valueName */
1872285809Sscottl                             buffer,
1873285809Sscottl                             buffLen,
1874285809Sscottl                             &lenRecv
1875285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1876285809Sscottl  {
1877285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1878285809Sscottl    {
1879285809Sscottl      tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1880285809Sscottl    }
1881285809Sscottl    else
1882285809Sscottl    {
1883285809Sscottl      tdsaAllShared->STP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1884285809Sscottl    }
1885285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: STP_MCT_TMO %d\n", tdsaAllShared->STP_MCT_TMO));
1886285809Sscottl  }
1887285809Sscottl  /* End  STP_MCT_TMO */
1888285809Sscottl
1889285809Sscottl  /* Start SSP_MCT_TMO */
1890285809Sscottl  osti_memset(buffer, 0, buffLen);
1891285809Sscottl  lenRecv = 0;
1892285809Sscottl  tdsaAllShared->SSP_MCT_TMO = 32;
1893285809Sscottl  if ((ostiGetTransportParam(
1894285809Sscottl                             tiRoot,
1895285809Sscottl                             globalStr,   /* key */
1896285809Sscottl                             SwParmsStr,  /* subkey1 */
1897285809Sscottl                             agNULL,/* subkey2 */
1898285809Sscottl                             agNULL,
1899285809Sscottl                             agNULL,
1900285809Sscottl                             agNULL,      /* subkey5 */
1901285809Sscottl                             "SAS_SSP_MCT_TMO", /* valueName */
1902285809Sscottl                             buffer,
1903285809Sscottl                             buffLen,
1904285809Sscottl                             &lenRecv
1905285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1906285809Sscottl  {
1907285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1908285809Sscottl    {
1909285809Sscottl      tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
1910285809Sscottl    }
1911285809Sscottl    else
1912285809Sscottl    {
1913285809Sscottl      tdsaAllShared->SSP_MCT_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
1914285809Sscottl    }
1915285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: SSP_MCT_TMO %d\n", tdsaAllShared->SSP_MCT_TMO));
1916285809Sscottl  }
1917285809Sscottl  /* End  SSP_MCT_TMO */
1918285809Sscottl
1919285809Sscottl
1920285809Sscottl  /* Start MAX_OPEN_TIME */
1921285809Sscottl  osti_memset(buffer, 0, buffLen);
1922285809Sscottl  lenRecv = 0;
1923285809Sscottl  tdsaAllShared->MAX_OPEN_TIME = 5;
1924285809Sscottl  if ((ostiGetTransportParam(
1925285809Sscottl                             tiRoot,
1926285809Sscottl                             globalStr,   /* key */
1927285809Sscottl                             SwParmsStr,  /* subkey1 */
1928285809Sscottl                             agNULL,/* subkey2 */
1929285809Sscottl                             agNULL,
1930285809Sscottl                             agNULL,
1931285809Sscottl                             agNULL,      /* subkey5 */
1932285809Sscottl                             "SAS_MAX_OPEN_TIME", /* valueName */
1933285809Sscottl                             buffer,
1934285809Sscottl                             buffLen,
1935285809Sscottl                             &lenRecv
1936285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1937285809Sscottl  {
1938285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1939285809Sscottl    {
1940285809Sscottl      tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 0);
1941285809Sscottl    }
1942285809Sscottl    else
1943285809Sscottl    {
1944285809Sscottl      tdsaAllShared->MAX_OPEN_TIME = osti_strtoul (buffer, &pLastUsedChar, 10);
1945285809Sscottl    }
1946285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: MAX_OPEN_TIME %d\n", tdsaAllShared->MAX_OPEN_TIME));
1947285809Sscottl  }
1948285809Sscottl  /* End  MAX_OPEN_TIME */
1949285809Sscottl
1950285809Sscottl
1951285809Sscottl  /* Start SMP_MAX_CONN_TIMER */
1952285809Sscottl  osti_memset(buffer, 0, buffLen);
1953285809Sscottl  lenRecv = 0;
1954285809Sscottl  tdsaAllShared->SMP_MAX_CONN_TIMER = 0xFF;
1955285809Sscottl  if ((ostiGetTransportParam(
1956285809Sscottl                             tiRoot,
1957285809Sscottl                             globalStr,   /* key */
1958285809Sscottl                             SwParmsStr,  /* subkey1 */
1959285809Sscottl                             agNULL,/* subkey2 */
1960285809Sscottl                             agNULL,
1961285809Sscottl                             agNULL,
1962285809Sscottl                             agNULL,      /* subkey5 */
1963285809Sscottl                             "SAS_SMP_MAX_CONN_TIMER", /* valueName */
1964285809Sscottl                             buffer,
1965285809Sscottl                             buffLen,
1966285809Sscottl                             &lenRecv
1967285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1968285809Sscottl  {
1969285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
1970285809Sscottl    {
1971285809Sscottl      tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 0);
1972285809Sscottl    }
1973285809Sscottl    else
1974285809Sscottl    {
1975285809Sscottl      tdsaAllShared->SMP_MAX_CONN_TIMER = osti_strtoul (buffer, &pLastUsedChar, 10);
1976285809Sscottl    }
1977285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: SMP_MAX_CONN_TIMER %d\n", tdsaAllShared->SMP_MAX_CONN_TIMER));
1978285809Sscottl  }
1979285809Sscottl  /* End  SMP_MAX_CONN_TIMER */
1980285809Sscottl
1981285809Sscottl  /* Start STP_FRM_TMO */
1982285809Sscottl  osti_memset(buffer, 0, buffLen);
1983285809Sscottl  lenRecv = 0;
1984285809Sscottl  tdsaAllShared->STP_FRM_TMO = 0;
1985285809Sscottl  if ((ostiGetTransportParam(
1986285809Sscottl                             tiRoot,
1987285809Sscottl                             globalStr,   /* key */
1988285809Sscottl                             SwParmsStr,  /* subkey1 */
1989285809Sscottl                             agNULL,/* subkey2 */
1990285809Sscottl                             agNULL,
1991285809Sscottl                             agNULL,
1992285809Sscottl                             agNULL,      /* subkey5 */
1993285809Sscottl                             "SAS_STP_FRM_TMO", /* valueName */
1994285809Sscottl                             buffer,
1995285809Sscottl                             buffLen,
1996285809Sscottl                             &lenRecv
1997285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
1998285809Sscottl  {
1999285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2000285809Sscottl    {
2001285809Sscottl      tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2002285809Sscottl    }
2003285809Sscottl    else
2004285809Sscottl    {
2005285809Sscottl      tdsaAllShared->STP_FRM_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2006285809Sscottl    }
2007285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: STP_FRM_TMO %d\n", tdsaAllShared->STP_FRM_TMO));
2008285809Sscottl  }
2009285809Sscottl  /* End  STP_FRM_TMO */
2010285809Sscottl
2011285809Sscottl  /* Start MFD_OPNRJT_RTRY_INTVL */
2012285809Sscottl  osti_memset(buffer, 0, buffLen);
2013285809Sscottl  lenRecv = 0;
2014285809Sscottl  tdsaAllShared->MFD = 1; /* disabled  by default */
2015285809Sscottl  if ((ostiGetTransportParam(
2016285809Sscottl                             tiRoot,
2017285809Sscottl                             globalStr,   /* key */
2018285809Sscottl                             SwParmsStr,  /* subkey1 */
2019285809Sscottl                             agNULL,/* subkey2 */
2020285809Sscottl                             agNULL,
2021285809Sscottl                             agNULL,
2022285809Sscottl                             agNULL,      /* subkey5 */
2023285809Sscottl                             "SAS_MFD", /* valueName */
2024285809Sscottl                             buffer,
2025285809Sscottl                             buffLen,
2026285809Sscottl                             &lenRecv
2027285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2028285809Sscottl  {
2029285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2030285809Sscottl    {
2031285809Sscottl      tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 0);
2032285809Sscottl    }
2033285809Sscottl    else
2034285809Sscottl    {
2035285809Sscottl      tdsaAllShared->MFD = osti_strtoul (buffer, &pLastUsedChar, 10);
2036285809Sscottl    }
2037285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: MFD %d\n", tdsaAllShared->MFD));
2038285809Sscottl  }
2039285809Sscottl  /* End  MFD_OPNRJT_RTRY_INTVL */
2040285809Sscottl
2041285809Sscottl  /* Start MFD_OPNRJT_RTRY_INTVL */
2042285809Sscottl  osti_memset(buffer, 0, buffLen);
2043285809Sscottl  lenRecv = 0;
2044285809Sscottl  tdsaAllShared->OPNRJT_RTRY_INTVL = 2;
2045285809Sscottl  if ((ostiGetTransportParam(
2046285809Sscottl                             tiRoot,
2047285809Sscottl                             globalStr,   /* key */
2048285809Sscottl                             SwParmsStr,  /* subkey1 */
2049285809Sscottl                             agNULL,/* subkey2 */
2050285809Sscottl                             agNULL,
2051285809Sscottl                             agNULL,
2052285809Sscottl                             agNULL,      /* subkey5 */
2053285809Sscottl                             "SAS_OPNRJT_RTRY_INTVL", /* valueName */
2054285809Sscottl                             buffer,
2055285809Sscottl                             buffLen,
2056285809Sscottl                             &lenRecv
2057285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2058285809Sscottl  {
2059285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2060285809Sscottl    {
2061285809Sscottl      tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 0);
2062285809Sscottl    }
2063285809Sscottl    else
2064285809Sscottl    {
2065285809Sscottl      tdsaAllShared->OPNRJT_RTRY_INTVL = osti_strtoul (buffer, &pLastUsedChar, 10);
2066285809Sscottl    }
2067285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: OPNRJT_RTRY_INTVL %d\n", tdsaAllShared->OPNRJT_RTRY_INTVL));
2068285809Sscottl  }
2069285809Sscottl  /* End  MFD_OPNRJT_RTRY_INTVL */
2070285809Sscottl
2071285809Sscottl  /* Start DOPNRJT_RTRY_TMO */
2072285809Sscottl  osti_memset(buffer, 0, buffLen);
2073285809Sscottl  lenRecv = 0;
2074285809Sscottl  tdsaAllShared->DOPNRJT_RTRY_TMO = 128;
2075285809Sscottl  if ((ostiGetTransportParam(
2076285809Sscottl                             tiRoot,
2077285809Sscottl                             globalStr,   /* key */
2078285809Sscottl                             SwParmsStr,  /* subkey1 */
2079285809Sscottl                             agNULL,/* subkey2 */
2080285809Sscottl                             agNULL,
2081285809Sscottl                             agNULL,
2082285809Sscottl                             agNULL,      /* subkey5 */
2083285809Sscottl                             "SAS_DOPNRJT_RTRY_TMO", /* valueName */
2084285809Sscottl                             buffer,
2085285809Sscottl                             buffLen,
2086285809Sscottl                             &lenRecv
2087285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2088285809Sscottl  {
2089285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2090285809Sscottl    {
2091285809Sscottl      tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2092285809Sscottl    }
2093285809Sscottl    else
2094285809Sscottl    {
2095285809Sscottl      tdsaAllShared->DOPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2096285809Sscottl    }
2097285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_TMO %d\n", tdsaAllShared->DOPNRJT_RTRY_TMO));
2098285809Sscottl  }
2099285809Sscottl  /* End  DOPNRJT_RTRY_TMO */
2100285809Sscottl
2101285809Sscottl  /* Start COPNRJT_RTRY_TMO */
2102285809Sscottl  osti_memset(buffer, 0, buffLen);
2103285809Sscottl  lenRecv = 0;
2104285809Sscottl//  tdsaAllShared->COPNRJT_RTRY_TMO = 32;
2105285809Sscottl  tdsaAllShared->COPNRJT_RTRY_TMO = 128;
2106285809Sscottl  if ((ostiGetTransportParam(
2107285809Sscottl                             tiRoot,
2108285809Sscottl                             globalStr,   /* key */
2109285809Sscottl                             SwParmsStr,  /* subkey1 */
2110285809Sscottl                             agNULL,/* subkey2 */
2111285809Sscottl                             agNULL,
2112285809Sscottl                             agNULL,
2113285809Sscottl                             agNULL,      /* subkey5 */
2114285809Sscottl                             "SAS_COPNRJT_RTRY_TMO", /* valueName */
2115285809Sscottl                             buffer,
2116285809Sscottl                             buffLen,
2117285809Sscottl                             &lenRecv
2118285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2119285809Sscottl  {
2120285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2121285809Sscottl    {
2122285809Sscottl      tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 0);
2123285809Sscottl    }
2124285809Sscottl    else
2125285809Sscottl    {
2126285809Sscottl      tdsaAllShared->COPNRJT_RTRY_TMO = osti_strtoul (buffer, &pLastUsedChar, 10);
2127285809Sscottl    }
2128285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_TMO %d\n", tdsaAllShared->COPNRJT_RTRY_TMO));
2129285809Sscottl  }
2130285809Sscottl  /* End  COPNRJT_RTRY_TMO */
2131285809Sscottl
2132285809Sscottl  /* Start DOPNRJT_RTRY_THR */
2133285809Sscottl  osti_memset(buffer, 0, buffLen);
2134285809Sscottl  lenRecv = 0;
2135285809Sscottl//  tdsaAllShared->DOPNRJT_RTRY_THR = 16; /* FW default */
2136285809Sscottl  /*
2137285809Sscottl    Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second.
2138285809Sscottl    Assuming a bigger value 3 second, 3000000/128 = 23437.5 where 128 is tdsaAllShared->DOPNRJT_RTRY_TMO
2139285809Sscottl  */
2140285809Sscottl  tdsaAllShared->DOPNRJT_RTRY_THR = 23438;
2141285809Sscottl  if ((ostiGetTransportParam(
2142285809Sscottl                             tiRoot,
2143285809Sscottl                             globalStr,   /* key */
2144285809Sscottl                             SwParmsStr,  /* subkey1 */
2145285809Sscottl                             agNULL,/* subkey2 */
2146285809Sscottl                             agNULL,
2147285809Sscottl                             agNULL,
2148285809Sscottl                             agNULL,      /* subkey5 */
2149285809Sscottl                             "SAS_DOPNRJT_RTRY_THR", /* valueName */
2150285809Sscottl                             buffer,
2151285809Sscottl                             buffLen,
2152285809Sscottl                             &lenRecv
2153285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2154285809Sscottl  {
2155285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2156285809Sscottl    {
2157285809Sscottl      tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
2158285809Sscottl    }
2159285809Sscottl    else
2160285809Sscottl    {
2161285809Sscottl      tdsaAllShared->DOPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
2162285809Sscottl    }
2163285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: DOPNRJT_RTRY_THR %d\n", tdsaAllShared->DOPNRJT_RTRY_THR));
2164285809Sscottl  }
2165285809Sscottl  /* End  DOPNRJT_RTRY_THR */
2166285809Sscottl
2167285809Sscottl  /* Start COPNRJT_RTRY_THR */
2168285809Sscottl  osti_memset(buffer, 0, buffLen);
2169285809Sscottl  lenRecv = 0;
2170285809Sscottl//  tdsaAllShared->COPNRJT_RTRY_THR = 1024; /* FW default */
2171285809Sscottl  /*
2172285809Sscottl    Making ORR bigger than IT NEXUS LOSS which is 2000000us = 2 second.
2173285809Sscottl    Assuming a bigger value 3 second, 3000000/128 =  23437.5 where 128 is tdsaAllShared->COPNRJT_RTRY_TMO
2174285809Sscottl  */
2175285809Sscottl  tdsaAllShared->COPNRJT_RTRY_THR = 23438;
2176285809Sscottl  if ((ostiGetTransportParam(
2177285809Sscottl                             tiRoot,
2178285809Sscottl                             globalStr,   /* key */
2179285809Sscottl                             SwParmsStr,  /* subkey1 */
2180285809Sscottl                             agNULL,/* subkey2 */
2181285809Sscottl                             agNULL,
2182285809Sscottl                             agNULL,
2183285809Sscottl                             agNULL,      /* subkey5 */
2184285809Sscottl                             "SAS_COPNRJT_RTRY_THR", /* valueName */
2185285809Sscottl                             buffer,
2186285809Sscottl                             buffLen,
2187285809Sscottl                             &lenRecv
2188285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2189285809Sscottl  {
2190285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2191285809Sscottl    {
2192285809Sscottl      tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 0);
2193285809Sscottl    }
2194285809Sscottl    else
2195285809Sscottl    {
2196285809Sscottl      tdsaAllShared->COPNRJT_RTRY_THR = osti_strtoul (buffer, &pLastUsedChar, 10);
2197285809Sscottl    }
2198285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: COPNRJT_RTRY_THR %d\n", tdsaAllShared->COPNRJT_RTRY_THR));
2199285809Sscottl  }
2200285809Sscottl  /* End  COPNRJT_RTRY_THR */
2201285809Sscottl
2202285809Sscottl  /* Start MAX_AIP */
2203285809Sscottl  osti_memset(buffer, 0, buffLen);
2204285809Sscottl  lenRecv = 0;
2205285809Sscottl  tdsaAllShared->MAX_AIP = 0x200000;
2206285809Sscottl  if ((ostiGetTransportParam(
2207285809Sscottl                             tiRoot,
2208285809Sscottl                             globalStr,   /* key */
2209285809Sscottl                             SwParmsStr,  /* subkey1 */
2210285809Sscottl                             agNULL,/* subkey2 */
2211285809Sscottl                             agNULL,
2212285809Sscottl                             agNULL,
2213285809Sscottl                             agNULL,      /* subkey5 */
2214285809Sscottl                             "SAS_MAX_AIP", /* valueName */
2215285809Sscottl                             buffer,
2216285809Sscottl                             buffLen,
2217285809Sscottl                             &lenRecv
2218285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2219285809Sscottl  {
2220285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2221285809Sscottl    {
2222285809Sscottl      tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 0);
2223285809Sscottl    }
2224285809Sscottl    else
2225285809Sscottl    {
2226285809Sscottl      tdsaAllShared->MAX_AIP = osti_strtoul (buffer, &pLastUsedChar, 10);
2227285809Sscottl    }
2228285809Sscottl    TI_DBG2(("tdsaGetSwConfigParams: MAX_AIP %d\n", tdsaAllShared->MAX_AIP));
2229285809Sscottl  }
2230285809Sscottl  /* End  MAX_AIP */
2231285809Sscottl
2232285809Sscottl  /***********************************************************************/
2233285809Sscottl  osti_memset(buffer, 0, buffLen);
2234285809Sscottl  lenRecv = 0;
2235285809Sscottl
2236285809Sscottl
2237285809Sscottl    /*
2238285809Sscottl    typedef struct agsaMPIContext_s
2239285809Sscottl    {
2240285809Sscottl      bit32   MPITableType;
2241285809Sscottl      bit32   offset;
2242285809Sscottl      bit32   value;
2243285809Sscottl    } agsaMPIContext_t;
2244285809Sscottl    */
2245285809Sscottl
2246285809Sscottl  {
2247285809Sscottl    bit32 MpiContextvalue  = 0;
2248285809Sscottl    SwConfig->mpiContextTable = agNULL;
2249285809Sscottl    SwConfig->mpiContextTablelen = 0;
2250285809Sscottl
2251285809Sscottl    if ((ostiGetTransportParam(
2252285809Sscottl                               tiRoot,
2253285809Sscottl                               globalStr,   /* key */
2254285809Sscottl                               SwParmsStr,  /* subkey1 */
2255285809Sscottl                               agNULL,      /* subkey2 */
2256285809Sscottl                               agNULL,
2257285809Sscottl                               agNULL,
2258285809Sscottl                               agNULL,      /* subkey5 */
2259285809Sscottl                               "MpiContext", /* valueName */
2260285809Sscottl                               buffer,
2261285809Sscottl                               buffLen,
2262285809Sscottl                               &lenRecv
2263285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
2264285809Sscottl    {
2265285809Sscottl
2266285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
2267285809Sscottl      {
2268285809Sscottl        MpiContextvalue = osti_strtoul (buffer, &pLastUsedChar, 0);
2269285809Sscottl      }
2270285809Sscottl      else
2271285809Sscottl      {
2272285809Sscottl        MpiContextvalue =  osti_strtoul (buffer, &pLastUsedChar, 10);
2273285809Sscottl      }
2274285809Sscottl
2275285809Sscottl
2276285809Sscottl      if (MpiContextvalue  == 0)
2277285809Sscottl      {
2278285809Sscottl        SwConfig->mpiContextTable = agNULL;
2279285809Sscottl        SwConfig->mpiContextTablelen = 0;
2280285809Sscottl      }
2281285809Sscottl      else
2282285809Sscottl      {
2283285809Sscottl        tdsaRoot_t    *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2284285809Sscottl        if(agNULL != tdsaRoot)
2285285809Sscottl        {
2286285809Sscottl          tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = 0xFF;
2287285809Sscottl          tdsaRoot->tdsaAllShared.MpiOverride.offset = 0;
2288285809Sscottl          tdsaRoot->tdsaAllShared.MpiOverride.value = 0;
2289285809Sscottl
2290285809Sscottl          SwConfig->mpiContextTable = &(tdsaRoot->tdsaAllShared.MpiOverride);
2291285809Sscottl          SwConfig->mpiContextTablelen = sizeof(agsaMPIContext_t);
2292285809Sscottl        }
2293285809Sscottl
2294285809Sscottl        TI_DBG1(("tdsaGetSwConfigParams: MpiContext %p Len %d\n", SwConfig->mpiContextTable, SwConfig->mpiContextTablelen));
2295285809Sscottl
2296285809Sscottl      }
2297285809Sscottl    }
2298285809Sscottl
2299285809Sscottl    if(SwConfig->mpiContextTable != agNULL )
2300285809Sscottl    {
2301285809Sscottl      tdsaRoot_t    *tdsaRoot = (tdsaRoot_t *)tiRoot->tdData;
2302285809Sscottl      if(agNULL != tdsaRoot)
2303285809Sscottl      {
2304285809Sscottl        if ((ostiGetTransportParam(
2305285809Sscottl                                   tiRoot,
2306285809Sscottl                                   globalStr,   /* key */
2307285809Sscottl                                   SwParmsStr,  /* subkey1 */
2308285809Sscottl                                   agNULL,      /* subkey2 */
2309285809Sscottl                                   agNULL,
2310285809Sscottl                                   agNULL,
2311285809Sscottl                                   agNULL,      /* subkey5 */
2312285809Sscottl                                   "MpiTableType", /* valueName */
2313285809Sscottl                                   buffer,
2314285809Sscottl                                   buffLen,
2315285809Sscottl                                   &lenRecv
2316285809Sscottl                                   ) == tiSuccess) && (lenRecv != 0))
2317285809Sscottl        {
2318285809Sscottl          if (osti_strncmp(buffer, "0x", 2) == 0)
2319285809Sscottl          {
2320285809Sscottl            tdsaRoot->tdsaAllShared.MpiOverride.MPITableType = osti_strtoul (buffer, &pLastUsedChar, 0);
2321285809Sscottl          }
2322285809Sscottl          else
2323285809Sscottl          {
2324285809Sscottl            tdsaRoot->tdsaAllShared.MpiOverride.MPITableType =  osti_strtoul (buffer, &pLastUsedChar, 10);
2325285809Sscottl          }
2326285809Sscottl        TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.MPITableType  0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.MPITableType ));
2327285809Sscottl        }
2328285809Sscottl
2329285809Sscottl        if ((ostiGetTransportParam(
2330285809Sscottl                                   tiRoot,
2331285809Sscottl                                   globalStr,   /* key */
2332285809Sscottl                                   SwParmsStr,  /* subkey1 */
2333285809Sscottl                                   agNULL,      /* subkey2 */
2334285809Sscottl                                   agNULL,
2335285809Sscottl                                   agNULL,
2336285809Sscottl                                   agNULL,      /* subkey5 */
2337285809Sscottl                                   "MpiTableOffset", /* valueName */
2338285809Sscottl                                   buffer,
2339285809Sscottl                                   buffLen,
2340285809Sscottl                                   &lenRecv
2341285809Sscottl                                   ) == tiSuccess) && (lenRecv != 0))
2342285809Sscottl        {
2343285809Sscottl          if (osti_strncmp(buffer, "0x", 2) == 0)
2344285809Sscottl          {
2345285809Sscottl            tdsaRoot->tdsaAllShared.MpiOverride.offset = osti_strtoul (buffer, &pLastUsedChar, 0);
2346285809Sscottl          }
2347285809Sscottl          else
2348285809Sscottl          {
2349285809Sscottl            tdsaRoot->tdsaAllShared.MpiOverride.offset =  osti_strtoul (buffer, &pLastUsedChar, 10);
2350285809Sscottl          }
2351285809Sscottl
2352285809Sscottl        TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.offset 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.offset ));
2353285809Sscottl        }
2354285809Sscottl
2355285809Sscottl        if ((ostiGetTransportParam(
2356285809Sscottl                                   tiRoot,
2357285809Sscottl                                   globalStr,   /* key */
2358285809Sscottl                                   SwParmsStr,  /* subkey1 */
2359285809Sscottl                                   agNULL,      /* subkey2 */
2360285809Sscottl                                   agNULL,
2361285809Sscottl                                   agNULL,
2362285809Sscottl                                   agNULL,      /* subkey5 */
2363285809Sscottl                                   "MpiTableValue", /* valueName */
2364285809Sscottl                                   buffer,
2365285809Sscottl                                   buffLen,
2366285809Sscottl                                   &lenRecv
2367285809Sscottl                                   ) == tiSuccess) && (lenRecv != 0))
2368285809Sscottl        {
2369285809Sscottl          if (osti_strncmp(buffer, "0x", 2) == 0)
2370285809Sscottl          {
2371285809Sscottl            tdsaRoot->tdsaAllShared.MpiOverride.value = osti_strtoul (buffer, &pLastUsedChar, 0);
2372285809Sscottl          }
2373285809Sscottl          else
2374285809Sscottl          {
2375285809Sscottl            tdsaRoot->tdsaAllShared.MpiOverride.value =  osti_strtoul (buffer, &pLastUsedChar, 10);
2376285809Sscottl          }
2377285809Sscottl          TI_DBG1(("tdsaGetSwConfigParams: MpiOverride.value 0x%X\n",tdsaRoot->tdsaAllShared.MpiOverride.value ));
2378285809Sscottl        }
2379285809Sscottl      }
2380285809Sscottl    }
2381285809Sscottl  }
2382285809Sscottl  /***********************************************************************/
2383285809Sscottl
2384285809Sscottl#ifdef SA_ENABLE_PCI_TRIGGER
2385285809Sscottl
2386285809Sscottl  osti_memset(buffer, 0, buffLen);
2387285809Sscottl  lenRecv = 0;
2388285809Sscottl
2389285809Sscottl  if ((ostiGetTransportParam(
2390285809Sscottl                             tiRoot,
2391285809Sscottl                             globalStr,   /* key */
2392285809Sscottl                             SwParmsStr,  /* subkey1 */
2393285809Sscottl                             agNULL,      /* subkey2 */
2394285809Sscottl                             agNULL,
2395285809Sscottl                             agNULL,
2396285809Sscottl                             agNULL,      /* subkey5 */
2397285809Sscottl                             "PciTrigger", /* valueName */
2398285809Sscottl                             buffer,
2399285809Sscottl                             buffLen,
2400285809Sscottl                             &lenRecv
2401285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2402285809Sscottl  {
2403285809Sscottl
2404285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2405285809Sscottl    {
2406285809Sscottl      SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 0);
2407285809Sscottl    }
2408285809Sscottl    else
2409285809Sscottl    {
2410285809Sscottl      SwConfig->PCI_trigger = osti_strtoul (buffer, &pLastUsedChar, 10);
2411285809Sscottl    }
2412285809Sscottl    TI_DBG1(("tdsaGetSwConfigParams: PciTrigger %d\n",SwConfig->PCI_trigger));
2413285809Sscottl  }
2414285809Sscottl#endif /* SA_ENABLE_PCI_TRIGGER */
2415285809Sscottl
2416285809Sscottl
2417285809Sscottl  TI_DBG6(("tdsaGetSwConfigParams: $$$$$$$$$$$$$$$$$ merge $$$$$$$$$$$$$\n"));
2418285809Sscottl#if defined(SALLSDK_DEBUG)
2419285809Sscottl  TI_DBG2(("tdsaGetSwConfigParams: SwConfig->sallDebugLevel %d\n", SwConfig->sallDebugLevel));
2420285809Sscottl#endif
2421285809Sscottl
2422285809Sscottl#ifdef SA_ENABLE_PCI_TRIGGER
2423285809Sscottl  TI_DBG1(("tdsaGetSwConfigParams: SwConfig->PCI_trigger  0x%x   0x%x\n",SwConfig->PCI_trigger, tdsaRoot->itdsaIni->tdsaAllShared->SwConfig.PCI_trigger));
2424285809Sscottl#endif /* SA_ENABLE_PCI_TRIGGER */
2425285809Sscottl
2426285809Sscottl
2427285809Sscottl#ifdef AGTIAPI_CTL
2428285809Sscottl  TI_DBG6(("tdsaLoLevelGetResource: SASConnectTimeLimit 0x%x\n",
2429285809Sscottl           tdsaAllShared->SASConnectTimeLimit));
2430285809Sscottl#endif
2431285809Sscottl
2432285809Sscottl  return;
2433285809Sscottl}
2434285809Sscottl
2435285809Sscottl/*****************************************************************************
2436285809Sscottl*! \brief  tdsaParseLinkRateMode
2437285809Sscottl*
2438285809Sscottl*  Purpose:  This function parses link rate and mode.
2439285809Sscottl*
2440285809Sscottl*  \param   LinkRate: Link rate specified by user.
2441285809Sscottl*  \param   Mode: Link rate specified by user.
2442285809Sscottl*
2443285809Sscottl*  \return:
2444285809Sscottl*           Value combined with Linkrate and Mode
2445285809Sscottl*
2446285809Sscottl*   \note:
2447285809Sscottl*
2448285809Sscottl*****************************************************************************/
2449285809SscottlosGLOBAL void
2450285809SscottltdsaParseLinkRateMode(
2451285809Sscottl                      tiRoot_t *tiRoot,
2452285809Sscottl                      bit32 index,
2453285809Sscottl                      bit32 LinkRateRead,
2454285809Sscottl                      bit32 ModeRead,
2455285809Sscottl                      bit32 OpticalModeRead,
2456285809Sscottl                      bit32 LinkRate,
2457285809Sscottl                      bit32 Mode,
2458285809Sscottl                      bit32 OpticalMode
2459285809Sscottl                      )
2460285809Sscottl{
2461285809Sscottl  tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2462285809Sscottl  tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
2463285809Sscottl
2464285809Sscottl  TI_DBG3(("tdsaParseLinkRateMode: index 0x%X\n",index));
2465285809Sscottl  TI_DBG3(("tdsaParseLinkRateMode: LinkRateRead 0x%X    LinkRate 0x%X\n",LinkRateRead,LinkRate));
2466285809Sscottl  TI_DBG3(("tdsaParseLinkRateMode: ModeRead 0x%X        Mode 0x%X\n",ModeRead,Mode));
2467285809Sscottl  TI_DBG3(("tdsaParseLinkRateMode: OpticalModeRead 0x%X OpticalMode 0x%X\n",OpticalModeRead,OpticalMode));
2468285809Sscottl
2469285809Sscottl
2470285809Sscottl  if (LinkRateRead == agTRUE)
2471285809Sscottl  {
2472285809Sscottl    /* link rate */
2473285809Sscottl    if (LinkRate & 0x1)
2474285809Sscottl    {
2475285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
2476285809Sscottl    }
2477285809Sscottl    if (LinkRate & 0x2)
2478285809Sscottl    {
2479285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x2;
2480285809Sscottl    }
2481285809Sscottl    if (LinkRate & 0x4)
2482285809Sscottl    {
2483285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x4;
2484285809Sscottl    }
2485285809Sscottl    if (LinkRate & 0x8)
2486285809Sscottl    {
2487285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x8;
2488285809Sscottl    }
2489285809Sscottl    if (LinkRate == 0 || LinkRate > 0xF )
2490285809Sscottl    {
2491285809Sscottl      /* not allowed, set the rate to default 1.5 G */
2492285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = 0;
2493285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x1;
2494285809Sscottl      TI_DBG1(("tdsaParseLinkRateMode:  LinkRate == 0 || LinkRate >= 0x%x\n",tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2495285809Sscottl    }
2496285809Sscottl    TI_DBG2(("tdsaParseLinkRateMode:A index 0x%x LinkRate 0x%x Mode 0x%x\n",index,LinkRate,Mode));
2497285809Sscottl
2498285809Sscottl  }
2499285809Sscottl
2500285809Sscottl  if ( ModeRead == agTRUE)
2501285809Sscottl  {
2502285809Sscottl    /* mode */
2503285809Sscottl    if (Mode & 0x1)
2504285809Sscottl    {
2505285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x10;
2506285809Sscottl    }
2507285809Sscottl    if (Mode & 0x2)
2508285809Sscottl    {
2509285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x20;
2510285809Sscottl    }
2511285809Sscottl    if (Mode == 0 || Mode >= 4 )
2512285809Sscottl    {
2513285809Sscottl      /* not allowed, set the mode to default SAS/SATA */
2514285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties & 0xf;
2515285809Sscottl      tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | 0x30;
2516285809Sscottl    }
2517285809Sscottl    TI_DBG2(("tdsaParseLinkRateMode:1 index 0x%x Mode 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2518285809Sscottl  }
2519285809Sscottl
2520285809Sscottl  if ( OpticalModeRead == agTRUE)
2521285809Sscottl  {
2522285809Sscottl    /* setting bit20 */
2523285809Sscottl    agsaRoot_t     *agRoot = &tdsaAllShared->agRootInt;
2524285809Sscottl
2525285809Sscottl    if (OpticalMode == 0)
2526285809Sscottl    {
2527285809Sscottl      TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 0  phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2528285809Sscottl    }
2529285809Sscottl    else if(OpticalMode == 1)
2530285809Sscottl    {
2531285809Sscottl      if(tIsSPCV12or6G(agRoot))
2532285809Sscottl      {
2533285809Sscottl        TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 1  phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2534285809Sscottl        tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
2535285809Sscottl      }
2536285809Sscottl      else
2537285809Sscottl      {
2538285809Sscottl        tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 22);
2539285809Sscottl        tdsaAllShared->Ports[index].agPhyConfig.phyProperties &= 0xFFFFFFF0;
2540285809Sscottl        tdsaAllShared->Ports[index].agPhyConfig.phyProperties |= 0x4;
2541285809Sscottl      }
2542285809Sscottl    }
2543285809Sscottl    else if(OpticalMode == 2 )
2544285809Sscottl    {
2545285809Sscottl      if(tIsSPCV12or6G(agRoot))
2546285809Sscottl      {
2547285809Sscottl        TI_DBG1(("tdsaParseLinkRateMode: OpticalMode 2  phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2548285809Sscottl        tdsaAllShared->Ports[index].agPhyConfig.phyProperties = tdsaAllShared->Ports[index].agPhyConfig.phyProperties | (1 << 20);
2549285809Sscottl      }
2550285809Sscottl      else
2551285809Sscottl      {
2552285809Sscottl        TD_ASSERT(0, "SPC optical mode 2");
2553285809Sscottl      }
2554285809Sscottl
2555285809Sscottl      TI_DBG1(("tdsaParseLinkRateMode: OpticalMode %d phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2556285809Sscottl    }
2557285809Sscottl    else
2558285809Sscottl    {
2559285809Sscottl       TI_DBG1(("tdsaParseLinkRateMode: OpticalMode unknown %d  phy %d phyProperties 0x%x\n",OpticalMode,index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2560285809Sscottl    }
2561285809Sscottl  }
2562285809Sscottl  else
2563285809Sscottl  {
2564285809Sscottl    TI_DBG1(("tdsaParseLinkRateMode: OpticalMode off phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2565285809Sscottl  }
2566285809Sscottl
2567285809Sscottl  TI_DBG1(("tdsaParseLinkRateMode: phy %d phyProperties 0x%x\n",index,tdsaAllShared->Ports[index].agPhyConfig.phyProperties));
2568285809Sscottl
2569285809Sscottl
2570285809Sscottl  return;
2571285809Sscottl}
2572285809Sscottl
2573285809Sscottl
2574285809Sscottl/*****************************************************************************
2575285809Sscottl*! \brief tdsaGetHwConfigParams
2576285809Sscottl*
2577285809Sscottl*  Purpose:  This function reads hardware configuration parameters from the
2578285809Sscottl*            configuration file
2579285809Sscottl*
2580285809Sscottl*  \param  tiRoot:            Pointer to driver/port instance.
2581285809Sscottl*
2582285809Sscottl*  \return: None
2583285809Sscottl*
2584285809Sscottl*  \note -
2585285809Sscottl*
2586285809Sscottl*****************************************************************************/
2587285809SscottlosGLOBAL void
2588285809SscottltdsaGetHwConfigParams(
2589285809Sscottl                      tiRoot_t *tiRoot
2590285809Sscottl                      )
2591285809Sscottl{
2592285809Sscottl  tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
2593285809Sscottl  tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
2594285809Sscottl  agsaHwConfig_t *HwConfig;
2595285809Sscottl  char           *buffer;
2596285809Sscottl  bit32          buffLen;
2597285809Sscottl  bit32          lenRecv = 0;
2598285809Sscottl  char           *pLastUsedChar = agNULL;
2599285809Sscottl  char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
2600285809Sscottl  char           globalStr[]     = "Global";
2601285809Sscottl  char           HwParmsStr[]   = "HWParms";
2602285809Sscottl  char           phyReg[10];
2603285809Sscottl  int            i,j;
2604285809Sscottl  agsaPhyAnalogSetupTable_t *phyRegTable;
2605285809Sscottl
2606285809Sscottl  TI_DBG6(("tdsaGetHwConfigParams: start\n"));
2607285809Sscottl  TI_DBG6(("tdsaGetHwConfigParams: tdsaRoot %p tdsaAllShared %p \n",tdsaRoot, tdsaAllShared));
2608285809Sscottl
2609285809Sscottl  buffer = tmpBuffer;
2610285809Sscottl  buffLen = sizeof(tmpBuffer);
2611285809Sscottl
2612285809Sscottl  osti_memset(buffer, 0, buffLen);
2613285809Sscottl
2614285809Sscottl  HwConfig = (agsaHwConfig_t *)&(tdsaAllShared->HwConfig);
2615285809Sscottl  phyRegTable = (agsaPhyAnalogSetupTable_t *)&(HwConfig->phyAnalogConfig);
2616285809Sscottl
2617285809Sscottl  osti_memset(HwConfig, 0, sizeof(agsaHwConfig_t));
2618285809Sscottl
2619285809Sscottl  /*
2620285809Sscottl    just default values
2621285809Sscottl    and are overwritten later by the configuration file contents
2622285809Sscottl    turning off hw control interrupt coalescing
2623285809Sscottl  */
2624285809Sscottl  tdsaAllShared->FWMaxPorts = DEFAULT_FW_MAX_PORTS; /* 8, applicable only to SPC not to SPCv */
2625285809Sscottl  HwConfig->phyCount = TD_MAX_NUM_PHYS;
2626285809Sscottl  HwConfig->hwInterruptCoalescingTimer = 1;
2627285809Sscottl  HwConfig->hwInterruptCoalescingControl = 0;
2628285809Sscottl  tdsaAllShared->phyCalibration = 0;
2629285809Sscottl  HwConfig->hwOption = 0; /* default: PI/CI addresses are 32-bit */
2630285809Sscottl
2631285809Sscottl  osti_memset(buffer, 0, buffLen);
2632285809Sscottl  lenRecv = 0;
2633285809Sscottl
2634285809Sscottl  if ((ostiGetTransportParam(
2635285809Sscottl                             tiRoot,
2636285809Sscottl                             globalStr,   /* key */
2637285809Sscottl                             HwParmsStr,  /* subkey1 */
2638285809Sscottl                             agNULL,      /* subkey2 */
2639285809Sscottl                             agNULL,
2640285809Sscottl                             agNULL,
2641285809Sscottl                             agNULL,      /* subkey5 */
2642285809Sscottl                             "HwIntCoalTimer", /* valueName */
2643285809Sscottl                             buffer,
2644285809Sscottl                             buffLen,
2645285809Sscottl                             &lenRecv
2646285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2647285809Sscottl  {
2648285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2649285809Sscottl    {
2650285809Sscottl      HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 0);
2651285809Sscottl    }
2652285809Sscottl    else
2653285809Sscottl    {
2654285809Sscottl      HwConfig->hwInterruptCoalescingTimer = osti_strtoul (buffer, &pLastUsedChar, 10);
2655285809Sscottl    }
2656285809Sscottl  }
2657285809Sscottl
2658285809Sscottl  osti_memset(buffer, 0, buffLen);
2659285809Sscottl  lenRecv = 0;
2660285809Sscottl
2661285809Sscottl  if ((ostiGetTransportParam(
2662285809Sscottl                             tiRoot,
2663285809Sscottl                             globalStr,   /* key */
2664285809Sscottl                             HwParmsStr,  /* subkey1 */
2665285809Sscottl                             agNULL,      /* subkey2 */
2666285809Sscottl                             agNULL,
2667285809Sscottl                             agNULL,
2668285809Sscottl                             agNULL,      /* subkey5 */
2669285809Sscottl                             "HwIntCoalControl", /* valueName */
2670285809Sscottl                             buffer,
2671285809Sscottl                             buffLen,
2672285809Sscottl                             &lenRecv
2673285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2674285809Sscottl  {
2675285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2676285809Sscottl    {
2677285809Sscottl      HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 0);
2678285809Sscottl    }
2679285809Sscottl    else
2680285809Sscottl    {
2681285809Sscottl      HwConfig->hwInterruptCoalescingControl = osti_strtoul (buffer, &pLastUsedChar, 10);
2682285809Sscottl    }
2683285809Sscottl  }
2684285809Sscottl
2685285809Sscottl  /* For hwInterruptCoalescingTimer, 0 disables interrrupt, not allowed */
2686285809Sscottl  if (HwConfig->hwInterruptCoalescingControl == 1 && HwConfig->hwInterruptCoalescingTimer == 0)
2687285809Sscottl  {
2688285809Sscottl    HwConfig->hwInterruptCoalescingTimer = 1;
2689285809Sscottl  }
2690285809Sscottl
2691285809Sscottl  osti_memset(buffer, 0, buffLen);
2692285809Sscottl  lenRecv = 0;
2693285809Sscottl
2694285809Sscottl  /* interrupt reassetion field*/
2695285809Sscottl  if ((ostiGetTransportParam(
2696285809Sscottl                             tiRoot,
2697285809Sscottl                             globalStr,   /* key */
2698285809Sscottl                             HwParmsStr,  /* subkey1 */
2699285809Sscottl                             agNULL,      /* subkey2 */
2700285809Sscottl                             agNULL,
2701285809Sscottl                             agNULL,
2702285809Sscottl                             agNULL,      /* subkey5 */
2703285809Sscottl                             "IntReassertionOpt", /* valueName */
2704285809Sscottl                             buffer,
2705285809Sscottl                             buffLen,
2706285809Sscottl                             &lenRecv
2707285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2708285809Sscottl  {
2709285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2710285809Sscottl    {
2711285809Sscottl      HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 0);
2712285809Sscottl    }
2713285809Sscottl    else
2714285809Sscottl    {
2715285809Sscottl      HwConfig->intReassertionOption = osti_strtoul (buffer, &pLastUsedChar, 10);
2716285809Sscottl    }
2717285809Sscottl  }
2718285809Sscottl
2719285809Sscottl  osti_memset(buffer, 0, buffLen);
2720285809Sscottl  lenRecv = 0;
2721285809Sscottl
2722285809Sscottl  /* interrupt reassetion field*/
2723285809Sscottl  if ((ostiGetTransportParam(
2724285809Sscottl                             tiRoot,
2725285809Sscottl                             globalStr,   /* key */
2726285809Sscottl                             HwParmsStr,  /* subkey1 */
2727285809Sscottl                             agNULL,      /* subkey2 */
2728285809Sscottl                             agNULL,
2729285809Sscottl                             agNULL,
2730285809Sscottl                             agNULL,      /* subkey5 */
2731285809Sscottl                             "HwOption", /* valueName */
2732285809Sscottl                             buffer,
2733285809Sscottl                             buffLen,
2734285809Sscottl                             &lenRecv
2735285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2736285809Sscottl  {
2737285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2738285809Sscottl    {
2739285809Sscottl      HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 0);
2740285809Sscottl    }
2741285809Sscottl    else
2742285809Sscottl    {
2743285809Sscottl      HwConfig->hwOption = osti_strtoul (buffer, &pLastUsedChar, 10);
2744285809Sscottl    }
2745285809Sscottl  }
2746285809Sscottl
2747285809Sscottl  osti_memset(buffer, 0, buffLen);
2748285809Sscottl  lenRecv = 0;
2749285809Sscottl
2750285809Sscottl  /* interrupt reassetion field*/
2751285809Sscottl  if ((ostiGetTransportParam(
2752285809Sscottl                             tiRoot,
2753285809Sscottl                             globalStr,   /* key */
2754285809Sscottl                             HwParmsStr,  /* subkey1 */
2755285809Sscottl                             agNULL,      /* subkey2 */
2756285809Sscottl                             agNULL,
2757285809Sscottl                             agNULL,
2758285809Sscottl                             agNULL,      /* subkey5 */
2759285809Sscottl                             "MaxFWPorts", /* valueName */
2760285809Sscottl                             buffer,
2761285809Sscottl                             buffLen,
2762285809Sscottl                             &lenRecv
2763285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2764285809Sscottl  {
2765285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2766285809Sscottl    {
2767285809Sscottl      tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 0);
2768285809Sscottl    }
2769285809Sscottl    else
2770285809Sscottl    {
2771285809Sscottl      tdsaAllShared->FWMaxPorts = osti_strtoul (buffer, &pLastUsedChar, 10);
2772285809Sscottl    }
2773285809Sscottl  }
2774285809Sscottl
2775285809Sscottl  osti_memset(buffer, 0, buffLen);
2776285809Sscottl  lenRecv = 0;
2777285809Sscottl
2778285809Sscottl  if ((ostiGetTransportParam(
2779285809Sscottl                             tiRoot,
2780285809Sscottl                             globalStr,   /* key */
2781285809Sscottl                             HwParmsStr,  /* subkey1 */
2782285809Sscottl                             agNULL,      /* subkey2 */
2783285809Sscottl                             agNULL,
2784285809Sscottl                             agNULL,
2785285809Sscottl                             agNULL,      /* subkey5 */
2786285809Sscottl                             "phyCalibration", /* valueName */
2787285809Sscottl                             buffer,
2788285809Sscottl                             buffLen,
2789285809Sscottl                             &lenRecv
2790285809Sscottl                             ) == tiSuccess) && (lenRecv != 0))
2791285809Sscottl  {
2792285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
2793285809Sscottl    {
2794285809Sscottl      tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 0);
2795285809Sscottl    }
2796285809Sscottl    else
2797285809Sscottl    {
2798285809Sscottl      tdsaAllShared->phyCalibration = osti_strtoul (buffer, &pLastUsedChar, 10);
2799285809Sscottl    }
2800285809Sscottl  }
2801285809Sscottl
2802285809Sscottl  osti_memset(buffer, 0, buffLen);
2803285809Sscottl  lenRecv = 0;
2804285809Sscottl
2805285809Sscottl
2806285809Sscottl  /* phy calibration */
2807285809Sscottl  for (i=0;i<MAX_INDEX;i++)
2808285809Sscottl  {
2809285809Sscottl    for(j=0;j<10;j++)
2810285809Sscottl    {
2811285809Sscottl      osti_sprintf(phyReg,"spaReg%d%d",i,j);
2812285809Sscottl      TI_DBG6(("tdsaGetHwConfigParams: phyReg %s\n", phyReg));
2813285809Sscottl
2814285809Sscottl      if (j == 0)
2815285809Sscottl      {
2816285809Sscottl        if ((ostiGetTransportParam(
2817285809Sscottl                               tiRoot,
2818285809Sscottl                               globalStr,   /* key */
2819285809Sscottl                               HwParmsStr,  /* subkey1 */
2820285809Sscottl                               agNULL,      /* subkey2 */
2821285809Sscottl                               agNULL,
2822285809Sscottl                               agNULL,
2823285809Sscottl                               agNULL,      /* subkey5 */
2824285809Sscottl                               phyReg, /* valueName */
2825285809Sscottl                               buffer,
2826285809Sscottl                               buffLen,
2827285809Sscottl                               &lenRecv
2828285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
2829285809Sscottl      {
2830285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
2831285809Sscottl        {
2832285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 0);
2833285809Sscottl        }
2834285809Sscottl        else
2835285809Sscottl        {
2836285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister0 = osti_strtoul (buffer, &pLastUsedChar, 10);
2837285809Sscottl        }
2838285809Sscottl      }
2839285809Sscottl
2840285809Sscottl      osti_memset(buffer, 0, buffLen);
2841285809Sscottl      lenRecv = 0;
2842285809Sscottl      }
2843285809Sscottl      else if (j == 1)
2844285809Sscottl      {
2845285809Sscottl        if ((ostiGetTransportParam(
2846285809Sscottl                               tiRoot,
2847285809Sscottl                               globalStr,   /* key */
2848285809Sscottl                               HwParmsStr,  /* subkey1 */
2849285809Sscottl                               agNULL,      /* subkey2 */
2850285809Sscottl                               agNULL,
2851285809Sscottl                               agNULL,
2852285809Sscottl                               agNULL,      /* subkey5 */
2853285809Sscottl                               phyReg, /* valueName */
2854285809Sscottl                               buffer,
2855285809Sscottl                               buffLen,
2856285809Sscottl                               &lenRecv
2857285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
2858285809Sscottl      {
2859285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
2860285809Sscottl        {
2861285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 0);
2862285809Sscottl        }
2863285809Sscottl        else
2864285809Sscottl        {
2865285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister1 = osti_strtoul (buffer, &pLastUsedChar, 10);
2866285809Sscottl        }
2867285809Sscottl      }
2868285809Sscottl
2869285809Sscottl      osti_memset(buffer, 0, buffLen);
2870285809Sscottl      lenRecv = 0;
2871285809Sscottl      }
2872285809Sscottl      else if (j == 2)
2873285809Sscottl      {
2874285809Sscottl        if ((ostiGetTransportParam(
2875285809Sscottl                               tiRoot,
2876285809Sscottl                               globalStr,   /* key */
2877285809Sscottl                               HwParmsStr,  /* subkey1 */
2878285809Sscottl                               agNULL,      /* subkey2 */
2879285809Sscottl                               agNULL,
2880285809Sscottl                               agNULL,
2881285809Sscottl                               agNULL,      /* subkey5 */
2882285809Sscottl                               phyReg, /* valueName */
2883285809Sscottl                               buffer,
2884285809Sscottl                               buffLen,
2885285809Sscottl                               &lenRecv
2886285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
2887285809Sscottl      {
2888285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
2889285809Sscottl        {
2890285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 0);
2891285809Sscottl        }
2892285809Sscottl        else
2893285809Sscottl        {
2894285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister2 = osti_strtoul (buffer, &pLastUsedChar, 10);
2895285809Sscottl        }
2896285809Sscottl      }
2897285809Sscottl
2898285809Sscottl      osti_memset(buffer, 0, buffLen);
2899285809Sscottl      lenRecv = 0;
2900285809Sscottl      }
2901285809Sscottl      else if (j == 3)
2902285809Sscottl      {
2903285809Sscottl        if ((ostiGetTransportParam(
2904285809Sscottl                               tiRoot,
2905285809Sscottl                               globalStr,   /* key */
2906285809Sscottl                               HwParmsStr,  /* subkey1 */
2907285809Sscottl                               agNULL,      /* subkey2 */
2908285809Sscottl                               agNULL,
2909285809Sscottl                               agNULL,
2910285809Sscottl                               agNULL,      /* subkey5 */
2911285809Sscottl                               phyReg, /* valueName */
2912285809Sscottl                               buffer,
2913285809Sscottl                               buffLen,
2914285809Sscottl                               &lenRecv
2915285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
2916285809Sscottl      {
2917285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
2918285809Sscottl        {
2919285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 0);
2920285809Sscottl        }
2921285809Sscottl        else
2922285809Sscottl        {
2923285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister3 = osti_strtoul (buffer, &pLastUsedChar, 10);
2924285809Sscottl        }
2925285809Sscottl      }
2926285809Sscottl
2927285809Sscottl      osti_memset(buffer, 0, buffLen);
2928285809Sscottl      lenRecv = 0;
2929285809Sscottl      }
2930285809Sscottl      else if (j == 4)
2931285809Sscottl      {
2932285809Sscottl        if ((ostiGetTransportParam(
2933285809Sscottl                               tiRoot,
2934285809Sscottl                               globalStr,   /* key */
2935285809Sscottl                               HwParmsStr,  /* subkey1 */
2936285809Sscottl                               agNULL,      /* subkey2 */
2937285809Sscottl                               agNULL,
2938285809Sscottl                               agNULL,
2939285809Sscottl                               agNULL,      /* subkey5 */
2940285809Sscottl                               phyReg, /* valueName */
2941285809Sscottl                               buffer,
2942285809Sscottl                               buffLen,
2943285809Sscottl                               &lenRecv
2944285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
2945285809Sscottl      {
2946285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
2947285809Sscottl        {
2948285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 0);
2949285809Sscottl        }
2950285809Sscottl        else
2951285809Sscottl        {
2952285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister4 = osti_strtoul (buffer, &pLastUsedChar, 10);
2953285809Sscottl        }
2954285809Sscottl      }
2955285809Sscottl
2956285809Sscottl      osti_memset(buffer, 0, buffLen);
2957285809Sscottl      lenRecv = 0;
2958285809Sscottl      }
2959285809Sscottl      else if (j == 5)
2960285809Sscottl      {
2961285809Sscottl        if ((ostiGetTransportParam(
2962285809Sscottl                               tiRoot,
2963285809Sscottl                               globalStr,   /* key */
2964285809Sscottl                               HwParmsStr,  /* subkey1 */
2965285809Sscottl                               agNULL,      /* subkey2 */
2966285809Sscottl                               agNULL,
2967285809Sscottl                               agNULL,
2968285809Sscottl                               agNULL,      /* subkey5 */
2969285809Sscottl                               phyReg, /* valueName */
2970285809Sscottl                               buffer,
2971285809Sscottl                               buffLen,
2972285809Sscottl                               &lenRecv
2973285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
2974285809Sscottl      {
2975285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
2976285809Sscottl        {
2977285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 0);
2978285809Sscottl        }
2979285809Sscottl        else
2980285809Sscottl        {
2981285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister5 = osti_strtoul (buffer, &pLastUsedChar, 10);
2982285809Sscottl        }
2983285809Sscottl      }
2984285809Sscottl
2985285809Sscottl      osti_memset(buffer, 0, buffLen);
2986285809Sscottl      lenRecv = 0;
2987285809Sscottl      }
2988285809Sscottl      else if (j == 6)
2989285809Sscottl      {
2990285809Sscottl        if ((ostiGetTransportParam(
2991285809Sscottl                               tiRoot,
2992285809Sscottl                               globalStr,   /* key */
2993285809Sscottl                               HwParmsStr,  /* subkey1 */
2994285809Sscottl                               agNULL,      /* subkey2 */
2995285809Sscottl                               agNULL,
2996285809Sscottl                               agNULL,
2997285809Sscottl                               agNULL,      /* subkey5 */
2998285809Sscottl                               phyReg, /* valueName */
2999285809Sscottl                               buffer,
3000285809Sscottl                               buffLen,
3001285809Sscottl                               &lenRecv
3002285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
3003285809Sscottl      {
3004285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
3005285809Sscottl        {
3006285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 0);
3007285809Sscottl        }
3008285809Sscottl        else
3009285809Sscottl        {
3010285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister6 = osti_strtoul (buffer, &pLastUsedChar, 10);
3011285809Sscottl        }
3012285809Sscottl      }
3013285809Sscottl
3014285809Sscottl      osti_memset(buffer, 0, buffLen);
3015285809Sscottl      lenRecv = 0;
3016285809Sscottl      }
3017285809Sscottl      else if (j == 7)
3018285809Sscottl      {
3019285809Sscottl        if ((ostiGetTransportParam(
3020285809Sscottl                               tiRoot,
3021285809Sscottl                               globalStr,   /* key */
3022285809Sscottl                               HwParmsStr,  /* subkey1 */
3023285809Sscottl                               agNULL,      /* subkey2 */
3024285809Sscottl                               agNULL,
3025285809Sscottl                               agNULL,
3026285809Sscottl                               agNULL,      /* subkey5 */
3027285809Sscottl                               phyReg, /* valueName */
3028285809Sscottl                               buffer,
3029285809Sscottl                               buffLen,
3030285809Sscottl                               &lenRecv
3031285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
3032285809Sscottl      {
3033285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
3034285809Sscottl        {
3035285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 0);
3036285809Sscottl        }
3037285809Sscottl        else
3038285809Sscottl        {
3039285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister7 = osti_strtoul (buffer, &pLastUsedChar, 10);
3040285809Sscottl        }
3041285809Sscottl      }
3042285809Sscottl
3043285809Sscottl      osti_memset(buffer, 0, buffLen);
3044285809Sscottl      lenRecv = 0;
3045285809Sscottl      }
3046285809Sscottl      else if (j == 8)
3047285809Sscottl      {
3048285809Sscottl        if ((ostiGetTransportParam(
3049285809Sscottl                               tiRoot,
3050285809Sscottl                               globalStr,   /* key */
3051285809Sscottl                               HwParmsStr,  /* subkey1 */
3052285809Sscottl                               agNULL,      /* subkey2 */
3053285809Sscottl                               agNULL,
3054285809Sscottl                               agNULL,
3055285809Sscottl                               agNULL,      /* subkey5 */
3056285809Sscottl                               phyReg, /* valueName */
3057285809Sscottl                               buffer,
3058285809Sscottl                               buffLen,
3059285809Sscottl                               &lenRecv
3060285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
3061285809Sscottl      {
3062285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
3063285809Sscottl        {
3064285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 0);
3065285809Sscottl        }
3066285809Sscottl        else
3067285809Sscottl        {
3068285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister8 = osti_strtoul (buffer, &pLastUsedChar, 10);
3069285809Sscottl        }
3070285809Sscottl      }
3071285809Sscottl
3072285809Sscottl      osti_memset(buffer, 0, buffLen);
3073285809Sscottl      lenRecv = 0;
3074285809Sscottl      }
3075285809Sscottl      else if (j == 9)
3076285809Sscottl      {
3077285809Sscottl        if ((ostiGetTransportParam(
3078285809Sscottl                               tiRoot,
3079285809Sscottl                               globalStr,   /* key */
3080285809Sscottl                               HwParmsStr,  /* subkey1 */
3081285809Sscottl                               agNULL,      /* subkey2 */
3082285809Sscottl                               agNULL,
3083285809Sscottl                               agNULL,
3084285809Sscottl                               agNULL,      /* subkey5 */
3085285809Sscottl                               phyReg, /* valueName */
3086285809Sscottl                               buffer,
3087285809Sscottl                               buffLen,
3088285809Sscottl                               &lenRecv
3089285809Sscottl                               ) == tiSuccess) && (lenRecv != 0))
3090285809Sscottl      {
3091285809Sscottl        if (osti_strncmp(buffer, "0x", 2) == 0)
3092285809Sscottl        {
3093285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 0);
3094285809Sscottl        }
3095285809Sscottl        else
3096285809Sscottl        {
3097285809Sscottl          phyRegTable->phyAnalogSetupRegisters[i].spaRegister9 = osti_strtoul (buffer, &pLastUsedChar, 10);
3098285809Sscottl        }
3099285809Sscottl      }
3100285809Sscottl
3101285809Sscottl      osti_memset(buffer, 0, buffLen);
3102285809Sscottl      lenRecv = 0;
3103285809Sscottl      }
3104285809Sscottl
3105285809Sscottl    } /* inner loop */
3106285809Sscottl  } /* outer loop */
3107285809Sscottl  return;
3108285809Sscottl}
3109285809Sscottl/*****************************************************************************
3110285809Sscottl*! \brief tdsaGetCardPhyParams
3111285809Sscottl*
3112285809Sscottl*  Purpose:  This function reads phy-related configuration parameters from the
3113285809Sscottl*            configuration file
3114285809Sscottl*
3115285809Sscottl*  \param  tiRoot:            Pointer to driver/port instance.
3116285809Sscottl*
3117285809Sscottl*  \return: None
3118285809Sscottl*
3119285809Sscottl*  \note - just a place holder for now
3120285809Sscottl*
3121285809Sscottl*****************************************************************************/
3122285809SscottlosGLOBAL void
3123285809SscottltdsaGetCardPhyParams(
3124285809Sscottl                 tiRoot_t *tiRoot
3125285809Sscottl                 )
3126285809Sscottl{
3127285809Sscottl  tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3128285809Sscottl  tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3129285809Sscottl  agsaRoot_t     *agRoot = &tdsaAllShared->agRootInt;
3130285809Sscottl  char           *buffer;
3131285809Sscottl  bit32          buffLen;
3132285809Sscottl  bit32          lenRecv = 0;
3133285809Sscottl  char           *pLastUsedChar = agNULL;
3134285809Sscottl  char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3135285809Sscottl  char           *globalStr = tdsaAllShared->CardIDString;
3136285809Sscottl  char           phyParmsStr[12];
3137285809Sscottl  int            i;
3138285809Sscottl  bit32          LinkRate = 15, Mode = 3, OpticalMode = 0; //VG
3139285809Sscottl  bit32          LinkRateRead = agTRUE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
3140285809Sscottl  bit32          flag = agFALSE; /* true only for PM8008 or PM8009 (SPCv and SPCve) controller */
3141285809Sscottl
3142285809Sscottl  TI_DBG6(("tdsaGetCardPhyParams: start \n"));
3143285809Sscottl  TI_DBG6(("tdsaGetCardPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3144285809Sscottl
3145285809Sscottl  if (tiIS_8PHY(agRoot))
3146285809Sscottl  {
3147285809Sscottl    TI_DBG6(("tdsaGetCardPhyParams: SPCv or SPCve \n"));
3148285809Sscottl    flag = agTRUE;
3149285809Sscottl  }
3150285809Sscottl  TI_DBG6(("tdsaGetCardPhyParams: flag %d\n", flag));
3151285809Sscottl
3152285809Sscottl#ifdef REMOVED
3153285809Sscottl#ifdef FPGA_CARD
3154285809Sscottl  for (i=0;i<TD_MAX_NUM_PHYS;i++)
3155285809Sscottl  {
3156285809Sscottl    /* setting default phy properties */
3157285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3158285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3159285809Sscottl    /* 1.5G only, SAS/SATA, no spin-up control */
3160285809Sscottl    tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 */
3161285809Sscottl  }
3162285809Sscottl#else
3163285809Sscottl#ifdef INITIATOR_DRIVER
3164285809Sscottl  /* ASIC */
3165285809Sscottl  for (i=0;i<TD_MAX_NUM_PHYS;i++)
3166285809Sscottl  {
3167285809Sscottl    /* setting default phy properties */
3168285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3169285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3170285809Sscottl    /* 1.5G/3G , SAS/SATA, no spin-up control */
3171285809Sscottl    tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37; /* 55 */
3172285809Sscottl    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))));
3173285809Sscottl  }
3174285809Sscottl#endif
3175285809Sscottl
3176285809Sscottl#ifdef TARGET_DRIVER
3177285809Sscottl  /* ASIC */
3178285809Sscottl  for (i=0;i<TD_MAX_NUM_PHYS;i++)
3179285809Sscottl  {
3180285809Sscottl    /* setting default phy properties */
3181285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3182285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3183285809Sscottl    /* 1.5G/3G , SAS/SATA, no spin-up control */
3184285809Sscottl    tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x37; /* 55 */
3185285809Sscottl    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))));
3186285809Sscottl  }
3187285809Sscottl#endif
3188285809Sscottl
3189285809Sscottl#endif
3190285809Sscottl#endif /* REMOVED */
3191285809Sscottl
3192285809Sscottl
3193285809Sscottl  buffer = tmpBuffer;
3194285809Sscottl  buffLen = sizeof(tmpBuffer);
3195285809Sscottl
3196285809Sscottl  osti_memset(buffer, 0, buffLen);
3197285809Sscottl  lenRecv = 0;
3198285809Sscottl
3199285809Sscottl  for (i=0;i<TD_MAX_NUM_PHYS;i++)
3200285809Sscottl  {
3201285809Sscottl    if (flag == agFALSE)
3202285809Sscottl    {
3203285809Sscottl      osti_sprintf(phyParmsStr,"PhyParms%d", i);
3204285809Sscottl    }
3205285809Sscottl    else
3206285809Sscottl    {
3207285809Sscottl      if (i >= 4)
3208285809Sscottl      {
3209285809Sscottl        osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
3210285809Sscottl      }
3211285809Sscottl      else
3212285809Sscottl      {
3213285809Sscottl        osti_sprintf(phyParmsStr,"PhyParms%d", i);
3214285809Sscottl      }
3215285809Sscottl    }
3216285809Sscottl
3217285809Sscottl    TI_DBG6(("tdsaGetCardPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
3218285809Sscottl
3219285809Sscottl    TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3220285809Sscottl
3221285809Sscottl
3222285809Sscottl    if ((ostiGetTransportParam (
3223285809Sscottl                                tiRoot,
3224285809Sscottl                                globalStr,
3225285809Sscottl                                phyParmsStr,
3226285809Sscottl                                agNULL,
3227285809Sscottl                                agNULL,
3228285809Sscottl                                agNULL,
3229285809Sscottl                                agNULL,
3230285809Sscottl                                "AddrHi",
3231285809Sscottl                                buffer,
3232285809Sscottl                                buffLen,
3233285809Sscottl                                &lenRecv
3234285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3235285809Sscottl    {
3236285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3237285809Sscottl      {
3238285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3239285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3240285809Sscottl      }
3241285809Sscottl      else
3242285809Sscottl      {
3243285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3244285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3245285809Sscottl      }
3246285809Sscottl    }
3247285809Sscottl
3248285809Sscottl
3249285809Sscottl    osti_memset(buffer, 0, buffLen);
3250285809Sscottl    lenRecv = 0;
3251285809Sscottl
3252285809Sscottl    if ((ostiGetTransportParam (
3253285809Sscottl                                tiRoot,
3254285809Sscottl                                globalStr,
3255285809Sscottl                                phyParmsStr,
3256285809Sscottl                                agNULL,
3257285809Sscottl                                agNULL,
3258285809Sscottl                                agNULL,
3259285809Sscottl                                agNULL,
3260285809Sscottl                                "AddrLow",
3261285809Sscottl                                buffer,
3262285809Sscottl                                buffLen,
3263285809Sscottl                                &lenRecv
3264285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3265285809Sscottl    {
3266285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3267285809Sscottl      {
3268285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3269285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3270285809Sscottl      }
3271285809Sscottl      else
3272285809Sscottl      {
3273285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3274285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3275285809Sscottl      }
3276285809Sscottl    }
3277285809Sscottl    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))));
3278285809Sscottl
3279285809Sscottl    /* phy properties */
3280285809Sscottl    osti_memset(buffer, 0, buffLen);
3281285809Sscottl    lenRecv = 0;
3282285809Sscottl/*
3283285809Sscottl    if ((ostiGetTransportParam (
3284285809Sscottl                                tiRoot,
3285285809Sscottl                                globalStr,
3286285809Sscottl                                phyParmsStr,
3287285809Sscottl                                agNULL,
3288285809Sscottl                                agNULL,
3289285809Sscottl                                agNULL,
3290285809Sscottl                                agNULL,
3291285809Sscottl                                "LinkRate",
3292285809Sscottl                                buffer,
3293285809Sscottl                                buffLen,
3294285809Sscottl                                &lenRecv
3295285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3296285809Sscottl    {
3297285809Sscottl      LinkRateRead = agTRUE;
3298285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3299285809Sscottl      {
3300285809Sscottl        LinkRate = osti_strtoul(buffer, &pLastUsedChar, 0);
3301285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d linkrate 0x%x \n", i, LinkRate));
3302285809Sscottl      }
3303285809Sscottl      else
3304285809Sscottl      {
3305285809Sscottl        LinkRate = osti_strtoul(buffer, &pLastUsedChar, 10);
3306285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d linkrate %d \n", i, LinkRate));
3307285809Sscottl      }
3308285809Sscottl    }
3309285809Sscottl
3310285809Sscottl    TI_DBG2(("tdsaGetCardPhyParams: phy %d linkrate %d \n", i, LinkRate));
3311285809Sscottl*/
3312285809Sscottl
3313285809Sscottl    osti_memset(buffer, 0, buffLen);
3314285809Sscottl    lenRecv = 0;
3315285809Sscottl
3316285809Sscottl    if ((ostiGetTransportParam (
3317285809Sscottl                                tiRoot,
3318285809Sscottl                                globalStr,
3319285809Sscottl                                phyParmsStr,
3320285809Sscottl                                agNULL,
3321285809Sscottl                                agNULL,
3322285809Sscottl                                agNULL,
3323285809Sscottl                                agNULL,
3324285809Sscottl                                "Mode",
3325285809Sscottl                                buffer,
3326285809Sscottl                                buffLen,
3327285809Sscottl                                &lenRecv
3328285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3329285809Sscottl    {
3330285809Sscottl      ModeRead = agTRUE;
3331285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3332285809Sscottl      {
3333285809Sscottl        Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
3334285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode 0x%x \n", i, Mode));
3335285809Sscottl      }
3336285809Sscottl      else
3337285809Sscottl      {
3338285809Sscottl        Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
3339285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d Mode %d \n", i, Mode));
3340285809Sscottl      }
3341285809Sscottl    }
3342285809Sscottl
3343285809Sscottl    osti_memset(buffer, 0, buffLen);
3344285809Sscottl    lenRecv = 0;
3345285809Sscottl
3346285809Sscottl    if ((ostiGetTransportParam (
3347285809Sscottl                                tiRoot,
3348285809Sscottl                                globalStr,
3349285809Sscottl                                phyParmsStr,
3350285809Sscottl                                agNULL,
3351285809Sscottl                                agNULL,
3352285809Sscottl                                agNULL,
3353285809Sscottl                                agNULL,
3354285809Sscottl                                "OpticalMode",
3355285809Sscottl                                buffer,
3356285809Sscottl                                buffLen,
3357285809Sscottl                                &lenRecv
3358285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3359285809Sscottl    {
3360285809Sscottl      OpticalModeRead = agTRUE;
3361285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3362285809Sscottl      {
3363285809Sscottl        OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
3364285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
3365285809Sscottl      }
3366285809Sscottl      else
3367285809Sscottl      {
3368285809Sscottl        OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
3369285809Sscottl        TI_DBG6(("tdsaGetCardPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
3370285809Sscottl      }
3371285809Sscottl    }
3372285809Sscottl
3373285809Sscottl    tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
3374285809Sscottl
3375285809Sscottl    TI_DBG2(("tdsaGetCardPhyParams: phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3376285809Sscottl
3377285809Sscottl
3378285809Sscottl    /**********************************************/
3379285809Sscottl    osti_memset(buffer, 0, buffLen);
3380285809Sscottl    lenRecv = 0;
3381285809Sscottl    LinkRateRead = agTRUE;//VG
3382285809Sscottl    ModeRead = agFALSE;
3383285809Sscottl    OpticalModeRead = agFALSE;
3384285809Sscottl
3385285809Sscottl  } /* end for */
3386285809Sscottl  return;
3387285809Sscottl}
3388285809Sscottl
3389285809Sscottl
3390285809Sscottl
3391285809Sscottl
3392285809Sscottl
3393285809Sscottl/*****************************************************************************
3394285809Sscottl*! \brief tdsaGetGlobalPhyParams
3395285809Sscottl*
3396285809Sscottl*  Purpose:  This function reads phy-related configuration parameters from the
3397285809Sscottl*            configuration file
3398285809Sscottl*
3399285809Sscottl*  \param  tiRoot:            Pointer to driver/port instance.
3400285809Sscottl*
3401285809Sscottl*  \return: None
3402285809Sscottl*
3403285809Sscottl*  \note - just a place holder for now
3404285809Sscottl*
3405285809Sscottl*****************************************************************************/
3406285809SscottlosGLOBAL void
3407285809SscottltdsaGetGlobalPhyParams(
3408285809Sscottl                 tiRoot_t *tiRoot
3409285809Sscottl                 )
3410285809Sscottl{
3411285809Sscottl  tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3412285809Sscottl  tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3413285809Sscottl  agsaRoot_t     *agRoot = &tdsaAllShared->agRootInt;
3414285809Sscottl  char           *buffer;
3415285809Sscottl  bit32          buffLen;
3416285809Sscottl  bit32          lenRecv = 0;
3417285809Sscottl  char           *pLastUsedChar = agNULL;
3418285809Sscottl  char           tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3419285809Sscottl  char           globalStr[]     = "Global";
3420285809Sscottl  char           phyParmsStr[12];
3421285809Sscottl  int            i;
3422285809Sscottl  bit32          LinkRate = 15/*7*/, Mode = 3, OpticalMode = 0;
3423285809Sscottl  bit32          LinkRateRead = agFALSE, ModeRead = agFALSE, OpticalModeRead = agFALSE;
3424285809Sscottl  bit32          flag = agFALSE; /* true only for PM8008 or PM8009 (SPCv and SPCve) controller */
3425285809Sscottl
3426285809Sscottl  TI_DBG6(("tdsaGetGlobalPhyParams: start \n"));
3427285809Sscottl  TI_DBG6(("tdsaGetGlobalPhyParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3428285809Sscottl
3429285809Sscottl  if (tiIS_8PHY(agRoot) )
3430285809Sscottl  {
3431285809Sscottl    TI_DBG6(("tdsaGetGlobalPhyParams: SPCv or SPCve \n"));
3432285809Sscottl    flag = agTRUE;
3433285809Sscottl  }
3434285809Sscottl
3435285809Sscottl  TI_DBG6(("tdsaGetGlobalPhyParams: flag %d\n", flag));
3436285809Sscottl
3437285809Sscottl#ifdef FPGA_CARD
3438285809Sscottl  for (i=0;i<TD_MAX_NUM_PHYS;i++)
3439285809Sscottl  {
3440285809Sscottl    /* setting default phy properties */
3441285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3442285809Sscottl    OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3443285809Sscottl    /* 1.5G only, SAS/SATA, no spin-up control */
3444285809Sscottl    tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 */
3445285809Sscottl  }
3446285809Sscottl#else
3447285809Sscottl  /* ASIC */
3448285809Sscottl#ifdef INITIATOR_DRIVER
3449285809Sscottl  for (i=0;i<TD_MAX_NUM_PHYS;i++)
3450285809Sscottl  {
3451285809Sscottl    /* setting default phy properties */
3452285809Sscottl    if (flag == agFALSE) /* SPC or SPCv+ */
3453285809Sscottl    {
3454285809Sscottl      if (0 <= i && i <= 7)
3455285809Sscottl      {
3456285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3457285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3458285809Sscottl      }
3459285809Sscottl      else
3460285809Sscottl      {
3461285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
3462285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
3463285809Sscottl      }
3464285809Sscottl    }
3465285809Sscottl    else /* SPCv or SPCve */
3466285809Sscottl    {
3467285809Sscottl      if (0 <= i && i <= 3)
3468285809Sscottl      {
3469285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3470285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05060708);
3471285809Sscottl      }
3472285809Sscottl      else if (4 <= i && i <= 7)
3473285809Sscottl      {
3474285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3475285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x02020202);
3476285809Sscottl      }
3477285809Sscottl      else /* don't care */
3478285809Sscottl      {
3479285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01010101);
3480285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f);
3481285809Sscottl      }
3482285809Sscottl
3483285809Sscottl    }
3484285809Sscottl    /* 1.5G/3G , SAS/SATA, no spin-up control */
3485285809Sscottl    tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 55 */
3486285809Sscottl    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))));
3487285809Sscottl
3488285809Sscottl  }
3489285809Sscottl#endif
3490285809Sscottl#ifdef TARGET_DRIVER
3491285809Sscottl   for (i=0;i<TD_MAX_NUM_PHYS;i++)
3492285809Sscottl  {
3493285809Sscottl    /* setting default phy properties */
3494285809Sscottl    /* SPC; narrow ports; 8 ports
3495285809Sscottl       SPCv, SPCve wide port; 8 ports
3496285809Sscottl       SPCv+ wide port; 16 ports
3497285809Sscottl    */
3498285809Sscottl    if (tiIS_SPC(agRoot))
3499285809Sscottl    {
3500285809Sscottl       if (0 <= i && i <= 7)
3501285809Sscottl      {
3502285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3503285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3504285809Sscottl      }
3505285809Sscottl      else
3506285809Sscottl      {
3507285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3508285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3509285809Sscottl      }
3510285809Sscottl    }
3511285809Sscottl    else if (tiIS_16PHY(agRoot))
3512285809Sscottl    {
3513285809Sscottl       if (0 <= i && i <= 7)
3514285809Sscottl      {
3515285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3516285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3517285809Sscottl      }
3518285809Sscottl      else
3519285809Sscottl      {
3520285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3521285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3522285809Sscottl      }
3523285809Sscottl    }
3524285809Sscottl    else
3525285809Sscottl    {
3526285809Sscottl      if (0 <= i && i <= 3)
3527285809Sscottl      {
3528285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3529285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x05050500+i);
3530285809Sscottl      }
3531285809Sscottl      else if (4 <= i && i <= 7)
3532285809Sscottl      {
3533285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3534285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x06060600+i);
3535285809Sscottl      }
3536285809Sscottl      else /* don't care */
3537285809Sscottl      {
3538285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, 0x01020304);
3539285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, 0x0f0f0f0f+i);
3540285809Sscottl      }
3541285809Sscottl    }
3542285809Sscottl    /* 1.5G/3G , SAS/SATA, no spin-up control */
3543285809Sscottl    tdsaAllShared->Ports[i].agPhyConfig.phyProperties = 0x31; /* 49 The default is 1.5G and will be changed based on the registry value */
3544285809Sscottl    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))));
3545285809Sscottl
3546285809Sscottl  }
3547285809Sscottl#endif
3548285809Sscottl#endif
3549285809Sscottl
3550285809Sscottl
3551285809Sscottl  buffer = tmpBuffer;
3552285809Sscottl  buffLen = sizeof(tmpBuffer);
3553285809Sscottl
3554285809Sscottl  osti_memset(buffer, 0, buffLen);
3555285809Sscottl  lenRecv = 0;
3556285809Sscottl
3557285809Sscottl  /* needs to read Phy's id frame */
3558285809Sscottl  for (i=0;i<TD_MAX_NUM_PHYS;i++)
3559285809Sscottl  {
3560285809Sscottl    if (flag == agFALSE)
3561285809Sscottl    {
3562285809Sscottl      osti_sprintf(phyParmsStr,"PhyParms%d", i);
3563285809Sscottl    }
3564285809Sscottl    else
3565285809Sscottl    {
3566285809Sscottl      if (i >= 4)
3567285809Sscottl      {
3568285809Sscottl        osti_sprintf(phyParmsStr,"PhyParms%d", i+4);
3569285809Sscottl      }
3570285809Sscottl      else
3571285809Sscottl      {
3572285809Sscottl        osti_sprintf(phyParmsStr,"PhyParms%d", i);
3573285809Sscottl      }
3574285809Sscottl    }
3575285809Sscottl
3576285809Sscottl    TI_DBG6(("tdsaGetGlobalPhyParams: i %d PhyParms %s\n", i, phyParmsStr));
3577285809Sscottl
3578285809Sscottl
3579285809Sscottl    if ((ostiGetTransportParam (
3580285809Sscottl                                tiRoot,
3581285809Sscottl                                globalStr,
3582285809Sscottl                                phyParmsStr,
3583285809Sscottl                                agNULL,
3584285809Sscottl                                agNULL,
3585285809Sscottl                                agNULL,
3586285809Sscottl                                agNULL,
3587285809Sscottl                                "AddrHi",
3588285809Sscottl                                buffer,
3589285809Sscottl                                buffLen,
3590285809Sscottl                                &lenRecv
3591285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3592285809Sscottl    {
3593285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3594285809Sscottl      {
3595285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3596285809Sscottl        TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi 0x%x \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3597285809Sscottl      }
3598285809Sscottl      else
3599285809Sscottl      {
3600285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressHi, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3601285809Sscottl        TI_DBG6(("tdsaGetGlobalPhyParams: phy %d hi %d \n", i, SA_IDFRM_GET_SAS_ADDRESSHI(&(tdsaAllShared->Ports[i].SASID))));
3602285809Sscottl
3603285809Sscottl      }
3604285809Sscottl    }
3605285809Sscottl
3606285809Sscottl
3607285809Sscottl    osti_memset(buffer, 0, buffLen);
3608285809Sscottl    lenRecv = 0;
3609285809Sscottl
3610285809Sscottl    if ((ostiGetTransportParam (
3611285809Sscottl                                tiRoot,
3612285809Sscottl                                globalStr,
3613285809Sscottl                                phyParmsStr,
3614285809Sscottl                                agNULL,
3615285809Sscottl                                agNULL,
3616285809Sscottl                                agNULL,
3617285809Sscottl                                agNULL,
3618285809Sscottl                                "AddrLow",
3619285809Sscottl                                buffer,
3620285809Sscottl                                buffLen,
3621285809Sscottl                                &lenRecv
3622285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3623285809Sscottl    {
3624285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3625285809Sscottl      {
3626285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 0));
3627285809Sscottl        TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo 0x%x\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3628285809Sscottl      }
3629285809Sscottl      else
3630285809Sscottl      {
3631285809Sscottl        OSSA_WRITE_BE_32(agRoot, tdsaAllShared->Ports[i].SASID.sasAddressLo, 0, osti_strtoul(buffer, &pLastUsedChar, 10));
3632285809Sscottl        TI_DBG6(("tdsaGetGlobalPhyParams: phy %d lo %d\n", i, SA_IDFRM_GET_SAS_ADDRESSLO(&(tdsaAllShared->Ports[i].SASID))));
3633285809Sscottl
3634285809Sscottl      }
3635285809Sscottl    }
3636285809Sscottl    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))));
3637285809Sscottl
3638285809Sscottl    /* phy properties */
3639285809Sscottl    osti_memset(buffer, 0, buffLen);
3640285809Sscottl    lenRecv = 0;
3641285809Sscottl/*
3642285809Sscottl    if ((ostiGetTransportParam (
3643285809Sscottl                                tiRoot,
3644285809Sscottl                                globalStr,
3645285809Sscottl                                phyParmsStr,
3646285809Sscottl                                agNULL,
3647285809Sscottl                                agNULL,
3648285809Sscottl                                agNULL,
3649285809Sscottl                                agNULL,
3650285809Sscottl                                "LinkRate",
3651285809Sscottl                                buffer,
3652285809Sscottl                                buffLen,
3653285809Sscottl                                &lenRecv
3654285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3655285809Sscottl    {
3656285809Sscottl      LinkRateRead = agTRUE;
3657285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3658285809Sscottl      {
3659285809Sscottl        LinkRate = osti_strtoul(buffer, &pLastUsedChar, 0);
3660285809Sscottl        TI_DBG2(("tdsaGetGlobalPhyParams: phy %d linkrate 0x%x \n", i, LinkRate));
3661285809Sscottl      }
3662285809Sscottl      else
3663285809Sscottl      {
3664285809Sscottl        LinkRate = osti_strtoul(buffer, &pLastUsedChar, 10);
3665285809Sscottl        TI_DBG2(("tdsaGetGlobalPhyParams: phy %d linkrate %d \n", i, LinkRate));
3666285809Sscottl      }
3667285809Sscottl    }
3668285809Sscottl*/
3669285809Sscottl
3670285809Sscottl    osti_memset(buffer, 0, buffLen);
3671285809Sscottl    lenRecv = 0;
3672285809Sscottl
3673285809Sscottl    if ((ostiGetTransportParam (
3674285809Sscottl                                tiRoot,
3675285809Sscottl                                globalStr,
3676285809Sscottl                                phyParmsStr,
3677285809Sscottl                                agNULL,
3678285809Sscottl                                agNULL,
3679285809Sscottl                                agNULL,
3680285809Sscottl                                agNULL,
3681285809Sscottl                                "Mode",
3682285809Sscottl                                buffer,
3683285809Sscottl                                buffLen,
3684285809Sscottl                                &lenRecv
3685285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3686285809Sscottl    {
3687285809Sscottl      ModeRead = agTRUE;
3688285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3689285809Sscottl      {
3690285809Sscottl        Mode = osti_strtoul(buffer, &pLastUsedChar, 0);
3691285809Sscottl        TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode 0x%x \n", i, Mode));
3692285809Sscottl      }
3693285809Sscottl      else
3694285809Sscottl      {
3695285809Sscottl        Mode = osti_strtoul(buffer, &pLastUsedChar, 10);
3696285809Sscottl        TI_DBG2(("tdsaGetGlobalPhyParams: phy %d Mode %d \n", i, Mode));
3697285809Sscottl      }
3698285809Sscottl    }
3699285809Sscottl
3700285809Sscottl    osti_memset(buffer, 0, buffLen);
3701285809Sscottl    lenRecv = 0;
3702285809Sscottl
3703285809Sscottl    if ((ostiGetTransportParam (
3704285809Sscottl                                tiRoot,
3705285809Sscottl                                globalStr,
3706285809Sscottl                                phyParmsStr,
3707285809Sscottl                                agNULL,
3708285809Sscottl                                agNULL,
3709285809Sscottl                                agNULL,
3710285809Sscottl                                agNULL,
3711285809Sscottl                                "OpticalMode",
3712285809Sscottl                                buffer,
3713285809Sscottl                                buffLen,
3714285809Sscottl                                &lenRecv
3715285809Sscottl                                ) == tiSuccess) && (lenRecv != 0))
3716285809Sscottl    {
3717285809Sscottl      OpticalModeRead = agTRUE;
3718285809Sscottl      if (osti_strncmp(buffer, "0x", 2) == 0)
3719285809Sscottl      {
3720285809Sscottl        OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 0);
3721285809Sscottl        TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode 0x%x \n", i, OpticalMode));
3722285809Sscottl      }
3723285809Sscottl      else
3724285809Sscottl      {
3725285809Sscottl        OpticalMode = osti_strtoul(buffer, &pLastUsedChar, 10);
3726285809Sscottl        TI_DBG2(("tdsaGetGlobalPhyParams: phy %d OpticalMode %d \n", i, OpticalMode));
3727285809Sscottl      }
3728285809Sscottl    }
3729285809Sscottl
3730285809Sscottl    TI_DBG2(("tdsaGetGlobalPhyParams:A phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3731285809Sscottl    tdsaParseLinkRateMode(tiRoot, i, LinkRateRead, ModeRead, OpticalModeRead, LinkRate, Mode, OpticalMode);
3732285809Sscottl
3733285809Sscottl    TI_DBG2(("tdsaGetGlobalPhyParams:B phy %d phyProperties %d\n", i, tdsaAllShared->Ports[i].agPhyConfig.phyProperties));
3734285809Sscottl
3735285809Sscottl
3736285809Sscottl
3737285809Sscottl    /**********************************************/
3738285809Sscottl    osti_memset(buffer, 0, buffLen);
3739285809Sscottl    lenRecv = 0;
3740285809Sscottl    /* restore default */
3741285809Sscottl    LinkRate = 15;
3742285809Sscottl    Mode = 3;
3743285809Sscottl    OpticalMode = 0;
3744285809Sscottl    LinkRateRead = agTRUE;//VG
3745285809Sscottl    ModeRead = agFALSE;
3746285809Sscottl    OpticalModeRead = agFALSE;
3747285809Sscottl
3748285809Sscottl
3749285809Sscottl  } /* end for */
3750285809Sscottl
3751285809Sscottl  return;
3752285809Sscottl}
3753285809Sscottl
3754285809Sscottl/*****************************************************************************
3755285809Sscottl*! \brief  tdsaGetPortParams
3756285809Sscottl*
3757285809Sscottl*  Purpose:  This function reads port-related configuration parameters from the
3758285809Sscottl*            configuration file
3759285809Sscottl*
3760285809Sscottl*  \param  tiRoot:            Pointer to driver/port instance.
3761285809Sscottl*
3762285809Sscottl*  \return:     None
3763285809Sscottl*
3764285809Sscottl*  \note - just a place holder for now
3765285809Sscottl*
3766285809Sscottl*****************************************************************************/
3767285809SscottlosGLOBAL void
3768285809SscottltdsaGetPortParams(
3769285809Sscottl                  tiRoot_t *tiRoot
3770285809Sscottl                  )
3771285809Sscottl{
3772285809Sscottl  tdsaRoot_t     *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3773285809Sscottl  tdsaContext_t  *tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3774285809Sscottl
3775285809Sscottl
3776285809Sscottl  char    *buffer;
3777285809Sscottl  bit32   buffLen;
3778285809Sscottl  bit32   lenRecv = 0;
3779285809Sscottl  char    *pLastUsedChar = agNULL;
3780285809Sscottl  char    tmpBuffer[DEFAULT_KEY_BUFFER_SIZE];
3781285809Sscottl  char    globalStr[]     = "Global";
3782285809Sscottl  char    portParmsStr[] = "PortParms";
3783285809Sscottl
3784285809Sscottl  TI_DBG6(("tdsaGetPortParams: start \n"));
3785285809Sscottl  TI_DBG6(("tdsaGetPortParams: tdsaRoot %p tdsaAllShared %p \n", tdsaRoot,tdsaAllShared));
3786285809Sscottl
3787285809Sscottl  buffer = tmpBuffer;
3788285809Sscottl  buffLen = sizeof(tmpBuffer);
3789285809Sscottl  osti_memset(buffer, 0, buffLen);
3790285809Sscottl
3791285809Sscottl  if ((ostiGetTransportParam (
3792285809Sscottl                              tiRoot,
3793285809Sscottl                              globalStr,
3794285809Sscottl                              portParmsStr,
3795285809Sscottl                              agNULL,
3796285809Sscottl                              agNULL,
3797285809Sscottl                              agNULL,
3798285809Sscottl                              agNULL,
3799285809Sscottl                              "InterruptDelay",
3800285809Sscottl                              buffer,
3801285809Sscottl                              buffLen,
3802285809Sscottl                              &lenRecv
3803285809Sscottl                              ) == tiSuccess) && (lenRecv != 0))
3804285809Sscottl  {
3805285809Sscottl    if (osti_strncmp(buffer, "0x", 2) == 0)
3806285809Sscottl    {
3807285809Sscottl      tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 0);
3808285809Sscottl    }
3809285809Sscottl    else
3810285809Sscottl    {
3811285809Sscottl      tdsaAllShared->currentInterruptDelay = osti_strtoul (buffer, &pLastUsedChar, 10);
3812285809Sscottl    }
3813285809Sscottl    TI_DBG6(("tdsaGetPortParams: in \n"));
3814285809Sscottl  }
3815285809Sscottl  osti_memset(buffer, 0, buffLen);
3816285809Sscottl  lenRecv = 0;
3817285809Sscottl
3818285809Sscottl  TI_DBG6(("tdsaGetPortParams: out \n"));
3819285809Sscottl
3820285809Sscottl  /* and more .... */
3821285809Sscottl
3822285809Sscottl
3823285809Sscottl  return;
3824285809Sscottl}
3825285809Sscottl
3826285809Sscottl#ifdef FW_EVT_LOG_TST
3827285809Sscottlvoid saLogDump(agsaRoot_t *agRoot,
3828285809Sscottl               U32    *eventLogSize,
3829285809Sscottl               U32   **eventLogAddress);
3830285809Sscottl
3831285809Sscottlvoid tiLogDump(tiRoot_t *tiRoot, U32 *size, U32 **addr)
3832285809Sscottl{
3833285809Sscottl  tdsaRoot_t    *tdsaRoot;
3834285809Sscottl  tdsaContext_t *tdsaAllShared;
3835285809Sscottl
3836285809Sscottl  tdsaRoot = (tdsaRoot_t*)tiRoot->tdData;
3837285809Sscottl  tdsaAllShared = (tdsaContext_t*)&(tdsaRoot->tdsaAllShared);
3838285809Sscottl  saLogDump(&tdsaAllShared->agRootNonInt, size, addr);
3839285809Sscottl}
3840285809Sscottl#endif
3841285809Sscottl
3842285809Sscottl
3843285809Sscottl
3844285809Sscottl/*****************************************************************************
3845285809Sscottl*! \brief  tiCOMPortInit
3846285809Sscottl*
3847285809Sscottl*  Purpose: This function is called to initialize the port hardware.
3848285809Sscottl*           This call could only be called until after the successful
3849285809Sscottl*           completion tiCOMInit().
3850285809Sscottl*
3851285809Sscottl*  \param   tiRoot:         Pointer to root data structure.
3852285809Sscottl*  \param   sysIntsActive:  system interrupt flag
3853285809Sscottl*
3854285809Sscottl*  \return:
3855285809Sscottl*           tiSuccess:      Successful.
3856285809Sscottl*           Others:             Fail.
3857285809Sscottl*
3858285809Sscottl*  \note -
3859285809Sscottl*
3860285809Sscottl*****************************************************************************/
3861285809SscottlosGLOBAL bit32
3862285809SscottltiCOMPortInit(
3863285809Sscottl              tiRoot_t      *tiRoot,
3864285809Sscottl              bit32         sysIntsActive
3865285809Sscottl              )
3866285809Sscottl{
3867285809Sscottl  tdsaRoot_t          *tdsaRoot;
3868285809Sscottl  tdsaContext_t       *tdsaAllShared;
3869285809Sscottl  agsaRoot_t          *agRoot;
3870285809Sscottl  tiLoLevelResource_t *loResource;
3871285809Sscottl  bit32                status = tiError;
3872285809Sscottl  bit32                i;
3873285809Sscottl
3874285809Sscottl  agsaQueueConfig_t   *QueueConfig;
3875285809Sscottl
3876285809Sscottl#ifdef CONTROLLER_STATUS_TESTING
3877285809Sscottl  static agsaControllerStatus_t  agcontrollerStatus;
3878285809Sscottl#endif /* CONTROLLER_STATUS_TESTING */
3879285809Sscottl
3880285809Sscottl#ifdef CONTROLLER_INFO_TESTING
3881285809Sscottl  static agsaControllerInfo_t  agcontrollerInfo;
3882285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
3883285809Sscottl
3884285809Sscottl#ifdef CONTROLLER_ENCRYPT_TESTING
3885285809Sscottl  static  agsaEncryptInfo_t       agsaEncryptInfo;
3886285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
3887285809Sscottl
3888285809Sscottl  static agsaMemoryRequirement_t agMemoryRequirement;
3889285809Sscottl#ifdef ECHO_TESTING
3890285809Sscottl  /* temp */
3891285809Sscottl  static   bit8                     payload[56];
3892285809Sscottl#endif
3893285809Sscottl
3894285809Sscottl#if defined(FDS_DM) || defined(FDS_SM)
3895285809Sscottl  static agsaMemoryRequirement_t memRequirement;
3896285809Sscottl  bit32                          maxQueueSets = 0;
3897285809Sscottl  bit32                          LLMemCount = 0;
3898285809Sscottl  bit32                          usecsPerTick = 0;
3899285809Sscottl  static agsaSwConfig_t          tmpLLSwConfig;
3900285809Sscottl#endif
3901285809Sscottl
3902285809Sscottl#ifdef FDS_DM
3903285809Sscottl   static  dmRoot_t                       *dmRoot = agNULL;
3904285809Sscottl#ifdef FDS_SM
3905285809Sscottl   static dmSwConfig_t                   dmSwConfig;
3906285809Sscottl#endif
3907285809Sscottl  static dmMemoryRequirement_t   dmMemRequirement;
3908285809Sscottl  bit32                          DMMemCount = 0;
3909285809Sscottl#endif
3910285809Sscottl
3911285809Sscottl#if defined(FDS_DM) && defined(FDS_SM)
3912285809Sscottl  bit32                          dmUsecsPerTick = 0;
3913285809Sscottl  bit32                          dmMaxNumLocks = 0;
3914285809Sscottl#endif
3915285809Sscottl
3916285809Sscottl#ifdef FDS_SM
3917285809Sscottl  smRoot_t                       *smRoot = agNULL;
3918285809Sscottl//  smSwConfig_t                   smSwConfig;
3919285809Sscottl  static smMemoryRequirement_t   smMemRequirement;
3920285809Sscottl  bit32                          SMMemCount = 0;
3921285809Sscottl#endif
3922285809Sscottl
3923285809Sscottl#ifndef TURN_OFF_HDA
3924285809Sscottl  static agsaFwImg_t                    HDAImg;
3925285809Sscottl#endif /*  TURN_OFF_HDA */
3926285809Sscottl
3927285809Sscottl  TI_DBG3(("tiCOMPortInit: start\n"));
3928285809Sscottl  TI_DBG6(("tiCOMPortInit: sizeof agsaMemoryRequirement_t %d\n", (int)sizeof(agsaMemoryRequirement_t)));
3929285809Sscottl
3930285809Sscottl  tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
3931285809Sscottl  tdsaAllShared = (tdsaContext_t *)&(tdsaRoot->tdsaAllShared);
3932285809Sscottl
3933285809Sscottl  osti_memset(&agMemoryRequirement, 0, sizeof(agsaMemoryRequirement_t));
3934285809Sscottl  /*
3935285809Sscottl   * don't do anything if reset is in progress
3936285809Sscottl   */
3937285809Sscottl  if (tdsaAllShared->flags.resetInProgress == agTRUE)
3938285809Sscottl  {
3939285809Sscottl    TI_DBG1(("tiCOMPortInit: resetinProgress error\n"));
3940285809Sscottl    return tiError;
3941285809Sscottl  }
3942285809Sscottl
3943285809Sscottl  loResource = &(tdsaAllShared->loResource);
3944285809Sscottl
3945285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
3946285809Sscottl  tdsaAllShared->flags.sysIntsActive    = sysIntsActive;
3947285809Sscottl
3948285809Sscottl  /*
3949285809Sscottl     gets port-related parameters; not in use for now
3950285809Sscottl     tdsaGetPortParams(tiRoot);
3951285809Sscottl   */
3952285809Sscottl
3953285809Sscottl  /* call these before agroot is created  for testing */
3954285809Sscottl
3955285809Sscottl
3956285809Sscottl#ifdef CONTROLLER_STATUS_TESTING
3957285809Sscottl  TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
3958285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
3959285809Sscottl
3960285809Sscottl#ifdef CONTROLLER_INFO_TESTING
3961285809Sscottl  TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
3962285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
3963285809Sscottl
3964285809Sscottl#ifdef CONTROLLER_ENCRYPT_TESTING
3965285809Sscottl  TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo ) ));
3966285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
3967285809Sscottl
3968285809Sscottl
3969285809Sscottl  tdsaGetSwConfigParams(tiRoot);
3970285809Sscottl  tdsaPrintSwConfig(&(tdsaAllShared->SwConfig));
3971285809Sscottl
3972285809Sscottl  /* setting interrupt requirements */
3973285809Sscottl  tdsaAllShared->SwConfig.max_MSIX_InterruptVectors = loResource->loLevelOption.maxInterruptVectors;
3974285809Sscottl  tdsaAllShared->SwConfig.max_MSI_InterruptVectors = loResource->loLevelOption.max_MSI_InterruptVectors;
3975285809Sscottl  tdsaAllShared->SwConfig.legacyInt_X = loResource->loLevelOption.flag;
3976285809Sscottl  TI_DBG2(("tiCOMPortInit: got max_MSIX_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSIX_InterruptVectors));
3977285809Sscottl  TI_DBG2(("tiCOMPortInit: got max_MSI_InterruptVectors %d \n", tdsaAllShared->SwConfig.max_MSI_InterruptVectors));
3978285809Sscottl  TI_DBG2(("tiCOMPortInit: got flag - legacyInt_X %d \n", tdsaAllShared->SwConfig.legacyInt_X));
3979285809Sscottl
3980285809Sscottl  /* error checking for interrupt types */
3981285809Sscottl  if (
3982285809Sscottl      ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3983285809Sscottl       (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0)  &&
3984285809Sscottl       (tdsaAllShared->SwConfig.legacyInt_X == 0))
3985285809Sscottl      ||
3986285809Sscottl      ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0) &&
3987285809Sscottl       (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0)  &&
3988285809Sscottl       (tdsaAllShared->SwConfig.legacyInt_X == 0))
3989285809Sscottl      ||
3990285809Sscottl      ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3991285809Sscottl       (tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0)  &&
3992285809Sscottl       (tdsaAllShared->SwConfig.legacyInt_X == 0))
3993285809Sscottl      ||
3994285809Sscottl      ((tdsaAllShared->SwConfig.max_MSIX_InterruptVectors == 0) &&
3995285809Sscottl       (tdsaAllShared->SwConfig.max_MSI_InterruptVectors == 0)  &&
3996285809Sscottl       (tdsaAllShared->SwConfig.legacyInt_X != 0))
3997285809Sscottl     )
3998285809Sscottl  {
3999285809Sscottl    /* do nothing */
4000285809Sscottl  }
4001285809Sscottl  else
4002285809Sscottl  {
4003285809Sscottl    TI_DBG1(("tiCOMPortInit: incorrect interrupt\n"));
4004285809Sscottl    return tiError;
4005285809Sscottl  }
4006285809Sscottl
4007285809Sscottl  QueueConfig = &tdsaAllShared->QueueConfig;
4008285809Sscottl
4009285809Sscottl  for(i=0;i<QueueConfig->numInboundQueues;i++)
4010285809Sscottl  {
4011285809Sscottl    QueueConfig->inboundQueues[i].elementCount = tdsaAllShared->InboundQueueSize[i];
4012285809Sscottl    QueueConfig->inboundQueues[i].elementSize = tdsaAllShared->InboundQueueEleSize[i];
4013285809Sscottl    QueueConfig->inboundQueues[i].priority = tdsaAllShared->InboundQueuePriority[i];
4014285809Sscottl    QueueConfig->inboundQueues[i].reserved = 0;
4015285809Sscottl    TI_DBG6(("tiCOMPortInit: InboundQueuePriroity %d \n", tdsaAllShared->InboundQueuePriority[i]));
4016285809Sscottl  }
4017285809Sscottl  for(i=0;i<QueueConfig->numOutboundQueues;i++)
4018285809Sscottl  {
4019285809Sscottl    QueueConfig->outboundQueues[i].elementCount = tdsaAllShared->OutboundQueueSize[i];
4020285809Sscottl    QueueConfig->outboundQueues[i].elementSize = tdsaAllShared->OutboundQueueEleSize[i];
4021285809Sscottl    QueueConfig->outboundQueues[i].interruptDelay = tdsaAllShared->OutboundQueueInterruptDelay[i]; /* default 0; no interrupt delay */
4022285809Sscottl    QueueConfig->outboundQueues[i].interruptCount = tdsaAllShared->OutboundQueueInterruptCount[i]; /* default 1 */
4023285809Sscottl    QueueConfig->outboundQueues[i].interruptEnable = tdsaAllShared->OutboundQueueInterruptEnable[i]; /* default 1 */
4024285809Sscottl    QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
4025285809Sscottl    if (tdsaAllShared->SwConfig.max_MSIX_InterruptVectors != 0)
4026285809Sscottl    {
4027285809Sscottl      QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSIX_InterruptVectors;
4028285809Sscottl    }
4029285809Sscottl    else if (tdsaAllShared->SwConfig.max_MSI_InterruptVectors != 0)
4030285809Sscottl    {
4031285809Sscottl      QueueConfig->outboundQueues[i].interruptVectorIndex = i % tdsaAllShared->SwConfig.max_MSI_InterruptVectors;
4032285809Sscottl    }
4033285809Sscottl    else
4034285809Sscottl    {
4035285809Sscottl      QueueConfig->outboundQueues[i].interruptVectorIndex = 0;
4036285809Sscottl    }
4037285809Sscottl    TI_DBG6(("tiCOMPortInit: OutboundQueueInterruptDelay %d OutboundQueueInterruptCount %d OutboundQueueInterruptEnable %d\n", tdsaAllShared->OutboundQueueInterruptDelay[i], tdsaAllShared->OutboundQueueInterruptCount[i], tdsaAllShared->OutboundQueueInterruptEnable[i]));
4038285809Sscottl
4039285809Sscottl  }
4040285809Sscottl  /* queue option */
4041285809Sscottl  QueueConfig->queueOption = tdsaAllShared->QueueOption;
4042285809Sscottl
4043285809Sscottl  tdsaAllShared->SwConfig.param3 = (void *)QueueConfig;
4044285809Sscottl  tdsaAllShared->SwConfig.stallUsec = 10;
4045285809Sscottl
4046285809Sscottl  /* finds a first high priority queue for SMP */
4047285809Sscottl  tdsaAllShared->SMPQNum = 0; /* default */
4048285809Sscottl  for(i=0;i<QueueConfig->numInboundQueues;i++)
4049285809Sscottl  {
4050285809Sscottl    if (QueueConfig->inboundQueues[i].priority != DEFAULT_INBOUND_QUEUE_PRIORITY) /* 0 */
4051285809Sscottl    {
4052285809Sscottl      tdsaAllShared->SMPQNum = i;
4053285809Sscottl      break;
4054285809Sscottl    }
4055285809Sscottl  }
4056285809Sscottl
4057285809Sscottl  tdsaGetHwConfigParams(tiRoot);
4058285809Sscottl
4059285809Sscottl  tdsaPrintHwConfig(&(tdsaAllShared->HwConfig));
4060285809Sscottl
4061285809Sscottl#ifdef TARGET_DRIVER
4062285809Sscottl  /* target, not yet */
4063285809Sscottl  if (tdsaAllShared->currentOperation & TD_OPERATION_TARGET)
4064285809Sscottl  {
4065285809Sscottl    ttdssGetTargetParams(tiRoot);
4066285809Sscottl  }
4067285809Sscottl#endif
4068285809Sscottl
4069285809Sscottl#if defined(FDS_DM) && defined(FDS_SM)
4070285809Sscottl  /*
4071285809Sscottl    needs to call saGetRequirements() to find out agMemoryRequirement.count requested by LL
4072285809Sscottl  */
4073285809Sscottl  osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4074285809Sscottl
4075285809Sscottl  saGetRequirements(agRoot,
4076285809Sscottl                    &tmpLLSwConfig,
4077285809Sscottl                    &memRequirement,
4078285809Sscottl                    &usecsPerTick,
4079285809Sscottl                    &maxQueueSets
4080285809Sscottl                    );
4081285809Sscottl  TI_DBG1(("tiCOMPortInit: usecsPerTick %d\n", usecsPerTick));
4082285809Sscottl
4083285809Sscottl  TI_DBG1(("tiCOMPortInit: LL memRequirement.count %d\n", memRequirement.count));
4084285809Sscottl  TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4085285809Sscottl  LLMemCount = memRequirement.count;
4086285809Sscottl
4087285809Sscottl  /*
4088285809Sscottl    needs to call dmGetRequirements() to find out dmMemoryRequirement.count requested by DM
4089285809Sscottl  */
4090285809Sscottl
4091285809Sscottl  dmGetRequirements(dmRoot,
4092285809Sscottl                    &dmSwConfig,
4093285809Sscottl                    &dmMemRequirement,
4094285809Sscottl                    &dmUsecsPerTick,
4095285809Sscottl                    &dmMaxNumLocks
4096285809Sscottl                    );
4097285809Sscottl
4098285809Sscottl  TI_DBG1(("tiCOMPortInit: DM dmmemRequirement.count %d\n", dmMemRequirement.count));
4099285809Sscottl  TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4100285809Sscottl
4101285809Sscottl  DMMemCount = dmMemRequirement.count;
4102285809Sscottl  SMMemCount = loResource->loLevelMem.count - LLMemCount - DMMemCount;
4103285809Sscottl  agMemoryRequirement.count =  LLMemCount;
4104285809Sscottl
4105285809Sscottl  TI_DBG1(("tiCOMPortInit: SMMemCount %d\n", SMMemCount));
4106285809Sscottl
4107285809Sscottl
4108285809Sscottl#elif defined(FDS_DM)
4109285809Sscottl  /*
4110285809Sscottl    needs to call saGetRequirements() to find out agMemoryRequirement.count requested by LL
4111285809Sscottl  */
4112285809Sscottl  osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4113285809Sscottl
4114285809Sscottl  saGetRequirements(agRoot,
4115285809Sscottl                    &tmpLLSwConfig,
4116285809Sscottl                    &memRequirement,
4117285809Sscottl                    &usecsPerTick,
4118285809Sscottl                    &maxQueueSets
4119285809Sscottl                    );
4120285809Sscottl
4121285809Sscottl  TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
4122285809Sscottl  TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4123285809Sscottl
4124285809Sscottl  LLMemCount = memRequirement.count;
4125285809Sscottl  DMMemCount = loResource->loLevelMem.count - LLMemCount;
4126285809Sscottl
4127285809Sscottl  agMemoryRequirement.count =  LLMemCount;
4128285809Sscottl
4129285809Sscottl#elif defined(FDS_SM)
4130285809Sscottl  osti_memcpy(&tmpLLSwConfig, &(tdsaAllShared->SwConfig), sizeof(agsaSwConfig_t));
4131285809Sscottl
4132285809Sscottl  saGetRequirements(agRoot,
4133285809Sscottl                    &tmpLLSwConfig,
4134285809Sscottl                    &memRequirement,
4135285809Sscottl                    &usecsPerTick,
4136285809Sscottl                    &maxQueueSets
4137285809Sscottl                    );
4138285809Sscottl
4139285809Sscottl  TI_DBG1(("tiCOMPortInit: memRequirement.count %d\n", memRequirement.count));
4140285809Sscottl  TI_DBG1(("tiCOMPortInit: loResource->loLevelMem.count %d\n", loResource->loLevelMem.count));
4141285809Sscottl
4142285809Sscottl  LLMemCount = memRequirement.count;
4143285809Sscottl  SMMemCount = loResource->loLevelMem.count - LLMemCount;
4144285809Sscottl
4145285809Sscottl  agMemoryRequirement.count =  LLMemCount;
4146285809Sscottl
4147285809Sscottl#else
4148285809Sscottl
4149285809Sscottl  agMemoryRequirement.count = loResource->loLevelMem.count;
4150285809Sscottl
4151285809Sscottl#endif
4152285809Sscottl
4153285809Sscottl#if defined(FDS_DM) && defined(FDS_SM)
4154285809Sscottl  /* for debugging */
4155285809Sscottl  for(i=0;i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
4156285809Sscottl  {
4157285809Sscottl    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));
4158285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4159285809Sscottl  }
4160285809Sscottl#endif
4161285809Sscottl
4162285809Sscottl  /* initialize */
4163285809Sscottl  TI_DBG6(("tiCOMPortInit: AGSA_NUM_MEM_CHUNKS %d\n", AGSA_NUM_MEM_CHUNKS));
4164285809Sscottl  for(i=0;i<AGSA_NUM_MEM_CHUNKS;i++)
4165285809Sscottl  {
4166285809Sscottl    agMemoryRequirement.agMemory[i].virtPtr = agNULL;
4167285809Sscottl    agMemoryRequirement.agMemory[i].osHandle = agNULL;
4168285809Sscottl    agMemoryRequirement.agMemory[i].phyAddrUpper = 0;
4169285809Sscottl    agMemoryRequirement.agMemory[i].phyAddrLower = 0;
4170285809Sscottl    agMemoryRequirement.agMemory[i].totalLength = 0;
4171285809Sscottl    agMemoryRequirement.agMemory[i].numElements = 0;
4172285809Sscottl    agMemoryRequirement.agMemory[i].singleElementLength = 0;
4173285809Sscottl    agMemoryRequirement.agMemory[i].alignment = 0;
4174285809Sscottl    agMemoryRequirement.agMemory[i].type = 0;
4175285809Sscottl    agMemoryRequirement.agMemory[i].reserved = 0;
4176285809Sscottl  }
4177285809Sscottl
4178285809Sscottl  for(i=0;i<(int)agMemoryRequirement.count;i++)
4179285809Sscottl  {
4180285809Sscottl    TI_DBG2(("tiCOMPortInit: LL copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4181285809Sscottl    agMemoryRequirement.agMemory[i].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4182285809Sscottl    agMemoryRequirement.agMemory[i].osHandle = loResource->loLevelMem.mem[i].osHandle;
4183285809Sscottl    agMemoryRequirement.agMemory[i].phyAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4184285809Sscottl    agMemoryRequirement.agMemory[i].phyAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4185285809Sscottl    agMemoryRequirement.agMemory[i].totalLength = loResource->loLevelMem.mem[i].totalLength;
4186285809Sscottl    agMemoryRequirement.agMemory[i].numElements = loResource->loLevelMem.mem[i].numElements;
4187285809Sscottl    agMemoryRequirement.agMemory[i].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4188285809Sscottl    agMemoryRequirement.agMemory[i].alignment = loResource->loLevelMem.mem[i].alignment;
4189285809Sscottl    if (loResource->loLevelMem.mem[i].type == TI_DMA_MEM)
4190285809Sscottl    {
4191285809Sscottl      agMemoryRequirement.agMemory[i].type = AGSA_DMA_MEM;
4192285809Sscottl    }
4193285809Sscottl    else if (loResource->loLevelMem.mem[i].type == TI_CACHED_MEM)
4194285809Sscottl    {
4195285809Sscottl      agMemoryRequirement.agMemory[i].type = AGSA_CACHED_MEM;
4196285809Sscottl
4197285809Sscottl    }
4198285809Sscottl    else if (loResource->loLevelMem.mem[i].type == TI_CACHED_DMA_MEM)
4199285809Sscottl    {
4200285809Sscottl      agMemoryRequirement.agMemory[i].type = AGSA_CACHED_DMA_MEM;
4201285809Sscottl    }
4202285809Sscottl
4203285809Sscottl    agMemoryRequirement.agMemory[i].reserved = loResource->loLevelMem.mem[i].reserved;
4204285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4205285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4206285809Sscottl    loResource->loLevelMem.mem[i].physAddrUpper,
4207285809Sscottl    loResource->loLevelMem.mem[i].physAddrLower,
4208285809Sscottl    loResource->loLevelMem.mem[i].totalLength,
4209285809Sscottl    loResource->loLevelMem.mem[i].numElements));
4210285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4211285809Sscottl    loResource->loLevelMem.mem[i].singleElementLength,
4212285809Sscottl    loResource->loLevelMem.mem[i].alignment,
4213285809Sscottl    loResource->loLevelMem.mem[i].type,
4214285809Sscottl    loResource->loLevelMem.mem[i].reserved));
4215285809Sscottl
4216285809Sscottl  }
4217285809Sscottl  osti_memset(&(tdsaAllShared->tdFWControlEx), 0, sizeof(tdFWControlEx_t));
4218285809Sscottl
4219285809Sscottl  /*
4220285809Sscottl   * Note: Be sure to call this only once since sallsdk does initialization only once
4221285809Sscottl   * saInitialize(IN, IN, IN, IN, IN);
4222285809Sscottl   */
4223285809Sscottl
4224285809Sscottl  TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdDeviceIdVendId %x\n",tdsaAllShared->tdDeviceIdVendId));
4225285809Sscottl  TI_DBG1(("tiCOMPortInit: tdsaAllShared->tdSubVendorId= SUB_VEN_ID %x\n",tdsaAllShared->tdSubVendorId));
4226285809Sscottl
4227285809Sscottl  TI_DBG1(("tiCOMPortInit: swConfig->param1 hwDEVICE_ID_VENDID %x\n", tdsaAllShared->SwConfig.param1 ));
4228285809Sscottl  TI_DBG1(("tiCOMPortInit: swConfig->param2 hwSVID             %x\n", tdsaAllShared->SwConfig.param2));
4229285809Sscottl
4230285809Sscottl  /*
4231285809Sscottl    1. Read hostDirectAccessSupport
4232285809Sscottl    2. If set, read HDA images based on chip ID
4233285809Sscottl */
4234285809Sscottl
4235285809Sscottl  t_MacroCheck(agRoot);
4236285809Sscottl
4237285809Sscottl#ifndef TURN_OFF_HDA
4238285809Sscottl  if (tdsaAllShared->SwConfig.hostDirectAccessSupport != 0)
4239285809Sscottl  {
4240285809Sscottl    osti_memset(&HDAImg, 0, sizeof(HDAImg));
4241285809Sscottl    if (tiIS_SPC(agRoot))
4242285809Sscottl    {
4243285809Sscottl      TI_DBG1(("tiCOMPortInit: SPC HDA\n"));
4244285809Sscottl      HDAImg.aap1Img = (bit8*)(&aap1array);
4245285809Sscottl      HDAImg.aap1Len = sizeof( aap1array);
4246285809Sscottl      HDAImg.iopImg  = (bit8*)(&ioparray);
4247285809Sscottl      HDAImg.iopLen  = sizeof(  ioparray);
4248285809Sscottl      HDAImg.istrImg = (bit8*)(&istrarray);
4249285809Sscottl      HDAImg.istrLen = sizeof( istrarray);
4250285809Sscottl
4251285809Sscottl      HDAImg.ilaImg  = (bit8*)(&ilaarray);
4252285809Sscottl      HDAImg.ilaLen  = sizeof(ilaarray);
4253285809Sscottl    }
4254285809Sscottl    else if (tiIS_SPC6V(agRoot))
4255285809Sscottl    {
4256285809Sscottl      TI_DBG1(("tiCOMPortInit: SPCv HDA\n"));
4257285809Sscottl      HDAImg.aap1Img = (bit8*)(&spcv_aap1array);
4258285809Sscottl      HDAImg.aap1Len =  sizeof( spcv_aap1array);
4259285809Sscottl      HDAImg.iopImg  = (bit8*)(&spcv_ioparray);
4260285809Sscottl      HDAImg.iopLen  = sizeof(  spcv_ioparray);
4261285809Sscottl
4262285809Sscottl      HDAImg.ilaImg  = (bit8*)(&spcv_ilaarray);
4263285809Sscottl      HDAImg.ilaLen  = sizeof(spcv_ilaarray);
4264285809Sscottl    }
4265285809Sscottl    else if (tIsSPCV12G(agRoot))
4266285809Sscottl    {
4267285809Sscottl      TI_DBG1(("tiCOMPortInit: SPCv12G HDA\n"));
4268285809Sscottl      HDAImg.aap1Img = (bit8*)(&spcv12g_raaearray);
4269285809Sscottl      HDAImg.aap1Len =  sizeof( spcv12g_raaearray);
4270285809Sscottl      HDAImg.iopImg  = (bit8*)(&spcv12g_ioparray);
4271285809Sscottl      HDAImg.iopLen  = sizeof(  spcv12g_ioparray);
4272285809Sscottl
4273285809Sscottl      HDAImg.ilaImg  = (bit8*)(&spcv12g_ilaarray);
4274285809Sscottl      HDAImg.ilaLen  = sizeof(spcv12g_ilaarray);
4275285809Sscottl    }
4276285809Sscottl    else
4277285809Sscottl    {
4278285809Sscottl      TI_DBG1(("tiCOMPortInit: HDA Mode Unknown chip type 0x%08x\n",ossaHwRegReadConfig32(agRoot,0 )));
4279285809Sscottl      return tiError;
4280285809Sscottl    }
4281285809Sscottl    TI_DBG1(("tiCOMPortInit: HDA aap1Len 0x%08x iopLen 0x%08x ilaLen 0x%08x\n",HDAImg.aap1Len,HDAImg.iopLen,HDAImg.ilaLen ));
4282285809Sscottl    tdsaAllShared->SwConfig.param4 = &(HDAImg);
4283285809Sscottl  }
4284285809Sscottl  else
4285285809Sscottl  {
4286285809Sscottl    TI_DBG1(("tiCOMPortInit: HDA off\n"));
4287285809Sscottl    tdsaAllShared->SwConfig.param4 = agNULL;
4288285809Sscottl  }
4289285809Sscottl#endif /*  TURN_OFF_HDA */
4290285809Sscottl
4291285809Sscottl  if (tiIS_SPC(agRoot))
4292285809Sscottl  {
4293285809Sscottl    /* FW config is only for SPC */
4294285809Sscottl    tdsaAllShared->SwConfig.FWConfig = 0;
4295285809Sscottl    /* default port recovery timer 0x32 = 50 = 5000ms and port reset timer 3 (300 ms)*/
4296285809Sscottl    tdsaAllShared->SwConfig.PortRecoveryResetTimer = 0x30032;
4297285809Sscottl    TI_DBG1(("tiCOMPortInit:only for SPC FWConfig set\n"));
4298285809Sscottl  }
4299285809Sscottl
4300285809Sscottl  tdsaAllShared->SwConfig.fatalErrorInterruptVector = loResource->loLevelOption.maxInterruptVectors > 31 ? 31 : loResource->loLevelOption.maxInterruptVectors -1;
4301285809Sscottl
4302285809Sscottl  TI_DBG1(("tiCOMPortInit: SwConfig->FWConfig 0x%x\n", tdsaAllShared->SwConfig.FWConfig));
4303285809Sscottl  TI_DBG1(("tiCOMPortInit: SwConfig->fatalErrorInterruptVector 0x%x\n", tdsaAllShared->SwConfig.fatalErrorInterruptVector));
4304285809Sscottl  TI_DBG1(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d\n", loResource->loLevelOption.usecsPerTick));
4305285809Sscottl
4306285809Sscottl  status = saInitialize(agRoot,
4307285809Sscottl                        &agMemoryRequirement,
4308285809Sscottl                        &(tdsaAllShared->HwConfig),
4309285809Sscottl                        /* &temp_HwConfig, */
4310285809Sscottl                        &(tdsaAllShared->SwConfig),
4311285809Sscottl                        loResource->loLevelOption.usecsPerTick);
4312285809Sscottl
4313285809Sscottl  TI_DBG6(("tiCOMPortInit: loResource->loLevelOption.usecsPerTick %d 0x%x\n", loResource->loLevelOption.usecsPerTick, loResource->loLevelOption.usecsPerTick));
4314285809Sscottl
4315285809Sscottl  /*TI_DBG6(("tiCOMPortInit: tdsaAllShared->SwConfig.enableDIF %d\n", tdsaAllShared->SwConfig.enableDIF)); */
4316285809Sscottl  /*TI_DBG6(("tiCOMPortInit: tdsaAllShared->SwConfig.enableEncryption %d\n", tdsaAllShared->SwConfig.enableEncryption)); */
4317285809Sscottl
4318285809Sscottl  if(status == AGSA_RC_FAILURE )
4319285809Sscottl  {
4320285809Sscottl    TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_FAILURE, status 0x%x\n", status));
4321285809Sscottl    return tiError;
4322285809Sscottl  }
4323285809Sscottl
4324285809Sscottl  if( status == AGSA_RC_VERSION_INCOMPATIBLE)
4325285809Sscottl  {
4326285809Sscottl    TI_DBG1(("tiCOMPortInit: saInitialize AGSA_RC_VERSION_INCOMPATIBLE, status 0x%x\n", status));
4327285809Sscottl    return tiError;
4328285809Sscottl  }
4329285809Sscottl
4330285809Sscottl  /* let's make sdkData same for Int and Non-int agRoots */
4331285809Sscottl  tdsaAllShared->agRootInt.sdkData = tdsaAllShared->agRootNonInt.sdkData;
4332285809Sscottl
4333285809Sscottl
4334285809Sscottl  /* mark the port as initialized */
4335285809Sscottl  for(i=0;i<TD_MAX_NUM_PHYS;i++)
4336285809Sscottl  {
4337285809Sscottl    tdsaAllShared->Ports[i].flags.portInitialized = agTRUE;
4338285809Sscottl  }
4339285809Sscottl
4340285809Sscottl#ifdef INITIATOR_DRIVER                 //ini. only in stsdkll spec (TP)
4341285809Sscottl  /* register device registration callback function */
4342285809Sscottl  TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device registration\n"));
4343285809Sscottl  status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_ADDED, (void *)ossaDeviceRegistrationCB);
4344285809Sscottl  if (status == AGSA_RC_FAILURE)
4345285809Sscottl  {
4346285809Sscottl    TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register failed\n"));
4347285809Sscottl  }
4348285809Sscottl  else
4349285809Sscottl  {
4350285809Sscottl    TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Register succeeded\n"));
4351285809Sscottl  }
4352285809Sscottl#endif
4353285809Sscottl
4354285809Sscottl  /* register device deregistration callback function */
4355285809Sscottl  TI_DBG6(("tiCOMPortInit: calling saRegisterEventCallback for device de-registration\n"));
4356285809Sscottl  status = saRegisterEventCallback(agRoot, OSSA_EVENT_SOURCE_DEVICE_HANDLE_REMOVED, (void *)ossaDeregisterDeviceHandleCB);
4357285809Sscottl  if (status == AGSA_RC_FAILURE)
4358285809Sscottl  {
4359285809Sscottl    TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister failed\n"));
4360285809Sscottl  }
4361285809Sscottl  else
4362285809Sscottl  {
4363285809Sscottl    TI_DBG6(("tiCOMPortInit: saRegisterEventCallback Device Deregister succeeded\n"));
4364285809Sscottl  }
4365285809Sscottl
4366285809Sscottl#ifdef ECHO_TESTING
4367285809Sscottl  /* temporary to test saEchoCommand() */
4368285809Sscottl  /*
4369285809Sscottl    send echo
4370285809Sscottl  */
4371285809Sscottl  payload[0] = gEcho;
4372285809Sscottl  payload[55] = gEcho;
4373285809Sscottl  TI_DBG2(("tiCOMPortInit: calling saEchoCommand gEcho %d\n", gEcho));
4374285809Sscottl  saEchoCommand(agRoot, agNULL, tdsaRotateQnumber(tiRoot, agNULL), (void *)&payload);
4375285809Sscottl  gEcho++;
4376285809Sscottl#endif
4377285809Sscottl
4378285809Sscottl#ifdef CONTROLLER_STATUS_TESTING
4379285809Sscottl  TI_DBG1(("tiCOMPortInit: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
4380285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
4381285809Sscottl
4382285809Sscottl#ifdef CONTROLLER_INFO_TESTING
4383285809Sscottl  TI_DBG1(("tiCOMPortInit: saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
4384285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
4385285809Sscottl
4386285809Sscottl#ifdef CONTROLLER_ENCRYPT_TESTING
4387285809Sscottl  TI_DBG1(("tiCOMPortInit: saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
4388285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
4389285809Sscottl
4390285809Sscottl
4391285809Sscottl#ifdef VPD_TESTING
4392285809Sscottl  /* temporary to test saSetVPDCommand() and saGetVPDCommand */
4393285809Sscottl  tdsaVPDSet(tiRoot);
4394285809Sscottl#endif /* VPD_TESTING */
4395285809Sscottl
4396285809Sscottl#if defined(FDS_DM) && defined(FDS_SM)
4397285809Sscottl  /* initialize DM then SM */
4398285809Sscottl  /* DM */
4399285809Sscottl  dmRoot = &(tdsaAllShared->dmRoot);
4400285809Sscottl  osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
4401285809Sscottl
4402285809Sscottl  dmMemRequirement.count = DMMemCount;
4403285809Sscottl
4404285809Sscottl  for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
4405285809Sscottl  {
4406285809Sscottl    TI_DBG2(("tiCOMPortInit: DM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4407285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4408285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4409285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4410285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4411285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4412285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4413285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4414285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4415285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4416285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4417285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4418285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4419285809Sscottl    loResource->loLevelMem.mem[i].physAddrUpper,
4420285809Sscottl    loResource->loLevelMem.mem[i].physAddrLower,
4421285809Sscottl    loResource->loLevelMem.mem[i].totalLength,
4422285809Sscottl    loResource->loLevelMem.mem[i].numElements));
4423285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4424285809Sscottl    loResource->loLevelMem.mem[i].singleElementLength,
4425285809Sscottl    loResource->loLevelMem.mem[i].alignment,
4426285809Sscottl    loResource->loLevelMem.mem[i].type,
4427285809Sscottl    loResource->loLevelMem.mem[i].reserved));
4428285809Sscottl
4429285809Sscottl  }
4430285809Sscottl
4431285809Sscottl  status = dmInitialize(dmRoot,
4432285809Sscottl                        agRoot,
4433285809Sscottl                        &dmMemRequirement,
4434285809Sscottl                        &(tdsaAllShared->dmSwConfig), //&dmSwConfig, /* start here */
4435285809Sscottl                        loResource->loLevelOption.usecsPerTick);
4436285809Sscottl
4437285809Sscottl  if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
4438285809Sscottl  {
4439285809Sscottl    TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
4440285809Sscottl    return tiError;
4441285809Sscottl  }
4442285809Sscottl
4443285809Sscottl  /* SM */
4444285809Sscottl  smRoot = &(tdsaAllShared->smRoot);
4445285809Sscottl  osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
4446285809Sscottl
4447285809Sscottl  smMemRequirement.count = SMMemCount;
4448285809Sscottl
4449285809Sscottl  for(i=(LLMemCount + DMMemCount);i<(int)(LLMemCount + DMMemCount + SMMemCount);i++)
4450285809Sscottl  {
4451285809Sscottl    TI_DBG1(("tiCOMPortInit: SM copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4452285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4453285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4454285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4455285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4456285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4457285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4458285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4459285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4460285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].type = loResource->loLevelMem.mem[i].type;
4461285809Sscottl    smMemRequirement.smMemory[i-LLMemCount-DMMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4462285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d virtPtr %p osHandle %p\n",i, loResource->loLevelMem.mem[i].virtPtr, loResource->loLevelMem.mem[i].osHandle));
4463285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d phyAddrUpper 0x%x phyAddrLower 0x%x totalLength %d numElements %d\n", i,
4464285809Sscottl    loResource->loLevelMem.mem[i].physAddrUpper,
4465285809Sscottl    loResource->loLevelMem.mem[i].physAddrLower,
4466285809Sscottl    loResource->loLevelMem.mem[i].totalLength,
4467285809Sscottl    loResource->loLevelMem.mem[i].numElements));
4468285809Sscottl    TI_DBG2(("tiCOMPortInit: index %d singleElementLength 0x%x alignment 0x%x type %d reserved %d\n", i,
4469285809Sscottl    loResource->loLevelMem.mem[i].singleElementLength,
4470285809Sscottl    loResource->loLevelMem.mem[i].alignment,
4471285809Sscottl    loResource->loLevelMem.mem[i].type,
4472285809Sscottl    loResource->loLevelMem.mem[i].reserved));
4473285809Sscottl
4474285809Sscottl  }
4475285809Sscottl
4476285809Sscottl  status = smInitialize(smRoot,
4477285809Sscottl                        agRoot,
4478285809Sscottl                        &smMemRequirement,
4479285809Sscottl                        &(tdsaAllShared->smSwConfig), //&smSwConfig, /* start here */
4480285809Sscottl                        loResource->loLevelOption.usecsPerTick);
4481285809Sscottl
4482285809Sscottl  if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
4483285809Sscottl  {
4484285809Sscottl    TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
4485285809Sscottl    return tiError;
4486285809Sscottl  }
4487285809Sscottl
4488285809Sscottl#elif defined(FDS_DM)
4489285809Sscottl  dmRoot = &(tdsaAllShared->dmRoot);
4490285809Sscottl  osti_memset(&dmMemRequirement, 0, sizeof(dmMemoryRequirement_t));
4491285809Sscottl
4492285809Sscottl  dmMemRequirement.count = DMMemCount;
4493285809Sscottl
4494285809Sscottl  for(i=LLMemCount;i<(int)(LLMemCount + DMMemCount);i++)
4495285809Sscottl  {
4496285809Sscottl    TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4497285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4498285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4499285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4500285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4501285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4502285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4503285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4504285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4505285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4506285809Sscottl    dmMemRequirement.dmMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4507285809Sscottl    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));
4508285809Sscottl    TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4509285809Sscottl
4510285809Sscottl  }
4511285809Sscottl
4512285809Sscottl  status = dmInitialize(dmRoot,
4513285809Sscottl                        agRoot,
4514285809Sscottl                        &dmMemRequirement,
4515285809Sscottl                        &(tdsaAllShared->dmSwConfig), //&dmSwConfig, /* start here */
4516285809Sscottl                        loResource->loLevelOption.usecsPerTick);
4517285809Sscottl
4518285809Sscottl  if(status == DM_RC_FAILURE || status == DM_RC_VERSION_INCOMPATIBLE)
4519285809Sscottl  {
4520285809Sscottl    TI_DBG1(("tiCOMPortInit: dmInitialize FAILED, status 0x%x\n", status));
4521285809Sscottl    return tiError;
4522285809Sscottl  }
4523285809Sscottl
4524285809Sscottl#elif defined(FDS_SM)
4525285809Sscottl  smRoot = &(tdsaAllShared->smRoot);
4526285809Sscottl  osti_memset(&smMemRequirement, 0, sizeof(smMemoryRequirement_t));
4527285809Sscottl
4528285809Sscottl  smMemRequirement.count = SMMemCount;
4529285809Sscottl
4530285809Sscottl  for(i=LLMemCount;i<(int)(LLMemCount + SMMemCount);i++)
4531285809Sscottl  {
4532285809Sscottl    TI_DBG6(("tiCOMPortInit: copying loResource.loLevelMem to agsaMemoryRequirement_t index %d\n", i));
4533285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].virtPtr = loResource->loLevelMem.mem[i].virtPtr;
4534285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].osHandle = loResource->loLevelMem.mem[i].osHandle;
4535285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].physAddrUpper = loResource->loLevelMem.mem[i].physAddrUpper;
4536285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].physAddrLower = loResource->loLevelMem.mem[i].physAddrLower;
4537285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].totalLength = loResource->loLevelMem.mem[i].totalLength;
4538285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].numElements = loResource->loLevelMem.mem[i].numElements;
4539285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].singleElementLength = loResource->loLevelMem.mem[i].singleElementLength;
4540285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].alignment = loResource->loLevelMem.mem[i].alignment;
4541285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].type = loResource->loLevelMem.mem[i].type;
4542285809Sscottl    smMemRequirement.smMemory[i-LLMemCount].reserved = loResource->loLevelMem.mem[i].reserved;
4543285809Sscottl    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));
4544285809Sscottl    TI_DBG6(("tiCOMPortInit: index %d virtPtr %p\n",i, loResource->loLevelMem.mem[i].virtPtr));
4545285809Sscottl
4546285809Sscottl  }
4547285809Sscottl
4548285809Sscottl  status = smInitialize(smRoot,
4549285809Sscottl                        agRoot,
4550285809Sscottl                        &smMemRequirement,
4551285809Sscottl                        &(tdsaAllShared->smSwConfig), //&smSwConfig, /* start here */
4552285809Sscottl                        loResource->loLevelOption.usecsPerTick);
4553285809Sscottl
4554285809Sscottl  if(status == SM_RC_FAILURE || status == SM_RC_VERSION_INCOMPATIBLE)
4555285809Sscottl  {
4556285809Sscottl    TI_DBG1(("tiCOMPortInit: smInitialize FAILED, status 0x%x\n", status));
4557285809Sscottl    return tiError;
4558285809Sscottl  }
4559285809Sscottl#else
4560285809Sscottl  /* nothing */
4561285809Sscottl#endif /* FDS_DM && FDS_SM */
4562285809Sscottl
4563285809Sscottl  /* call these again after agroot is created  for testing */
4564285809Sscottl#ifdef CONTROLLER_STATUS_TESTING
4565285809Sscottl  TI_DBG1(("tiCOMPortInit:again saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
4566285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
4567285809Sscottl
4568285809Sscottl#ifdef CONTROLLER_INFO_TESTING
4569285809Sscottl  TI_DBG1(("tiCOMPortInit:again saGetControllerInfo returns 0x%X\n",saGetControllerInfo(agRoot,&agcontrollerInfo ) ));
4570285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
4571285809Sscottl
4572285809Sscottl#ifdef CONTROLLER_ENCRYPT_TESTING
4573285809Sscottl  TI_DBG1(("tiCOMPortInit:again saEncryptGetMode returns 0x%X\n",saEncryptGetMode(agRoot,agNULL,&agsaEncryptInfo ) ));
4574285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
4575285809Sscottl
4576285809Sscottl/* Enable SGPIO */
4577285809Sscottl  if (tiSuccess == tiCOMConfigureSgpio(tiRoot, agTRUE))
4578285809Sscottl  {
4579285809Sscottl    TI_DBG2(("tiCOMPortInit: Successfully sent request to enable SGPIO\n"));
4580285809Sscottl  }
4581285809Sscottl  else
4582285809Sscottl  {
4583285809Sscottl    TI_DBG1(("tiCOMPortInit: Failed to enable SGPIO\n"));
4584285809Sscottl  }
4585285809Sscottl
4586285809Sscottl  return tiSuccess;
4587285809Sscottl}
4588285809Sscottl
4589285809Sscottl/*****************************************************************************
4590285809Sscottl*! \brief SendSgpioRequest
4591285809Sscottl*
4592285809Sscottl*  Purpose: This function is used to send SGPIO request during initialization
4593285809Sscottl*
4594285809Sscottl*  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
4595285809Sscottl*                   instance.
4596285809Sscottl*  \param   regType: Register Type
4597285809Sscottl*  \param   regIndex: Register Index
4598285809Sscottl*  \param   regCount: Register Count
4599285809Sscottl*  \param   writeData: Part of the request
4600285809Sscottl*
4601285809Sscottl*  \return:
4602285809Sscottl*           tiSuccess on success
4603285809Sscottl*           Other status on failure
4604285809Sscottl*
4605285809Sscottl*****************************************************************************/
4606285809Sscottlstatic bit32 SendSgpioRequest(
4607285809Sscottl                            tiRoot_t    *tiRoot,
4608285809Sscottl                            bit8        regType,
4609285809Sscottl                            bit8        regIndex,
4610285809Sscottl                            bit8        regCount,
4611285809Sscottl                            bit32       *writeData
4612285809Sscottl                            )
4613285809Sscottl{
4614285809Sscottl    static bit32            buffer[128] = {0};
4615285809Sscottl    bit32                   status = tiError;
4616285809Sscottl    bit32		    retVal = IOCTL_CALL_FAIL;
4617285809Sscottl    tiIOCTLPayload_t        *agIOCTLPayload = (tiIOCTLPayload_t *) buffer;
4618285809Sscottl    agsaSGpioReqResponse_t  *pSGpioReq = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
4619285809Sscottl    agsaSGpioReqResponse_t  *pSgpioResponse = (agsaSGpioReqResponse_t *) &agIOCTLPayload->FunctionSpecificArea[0];
4620285809Sscottl
4621285809Sscottl    do{
4622285809Sscottl
4623285809Sscottl    /* Frame the Ioctl payload */
4624285809Sscottl    agIOCTLPayload->MajorFunction = IOCTL_MJ_SGPIO;
4625285809Sscottl    agIOCTLPayload->Length = sizeof(agsaSGpioReqResponse_t);
4626285809Sscottl
4627285809Sscottl    /* Frame the SGPIO request */
4628285809Sscottl    pSGpioReq->smpFrameType = SMP_REQUEST;
4629285809Sscottl    pSGpioReq->function = AGSA_WRITE_SGPIO_REGISTER;
4630285809Sscottl    pSGpioReq->registerType = regType;
4631285809Sscottl    pSGpioReq->registerIndex = regIndex;
4632285809Sscottl    pSGpioReq->registerCount = regCount;
4633285809Sscottl    memcpy(pSGpioReq->readWriteData, writeData, regCount * 4);
4634285809Sscottl
4635285809Sscottl    /* Send the SGPIO request */
4636285809Sscottl    sgpioResponseSet = 0;
4637285809Sscottl    retVal = tdsaSGpioIoctlSetup(tiRoot, agNULL, agIOCTLPayload, agNULL, agNULL);
4638285809Sscottl    if (retVal != IOCTL_CALL_PENDING)
4639285809Sscottl    {
4640285809Sscottl	break;
4641285809Sscottl    }
4642285809Sscottl    /* Waiting for SGPIO Response */
4643285809Sscottl    while(!sgpioResponseSet)
4644285809Sscottl    {
4645285809Sscottl	tiCOMDelayedInterruptHandler(tiRoot, 0, 1, tiNonInterruptContext);
4646285809Sscottl    }
4647285809Sscottl    sgpioResponseSet = 0;
4648285809Sscottl    /* Check the ioctl result */
4649285809Sscottl    if(agIOCTLPayload->Status != IOCTL_ERR_STATUS_OK)
4650285809Sscottl    {
4651285809Sscottl	break;
4652285809Sscottl    }
4653285809Sscottl    /* Check the sgpio function result */
4654285809Sscottl    if(pSgpioResponse->functionResult != 0x00)
4655285809Sscottl    {
4656285809Sscottl	break;
4657285809Sscottl    }
4658285809Sscottl
4659285809Sscottl    status = tiSuccess;
4660285809Sscottl
4661285809Sscottl  }while(0);
4662285809Sscottl
4663285809Sscottl    return status;
4664285809Sscottl}
4665285809Sscottl
4666285809Sscottl/*****************************************************************************
4667285809Sscottl*! \brief tiCOMConfigureSgpio
4668285809Sscottl*
4669285809Sscottl*  Purpose: This function is used to configure SGPIO during initialization
4670285809Sscottl*
4671285809Sscottl*  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
4672285809Sscottl*                   instance.
4673285809Sscottl*  \param   enableSgpio: Enable / Disable SGPIO
4674285809Sscottl*
4675285809Sscottl*  \return:
4676285809Sscottl*           tiSuccess on success
4677285809Sscottl*           Other status on failure
4678285809Sscottl*
4679285809Sscottl*****************************************************************************/
4680285809Sscottlbit32 tiCOMConfigureSgpio(
4681285809Sscottl                        tiRoot_t    *tiRoot,
4682285809Sscottl                        bit8        enableSgpio
4683285809Sscottl                        )
4684285809Sscottl{
4685285809Sscottl    bit32	    status = tiError;
4686285809Sscottl    bit32	    i;
4687285809Sscottl    bit8            regCount;
4688285809Sscottl    bit32           writeData[OSSA_SGPIO_MAX_READ_DATA_COUNT] = {0};
4689285809Sscottl    agsaSGpioCfg0_t *pCfg0 = (agsaSGpioCfg0_t *) &writeData[0];
4690285809Sscottl    agsaSGpioCfg1_t *pCfg1 = (agsaSGpioCfg1_t *) &writeData[1];
4691285809Sscottl    tdsaRoot_t	    *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
4692285809Sscottl    tdsaContext_t   *tdsaAllShared = (tdsaContext_t *) &tdsaRoot->tdsaAllShared;
4693285809Sscottl    bit32	    phyCount = tdsaAllShared->phyCount;
4694285809Sscottl
4695285809Sscottl    if (enableSgpio)
4696285809Sscottl    {
4697285809Sscottl        /* Configure both CFG[0] and CFG[1] */
4698285809Sscottl        regCount = 2;
4699285809Sscottl
4700285809Sscottl        /* Enable SGPIO */
4701285809Sscottl        pCfg0->gpioEnable = 1;
4702285809Sscottl
4703285809Sscottl        /* The following are the default values for CFG[1] suggested by SFF-8485 spec */
4704285809Sscottl        /* Maximum Activity ON: 2 */
4705285809Sscottl        /* Forced Activity OFF: 1 */
4706285809Sscottl        pCfg1->maxActOn = 2;
4707285809Sscottl        pCfg1->forceActOff = 1;
4708285809Sscottl    }
4709285809Sscottl    else
4710285809Sscottl    {
4711285809Sscottl        /* Configure CFG[0] only */
4712285809Sscottl        regCount = 1;
4713285809Sscottl
4714285809Sscottl        /* Disable SGPIO */
4715285809Sscottl        pCfg0->gpioEnable = 0;
4716285809Sscottl    }
4717285809Sscottl
4718285809Sscottl    status = SendSgpioRequest(tiRoot, AGSA_SGPIO_CONFIG_REG, 0, regCount, writeData);
4719285809Sscottl    if((tiSuccess == status) && (enableSgpio))
4720285809Sscottl    {
4721285809Sscottl	 /* Write default values to transmit registers */
4722285809Sscottl	 /* RegisterCount = Number of phys present in HBA / 4 */
4723285809Sscottl	 regCount = phyCount / 4;
4724285809Sscottl         for(i = 0; i < regCount; i++)
4725285809Sscottl	 {
4726285809Sscottl	   /* Following are the default values specified in SFF-8485 spec */
4727285809Sscottl	   /* Activity: 5 */
4728285809Sscottl	   /* Locate: 0 */
4729285809Sscottl	   /* Error: 0 */
4730285809Sscottl	   writeData[i] = 0xA0A0A0A0;
4731285809Sscottl  	}
4732285809Sscottl	status = SendSgpioRequest(tiRoot, AGSA_SGPIO_DRIVE_BY_DRIVE_TRANSMIT_REG, 0, regCount, writeData);
4733285809Sscottl   }
4734285809Sscottl
4735285809Sscottl   return status;
4736285809Sscottl}
4737285809Sscottl
4738285809Sscottl
4739285809Sscottl/*****************************************************************************
4740285809Sscottl*! \brief  tiCOMPortStart
4741285809Sscottl*
4742285809Sscottl*  Purpose: This function is called to bring the port hardware online. This
4743285809Sscottl*           call could only be called until after the successful completion
4744285809Sscottl*           tiCOMPortInit().
4745285809Sscottl*
4746285809Sscottl*  \param  tiRoot:          Pointer to root data structure.
4747285809Sscottl*  \param  portID:          A ID for this portal to be used by the TD Layer
4748285809Sscottl*                           to get the portal configuration information.
4749285809Sscottl*  \param  portalContext:   Pointer to the context for this portal.
4750285809Sscottl*  \param  option:          An option for starting a port
4751285809Sscottl*
4752285809Sscottl*  \return:
4753285809Sscottl*          tiSuccess:      Successful.
4754285809Sscottl*          Others:             Fail.
4755285809Sscottl*
4756285809Sscottl*  \note -
4757285809Sscottl*   If sas or sata initiator, this will be called 8 (the number of phys) times.
4758285809Sscottl*   If both sas and sata initiator, this will be called 16 times
4759285809Sscottl*
4760285809Sscottl*****************************************************************************/
4761285809Sscottl/* portID is used as PhyID
4762285809Sscottl   Should return always tiSuccess. PortStarted is returned in ossaHwCB()
4763285809Sscottl*/
4764285809SscottlosGLOBAL bit32
4765285809SscottltiCOMPortStart(
4766285809Sscottl               tiRoot_t          * tiRoot,
4767285809Sscottl               bit32               portID,
4768285809Sscottl               tiPortalContext_t * portalContext,
4769285809Sscottl               bit32               option
4770285809Sscottl               )
4771285809Sscottl{
4772285809Sscottl  tdsaRoot_t    *tdsaRoot = (tdsaRoot_t *) tiRoot->tdData;
4773285809Sscottl  tdsaContext_t *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
4774285809Sscottl  agsaRoot_t *agRoot = &tdsaAllShared->agRootInt;
4775285809Sscottl  agsaSASProtocolTimerConfigurationPage_t SASConfigPage;
4776285809Sscottl  bit32 status = AGSA_RC_FAILURE;
4777285809Sscottl  static bit32 IsSendSASConfigPage = agFALSE;
4778285809Sscottl
4779285809Sscottl
4780285809Sscottl  TI_DBG3(("tiCOMPortStart: start portID %d\n", portID));
4781285809Sscottl
4782285809Sscottl  /*
4783285809Sscottl   * return error if reset is in progress
4784285809Sscottl   */
4785285809Sscottl  if (tdsaAllShared->flags.resetInProgress == agTRUE)
4786285809Sscottl  {
4787285809Sscottl    TI_DBG1(("tiCOMPortStart: reset error\n"));
4788285809Sscottl    return tiError;
4789285809Sscottl  }
4790285809Sscottl
4791285809Sscottl  /*
4792285809Sscottl   *
4793285809Sscottl   * port is not initialized, return error
4794285809Sscottl   */
4795285809Sscottl  if (tdsaAllShared->Ports[portID].flags.portInitialized == agFALSE)
4796285809Sscottl  {
4797285809Sscottl    TI_DBG1(("tiCOMPortStart: not intialized error\n"));
4798285809Sscottl    return tiError;
4799285809Sscottl  }
4800285809Sscottl
4801285809Sscottl  /* portal has been started. */
4802285809Sscottl  if (portalContext->tdData != NULL)
4803285809Sscottl  {
4804285809Sscottl    if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
4805285809Sscottl    {
4806285809Sscottl      TI_DBG3 (("tiCOMPortStart : Cannot start port again: Port has already been started\n"));
4807285809Sscottl      ostiPortEvent (
4808285809Sscottl                     tiRoot,
4809285809Sscottl                     tiPortStarted,
4810285809Sscottl                     tiSuccess,
4811285809Sscottl                     (void *) tdsaAllShared->Ports[portID].tiPortalContext
4812285809Sscottl                     );
4813285809Sscottl      return tiSuccess;
4814285809Sscottl    }
4815285809Sscottl  }
4816285809Sscottl
4817285809Sscottl  portalContext->tdData =  &(tdsaAllShared->Ports[portID]);
4818285809Sscottl  TI_DBG4 (("tiCOMPortStart : saving portalconext portID %d tdsaAllShared %p\n", portID, tdsaAllShared));
4819285809Sscottl  /* saving tiportalContext_t */
4820285809Sscottl  tdsaAllShared->Ports[portID].tiPortalContext = portalContext;
4821285809Sscottl  TI_DBG4(("tiCOMPortStart : portID/phyID %d tiPortalContext %p\n", portID, tdsaAllShared->Ports[portID].tiPortalContext));
4822285809Sscottl
4823285809Sscottl  /*
4824285809Sscottl    where is "tdsaAllShared->Ports[0].portContext" set?
4825285809Sscottl    in ossaHWCB
4826285809Sscottl  */
4827285809Sscottl  if (tdsaAllShared->Ports[portID].flags.portStarted == agTRUE)
4828285809Sscottl  {
4829285809Sscottl    TI_DBG1(("tiCOMPortStart: port already has been started \n"));
4830285809Sscottl    return tiSuccess;
4831285809Sscottl  }
4832285809Sscottl
4833285809Sscottl
4834285809Sscottl  /*
4835285809Sscottl    hardcode sasID frame. It should be read by ostigettransportparams later from configuration file
4836285809Sscottl  */
4837285809Sscottl#ifdef INITIATOR_DRIVER
4838285809Sscottl
4839285809Sscottl  tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = 0;
4840285809Sscottl  tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
4841285809Sscottl      = SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
4842285809Sscottl  tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4843285809Sscottl
4844285809Sscottl  tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4845285809Sscottl
4846285809Sscottl#endif
4847285809Sscottl
4848285809Sscottl#ifdef TARGET_DRIVER
4849285809Sscottl
4850285809Sscottl  tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
4851285809Sscottl  tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp = 0;
4852285809Sscottl  tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4853285809Sscottl  tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4854285809Sscottl
4855285809Sscottl#endif
4856285809Sscottl
4857285809Sscottl#if defined (INITIATOR_DRIVER) && defined (TARGET_DRIVER)
4858285809Sscottl
4859285809Sscottl  /* for combo testing */
4860285809Sscottl  tdsaAllShared->Ports[portID].SASID.target_ssp_stp_smp = SA_IDFRM_SSP_BIT;
4861285809Sscottl  tdsaAllShared->Ports[portID].SASID.initiator_ssp_stp_smp
4862285809Sscottl      = SA_IDFRM_SSP_BIT | SA_IDFRM_STP_BIT | SA_IDFRM_SMP_BIT;
4863285809Sscottl  tdsaAllShared->Ports[portID].SASID.deviceType_addressFrameType = AGSA_DEV_TYPE_END_DEVICE;
4864285809Sscottl
4865285809Sscottl  tdsaAllShared->Ports[portID].SASID.phyIdentifier = (bit8)portID;
4866285809Sscottl
4867285809Sscottl#endif
4868285809Sscottl
4869285809Sscottl
4870285809Sscottl  TI_DBG6(("tiCOMPortStart: before pid %d\n", portID));
4871285809Sscottl  tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
4872285809Sscottl
4873285809Sscottl  TI_DBG6(("tiCOMPortStart: sysIntsActive %s\n",
4874285809Sscottl           (tdsaAllShared->flags.sysIntsActive == agTRUE) ? "agTRUE" : "agFALSE"));
4875285809Sscottl
4876285809Sscottl  /* Read global configuration first then card-specific configuration */
4877285809Sscottl
4878285809Sscottl  /* the following must be processed only once */
4879285809Sscottl  if ( tdsaAllShared->first_process == agFALSE)
4880285809Sscottl  {
4881285809Sscottl    tdsaGetGlobalPhyParams(tiRoot);
4882285809Sscottl    tdsaGetCardPhyParams(tiRoot);
4883285809Sscottl    tdsaAllShared->first_process = agTRUE;
4884285809Sscottl  }
4885285809Sscottl
4886285809Sscottl  TI_DBG6(("tiCOMPortStart: after pid %d\n", portID));
4887285809Sscottl  tdssPrintSASIdentify(&(tdsaAllShared->Ports[portID].SASID));
4888285809Sscottl
4889285809Sscottl  /*
4890285809Sscottl     Phy Calibration
4891285809Sscottl  */
4892285809Sscottl  if (tdsaAllShared->phyCalibration)
4893285809Sscottl  {
4894285809Sscottl    /* Change default phy calibration */
4895285809Sscottl    tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
4896285809Sscottl      (tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | 0x80;
4897285809Sscottl    /* Setting index of phy calibration table index
4898285809Sscottl       portID is used as phy calibration table index
4899285809Sscottl    */
4900285809Sscottl    tdsaAllShared->Ports[portID].agPhyConfig.phyProperties =
4901285809Sscottl      (tdsaAllShared->Ports[portID].agPhyConfig.phyProperties) | (portID << 8);
4902285809Sscottl  }
4903285809Sscottl  TI_DBG2(("tiCOMPortStart: tdsaAllShared->Ports[0x%x].agPhyConfig.phyProperties 0x%x\n",
4904285809Sscottl    portID, tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
4905285809Sscottl
4906285809Sscottl
4907285809Sscottl  if(gSSC_Disable)
4908285809Sscottl  {
4909285809Sscottl    tdsaAllShared->Ports[portID].agPhyConfig.phyProperties = tdsaAllShared->Ports[portID].agPhyConfig.phyProperties | 0x40000;
4910285809Sscottl    TI_DBG1(("tiCOMPortStart:gSSC_Disable tdsaAllShared->Ports[portID].agPhyConfig.phyProperties 0x%x\n", tdsaAllShared->Ports[portID].agPhyConfig.phyProperties));
4911285809Sscottl
4912285809Sscottl  }
4913285809Sscottl
4914285809Sscottl  if(tIsSPCV12or6G(agRoot) && !IsSendSASConfigPage) /* Not SPC */
4915285809Sscottl  {
4916285809Sscottl    /* call saSetControllerConfig() to set STP_IDLE_TIME; All others are the defaults */
4917285809Sscottl    osti_memset(&SASConfigPage, 0, sizeof(agsaSASProtocolTimerConfigurationPage_t));
4918285809Sscottl    SASConfigPage.pageCode        =  AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE;
4919285809Sscottl    SASConfigPage.MST_MSI         =  3 << 15; /* enables both MCT for SSP target and initiator */
4920285809Sscottl    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 */
4921285809Sscottl    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 */
4922285809Sscottl    SASConfigPage.STP_IDLE_TMO    =  tdsaAllShared->stp_idle_time;
4923285809Sscottl    if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF)
4924285809Sscottl    {
4925285809Sscottl      SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF;
4926285809Sscottl    }
4927285809Sscottl    SASConfigPage.OPNRJT_RTRY_INTVL =         (tdsaAllShared->MFD << 16)              | tdsaAllShared->OPNRJT_RTRY_INTVL; /* Multi Data Fetach enabled and 2 us for Open Reject Retry interval */
4928285809Sscottl    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 */
4929285809Sscottl    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 */
4930285809Sscottl    SASConfigPage.MAX_AIP =  tdsaAllShared->MAX_AIP; /* MAX AIP. Default is  0x200000 */
4931285809Sscottl
4932285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.pageCode                 0x%08x\n",SASConfigPage.pageCode));
4933285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MST_MSI                  0x%08x\n",SASConfigPage.MST_MSI));
4934285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_SSP_MCT_TMO          0x%08x\n",SASConfigPage.STP_SSP_MCT_TMO));
4935285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_FRM_TMO              0x%08x\n",SASConfigPage.STP_FRM_TMO));
4936285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.STP_IDLE_TMO             0x%08x\n",SASConfigPage.STP_IDLE_TMO));
4937285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.OPNRJT_RTRY_INTVL        0x%08x\n",SASConfigPage.OPNRJT_RTRY_INTVL));
4938285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO));
4939285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR 0x%08x\n",SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR));
4940285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig SASConfigPage.MAX_AIP                  0x%08x\n",SASConfigPage.MAX_AIP));
4941285809Sscottl
4942285809Sscottl    status = saSetControllerConfig(agRoot,
4943285809Sscottl                                    0,
4944285809Sscottl                                    AGSA_SAS_PROTOCOL_TIMER_CONFIG_PAGE,
4945285809Sscottl                                    sizeof(agsaSASProtocolTimerConfigurationPage_t),
4946285809Sscottl                                    &SASConfigPage,
4947285809Sscottl                                    agNULL);
4948285809Sscottl    if (status != AGSA_RC_SUCCESS)
4949285809Sscottl    {
4950285809Sscottl      TI_DBG1(("tiCOMPortStart: calling saSetControllerConfig() failed\n"));
4951285809Sscottl    }
4952285809Sscottl    else
4953285809Sscottl    {
4954285809Sscottl      TI_DBG2(("tiCOMPortStart: calling saSetControllerConfig() is OK\n"));
4955285809Sscottl    }
4956285809Sscottl    IsSendSASConfigPage = agTRUE;
4957285809Sscottl  }
4958285809Sscottl  else
4959285809Sscottl  {
4960285809Sscottl    TI_DBG1(("tiCOMPortStart: saSetControllerConfig not called tIsSPCV12or6G %d IsSendSASConfigPage %d\n",tIsSPCV12or6G(agRoot),IsSendSASConfigPage));
4961285809Sscottl  }
4962285809Sscottl
4963285809Sscottl  /* maps portID to phyID */
4964285809Sscottl  status = saPhyStart(agRoot,
4965285809Sscottl                      agNULL,
4966285809Sscottl                      0,
4967285809Sscottl                      portID,
4968285809Sscottl                      &(tdsaAllShared->Ports[portID].agPhyConfig),
4969285809Sscottl                      &(tdsaAllShared->Ports[portID].SASID)
4970285809Sscottl                      );
4971285809Sscottl
4972285809Sscottl  TI_DBG6(("tiCOMPortStart: saPhyStart status %d\n", status));
4973285809Sscottl
4974285809Sscottl  if (status == AGSA_RC_SUCCESS)
4975285809Sscottl  {
4976285809Sscottl    TI_DBG3(("tiCOMPortStart : calling portstarted\n"));
4977285809Sscottl    ostiPortEvent(
4978285809Sscottl                  tiRoot,
4979285809Sscottl                  tiPortStarted,
4980285809Sscottl                  tiSuccess,
4981285809Sscottl                  (void *) tdsaAllShared->Ports[portID].tiPortalContext
4982285809Sscottl                  );
4983285809Sscottl    return tiSuccess;
4984285809Sscottl  }
4985285809Sscottl  else
4986285809Sscottl  {
4987285809Sscottl    TI_DBG3(("tiCOMPortStart : cant' start port\n"));
4988285809Sscottl    return tiError;
4989285809Sscottl  }
4990285809Sscottl
4991285809Sscottl}
4992285809Sscottl
4993285809Sscottl/*****************************************************************************
4994285809Sscottl*! \brief  tiCOMPortStop
4995285809Sscottl*
4996285809Sscottl*  Purpose: This function is called to bring the port hardware down.
4997285809Sscottl*
4998285809Sscottl*  \param  tiRoot:          Pointer to root data structure.
4999285809Sscottl*  \param  portalContext:   Pointer to the context for this portal.
5000285809Sscottl*
5001285809Sscottl*  \return:
5002285809Sscottl*          tiSuccess:      Successful.
5003285809Sscottl*          Others:             Fail.
5004285809Sscottl*
5005285809Sscottl*  \note -
5006285809Sscottl*
5007285809Sscottl*****************************************************************************/
5008285809SscottlosGLOBAL bit32
5009285809SscottltiCOMPortStop (
5010285809Sscottl  tiRoot_t          *tiRoot,
5011285809Sscottl  tiPortalContext_t *portalContext
5012285809Sscottl  )
5013285809Sscottl{
5014285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5015285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5016285809Sscottl  tdList_t          *PortContextList;
5017285809Sscottl  tdsaPortContext_t *onePortContext = agNULL;
5018285809Sscottl  agsaRoot_t        *agRoot = agNULL;
5019285809Sscottl  bit32             i;
5020285809Sscottl  bit32             found = agFALSE;
5021285809Sscottl
5022285809Sscottl#ifdef CONTROLLER_STATUS_TESTING
5023285809Sscottl  agsaControllerStatus_t  agcontrollerStatus;
5024285809Sscottl#endif /* CONTROLLER_STATUS_TESTING */
5025285809Sscottl
5026285809Sscottl
5027285809Sscottl  TI_DBG3(("tiCOMPortStop: start\n"));
5028285809Sscottl  /*
5029285809Sscottl    find the portcontext
5030285809Sscottl    find phys belonging to that portcotext
5031285809Sscottl    call saPhyStop for all those phys
5032285809Sscottl    call saPhyStop()
5033285809Sscottl    remove the portcontext from the portcontext list
5034285809Sscottl  */
5035285809Sscottl
5036285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
5037285809Sscottl
5038285809Sscottl#ifdef CONTROLLER_STATUS_TESTING
5039285809Sscottl  TI_DBG1(("tiCOMPortStop: saGetControllerStatus returns 0x%X\n",saGetControllerStatus(agRoot,&agcontrollerStatus ) ));
5040285809Sscottl#endif /* CONTROLLER_INFO_TESTING */
5041285809Sscottl
5042285809Sscottl  if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
5043285809Sscottl  {
5044285809Sscottl    TI_DBG1(("tiCOMPortStop: empty tdsaPortContext\n"));
5045285809Sscottl    return tiError;
5046285809Sscottl  }
5047285809Sscottl
5048285809Sscottl  /* find a right portcontext */
5049285809Sscottl  PortContextList = tdsaAllShared->MainPortContextList.flink;
5050285809Sscottl  while (PortContextList != &(tdsaAllShared->MainPortContextList))
5051285809Sscottl  {
5052285809Sscottl    onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
5053285809Sscottl    if (onePortContext == agNULL)
5054285809Sscottl    {
5055285809Sscottl      TI_DBG1(("tiCOMPortStop: onePortContext is NULL!!!\n"));
5056285809Sscottl      return tiError;
5057285809Sscottl    }
5058285809Sscottl    if (onePortContext->tiPortalContext == portalContext)
5059285809Sscottl    {
5060285809Sscottl      TI_DBG6(("tiCOMPortStop: found; oneportContext ID %d\n", onePortContext->id));
5061285809Sscottl      found = agTRUE;
5062285809Sscottl      break;
5063285809Sscottl    }
5064285809Sscottl    PortContextList = PortContextList->flink;
5065285809Sscottl  }
5066285809Sscottl
5067285809Sscottl  if (found == agFALSE)
5068285809Sscottl  {
5069285809Sscottl    TI_DBG1(("tiCOMPortStop: No corressponding tdsaPortContext\n"));
5070285809Sscottl    return tiError;
5071285809Sscottl  }
5072285809Sscottl
5073285809Sscottl#ifdef INITIATOR_DRIVER
5074285809Sscottl  /* reset the fields of portcontext */
5075285809Sscottl  onePortContext->DiscoveryState = ITD_DSTATE_NOT_STARTED;
5076285809Sscottl  onePortContext->discoveryOptions = AG_SA_DISCOVERY_OPTION_FULL_START;
5077285809Sscottl#endif /* INITIATOR_DRIVER */
5078285809Sscottl
5079285809Sscottl  onePortContext->Count = 0;
5080285809Sscottl  onePortContext->agContext.osData = onePortContext;
5081285809Sscottl  for(i=0;i<TD_MAX_NUM_PHYS;i++)
5082285809Sscottl  {
5083285809Sscottl    if (onePortContext->PhyIDList[i] == agTRUE)
5084285809Sscottl    {
5085285809Sscottl      tdsaAllShared->Ports[i].portContext = agNULL;
5086285809Sscottl#ifdef CCFLAGS_PHYCONTROL_COUNTS
5087285809Sscottl      if( tiIS_SPC(agRoot) )
5088285809Sscottl      {
5089285809Sscottl
5090285809Sscottl        saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_ERROR_COUNTS, agNULL);
5091285809Sscottl        saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_CLEAR_ERROR_COUNTS, agNULL);
5092285809Sscottl        saLocalPhyControl(agRoot,&onePortContext->agContext,0 , i, AGSA_PHY_GET_BW_COUNTS, agNULL);
5093285809Sscottl      }
5094285809Sscottl      else
5095285809Sscottl      {
5096285809Sscottl        TI_DBG1(("\ntiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
5097285809Sscottl        saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_PAGE, i);
5098285809Sscottl        saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_BW_COUNTERS_PAGE,i);
5099285809Sscottl        saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ANALOG_SETTINGS_PAGE,i);
5100285809Sscottl        saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_GENERAL_STATUS_PAGE,i);
5101285809Sscottl        saGetPhyProfile( agRoot,&onePortContext->agContext,0, AGSA_SAS_PHY_ERR_COUNTERS_CLR_PAGE,i);
5102285809Sscottl
5103285809Sscottl        TI_DBG1(("tiCOMPortStop: CCFLAGS_PHYCONTROL_COUNTS PHY %d\n",i));
5104285809Sscottl
5105285809Sscottl      }
5106285809Sscottl
5107285809Sscottl#endif /* CCFLAGS_PHYCONTROL_COUNTS */
5108285809Sscottl      saPhyStop(agRoot, &onePortContext->agContext, 0, i);
5109285809Sscottl    }
5110285809Sscottl  }
5111285809Sscottl
5112285809Sscottl  return tiSuccess;
5113285809Sscottl}
5114285809Sscottl
5115285809Sscottl
5116285809Sscottl/*****************************************************************************
5117285809Sscottl*! \brief tiCOMGetPortInfo
5118285809Sscottl*
5119285809Sscottl*  Purpose:  This function is called to return information about the specific
5120285809Sscottl*            port instant
5121285809Sscottl*
5122285809Sscottl*
5123285809Sscottl*  \param   tiRoot:        Pointer to driver/port instance.
5124285809Sscottl*  \param   portalContext  Pointer to the context for this portal.
5125285809Sscottl*  \param   tiPortInfo:    Pointer to port information structure.
5126285809Sscottl*
5127285809Sscottl*  \Return: tiSuccess
5128285809Sscottl*
5129285809Sscottl*****************************************************************************/
5130285809Sscottl/*
5131285809Sscottl  can't find tdsaportcontext in this function
5132285809Sscottl  since discovery has not been called by OS layer yet
5133285809Sscottl  Therefore, hardcoded value are being returned for now
5134285809Sscottl*/
5135285809SscottlosGLOBAL bit32 tiCOMGetPortInfo(
5136285809Sscottl                                tiRoot_t            *tiRoot,
5137285809Sscottl                                tiPortalContext_t   *portalContext,
5138285809Sscottl                                tiPortInfo_t        *tiPortInfo
5139285809Sscottl                                )
5140285809Sscottl
5141285809Sscottl{
5142285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5143285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5144285809Sscottl  tdList_t          *PortContextList;
5145285809Sscottl  tdsaPortContext_t *onePortContext = agNULL;
5146285809Sscottl  bit32             found = agFALSE;
5147285809Sscottl  static bit8       localname[68], remotename[68];
5148285809Sscottl
5149285809Sscottl  TI_DBG6(("tiCOMGetPortInfo: start\n"));
5150285809Sscottl
5151285809Sscottl
5152285809Sscottl  tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
5153285809Sscottl  if (TDLIST_EMPTY(&(tdsaAllShared->MainPortContextList)))
5154285809Sscottl  {
5155285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
5156285809Sscottl    TI_DBG1(("tiCOMGetPortInfo: No tdsaPortContext\n"));
5157285809Sscottl    return tiError;
5158285809Sscottl  }
5159285809Sscottl  else
5160285809Sscottl  {
5161285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
5162285809Sscottl  }
5163285809Sscottl
5164285809Sscottl  /* find a corresponding portcontext */
5165285809Sscottl  PortContextList = tdsaAllShared->MainPortContextList.flink;
5166285809Sscottl  while (PortContextList != &(tdsaAllShared->MainPortContextList))
5167285809Sscottl  {
5168285809Sscottl    onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
5169285809Sscottl    TI_DBG3(("tiCOMGetPortInfo: oneportContext pid %d\n", onePortContext->id));
5170285809Sscottl    if (onePortContext->tiPortalContext == portalContext && onePortContext->valid == agTRUE)
5171285809Sscottl    {
5172285809Sscottl      TI_DBG3(("tiCOMGetPortInfo: found; oneportContext pid %d\n", onePortContext->id));
5173285809Sscottl      found = agTRUE;
5174285809Sscottl      break;
5175285809Sscottl    }
5176285809Sscottl    PortContextList = PortContextList->flink;
5177285809Sscottl  }
5178285809Sscottl
5179285809Sscottl  if (found == agFALSE)
5180285809Sscottl  {
5181285809Sscottl    TI_DBG1(("tiCOMGetPortInfo: First, No corresponding tdsaPortContext\n"));
5182285809Sscottl    return tiError;
5183285809Sscottl  }
5184285809Sscottl
5185285809Sscottl  if (onePortContext == agNULL)
5186285809Sscottl  {
5187285809Sscottl    TI_DBG1(("tiCOMGetPortInfo: Second, No corressponding tdsaPortContext\n"));
5188285809Sscottl    return tiError;
5189285809Sscottl  }
5190285809Sscottl
5191285809Sscottl  osti_memset(localname, 0, sizeof(localname));
5192285809Sscottl  osti_memset(remotename, 0, sizeof(remotename));
5193285809Sscottl
5194285809Sscottl  /*
5195285809Sscottl    Parse the type of port then fill in the information
5196285809Sscottl  */
5197285809Sscottl  if ( onePortContext->sasRemoteAddressHi == 0xFFFFFFFF && onePortContext->sasRemoteAddressLo == 0xFFFFFFFF)
5198285809Sscottl  {
5199285809Sscottl    /* directly attached SATA port */
5200285809Sscottl    osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
5201285809Sscottl    osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
5202285809Sscottl    tiPortInfo->localNameLen = 8;
5203285809Sscottl    /* information is from SATA ID device data. remoteName is serial number, firmware version, model number */
5204285809Sscottl    osti_memcpy(remotename, onePortContext->remoteName, 68);
5205285809Sscottl    tiPortInfo->remoteNameLen = 68;
5206285809Sscottl  }
5207285809Sscottl  else
5208285809Sscottl  {
5209285809Sscottl    /* copy hi address and low address */
5210285809Sscottl    osti_memcpy(localname, &(onePortContext->sasLocalAddressHi), 4);
5211285809Sscottl    osti_memcpy(&(localname[4]), &(onePortContext->sasLocalAddressLo), 4);
5212285809Sscottl    tiPortInfo->localNameLen = 8;
5213285809Sscottl    osti_memcpy(remotename, &(onePortContext->sasRemoteAddressHi), 4);
5214285809Sscottl    osti_memcpy(&(remotename[4]), &(onePortContext->sasRemoteAddressLo), 4);
5215285809Sscottl    tiPortInfo->remoteNameLen = 8;
5216285809Sscottl  }
5217285809Sscottl
5218285809Sscottl  tiPortInfo->localName = (char *)&localname;
5219285809Sscottl  tiPortInfo->remoteName = (char *)&remotename;
5220285809Sscottl
5221285809Sscottl
5222285809Sscottl  return tiSuccess;
5223285809Sscottl
5224285809Sscottl}
5225285809Sscottl
5226285809Sscottl/*****************************************************************************
5227285809Sscottl*
5228285809Sscottl* tiCOMSetControllerConfig
5229285809Sscottl*
5230285809Sscottl*  Purpose:  This function is called to set the controller's advanced configuration.
5231285809Sscottl*            The status is reported via ostiPortEvent().
5232285809Sscottl*
5233285809Sscottl*  Parameters:
5234285809Sscottl*
5235285809Sscottl*    tiRoot:        Pointer to driver/port instance.
5236285809Sscottl*
5237285809Sscottl*  Return:
5238285809Sscottl*     tiSuccess:  The setting controller configuration was started.
5239285809Sscottl*     tiError:    The setting controller configuration was not started.
5240285809Sscottl*
5241285809Sscottl*****************************************************************************/
5242285809SscottlosGLOBAL bit32  tiCOMSetControllerConfig (
5243285809Sscottl         tiRoot_t    *tiRoot,
5244285809Sscottl         bit32       modePage,
5245285809Sscottl         bit32       length,
5246285809Sscottl         void        *buffer,
5247285809Sscottl         void        *context)
5248285809Sscottl{
5249285809Sscottl   agsaRoot_t      *agRoot;
5250285809Sscottl   bit32           returnCode = AGSA_RC_BUSY;
5251285809Sscottl   bit32           tiStatus = tiSuccess;
5252285809Sscottl   tdsaRoot_t      *tdsaRoot ;
5253285809Sscottl   tdsaContext_t   *tdsaAllShared ;
5254285809Sscottl
5255285809Sscottl   TD_ASSERT(tiRoot, "tiRoot");
5256285809Sscottl   tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5257285809Sscottl   TD_ASSERT(tdsaRoot, "tdsaRoot");
5258285809Sscottl
5259285809Sscottl   tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5260285809Sscottl   TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5261285809Sscottl   agRoot = &(tdsaAllShared->agRootNonInt);
5262285809Sscottl   TD_ASSERT(agRoot, "agRoot");
5263285809Sscottl
5264285809Sscottl   agRoot = &(tdsaAllShared->agRootNonInt);
5265285809Sscottl
5266285809Sscottl   TI_DBG1(("tiCOMSetControllerConfig:\n" ));
5267285809Sscottl
5268285809Sscottl   /*do some sanity checking */
5269285809Sscottl   if ( ((modePage == TI_INTERRUPT_CONFIGURATION_PAGE)   && (length != sizeof(tiInterruptConfigPage_t )))   ||
5270285809Sscottl        ((modePage == TI_ENCRYPTION_GENERAL_CONFIG_PAGE) && (length != sizeof(tiEncryptGeneralPage_t  )))    ||
5271285809Sscottl        ((modePage == TI_ENCRYPTION_DEK_CONFIG_PAGE)     && (length != sizeof(tiEncryptDekConfigPage_t)))    ||
5272285809Sscottl        ((modePage == TI_ENCRYPTION_CONTROL_PARM_PAGE)  && (length != sizeof(tiEncryptControlParamPage_t ))) ||
5273285809Sscottl        ((modePage == TI_ENCRYPTION_HMAC_CONFIG_PAGE)  && (length != sizeof(tiEncryptHMACConfigPage_t )))    ||
5274285809Sscottl        ((modePage == TI_SAS_PROTOCOL_TIMER_CONFIG_PAGE) && (length != sizeof(tiSASProtocolTimerConfigurationPage_t )))  )
5275285809Sscottl   {
5276285809Sscottl       tiStatus = tiError;
5277285809Sscottl   }
5278285809Sscottl   else
5279285809Sscottl   {
5280285809Sscottl       returnCode = saSetControllerConfig(agRoot, 0, modePage, length, buffer, context);
5281285809Sscottl
5282285809Sscottl       if (returnCode == AGSA_RC_SUCCESS)
5283285809Sscottl       {
5284285809Sscottl           tiStatus = tiSuccess;
5285285809Sscottl       }
5286285809Sscottl       else if (returnCode == AGSA_RC_BUSY)
5287285809Sscottl       {
5288285809Sscottl           tiStatus = tiBusy;
5289285809Sscottl       }
5290285809Sscottl       else
5291285809Sscottl       {
5292285809Sscottl           tiStatus = tiError;
5293285809Sscottl       }
5294285809Sscottl   }
5295285809Sscottl   return(tiStatus);
5296285809Sscottl}
5297285809Sscottl
5298285809Sscottl/*****************************************************************************
5299285809Sscottl*
5300285809Sscottl* tiCOMGetControllerConfig
5301285809Sscottl*
5302285809Sscottl*  Purpose:  This function is called to get the controller's advanced configuration.
5303285809Sscottl*            The status is reported via ostiPortEvent().
5304285809Sscottl*
5305285809Sscottl*  Parameters:
5306285809Sscottl*
5307285809Sscottl*    tiRoot:        Pointer to driver/port instance.
5308285809Sscottl*    flag:          Interrupt  Vector Mask
5309285809Sscottl*                   This parameter is valid only when modePage is set to TI_INTERRUPT_CONFIGURATION_PAGE.
5310285809Sscottl*                   When the modePage field is set to TI_INTERRUPT_CONFIGURATION_PAGE,
5311285809Sscottl*                   this field contains a bitmap of interrupt vectors for which interrupt coalescing parameters are retrieved.
5312285809Sscottl*  Return:
5313285809Sscottl*     tiSuccess:  The controller configuration retrival was started.
5314285809Sscottl*     tiError:    The controller configuration retrival was not started.
5315285809Sscottl*
5316285809Sscottl*****************************************************************************/
5317285809SscottlosGLOBAL bit32  tiCOMGetControllerConfig (
5318285809Sscottl         tiRoot_t    *tiRoot,
5319285809Sscottl         bit32       modePage,
5320285809Sscottl         bit32       flag,
5321285809Sscottl         void        *context)
5322285809Sscottl
5323285809Sscottl{
5324285809Sscottl  agsaRoot_t      *agRoot;
5325285809Sscottl  bit32           returnCode = AGSA_RC_BUSY;
5326285809Sscottl  bit32           tiStatus = tiSuccess;
5327285809Sscottl  tdsaRoot_t      *tdsaRoot ;
5328285809Sscottl  tdsaContext_t   *tdsaAllShared ;
5329285809Sscottl
5330285809Sscottl  TD_ASSERT(tiRoot, "tiRoot");
5331285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5332285809Sscottl  TD_ASSERT(tdsaRoot, "tdsaRoot");
5333285809Sscottl
5334285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5335285809Sscottl  TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5336285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
5337285809Sscottl  TD_ASSERT(agRoot, "agRoot");
5338285809Sscottl
5339285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
5340285809Sscottl
5341285809Sscottl  TI_DBG1(("tiCOMGetControllerConfig: modePage 0x%x context %p\n",modePage,context ));
5342285809Sscottl
5343285809Sscottl  returnCode = saGetControllerConfig(agRoot, 0, modePage, flag, 0, context);
5344285809Sscottl
5345285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
5346285809Sscottl  {
5347285809Sscottl    tiStatus = tiSuccess;
5348285809Sscottl    TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiSuccess\n",modePage ));
5349285809Sscottl  }
5350285809Sscottl  else if (returnCode == AGSA_RC_BUSY)
5351285809Sscottl  {
5352285809Sscottl    tiStatus = tiBusy;
5353285809Sscottl    TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiBusy\n",modePage ));
5354285809Sscottl  }
5355285809Sscottl  else
5356285809Sscottl  {
5357285809Sscottl    tiStatus = tiError;
5358285809Sscottl    TI_DBG1(("tiCOMGetControllerConfig:modePage 0x%x tiError\n",modePage ));
5359285809Sscottl  }
5360285809Sscottl
5361285809Sscottl   return(tiStatus);
5362285809Sscottl}
5363285809Sscottl
5364285809Sscottl/*****************************************************************************
5365285809Sscottl*
5366285809Sscottl* tiCOMEncryptGetInfo
5367285809Sscottl*
5368285809Sscottl*  Purpose:  This function is called to return information about the encryption
5369285809Sscottl*            engine for the specified port.
5370285809Sscottl*
5371285809Sscottl*  Parameters:
5372285809Sscottl*
5373285809Sscottl*    tiRoot:        Pointer to driver/port instance.
5374285809Sscottl*
5375285809Sscottl*  Return:
5376285809Sscottl*   tiSuccess       The request is being processed
5377285809Sscottl*   tiNotSupported  Encryption is not supported
5378285809Sscottl*
5379285809Sscottl*****************************************************************************/
5380285809SscottlosGLOBAL bit32 tiCOMEncryptGetInfo(tiRoot_t *tiRoot)
5381285809Sscottl{
5382285809Sscottl  tiEncryptInfo_t tiEncryptInfo;
5383285809Sscottl  agsaEncryptInfo_t agsaEncryptInfo;
5384285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5385285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5386285809Sscottl  agsaRoot_t      *agRoot;
5387285809Sscottl  tiEncryptPort_t tiEncryptPort;
5388285809Sscottl  bit32           returnCode;
5389285809Sscottl  bit32           tiStatus;
5390285809Sscottl
5391285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
5392285809Sscottl
5393285809Sscottl  returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
5394285809Sscottl  TI_DBG1(("tiCOMEncryptGetInfo: returnCode 0x%x\n", returnCode));
5395285809Sscottl
5396285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
5397285809Sscottl  {
5398285809Sscottl      tiStatus = tiSuccess;
5399285809Sscottl
5400285809Sscottl      /*
5401285809Sscottl       * The data encoded in the agsaEncryptInfo must be converted
5402285809Sscottl       * to match the fields of the tiEncryptInfo structure.
5403285809Sscottl       *
5404285809Sscottl       * No sector information is currently available.
5405285809Sscottl       */
5406285809Sscottl      osti_memset(&tiEncryptInfo, 0x0, sizeof(tiEncryptInfo_t));
5407285809Sscottl
5408285809Sscottl      /* cipher mode */
5409285809Sscottl      if (agsaEncryptInfo.encryptionCipherMode == agsaEncryptCipherModeXTS)
5410285809Sscottl      {
5411285809Sscottl         tiEncryptInfo.securityCipherMode = TI_ENCRYPT_ATTRIB_CIPHER_XTS;
5412285809Sscottl      }
5413285809Sscottl      /* security mode */
5414285809Sscottl      if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMF)
5415285809Sscottl      {
5416285809Sscottl         tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_FACT_INIT;
5417285809Sscottl      }
5418285809Sscottl      else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMA)
5419285809Sscottl      {
5420285809Sscottl         tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_A;
5421285809Sscottl      }
5422285809Sscottl      else if (agsaEncryptInfo.encryptionSecurityMode == agsaEncryptSMB)
5423285809Sscottl      {
5424285809Sscottl         tiEncryptInfo.securityCipherMode |= TI_ENCRYPT_SEC_MODE_B;
5425285809Sscottl      }
5426285809Sscottl
5427285809Sscottl      tiEncryptInfo.status = agsaEncryptInfo.status;
5428285809Sscottl
5429285809Sscottl      tiEncryptPort.pData = &tiEncryptInfo;
5430285809Sscottl
5431285809Sscottl      /* The low level returns synchronously, so fake a port event now.*/
5432285809Sscottl      tiEncryptPort.encryptEvent = tiEncryptGetInfo;
5433285809Sscottl      tiEncryptPort.subEvent = 0;
5434285809Sscottl
5435285809Sscottl      ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
5436285809Sscottl  }
5437285809Sscottl  else
5438285809Sscottl  {
5439285809Sscottl    if (returnCode == AGSA_RC_NOT_SUPPORTED)
5440285809Sscottl    {
5441285809Sscottl      tiStatus = tiNotSupported;
5442285809Sscottl      TI_DBG1(("tiCOMEncryptGetInfo: tiNotSupported\n"));
5443285809Sscottl    }
5444285809Sscottl    else
5445285809Sscottl    {
5446285809Sscottl      TI_DBG1(("tiCOMEncryptGetInfo: tiError returnCode 0x%x\n",returnCode));
5447285809Sscottl      tiStatus = tiError;
5448285809Sscottl    }
5449285809Sscottl
5450285809Sscottl    tiEncryptPort.pData = NULL;
5451285809Sscottl  }
5452285809Sscottl
5453285809Sscottl  return(tiStatus);
5454285809Sscottl}
5455285809Sscottl
5456285809Sscottl/*****************************************************************************
5457285809Sscottl*
5458285809Sscottl* tiCOMEncryptSetMode
5459285809Sscottl*
5460285809Sscottl*  Purpose:  This function is called to set the encryption security and cipher modes
5461285809Sscottl*            for the encryption engine.
5462285809Sscottl*
5463285809Sscottl*  Parameters:
5464285809Sscottl*
5465285809Sscottl*    tiRoot:        Pointer to driver/port instance.
5466285809Sscottl*
5467285809Sscottl*  Return:
5468285809Sscottl*   tiSuccess       The request is being processed
5469285809Sscottl*   tiError         The encryption engine is not in factory init mode or multiple
5470285809Sscottl*                   security modes were specified.
5471285809Sscottl*
5472285809Sscottl*****************************************************************************/
5473285809Sscottl
5474285809SscottlosGLOBAL bit32 tiCOMEncryptSetMode(tiRoot_t            *tiRoot,
5475285809Sscottl                                   bit32               securityCipherMode)
5476285809Sscottl{
5477285809Sscottl  bit32                         returnCode;
5478285809Sscottl  bit32                         tiStatus;
5479285809Sscottl  agsaEncryptInfo_t mode;
5480285809Sscottl  agsaEncryptInfo_t *pmode = &mode;
5481285809Sscottl
5482285809Sscottl  tdsaRoot_t        *tdsaRoot ;
5483285809Sscottl  tdsaContext_t     *tdsaAllShared;
5484285809Sscottl  agsaRoot_t        *agRoot;
5485285809Sscottl
5486285809Sscottl  TD_ASSERT(tiRoot, "tiRoot");
5487285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5488285809Sscottl  TD_ASSERT(tdsaRoot, "tdsaRoot");
5489285809Sscottl
5490285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5491285809Sscottl  TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5492285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
5493285809Sscottl  TD_ASSERT(agRoot, "agRoot");
5494285809Sscottl
5495285809Sscottl  pmode->encryptionSecurityMode = 0;
5496285809Sscottl  pmode->encryptionCipherMode = 0;
5497285809Sscottl  pmode->status = 0;
5498285809Sscottl
5499285809Sscottl  TI_DBG1(("tiCOMEncryptSetMode:\n"));
5500285809Sscottl
5501285809Sscottl
5502285809Sscottl  if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_A ) == TI_ENCRYPT_SEC_MODE_A)
5503285809Sscottl  {
5504285809Sscottl    pmode->encryptionSecurityMode = agsaEncryptSMA;
5505285809Sscottl  }
5506285809Sscottl
5507285809Sscottl  if(( securityCipherMode & TI_ENCRYPT_SEC_MODE_B ) == TI_ENCRYPT_SEC_MODE_B)
5508285809Sscottl  {
5509285809Sscottl    pmode->encryptionSecurityMode = agsaEncryptSMB;
5510285809Sscottl  }
5511285809Sscottl
5512285809Sscottl  if( (securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_XTS)  == TI_ENCRYPT_ATTRIB_CIPHER_XTS)
5513285809Sscottl  {
5514285809Sscottl    pmode->encryptionCipherMode |= agsaEncryptCipherModeXTS;
5515285809Sscottl  }
5516285809Sscottl
5517285809Sscottl  /* ECB is not supported in SPCv */
5518285809Sscottl  if(( securityCipherMode & TI_ENCRYPT_ATTRIB_CIPHER_ECB)  == TI_ENCRYPT_ATTRIB_CIPHER_ECB)
5519285809Sscottl  {
5520285809Sscottl    return tiError;
5521285809Sscottl  }
5522285809Sscottl
5523285809Sscottl  returnCode = saEncryptSetMode(agRoot,agNULL, 0, pmode );
5524285809Sscottl
5525285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
5526285809Sscottl  {
5527285809Sscottl    tiStatus = tiSuccess;
5528285809Sscottl  }
5529285809Sscottl  else if (returnCode == AGSA_RC_BUSY)
5530285809Sscottl  {
5531285809Sscottl    TI_DBG1(("tiCOMEncryptSetMode:tiBusy\n"));
5532285809Sscottl    tiStatus = tiBusy;
5533285809Sscottl  }
5534285809Sscottl  else
5535285809Sscottl  {
5536285809Sscottl    TI_DBG1(("tiCOMEncryptSetMode:tiError\n"));
5537285809Sscottl    tiStatus = tiError;
5538285809Sscottl  }
5539285809Sscottl
5540285809Sscottl  return(tiStatus);
5541285809Sscottl}
5542285809Sscottl
5543285809Sscottl/*****************************************************************************
5544285809Sscottl*
5545285809Sscottl* tiCOMEncryptDekAdd
5546285809Sscottl*
5547285809Sscottl*  Purpose:  This function is called to add a DEK to the controller cache.
5548285809Sscottl*
5549285809Sscottl*  Parameters:
5550285809Sscottl*
5551285809Sscottl*    tiRoot:          Pointer to driver/port instance.
5552285809Sscottl*    kekIndext:         Index of the KEK table
5553285809Sscottl*    dekTableSelect:  Number of the DEK table receiving a new entry
5554285809Sscottl*    dekAddrHi:       Upper 32-bits of the DEK table physical address
5555285809Sscottl*    dekAddrLo:       Lower 32-bits of the DEK table physical address
5556285809Sscottl*    dekIndex:        Number of the first entry in the DEK table that will inserted in the cache
5557285809Sscottl*    dekNumberOfEntries: Number of entries to be inserted in the cache
5558285809Sscottl*    dekBlobFormat:     Specifies the DEK blob format
5559285809Sscottl*    dekTableKeyEntrySize: Encoded value for DEK Entry Size in the DEK Table
5560285809Sscottl*
5561285809Sscottl*  Return:
5562285809Sscottl*   tiSuccess       The request is being processed
5563285809Sscottl*   tiError         An invalid parameter was specified
5564285809Sscottl*
5565285809Sscottl*****************************************************************************/
5566285809SscottlosGLOBAL bit32 tiCOMEncryptDekAdd(tiRoot_t            *tiRoot,
5567285809Sscottl                                  bit32               kekIndex,
5568285809Sscottl                                  bit32               dekTableSelect,
5569285809Sscottl                                  bit32               dekAddrHi,
5570285809Sscottl                                  bit32               dekAddrLo,
5571285809Sscottl                                  bit32               dekIndex,
5572285809Sscottl                                  bit32               dekNumberOfEntries,
5573285809Sscottl                                  bit32               dekBlobFormat,
5574285809Sscottl                                  bit32               dekTableKeyEntrySize
5575285809Sscottl
5576285809Sscottl                                  )
5577285809Sscottl{
5578285809Sscottl    agsaRoot_t        *agRoot;
5579285809Sscottl    bit32           returnCode;
5580285809Sscottl    bit32           tiStatus;
5581285809Sscottl    tdsaRoot_t        *tdsaRoot ;
5582285809Sscottl    tdsaContext_t     *tdsaAllShared ;
5583285809Sscottl
5584285809Sscottl    TD_ASSERT(tiRoot, "tiRoot");
5585285809Sscottl    tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5586285809Sscottl    TD_ASSERT(tdsaRoot, "tdsaRoot");
5587285809Sscottl
5588285809Sscottl    tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5589285809Sscottl    TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5590285809Sscottl    agRoot = &(tdsaAllShared->agRootNonInt);
5591285809Sscottl    TD_ASSERT(agRoot, "agRoot");
5592285809Sscottl
5593285809Sscottl
5594285809Sscottl    agRoot = &(tdsaAllShared->agRootNonInt);
5595285809Sscottl
5596285809Sscottl
5597285809Sscottl    TI_DBG1(("tiCOMEncryptDekAdd:\n" ));
5598285809Sscottl
5599285809Sscottl    returnCode = saEncryptDekCacheUpdate(agRoot,
5600285809Sscottl                                    agNULL,
5601285809Sscottl                                    0,
5602285809Sscottl                                    kekIndex,
5603285809Sscottl                                    dekTableSelect,
5604285809Sscottl                                    dekAddrHi,
5605285809Sscottl                                    dekAddrLo,
5606285809Sscottl                                    dekIndex,
5607285809Sscottl                                    dekNumberOfEntries,
5608285809Sscottl                                    dekBlobFormat,
5609285809Sscottl                                    dekTableKeyEntrySize
5610285809Sscottl                                    );
5611285809Sscottl
5612285809Sscottl    if (returnCode == AGSA_RC_SUCCESS)
5613285809Sscottl    {
5614285809Sscottl        tiStatus = tiSuccess;
5615285809Sscottl    }
5616285809Sscottl    else if (returnCode == AGSA_RC_BUSY)
5617285809Sscottl    {
5618285809Sscottl        tiStatus = tiBusy;
5619285809Sscottl    }
5620285809Sscottl    else
5621285809Sscottl    {
5622285809Sscottl        tiStatus = tiError;
5623285809Sscottl    }
5624285809Sscottl
5625285809Sscottl    return(tiStatus);
5626285809Sscottl}
5627285809Sscottl
5628285809Sscottl/*****************************************************************************
5629285809Sscottl*
5630285809Sscottl* tiCOMEncryptDekInvalidate
5631285809Sscottl*
5632285809Sscottl*  Purpose:  This function is called to remove a DEK entry from the hardware cache.
5633285809Sscottl*
5634285809Sscottl*  Parameters:
5635285809Sscottl*
5636285809Sscottl*    tiRoot:        Pointer to driver/port instance.
5637285809Sscottl*    dekTable       DEK table that will be affected
5638285809Sscottl*    dekIndex:      DEK table entry that will be affected. The value 0xfffffff clears the cache.
5639285809Sscottl*
5640285809Sscottl*  Return:
5641285809Sscottl*   tiSuccess       The request is being processed
5642285809Sscottl*   tiError         An invalid parameter was specified
5643285809Sscottl*   tiBusy          An operation is already in progress
5644285809Sscottl*
5645285809Sscottl*****************************************************************************/
5646285809Sscottl
5647285809SscottlosGLOBAL bit32 tiCOMEncryptDekInvalidate(tiRoot_t            *tiRoot,
5648285809Sscottl                                         bit32               dekTable,
5649285809Sscottl                                         bit32               dekIndex)
5650285809Sscottl{
5651285809Sscottl
5652285809Sscottl    tdsaRoot_t        *tdsaRoot;
5653285809Sscottl    tdsaContext_t     *tdsaAllShared;
5654285809Sscottl
5655285809Sscottl    agsaRoot_t        *agRoot;
5656285809Sscottl    tiEncryptPort_t tiEncryptPort;
5657285809Sscottl    tiEncryptDek_t  tiEncryptDek;
5658285809Sscottl    bit32           returnCode;
5659285809Sscottl    bit32           tiStatus;
5660285809Sscottl
5661285809Sscottl    TD_ASSERT(tiRoot, "tiRoot");
5662285809Sscottl    tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5663285809Sscottl    TD_ASSERT(tdsaRoot, "tdsaRoot");
5664285809Sscottl
5665285809Sscottl    tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5666285809Sscottl    TD_ASSERT(tdsaAllShared, "tdsaAllShared");
5667285809Sscottl    agRoot = &(tdsaAllShared->agRootNonInt);
5668285809Sscottl    TD_ASSERT(agRoot, "agRoot");
5669285809Sscottl
5670285809Sscottl    TI_DBG1(("tiCOMEncryptDekInvalidate:dekTable 0x%x dekIndex 0x%x\n", dekTable, dekIndex));
5671285809Sscottl
5672285809Sscottl    returnCode = saEncryptDekCacheInvalidate(agRoot, agNULL, 0, dekTable, dekIndex);
5673285809Sscottl
5674285809Sscottl    if (returnCode == AGSA_RC_SUCCESS)
5675285809Sscottl    {
5676285809Sscottl        tiStatus = tiSuccess;
5677285809Sscottl    }
5678285809Sscottl    else
5679285809Sscottl    {
5680285809Sscottl        if (returnCode == AGSA_RC_NOT_SUPPORTED)
5681285809Sscottl        {
5682285809Sscottl            tiStatus = tiNotSupported;
5683285809Sscottl        }
5684285809Sscottl        else if (returnCode == AGSA_RC_BUSY)
5685285809Sscottl        {
5686285809Sscottl            tiStatus = tiBusy;
5687285809Sscottl        }
5688285809Sscottl        else
5689285809Sscottl        {
5690285809Sscottl            tiStatus = tiError;
5691285809Sscottl        }
5692285809Sscottl
5693285809Sscottl        tiEncryptDek.dekTable = dekTable;
5694285809Sscottl        tiEncryptDek.dekIndex = dekIndex;
5695285809Sscottl
5696285809Sscottl        tiEncryptPort.encryptEvent = tiEncryptDekInvalidate;
5697285809Sscottl        tiEncryptPort.subEvent = 0;
5698285809Sscottl        tiEncryptPort.pData = (void *) &tiEncryptDek;
5699285809Sscottl
5700285809Sscottl        ostiPortEvent(tiRoot,tiEncryptOperation,tiStatus,&tiEncryptPort);
5701285809Sscottl    }
5702285809Sscottl
5703285809Sscottl    return(tiStatus);
5704285809Sscottl}
5705285809Sscottl
5706285809Sscottl/*****************************************************************************
5707285809Sscottl*
5708285809Sscottl* tiCOMEncryptKekAdd
5709285809Sscottl*
5710285809Sscottl*  Purpose:  This function is called to add a KEK in the register specified by
5711285809Sscottl*            the index parameter.
5712285809Sscottl*
5713285809Sscottl*  Parameters:
5714285809Sscottl*
5715285809Sscottl*    tiRoot:           Pointer to driver/port instance.
5716285809Sscottl*    kekIndex:         KEK table entry that will be affected
5717285809Sscottl*    wrapperKekIndex   KEK table entry that encrypt the KEK blob
5718285809Sscottl*    encryptKekBlob    KEK blob that will be added
5719285809Sscottl*
5720285809Sscottl*  Return:
5721285809Sscottl*   tiSuccess       The request is being processed
5722285809Sscottl*   tiError         An invalid parameter was specified
5723285809Sscottl*   tiBusy          A KEK operation is already in progress
5724285809Sscottl*
5725285809Sscottl*****************************************************************************/
5726285809Sscottl
5727285809SscottlosGLOBAL bit32 tiCOMEncryptKekAdd(tiRoot_t            *tiRoot,
5728285809Sscottl                                  bit32               kekIndex,
5729285809Sscottl                                  bit32               wrapperKekIndex,
5730285809Sscottl                                  bit32               blobFormat,
5731285809Sscottl                                  tiEncryptKekBlob_t *encryptKekBlob)
5732285809Sscottl{
5733285809Sscottl  tdsaRoot_t        *tdsaRoot;
5734285809Sscottl  tdsaContext_t     *tdsaAllShared;
5735285809Sscottl  agsaRoot_t        *agRoot;
5736285809Sscottl
5737285809Sscottl  bit32           returnCode= AGSA_RC_BUSY;
5738285809Sscottl  bit32           tiStatus= tiError;
5739285809Sscottl
5740285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5741285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5742285809Sscottl
5743285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
5744285809Sscottl
5745285809Sscottl  TI_DBG1(("tiCOMEncryptDekInvalidate: kekIndex 0x%x wrapperKekIndex 0x%x\n", kekIndex , wrapperKekIndex));
5746285809Sscottl
5747285809Sscottl  returnCode = saEncryptKekUpdate(agRoot,
5748285809Sscottl                                  agNULL,
5749285809Sscottl                                  0,
5750285809Sscottl                                  AGSA_ENCRYPT_STORE_NVRAM,
5751285809Sscottl                                  kekIndex,
5752285809Sscottl                                  wrapperKekIndex,
5753285809Sscottl                                  blobFormat,
5754285809Sscottl                                  (agsaEncryptKekBlob_t *) encryptKekBlob);
5755285809Sscottl
5756285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
5757285809Sscottl  {
5758285809Sscottl    tiStatus = tiSuccess;
5759285809Sscottl  }
5760285809Sscottl  else if (returnCode == AGSA_RC_BUSY)
5761285809Sscottl  {
5762285809Sscottl    tiStatus = tiBusy;
5763285809Sscottl  }
5764285809Sscottl  else
5765285809Sscottl  {
5766285809Sscottl    tiStatus = tiError;
5767285809Sscottl  }
5768285809Sscottl
5769285809Sscottl  return(tiStatus);
5770285809Sscottl}
5771285809Sscottl#ifdef HIALEAH_ENCRYPTION
5772285809Sscottl
5773285809SscottlosGLOBAL bit32 tiCOMEncryptHilSet(tiRoot_t            *tiRoot )
5774285809Sscottl{
5775285809Sscottl  tdsaRoot_t        *tdsaRoot;
5776285809Sscottl  tdsaContext_t     *tdsaAllShared;
5777285809Sscottl  agsaRoot_t        *agRoot;
5778285809Sscottl  agsaEncryptInfo_t agsaEncryptInfo;
5779285809Sscottl
5780285809Sscottl  bit32           returnCode= tiBusy;
5781285809Sscottl  bit32           tiStatus= tiError;
5782285809Sscottl
5783285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5784285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5785285809Sscottl
5786285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
5787285809Sscottl
5788285809Sscottl
5789285809Sscottl  returnCode = saEncryptGetMode(agRoot,agNULL, &agsaEncryptInfo);
5790285809Sscottl  TI_DBG1(("tiCOMEncryptHilSet: saEncryptGetMode returnCode 0x%x agsaEncryptInfo status 0x%x Smode 0x%x CMode 0x%x\n",
5791285809Sscottl          returnCode,
5792285809Sscottl          agsaEncryptInfo.status,
5793285809Sscottl          agsaEncryptInfo.encryptionSecurityMode,
5794285809Sscottl          agsaEncryptInfo.encryptionCipherMode ));
5795285809Sscottl
5796285809Sscottl  if (returnCode == AGSA_RC_FAILURE)
5797285809Sscottl  {
5798285809Sscottl   TI_DBG1(("tiCOMEncryptHilSet:agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5799285809Sscottl    if(agsaEncryptInfo.status == 0x81)
5800285809Sscottl    {
5801285809Sscottl   	  TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISMATCH agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5802285809Sscottl      returnCode = saEncryptHilUpdate(agRoot,
5803285809Sscottl                                      agNULL,
5804285809Sscottl                                      0 );
5805285809Sscottl      if (returnCode == AGSA_RC_SUCCESS)
5806285809Sscottl      {
5807285809Sscottl        TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_SUCCESS\n"));
5808285809Sscottl      }
5809285809Sscottl    }
5810285809Sscottl	else if(agsaEncryptInfo.status == 0x80)
5811285809Sscottl    {
5812285809Sscottl   		ostidisableEncryption(tiRoot);
5813285809Sscottl		TI_DBG1(("tiCOMEncryptHilSet: status 0x80 KEY CARD MISSING agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5814285809Sscottl    	returnCode = AGSA_RC_SUCCESS;
5815285809Sscottl	}
5816285809Sscottl    else
5817285809Sscottl    {
5818285809Sscottl      TI_DBG1(("tiCOMEncryptHilSet: not status 0x81 agsaEncryptInfo.status 0x%x\n",agsaEncryptInfo.status ));
5819285809Sscottl      returnCode = AGSA_RC_FAILURE;
5820285809Sscottl    }
5821285809Sscottl  }
5822285809Sscottl
5823285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
5824285809Sscottl  {
5825285809Sscottl    tiStatus = tiSuccess;
5826285809Sscottl  }
5827285809Sscottl  else if (returnCode == AGSA_RC_BUSY)
5828285809Sscottl  {
5829285809Sscottl    TI_DBG1(("tiCOMEncryptHilSet:AGSA_RC_BUSY\n"));
5830285809Sscottl    tiStatus = tiBusy;
5831285809Sscottl  }
5832285809Sscottl  else
5833285809Sscottl  {
5834285809Sscottl    TI_DBG1(("tiCOMEncryptHilSet:tiError\n"));
5835285809Sscottl    tiStatus = tiError;
5836285809Sscottl  }
5837285809Sscottl
5838285809Sscottl  return(tiStatus);
5839285809Sscottl}
5840285809Sscottl#endif /* HIALEAH_ENCRYPTION */
5841285809Sscottl
5842285809Sscottl/*****************************************************************************
5843285809Sscottl*
5844285809Sscottl* tiCOMEncryptKekStore
5845285809Sscottl*
5846285809Sscottl*  Purpose:  This function is called to store a KEK in NVRAM. If -1 is specified
5847285809Sscottl*            as the KEK index, then all KEKs will be stored.
5848285809Sscottl*
5849285809Sscottl*  Parameters:
5850285809Sscottl*
5851285809Sscottl*    tiRoot:        Pointer to driver/port instance.
5852285809Sscottl*    kekIndex:      The KEK to be stored in NVRAM
5853285809Sscottl*
5854285809Sscottl*  Return:
5855285809Sscottl*   tiSuccess       The request is being processed
5856285809Sscottl*   tiError         An invalid parameter was specified
5857285809Sscottl*   tiBusy          A KEK operation is already in progress
5858285809Sscottl*
5859285809Sscottl*****************************************************************************/
5860285809Sscottl
5861285809SscottlosGLOBAL bit32 tiCOMEncryptKekStore(tiRoot_t  *tiRoot,
5862285809Sscottl                                    bit32      kekIndex)
5863285809Sscottl{
5864285809Sscottl#ifdef NOT_YET
5865285809Sscottl    tdsaRoot_t        *tdsaRoot;
5866285809Sscottl    tdsaContext_t     *tdsaAllShared;
5867285809Sscottl    agsaRoot_t        *agRoot;
5868285809Sscottl#endif
5869285809Sscottl/*
5870285809Sscottl    bit32           returnCode= AGSA_RC_BUSY;
5871285809Sscottl*/
5872285809Sscottl    bit32           tiStatus = tiError;
5873285809Sscottl
5874285809Sscottl#ifdef NOT_YET
5875285809Sscottl    tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5876285809Sscottl    tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5877285809Sscottl
5878285809Sscottl    agRoot = &(tdsaAllShared->agRootNonInt);
5879285809Sscottl#endif
5880285809Sscottl
5881285809Sscottl    TI_DBG1(("tiCOMEncryptKekStore: Needs code !!!! kekIndex 0x%x\n", kekIndex ));
5882285809Sscottl/*
5883285809Sscottl    returnCode = fcEncryptKekStore(agRoot, kekIndex);
5884285809Sscottl
5885285809Sscottl    if (returnCode == AGSA_RC_SUCCESS)
5886285809Sscottl    {
5887285809Sscottl        tiStatus = tiSuccess;
5888285809Sscottl    }
5889285809Sscottl    else if (returnCode == AGSA_RC_BUSY)
5890285809Sscottl    {
5891285809Sscottl        tiStatus = tiBusy;
5892285809Sscottl    }
5893285809Sscottl    else
5894285809Sscottl    {
5895285809Sscottl        tiStatus;
5896285809Sscottl    }
5897285809Sscottl*/
5898285809Sscottl    return(tiStatus);
5899285809Sscottl}
5900285809Sscottl
5901285809Sscottl/*****************************************************************************
5902285809Sscottl*
5903285809Sscottl* tiCOMEncryptKekLoad
5904285809Sscottl*
5905285809Sscottl*  Purpose:  This function is called to load a KEK from NVRAM. If -1 is specified
5906285809Sscottl*            as the KEK index, then all KEKs will be loaded.
5907285809Sscottl*
5908285809Sscottl*  Parameters:
5909285809Sscottl*
5910285809Sscottl*    tiRoot:        Pointer to driver/port instance.
5911285809Sscottl*    kekIndex:      The KEK to be loaded in NVRAM
5912285809Sscottl*
5913285809Sscottl*  Return:
5914285809Sscottl*   tiSuccess       The request is being processed
5915285809Sscottl*   tiError         An invalid parameter was specified
5916285809Sscottl*   tiBusy          A KEK operation is already in progress
5917285809Sscottl*
5918285809Sscottl*****************************************************************************/
5919285809Sscottl
5920285809SscottlosGLOBAL bit32 tiCOMEncryptKekLoad(tiRoot_t            *tiRoot,
5921285809Sscottl                                   bit32               kekIndex)
5922285809Sscottl{
5923285809Sscottl#ifdef NOT_YET
5924285809Sscottl    tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
5925285809Sscottl    tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5926285809Sscottl    agsaRoot_t      *agRoot;
5927285809Sscottl    //bit32           returnCode;
5928285809Sscottl#endif
5929285809Sscottl    bit32           tiStatus = tiError;
5930285809Sscottl
5931285809Sscottl#ifdef NOT_YET
5932285809Sscottl    agRoot = &(tdsaAllShared->agRootNonInt);
5933285809Sscottl#endif
5934285809Sscottl/*
5935285809Sscottl    returnCode = fcEncryptKekLoad(agRoot, kekIndex);
5936285809Sscottl
5937285809Sscottl    if (returnCode == AGSA_RC_SUCCESS)
5938285809Sscottl    {
5939285809Sscottl        tiStatus = tiSuccess;
5940285809Sscottl    }
5941285809Sscottl    else if (returnCode == AGSA_RC_BUSY)
5942285809Sscottl    {
5943285809Sscottl        tiStatus = tiBusy;
5944285809Sscottl    }
5945285809Sscottl    else
5946285809Sscottl    {
5947285809Sscottl        tiStatus = tiError;
5948285809Sscottl    }
5949285809Sscottl*/
5950285809Sscottl    return(tiStatus);
5951285809Sscottl}
5952285809Sscottl
5953285809Sscottl/*****************************************************************************
5954285809Sscottl*
5955285809Sscottl* tiCOMEncryptSelfTest
5956285809Sscottl*
5957285809Sscottl*  Purpose:  This function starts the encryption self test. For the encryption self test, IOs must be quiesced.
5958285809Sscottl*                The completion of this function is via ostiPortEvent().
5959285809Sscottl*
5960285809Sscottl*  Parameters:
5961285809Sscottl*
5962285809Sscottl*    tiRoot:      Pointer to driver/port instance.
5963285809Sscottl*    type:        Types of test
5964285809Sscottl                      0x1: tiBISTTest
5965285809Sscottl                      0x2: tiHMACTest
5966285809Sscottl                      Others are reserved.
5967285809Sscottl*    length:
5968285809Sscottl                   Size of the test descriptor in bytes, e.g.,
5969285809Sscottl                   Sizeof(tiEncryptSelfTestDescriptor_t)
5970285809Sscottl                   Sizeof(tiEncryptHMACTestDescriptor_t)
5971285809Sscottl*    TestDescriptor       address of the test descriptor structure.
5972285809Sscottl*
5973285809Sscottl*  Return:
5974285809Sscottl*   tiSuccess     The request is being processed
5975285809Sscottl*   tiError          An invalid parameter was specified
5976285809Sscottl*   tiBusy          A encrytion operation is already in progress
5977285809Sscottl*
5978285809Sscottl*****************************************************************************/
5979285809SscottlosGLOBAL bit32 tiCOMEncryptSelfTest(
5980285809Sscottl                        tiRoot_t  *tiRoot,
5981285809Sscottl                        bit32      type,
5982285809Sscottl                        bit32      length,
5983285809Sscottl                        void      *TestDescriptor
5984285809Sscottl                        )
5985285809Sscottl{
5986285809Sscottl  tdsaRoot_t     *tdsaRoot       = agNULL;
5987285809Sscottl  tdsaContext_t  *tdsaAllShared  = agNULL;
5988285809Sscottl  agsaRoot_t     *agRoot         = agNULL;
5989285809Sscottl
5990285809Sscottl  bit32           returnCode     = AGSA_RC_BUSY;
5991285809Sscottl  bit32           tiStatus       = tiError;
5992285809Sscottl
5993285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
5994285809Sscottl  TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
5995285809Sscottl
5996285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
5997285809Sscottl  TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
5998285809Sscottl
5999285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
6000285809Sscottl  TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6001285809Sscottl
6002285809Sscottl  TI_DBG1(("tiCOMEncryptSelfTest: type =  0x%x length = 0x%x\n", type, length));
6003285809Sscottl
6004285809Sscottl  /*do some sanity checking */
6005285809Sscottl  if ( ((type == TI_ENCRYPTION_TEST_TYPE_BIST) && (length != sizeof(tiEncryptSelfTestDescriptor_t )))  ||
6006285809Sscottl       ((type == TI_ENCRYPTION_TEST_TYPE_HMAC) && (length != sizeof(tiEncryptHMACTestDescriptor_t))) )
6007285809Sscottl  {
6008285809Sscottl    TI_DBG1(("tiCOMEncryptSelfTest: type or length error, type 0x%x length 0x%x\n", type, length));
6009285809Sscottl    tiStatus = tiError;
6010285809Sscottl  }
6011285809Sscottl  else
6012285809Sscottl  {
6013285809Sscottl    returnCode = saEncryptSelftestExecute(agRoot,
6014285809Sscottl                                      agNULL,
6015285809Sscottl                                      0,
6016285809Sscottl                                      type,
6017285809Sscottl                                      length,
6018285809Sscottl                                      TestDescriptor
6019285809Sscottl                                      );
6020285809Sscottl
6021285809Sscottl    if (returnCode == AGSA_RC_SUCCESS)
6022285809Sscottl    {
6023285809Sscottl      tiStatus = tiSuccess;
6024285809Sscottl    }
6025285809Sscottl    else if (returnCode == AGSA_RC_BUSY)
6026285809Sscottl    {
6027285809Sscottl      tiStatus = tiBusy;
6028285809Sscottl    }
6029285809Sscottl    else
6030285809Sscottl    {
6031285809Sscottl      tiStatus = tiError;
6032285809Sscottl    }
6033285809Sscottl  }
6034285809Sscottl
6035285809Sscottl  return(tiStatus);
6036285809Sscottl}
6037285809Sscottl
6038285809Sscottl/*****************************************************************************
6039285809Sscottl*
6040285809Sscottl* tiCOMSetOperator
6041285809Sscottl*
6042285809Sscottl*  Purpose:  This function is called to login to or logout out from the controller by an operator.
6043285809Sscottl                  The status is reported via ostiPortEvent().
6044285809Sscottl*
6045285809Sscottl*  Parameters:
6046285809Sscottl*
6047285809Sscottl*    tiRoot:      Pointer to driver/port instance.
6048285809Sscottl*    flag:         operator flag.
6049285809Sscottl                     Bits 0-3: Access type (ACS)
6050285809Sscottl                       0x1: Login
6051285809Sscottl                       0x2: Logout
6052285809Sscottl                       All others are reserved.
6053285809Sscottl                     Bit 4: KEYopr pinned in the KEK table (PIN)
6054285809Sscottl                       0: Not pinned. Operator ID table will be searched during authentication.
6055285809Sscottl                       1: Pinned. OPRIDX is referenced to unwrap the certificate.
6056285809Sscottl                     Bits 5-7: Reserved
6057285809Sscottl                     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
6058285809Sscottl                     Bits 16-31: Reserved.
6059285809Sscottl
6060285809Sscottl     cert:         The pointer to the operator's certificate. The size of the certificate is 40 bytes.
6061285809Sscottl*
6062285809Sscottl*  Return:
6063285809Sscottl*   tiSuccess     Log in or log out was started.
6064285809Sscottl*   tiError          Log in or log out was not started.
6065285809Sscottl*   tiBusy          A operator management operation is already in progress
6066285809Sscottl*
6067285809Sscottl*****************************************************************************/
6068285809SscottlosGLOBAL bit32 tiCOMSetOperator(
6069285809Sscottl                        tiRoot_t      *tiRoot,
6070285809Sscottl                        bit32          flag,
6071285809Sscottl                        void          *cert
6072285809Sscottl                        )
6073285809Sscottl{
6074285809Sscottl  tdsaRoot_t     *tdsaRoot       = agNULL;
6075285809Sscottl  tdsaContext_t  *tdsaAllShared  = agNULL;
6076285809Sscottl  agsaRoot_t     *agRoot         = agNULL;
6077285809Sscottl
6078285809Sscottl  bit32           returnCode     = AGSA_RC_FAILURE;
6079285809Sscottl  bit32           tiStatus       = tiError;
6080285809Sscottl
6081285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
6082285809Sscottl  TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6083285809Sscottl
6084285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6085285809Sscottl  TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6086285809Sscottl
6087285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
6088285809Sscottl  TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6089285809Sscottl
6090285809Sscottl  TI_DBG1(("tiCOMSetOperator: flag =  0x%x \n", flag));
6091285809Sscottl
6092285809Sscottl  returnCode = saSetOperator(agRoot,
6093285809Sscottl                             agNULL,
6094285809Sscottl                             0,
6095285809Sscottl                             flag,
6096285809Sscottl                             cert);
6097285809Sscottl
6098285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
6099285809Sscottl  {
6100285809Sscottl    tiStatus = tiSuccess;
6101285809Sscottl  }
6102285809Sscottl  else if (returnCode == AGSA_RC_BUSY)
6103285809Sscottl  {
6104285809Sscottl    tiStatus = tiBusy;
6105285809Sscottl  }
6106285809Sscottl  else
6107285809Sscottl  {
6108285809Sscottl    tiStatus = tiError;
6109285809Sscottl  }
6110285809Sscottl
6111285809Sscottl  return(tiStatus);
6112285809Sscottl}
6113285809Sscottl
6114285809Sscottl/*****************************************************************************
6115285809Sscottl*
6116285809Sscottl* tiCOMGetOperator
6117285809Sscottl*
6118285809Sscottl*  Purpose:  This function is used to retrieve the role and ID of the current operator or all operators.
6119285809Sscottl                  The status is reported via ostiPortEvent().
6120285809Sscottl*
6121285809Sscottl*  Parameters:
6122285809Sscottl*
6123285809Sscottl*    tiRoot:      Pointer to driver/port instance.
6124285809Sscottl*    option:     Types of get operations
6125285809Sscottl                       0x1: Current operator only
6126285809Sscottl                       0x2: All operators
6127285809Sscottl                       All others are reserved.
6128285809Sscottl      AddrHi      Upper 32-bit host physical address to store operator certificates.
6129285809Sscottl                    This field is used only when option is 0x2
6130285809Sscottl      AddrLo     Lower 32-bit host physical address to store operator certificates.
6131285809Sscottl                    This field is used only when option is 0x2
6132285809Sscottl*
6133285809Sscottl*  Return:
6134285809Sscottl*   tiSuccess     The operation was started..
6135285809Sscottl*   tiError          The operation was not started.
6136285809Sscottl*   tiBusy          A operator management operation is already in progress
6137285809Sscottl*
6138285809Sscottl*****************************************************************************/
6139285809SscottlosGLOBAL bit32 tiCOMGetOperator(
6140285809Sscottl                           tiRoot_t   *tiRoot,
6141285809Sscottl                           bit32       option,
6142285809Sscottl                           bit32       AddrHi,
6143285809Sscottl                           bit32       AddrLo
6144285809Sscottl                           )
6145285809Sscottl{
6146285809Sscottl  tdsaRoot_t     *tdsaRoot       = agNULL;
6147285809Sscottl  tdsaContext_t  *tdsaAllShared  = agNULL;
6148285809Sscottl  agsaRoot_t     *agRoot         = agNULL;
6149285809Sscottl
6150285809Sscottl  bit32           returnCode     = AGSA_RC_FAILURE;
6151285809Sscottl  bit32           tiStatus       = tiError;
6152285809Sscottl
6153285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
6154285809Sscottl  TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6155285809Sscottl
6156285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6157285809Sscottl  TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6158285809Sscottl
6159285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
6160285809Sscottl  TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6161285809Sscottl
6162285809Sscottl  TI_DBG1(("tiCOMGetOperator: option = 0x%x \n", option));
6163285809Sscottl
6164285809Sscottl  returnCode = saGetOperator(agRoot,
6165285809Sscottl                             agNULL,
6166285809Sscottl                             0,
6167285809Sscottl                             option,
6168285809Sscottl                             AddrHi,
6169285809Sscottl                             AddrLo);
6170285809Sscottl
6171285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
6172285809Sscottl  {
6173285809Sscottl    tiStatus = tiSuccess;
6174285809Sscottl  }
6175285809Sscottl  else if (returnCode == AGSA_RC_BUSY)
6176285809Sscottl  {
6177285809Sscottl    tiStatus = tiBusy;
6178285809Sscottl  }
6179285809Sscottl  else
6180285809Sscottl  {
6181285809Sscottl    tiStatus = tiError;
6182285809Sscottl  }
6183285809Sscottl
6184285809Sscottl  return(tiStatus);
6185285809Sscottl}
6186285809Sscottl
6187285809Sscottl/*****************************************************************************
6188285809Sscottl*
6189285809Sscottl* tiCOMOperationManagement
6190285809Sscottl*
6191285809Sscottl*  Purpose:  this function is used to manage operators,  e.g. adding or deleting an operator..
6192285809Sscottl*
6193285809Sscottl*  Parameters:
6194285809Sscottl*
6195285809Sscottl*   tiRoot:      Pointer to driver/port instance.
6196285809Sscottl*   flag:         operation flag.
6197285809Sscottl                    Bits 0-7: Operator Management Operation(OMO)
6198285809Sscottl                       0: Add an operator.
6199285809Sscottl                       1: Delete an operator.
6200285809Sscottl                       2: Delete all operators.
6201285809Sscottl                       Others are reserved.
6202285809Sscottl                    Bit 8: Pinned to KEK RAM (PKR)
6203285809Sscottl                      0: Operator's KEK is stored in the operator ID table(OID_TLB) only.
6204285809Sscottl                      1: Operator's KEK is pinned to the internal KEK RAM (1 of the 16 entries) and is also stored in OID_TLB.
6205285809Sscottl                    Bits 9-10: KEKopr blob format (KBF)
6206285809Sscottl                      00b: Reserved.
6207285809Sscottl                      01b: AGSA_ENCRYPTED_KEK_PMCA.
6208285809Sscottl                      10b: AGSA_ENCRYPTED_KEK_PMCB.
6209285809Sscottl                      11b: Reserved.
6210285809Sscottl                    Bits 11-15: Reserved
6211285809Sscottl                    Bits 16-23: KEKauth Index in the KEK Table (AUTIDX)
6212285809Sscottl                    Bits 24-31: KEKopr Index in the KEK Table (OPRIDX). This field is valid only when PKR is 1.
6213285809Sscottl
6214285809Sscottl       role        Role
6215285809Sscottl                       01b: Crypto officer role.
6216285809Sscottl                       10b: User role.
6217285809Sscottl                       All others are reserved.
6218285809Sscottl
6219285809Sscottl*    idString:         Pointer to the tiID_t structure describing the ID string
6220285809Sscottl*    kekBlob          Pointer to the tiEncryptKekBlob_t structure describing KBLOB.
6221285809Sscottl*
6222285809Sscottl*  Return:
6223285809Sscottl*   tiSuccess     The request is being processed
6224285809Sscottl*   tiError          An invalid parameter was specified
6225285809Sscottl*   tiBusy          A operator management operation is already in progress
6226285809Sscottl*
6227285809Sscottl*****************************************************************************/
6228285809SscottlosGLOBAL bit32 tiCOMOperatorManagement(
6229285809Sscottl                        tiRoot_t            *tiRoot,
6230285809Sscottl                        bit32                flag,
6231285809Sscottl                        bit8                 role,
6232285809Sscottl                        tiID_t              *idString,
6233285809Sscottl                        tiEncryptKekBlob_t  *kekBlob
6234285809Sscottl                        )
6235285809Sscottl{
6236285809Sscottl  tdsaRoot_t     *tdsaRoot       = agNULL;
6237285809Sscottl  tdsaContext_t  *tdsaAllShared  = agNULL;
6238285809Sscottl  agsaRoot_t     *agRoot         = agNULL;
6239285809Sscottl
6240285809Sscottl  bit32           returnCode     = AGSA_RC_BUSY;
6241285809Sscottl  bit32           tiStatus       = tiError;
6242285809Sscottl
6243285809Sscottl  tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
6244285809Sscottl  TD_ASSERT(tdsaRoot != agNULL, "tdsaRoot is NULL !!!");
6245285809Sscottl
6246285809Sscottl  tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6247285809Sscottl  TD_ASSERT(tdsaAllShared != agNULL, "tdsaAllShared is NULL !!!");
6248285809Sscottl
6249285809Sscottl  agRoot = &(tdsaAllShared->agRootNonInt);
6250285809Sscottl  TD_ASSERT(agRoot != agNULL, "agRoot is NULL !!!");
6251285809Sscottl
6252285809Sscottl  TI_DBG1(("tiCOMOperatorManagement: flag =  0x%x role = 0x%x\n", flag, role));
6253285809Sscottl
6254285809Sscottl  returnCode = saOperatorManagement(agRoot,
6255285809Sscottl                                    agNULL,
6256285809Sscottl                                    0,
6257285809Sscottl                                    flag,
6258285809Sscottl                                    role,
6259285809Sscottl                                    (agsaID_t*)idString,
6260285809Sscottl                                    (agsaEncryptKekBlob_t *)kekBlob
6261285809Sscottl                                    );
6262285809Sscottl
6263285809Sscottl  if (returnCode == AGSA_RC_SUCCESS)
6264285809Sscottl  {
6265285809Sscottl    tiStatus = tiSuccess;
6266285809Sscottl  }
6267285809Sscottl  else if (returnCode == AGSA_RC_BUSY)
6268285809Sscottl  {
6269285809Sscottl    tiStatus = tiBusy;
6270285809Sscottl  }
6271285809Sscottl  else
6272285809Sscottl  {
6273285809Sscottl    tiStatus = tiError;
6274285809Sscottl  }
6275285809Sscottl
6276285809Sscottl  return(tiStatus);
6277285809Sscottl}
6278285809Sscottl
6279285809Sscottl/*****************************************************************************
6280285809Sscottl*! \brief tdssRemoveSASSATAFromSharedcontext
6281285809Sscottl*
6282285809Sscottl*  Purpose:  This function removes all discovered devices belonging to
6283285809Sscottl*            a given portcontext from device list
6284285809Sscottl*
6285285809Sscottl*
6286285809Sscottl*  \param   agRoot                   Pointer to the root data structure of
6287285809Sscottl*                                    TD and Lower layer
6288285809Sscottl*  \param   tsddPortContext_Instance Pointer to the target port context
6289285809Sscottl*
6290285809Sscottl*  \Return: none
6291285809Sscottl*
6292285809Sscottl*****************************************************************************/
6293285809Sscottl#ifdef INITIATOR_DRIVER                     /*TBD: added to compile tgt_drv. (TP)*/
6294285809SscottlosGLOBAL void
6295285809SscottltdssRemoveSASSATAFromSharedcontext(
6296285809Sscottl                          agsaRoot_t           *agRoot,
6297285809Sscottl                          tdsaPortContext_t    *PortContext_Instance
6298285809Sscottl                          )
6299285809Sscottl{
6300285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
6301285809Sscottl  tdList_t          *DeviceListList;
6302285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6303285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6304285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6305285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6306285809Sscottl
6307285809Sscottl  TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: start\n"));
6308285809Sscottl  TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d\n", PortContext_Instance->id));
6309285809Sscottl
6310285809Sscottl  /* find oneDeviceData belonging to the portcontext */
6311285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
6312285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6313285809Sscottl  {
6314285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6315285809Sscottl    if (oneDeviceData == agNULL)
6316285809Sscottl    {
6317285809Sscottl      TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: oneDeviceData is NULL!!!\n"));
6318285809Sscottl      return;
6319285809Sscottl    }
6320285809Sscottl    if (oneDeviceData->tdPortContext == PortContext_Instance)
6321285809Sscottl    {
6322285809Sscottl      TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: pid %d did %d\n", PortContext_Instance->id, oneDeviceData->id));
6323285809Sscottl      TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
6324285809Sscottl      TI_DBG1(("tdssRemoveSASSATAFromSharedcontext: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
6325285809Sscottl
6326285809Sscottl      /* reset valid bit */
6327285809Sscottl      oneDeviceData->valid = agFALSE;
6328285809Sscottl      oneDeviceData->valid2 = agFALSE;
6329285809Sscottl      oneDeviceData->registered = agFALSE;
6330285809Sscottl      /* notify only reported devices to OS layer*/
6331285809Sscottl      if ( DEVICE_IS_SSP_TARGET(oneDeviceData) ||
6332285809Sscottl           DEVICE_IS_STP_TARGET(oneDeviceData) ||
6333285809Sscottl           DEVICE_IS_SATA_DEVICE(oneDeviceData)
6334285809Sscottl        )
6335285809Sscottl      {
6336285809Sscottl        ostiInitiatorEvent(
6337285809Sscottl                         tiRoot,
6338285809Sscottl                         PortContext_Instance->tiPortalContext,
6339285809Sscottl                         &(oneDeviceData->tiDeviceHandle),
6340285809Sscottl                         tiIntrEventTypeDeviceChange,
6341285809Sscottl                         tiDeviceRemoval,
6342285809Sscottl                         agNULL
6343285809Sscottl                         );
6344285809Sscottl      }
6345285809Sscottl      DeviceListList = DeviceListList->flink;
6346285809Sscottl    /* to-do: deregister */
6347285809Sscottl#ifdef REMOVED  /* don't remove device from the device list. May screw up ordering */
6348285809Sscottl      TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
6349285809Sscottl      TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
6350285809Sscottl#endif
6351285809Sscottl    }
6352285809Sscottl    else
6353285809Sscottl    {
6354285809Sscottl      TI_DBG6(("tdssRemoveSASSATAFromSharedcontext: move to the next\n"));
6355285809Sscottl      DeviceListList = DeviceListList->flink;
6356285809Sscottl    }
6357285809Sscottl  } /* while */
6358285809Sscottl
6359285809Sscottl  return;
6360285809Sscottl}
6361285809Sscottl
6362285809Sscottl/*****************************************************************************
6363285809Sscottl*! \brief tdssRemoveSASSATAFromSharedcontextByReset
6364285809Sscottl*
6365285809Sscottl*  Purpose:  This function removes all ports and discovered devices
6366285809Sscottl*
6367285809Sscottl*
6368285809Sscottl*  \param   agRoot                   Pointer to the root data structure of
6369285809Sscottl*                                    TD and Lower layer
6370285809Sscottl*
6371285809Sscottl*  \Return: none
6372285809Sscottl*
6373285809Sscottl*****************************************************************************/
6374285809SscottlosGLOBAL void
6375285809SscottltdssRemoveSASSATAFromSharedcontextByReset(
6376285809Sscottl                                          agsaRoot_t           *agRoot
6377285809Sscottl                                          )
6378285809Sscottl{
6379285809Sscottl  tdsaPortContext_t *onePortContext = agNULL;
6380285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
6381285809Sscottl  tdList_t          *PortContextList;
6382285809Sscottl  tdList_t          *DeviceListList;
6383285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6384285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6385285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6386285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6387285809Sscottl#ifdef FDS_DM
6388285809Sscottl  dmRoot_t          *dmRoot = agNULL;
6389285809Sscottl  dmPortContext_t   *dmPortContext = agNULL;
6390285809Sscottl  dmPortInfo_t      dmPortInfo;
6391285809Sscottl#endif
6392285809Sscottl#ifdef FDS_SM
6393285809Sscottl  smRoot_t          *smRoot = &(tdsaAllShared->smRoot);
6394285809Sscottl  smDeviceHandle_t  *smDeviceHandle = agNULL;
6395285809Sscottl  agsaDevHandle_t   *agDevHandle = agNULL;
6396285809Sscottl#endif
6397285809Sscottl
6398285809Sscottl  TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: start\n"));
6399285809Sscottl
6400285809Sscottl#ifdef FDS_DM
6401285809Sscottl  dmRoot = &(tdsaAllShared->dmRoot);
6402285809Sscottl#endif
6403285809Sscottl  /* looping throuhg all portcontext */
6404285809Sscottl  PortContextList = tdsaAllShared->MainPortContextList.flink;
6405285809Sscottl  while (PortContextList != &(tdsaAllShared->MainPortContextList))
6406285809Sscottl  {
6407285809Sscottl    onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6408285809Sscottl    if (onePortContext == agNULL)
6409285809Sscottl    {
6410285809Sscottl      TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: onePortContext is NULL!!!\n"));
6411285809Sscottl      return;
6412285809Sscottl    }
6413285809Sscottl    TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneportContext pid %d\n", onePortContext->id));
6414285809Sscottl    TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", onePortContext->sasLocalAddressHi));
6415285809Sscottl    TI_DBG3(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", onePortContext->sasLocalAddressLo));
6416285809Sscottl#ifdef FDS_DM
6417285809Sscottl    if (onePortContext->UseDM == agTRUE)
6418285809Sscottl    {
6419285809Sscottl      dmPortContext = &(onePortContext->dmPortContext);
6420285809Sscottl      dmDestroyPort(dmRoot, dmPortContext, &dmPortInfo);
6421285809Sscottl    }
6422285809Sscottl#endif
6423285809Sscottl
6424285809Sscottl    tdsaPortContextReInit(tiRoot, onePortContext);
6425285809Sscottl
6426285809Sscottl    PortContextList = PortContextList->flink;
6427285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
6428285809Sscottl    TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
6429285809Sscottl    TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
6430285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
6431285809Sscottl  }
6432285809Sscottl
6433285809Sscottl  /* reinitialize the device data belonging to this portcontext */
6434285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
6435285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6436285809Sscottl  {
6437285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6438285809Sscottl    if (oneDeviceData == agNULL)
6439285809Sscottl    {
6440285809Sscottl      TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: oneDeviceData is NULL!!!\n"));
6441285809Sscottl      return;
6442285809Sscottl    }
6443285809Sscottl
6444285809Sscottl    TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: did %d\n", oneDeviceData->id));
6445285809Sscottl    TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
6446285809Sscottl    TI_DBG1(("tdssRemoveSASSATAFromSharedcontextByReset: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
6447285809Sscottl
6448285809Sscottl#ifdef FDS_SM
6449285809Sscottl    agDevHandle = oneDeviceData->agDevHandle;
6450285809Sscottl    smDeviceHandle = (smDeviceHandle_t *)&(oneDeviceData->smDeviceHandle);
6451285809Sscottl    smDeregisterDevice(smRoot, agDevHandle, smDeviceHandle);
6452285809Sscottl#endif
6453285809Sscottl
6454285809Sscottl    tdsaDeviceDataReInit(tiRoot, oneDeviceData);
6455285809Sscottl
6456285809Sscottl    DeviceListList = DeviceListList->flink;
6457285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6458285809Sscottl    osti_memset(&(oneDeviceData->satDevData.satIdentifyData), 0xFF, sizeof(agsaSATAIdentifyData_t));
6459285809Sscottl    TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
6460285809Sscottl    TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceList));
6461285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6462285809Sscottl    /* no dequeue from Mainlink for consistant ordering of devices */
6463285809Sscottl  }
6464285809Sscottl
6465285809Sscottl
6466285809Sscottl  return;
6467285809Sscottl}
6468285809Sscottl
6469285809Sscottl#endif
6470285809Sscottl
6471285809Sscottl
6472285809Sscottl/*****************************************************************************
6473285809Sscottl*! \brief tdssAddSASToSharedcontext
6474285809Sscottl*
6475285809Sscottl*  Purpose:  This function adds a discovered device to a device list of
6476285809Sscottl*            a shared context
6477285809Sscottl*
6478285809Sscottl*  \param   tsddPortContext_Instance Pointer to the target port context
6479285809Sscottl*  \param   agRoot                   Pointer to the root data structure of
6480285809Sscottl*                                    TD and Lower layer
6481285809Sscottl*  \param   agDevHandle              Pointer to a device handle
6482285809Sscottl*
6483285809Sscottl*  \Return: none
6484285809Sscottl*
6485285809Sscottl*****************************************************************************/
6486285809SscottlosGLOBAL void
6487285809SscottltdssAddSASToSharedcontext(
6488285809Sscottl                          tdsaPortContext_t    *tdsaPortContext_Instance,
6489285809Sscottl                          agsaRoot_t           *agRoot,
6490285809Sscottl                          agsaDevHandle_t      *agDevHandle, /* this is NULL */
6491285809Sscottl                          tdsaSASSubID_t       *agSASSubID,
6492285809Sscottl                          bit32                 registered, /* no longer in use */
6493285809Sscottl                          bit8                  phyID,
6494285809Sscottl                          bit32                 flag
6495285809Sscottl                          )
6496285809Sscottl{
6497285809Sscottl
6498285809Sscottl  tdsaPortContext_t *onePortContext = agNULL;
6499285809Sscottl  tdList_t          *PortContextList;
6500285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
6501285809Sscottl  tdList_t          *DeviceListList;
6502285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6503285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6504285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6505285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6506285809Sscottl  bit32             new_device = agTRUE;
6507285809Sscottl  bit32             Indenom = tdsaAllShared->QueueConfig.numInboundQueues;
6508285809Sscottl  bit32             Outdenom = tdsaAllShared->QueueConfig.numOutboundQueues;
6509285809Sscottl  bit8              dev_s_rate = 0;
6510285809Sscottl  bit8              sasorsata = 1;
6511285809Sscottl  bit8              connectionRate;
6512285809Sscottl  bit32             found = agFALSE;
6513285809Sscottl
6514285809Sscottl  TI_DBG3(("tdssAddSASToSharedcontext: start\n"));
6515285809Sscottl  /*
6516285809Sscottl    find a right portcontext
6517285809Sscottl    then, get devicedata from FreeLink in DeviceList
6518285809Sscottl    then, do pointer operations
6519285809Sscottl    then, add the devicedata to the portcontext
6520285809Sscottl  */
6521285809Sscottl
6522285809Sscottl  /* find a right portcontext */
6523285809Sscottl  PortContextList = tdsaAllShared->MainPortContextList.flink;
6524285809Sscottl  while (PortContextList != &(tdsaAllShared->MainPortContextList))
6525285809Sscottl  {
6526285809Sscottl    onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6527285809Sscottl    if (onePortContext == tdsaPortContext_Instance)
6528285809Sscottl    {
6529285809Sscottl      TI_DBG3(("tdssAddSASToSharedContext: found; oneportContext ID %d\n", onePortContext->id));
6530285809Sscottl      found = agTRUE;
6531285809Sscottl      break;
6532285809Sscottl    }
6533285809Sscottl    PortContextList = PortContextList->flink;
6534285809Sscottl  }
6535285809Sscottl
6536285809Sscottl  if (found == agTRUE)
6537285809Sscottl  {
6538285809Sscottl    TI_DBG3(("tdssAddSASToSharedcontext: found pid %d\n", onePortContext->id));
6539285809Sscottl  }
6540285809Sscottl  else
6541285809Sscottl  {
6542285809Sscottl    TI_DBG1(("tdssAddSASToSharedcontext: Error!!! no portcontext found!!!\n"));
6543285809Sscottl    return;
6544285809Sscottl  }
6545285809Sscottl
6546285809Sscottl  /* find a device's existence */
6547285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
6548285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6549285809Sscottl  {
6550285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6551285809Sscottl    if (oneDeviceData == agNULL)
6552285809Sscottl    {
6553285809Sscottl      TI_DBG1(("tdssAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
6554285809Sscottl      return;
6555285809Sscottl    }
6556285809Sscottl    if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
6557285809Sscottl        (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
6558285809Sscottl        (oneDeviceData->tdPortContext == onePortContext)
6559285809Sscottl         )
6560285809Sscottl    {
6561285809Sscottl      TI_DBG1(("tdssAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6562285809Sscottl      new_device = agFALSE;
6563285809Sscottl      break;
6564285809Sscottl    }
6565285809Sscottl    DeviceListList = DeviceListList->flink;
6566285809Sscottl  }
6567285809Sscottl
6568285809Sscottl  /* new device */
6569285809Sscottl  if (new_device == agTRUE)
6570285809Sscottl  {
6571285809Sscottl    TI_DBG3(("tdssAddSASToSharedcontext: new device\n"));
6572285809Sscottl
6573285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6574285809Sscottl    if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
6575285809Sscottl    {
6576285809Sscottl      tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6577285809Sscottl      TI_DBG1(("tdssAddSASToSharedContext: empty DeviceData FreeLink\n"));
6578285809Sscottl      return;
6579285809Sscottl    }
6580285809Sscottl
6581285809Sscottl    TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
6582285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6583285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
6584285809Sscottl
6585285809Sscottl    TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
6586285809Sscottl
6587285809Sscottl    onePortContext->Count++;
6588285809Sscottl    oneDeviceData->DeviceType = TD_SAS_DEVICE;
6589285809Sscottl    oneDeviceData->agRoot = agRoot;
6590285809Sscottl
6591285809Sscottl    if (flag == TD_OPERATION_TARGET)
6592285809Sscottl    {
6593285809Sscottl      oneDeviceData->agDevHandle = agDevHandle;
6594285809Sscottl      agDevHandle->osData = oneDeviceData; /* TD layer */
6595285809Sscottl    }
6596285809Sscottl
6597285809Sscottl    /* saving sas address */
6598285809Sscottl    oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
6599285809Sscottl    oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
6600285809Sscottl    oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
6601285809Sscottl    oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
6602285809Sscottl
6603285809Sscottl    oneDeviceData->tdPortContext = onePortContext;
6604285809Sscottl    oneDeviceData->valid = agTRUE;
6605285809Sscottl
6606285809Sscottl    /* new */
6607285809Sscottl    oneDeviceData->directlyAttached = agTRUE;
6608285809Sscottl    /* parse sasIDframe to fill in agDeviceInfo */
6609285809Sscottl    DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
6610285809Sscottl    DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
6611285809Sscottl    DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
6612285809Sscottl    /* enable TLR */
6613285809Sscottl    DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
6614285809Sscottl
6615285809Sscottl    sasorsata = SAS_DEVICE_TYPE; /* SAS target (SAS disk or expander) */
6616285809Sscottl    connectionRate = onePortContext->LinkRate;
6617285809Sscottl    dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
6618285809Sscottl    dev_s_rate = (bit8)(dev_s_rate | connectionRate);
6619285809Sscottl    DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
6620285809Sscottl
6621285809Sscottl
6622285809Sscottl    DEVINFO_PUT_SAS_ADDRESSLO(
6623285809Sscottl                              &oneDeviceData->agDeviceInfo,
6624285809Sscottl                              agSASSubID->sasAddressLo
6625285809Sscottl                              );
6626285809Sscottl    DEVINFO_PUT_SAS_ADDRESSHI(
6627285809Sscottl                              &oneDeviceData->agDeviceInfo,
6628285809Sscottl                              agSASSubID->sasAddressHi
6629285809Sscottl                              );
6630285809Sscottl
6631285809Sscottl    oneDeviceData->agContext.osData = oneDeviceData;
6632285809Sscottl    oneDeviceData->agContext.sdkData = agNULL;
6633285809Sscottl
6634285809Sscottl    if (flag == TD_OPERATION_INITIATOR)
6635285809Sscottl    {
6636285809Sscottl      if (oneDeviceData->registered == agFALSE )
6637285809Sscottl      {
6638285809Sscottl        if( tdsaAllShared->sflag )
6639285809Sscottl        {
6640285809Sscottl          if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
6641285809Sscottl          {
6642285809Sscottl            TI_DBG1(("tdssAddSASToSharedcontext: First, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
6643285809Sscottl            oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
6644285809Sscottl          }
6645285809Sscottl        }
6646285809Sscottl
6647285809Sscottl        saRegisterNewDevice( /* tdssAddSASToSharedcontext */
6648285809Sscottl                            agRoot,
6649285809Sscottl                            &oneDeviceData->agContext,
6650285809Sscottl                            0,
6651285809Sscottl                            &oneDeviceData->agDeviceInfo,
6652285809Sscottl                            onePortContext->agPortContext,
6653285809Sscottl                            0
6654285809Sscottl                           );
6655285809Sscottl      }
6656285809Sscottl    }
6657285809Sscottl    oneDeviceData->phyID = phyID;
6658285809Sscottl    oneDeviceData->InQID = oneDeviceData->id % Indenom;
6659285809Sscottl
6660285809Sscottl#ifdef TARGET_DRIVER
6661285809Sscottl    {
6662285809Sscottl      bit32 localId = oneDeviceData->id;
6663285809Sscottl      localId += 1;
6664285809Sscottl      oneDeviceData->OutQID = localId % Outdenom;
6665285809Sscottl      TI_DBG1(("tdssAddSASToSharedcontext: OutQID %d\n", oneDeviceData->OutQID)); /* tdsaRotateQnumber for tgt*/
6666285809Sscottl
6667285809Sscottl    }
6668285809Sscottl#endif /* TARGET_DRIVER */
6669285809Sscottl
6670285809Sscottl    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)));
6671285809Sscottl    /* add the devicedata to the portcontext */
6672285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6673285809Sscottl    TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
6674285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6675285809Sscottl    TI_DBG4(("tdssAddSASToSharedContext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
6676285809Sscottl    TI_DBG4(("tdssAddSASToSharedContext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
6677285809Sscottl
6678285809Sscottl  }
6679285809Sscottl  else /* old device */
6680285809Sscottl  {
6681285809Sscottl    TI_DBG3(("tdssAddSASToSharedcontext: old device\n"));
6682285809Sscottl    TI_DBG3(("tdssAddSASToSharedcontext: oneDeviceData %p\n", oneDeviceData));
6683285809Sscottl
6684285809Sscottl    oneDeviceData->DeviceType = TD_SAS_DEVICE;
6685285809Sscottl    oneDeviceData->agRoot = agRoot;
6686285809Sscottl
6687285809Sscottl    if (flag == TD_OPERATION_TARGET)
6688285809Sscottl    {
6689285809Sscottl      oneDeviceData->agDevHandle = agDevHandle;
6690285809Sscottl      agDevHandle->osData = oneDeviceData; /* TD layer */
6691285809Sscottl    }
6692285809Sscottl
6693285809Sscottl    /* saving sas address */
6694285809Sscottl    oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
6695285809Sscottl    oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
6696285809Sscottl    oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
6697285809Sscottl    oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
6698285809Sscottl
6699285809Sscottl
6700285809Sscottl    oneDeviceData->tdPortContext = onePortContext;
6701285809Sscottl    oneDeviceData->valid = agTRUE;
6702285809Sscottl
6703285809Sscottl    oneDeviceData->directlyAttached = agTRUE;
6704285809Sscottl    /* new */
6705285809Sscottl    if (oneDeviceData->registered == agFALSE)
6706285809Sscottl    {
6707285809Sscottl      TI_DBG1(("tdssAddSASToSharedcontext: registering\n"));
6708285809Sscottl      /* parse sasIDframe to fill in agDeviceInfo */
6709285809Sscottl      DEVINFO_PUT_SMPTO(&oneDeviceData->agDeviceInfo, DEFAULT_SMP_TIMEOUT);
6710285809Sscottl      DEVINFO_PUT_ITNEXUSTO(&oneDeviceData->agDeviceInfo, (bit16)tdsaAllShared->itNexusTimeout);
6711285809Sscottl      DEVINFO_PUT_FBS(&oneDeviceData->agDeviceInfo, 0);
6712285809Sscottl      DEVINFO_PUT_FLAG(&oneDeviceData->agDeviceInfo, 1);
6713285809Sscottl
6714285809Sscottl      sasorsata = SAS_DEVICE_TYPE; /* SAS target (SAS disk or expander) */
6715285809Sscottl      connectionRate = onePortContext->LinkRate;
6716285809Sscottl      dev_s_rate = (bit8)(dev_s_rate | (sasorsata << 4));
6717285809Sscottl      dev_s_rate = (bit8)(dev_s_rate | connectionRate);
6718285809Sscottl      DEVINFO_PUT_DEV_S_RATE(&oneDeviceData->agDeviceInfo, dev_s_rate);
6719285809Sscottl
6720285809Sscottl
6721285809Sscottl      DEVINFO_PUT_SAS_ADDRESSLO(
6722285809Sscottl                                &oneDeviceData->agDeviceInfo,
6723285809Sscottl                                agSASSubID->sasAddressLo
6724285809Sscottl                                );
6725285809Sscottl      DEVINFO_PUT_SAS_ADDRESSHI(
6726285809Sscottl                                &oneDeviceData->agDeviceInfo,
6727285809Sscottl                                agSASSubID->sasAddressHi
6728285809Sscottl                                );
6729285809Sscottl
6730285809Sscottl      oneDeviceData->agContext.osData = oneDeviceData;
6731285809Sscottl      oneDeviceData->agContext.sdkData = agNULL;
6732285809Sscottl
6733285809Sscottl      if (flag == TD_OPERATION_INITIATOR)
6734285809Sscottl      {
6735285809Sscottl        if( tdsaAllShared->sflag )
6736285809Sscottl        {
6737285809Sscottl          if( ! DEVICE_IS_SMP_TARGET(oneDeviceData))
6738285809Sscottl          {
6739285809Sscottl            TI_DBG1(("tdssAddSASToSharedcontext: Second, saRegisterNewDevice sflag %d\n", tdsaAllShared->sflag));
6740285809Sscottl            oneDeviceData->agDeviceInfo.flag = oneDeviceData->agDeviceInfo.flag | TD_XFER_RDY_PRIORTY_DEVICE_FLAG;
6741285809Sscottl          }
6742285809Sscottl        }
6743285809Sscottl        saRegisterNewDevice( /* tdssAddSASToSharedcontext */
6744285809Sscottl                            agRoot,
6745285809Sscottl                            &oneDeviceData->agContext,
6746285809Sscottl                            0,
6747285809Sscottl                            &oneDeviceData->agDeviceInfo,
6748285809Sscottl                            onePortContext->agPortContext,
6749285809Sscottl                            0
6750285809Sscottl                            );
6751285809Sscottl      }
6752285809Sscottl    }
6753285809Sscottl
6754285809Sscottl
6755285809Sscottl
6756285809Sscottl
6757285809Sscottl
6758285809Sscottl
6759285809Sscottl    oneDeviceData->phyID = phyID;
6760285809Sscottl    oneDeviceData->InQID = oneDeviceData->id % Indenom;
6761285809Sscottl    oneDeviceData->OutQID = oneDeviceData->id % Outdenom;
6762285809Sscottl
6763285809Sscottl    TI_DBG1(("tdssAddSASToSharedcontext: A OutQID %d\n", oneDeviceData->OutQID));
6764285809Sscottl    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)));
6765285809Sscottl    TI_DBG4(("tdssAddSASToSharedContext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
6766285809Sscottl  }
6767285809Sscottl
6768285809Sscottl  return;
6769285809Sscottl}
6770285809Sscottl
6771285809Sscottl
6772285809Sscottl
6773285809Sscottl
6774285809Sscottl/*****************************************************************************
6775285809Sscottl*! \brief tdssRemoveDevicedataFromSharedcontext
6776285809Sscottl*
6777285809Sscottl*  Purpose:  This function removes a discovered device from a device list of
6778285809Sscottl*            a port context
6779285809Sscottl*
6780285809Sscottl*  \param   tsddPortContext_Ins      Pointer to the target port context
6781285809Sscottl*  \param   tdsaDeviceData_Ins       Pointer to the target device
6782285809Sscottl*  \param   agRoot                   Pointer to the root data structure of
6783285809Sscottl*                                    TD and Lower layer
6784285809Sscottl
6785285809Sscottl*
6786285809Sscottl*  \Return: none
6787285809Sscottl*
6788285809Sscottl*****************************************************************************/
6789285809SscottlosGLOBAL void
6790285809SscottltdssRemoveSASFromSharedcontext(
6791285809Sscottl                               tdsaPortContext_t *tdsaPortContext_Ins,
6792285809Sscottl                               tdsaDeviceData_t  *tdsaDeviceData_Ins,
6793285809Sscottl                               agsaRoot_t        *agRoot
6794285809Sscottl                               )
6795285809Sscottl{
6796285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6797285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6798285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6799285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6800285809Sscottl  tdsaPortContext_t *onePortContext = agNULL;
6801285809Sscottl  tdList_t          *PortContextList;
6802285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
6803285809Sscottl  tdList_t          *DeviceListList;
6804285809Sscottl  bit32             found = agTRUE;
6805285809Sscottl
6806285809Sscottl  TI_DBG3(("tdssRemoveSASFromSharedcontext: start\n"));
6807285809Sscottl  /* find a right portcontext */
6808285809Sscottl  PortContextList = tdsaAllShared->MainPortContextList.flink;
6809285809Sscottl  while (PortContextList != &(tdsaAllShared->MainPortContextList))
6810285809Sscottl  {
6811285809Sscottl    onePortContext = TDLIST_OBJECT_BASE(tdsaPortContext_t, MainLink, PortContextList);
6812285809Sscottl    if (onePortContext == agNULL)
6813285809Sscottl    {
6814285809Sscottl      TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: onePortContext is NULL!!!\n"));
6815285809Sscottl      return;
6816285809Sscottl    }
6817285809Sscottl    if (onePortContext == tdsaPortContext_Ins)
6818285809Sscottl    {
6819285809Sscottl      TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: found; oneportContext ID %d\n", onePortContext->id));
6820285809Sscottl      break;
6821285809Sscottl    }
6822285809Sscottl    PortContextList = PortContextList->flink;
6823285809Sscottl  }
6824285809Sscottl
6825285809Sscottl  /* find a device's existence */
6826285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
6827285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6828285809Sscottl  {
6829285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6830285809Sscottl    if (oneDeviceData == agNULL)
6831285809Sscottl    {
6832285809Sscottl      TI_DBG1(("tdssRemoveDevicedataFromSharedcontext: oneDeviceData is NULL!!!\n"));
6833285809Sscottl      return;
6834285809Sscottl    }
6835285809Sscottl    if ((oneDeviceData->SASAddressID.sasAddressHi
6836285809Sscottl         == SA_DEVINFO_GET_SAS_ADDRESSHI(&tdsaDeviceData_Ins->agDeviceInfo))
6837285809Sscottl        &&
6838285809Sscottl        (oneDeviceData->SASAddressID.sasAddressLo ==
6839285809Sscottl         SA_DEVINFO_GET_SAS_ADDRESSLO(&tdsaDeviceData_Ins->agDeviceInfo)))
6840285809Sscottl    {
6841285809Sscottl      TI_DBG4(("tdssRemoveDevicedataFromSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6842285809Sscottl      found = agFALSE;
6843285809Sscottl      break;
6844285809Sscottl    }
6845285809Sscottl    DeviceListList = DeviceListList->flink;
6846285809Sscottl  }
6847285809Sscottl
6848285809Sscottl  if (found == agFALSE)
6849285809Sscottl  {
6850285809Sscottl    TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: can't find the right devicedata in MainLink\n"));
6851285809Sscottl    return;
6852285809Sscottl  }
6853285809Sscottl
6854285809Sscottl  /* remove it and put it back to FreeLink of Devicedata */
6855285809Sscottl  TI_DBG6(("tdssRemoveDevicedataFromSharedcontext: removing ... pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6856285809Sscottl
6857285809Sscottl  /* invalidate the device but keep it on the list for persistency */
6858285809Sscottl  oneDeviceData->valid = agFALSE;
6859285809Sscottl
6860285809Sscottl  return;
6861285809Sscottl}
6862285809Sscottl
6863285809Sscottl/*****************************************************************************
6864285809Sscottl*! \brief tdssRemoveAllDevicedataFromPortcontext
6865285809Sscottl*
6866285809Sscottl*  Purpose:  This function removes all discovered devices from a device list of
6867285809Sscottl*            a port context
6868285809Sscottl*
6869285809Sscottl*  \param   tdsaDeviceData           Pointer to a device header
6870285809Sscottl*
6871285809Sscottl*  \Return: none
6872285809Sscottl*
6873285809Sscottl*****************************************************************************/
6874285809SscottlosGLOBAL void
6875285809SscottltdssRemoveAllDevicelistFromPortcontext(
6876285809Sscottl                                       tdsaPortContext_t *PortContext_Ins,
6877285809Sscottl                                       agsaRoot_t        *agRoot
6878285809Sscottl                                       )
6879285809Sscottl{
6880285809Sscottl
6881285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6882285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6883285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6884285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6885285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
6886285809Sscottl  tdList_t          *DeviceListList;
6887285809Sscottl
6888285809Sscottl  TI_DBG6(("tdssRemoveAllDevicedataFromPortcontext: start\n"));
6889285809Sscottl
6890285809Sscottl  /*
6891285809Sscottl    loop through device list and find the matching portcontext. Then invalidate the
6892285809Sscottl    matching devices
6893285809Sscottl  */
6894285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
6895285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6896285809Sscottl  {
6897285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6898285809Sscottl    if (oneDeviceData == agNULL)
6899285809Sscottl    {
6900285809Sscottl      TI_DBG1(("tdssRemoveAllDevicelistFromPortcontext: oneDeviceData is NULL!!!\n"));
6901285809Sscottl      return;
6902285809Sscottl    }
6903285809Sscottl    if (oneDeviceData->tdPortContext == PortContext_Ins)
6904285809Sscottl    {
6905285809Sscottl      TI_DBG4(("tdssRemoveAllDevicelistFromPortcontext: pid %d did %d\n", PortContext_Ins->id, oneDeviceData->id));
6906285809Sscottl      PortContext_Ins->Count--;
6907285809Sscottl      oneDeviceData->valid = agFALSE;
6908285809Sscottl    }
6909285809Sscottl    DeviceListList = DeviceListList->flink;
6910285809Sscottl  }
6911285809Sscottl
6912285809Sscottl  return;
6913285809Sscottl}
6914285809Sscottl
6915285809Sscottl
6916285809Sscottl#ifdef INITIATOR_DRIVER
6917285809Sscottl#ifdef TD_DISCOVER
6918285809Sscottl/*****************************************************************************
6919285809Sscottl*! \brief tdssNewAddSASToSharedcontext
6920285809Sscottl*
6921285809Sscottl*  Purpose:  This function adds a discovered SAS device to a device list of
6922285809Sscottl*            a shared context. Used only in discovery.
6923285809Sscottl*
6924285809Sscottl*  \param   agRoot          Pointer to chip/driver Instance.
6925285809Sscottl*  \param   onePortContext  Pointer to the target port context
6926285809Sscottl*  \param   agSASSubID      Pointer to the SAS identification.
6927285809Sscottl*
6928285809Sscottl*  \Return:
6929285809Sscottl*           Pointer to the device data
6930285809Sscottl*
6931285809Sscottl*****************************************************************************/
6932285809SscottlosGLOBAL tdsaDeviceData_t *
6933285809SscottltdssNewAddSASToSharedcontext(
6934285809Sscottl                             agsaRoot_t           *agRoot,
6935285809Sscottl                             tdsaPortContext_t    *onePortContext,
6936285809Sscottl                             tdsaSASSubID_t       *agSASSubID,
6937285809Sscottl                             tdsaDeviceData_t     *oneExpDeviceData,
6938285809Sscottl                             bit8                 phyID
6939285809Sscottl                             )
6940285809Sscottl{
6941285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
6942285809Sscottl  tdList_t          *DeviceListList;
6943285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
6944285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
6945285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
6946285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
6947285809Sscottl  bit32             new_device = agTRUE;
6948285809Sscottl
6949285809Sscottl  TI_DBG3(("tdssNewAddSASToSharedcontext: start\n"));
6950285809Sscottl  /*
6951285809Sscottl    find a right portcontext
6952285809Sscottl    then, get devicedata from FreeLink in DeviceList
6953285809Sscottl    then, do pointer operations
6954285809Sscottl    then, add the devicedata to the portcontext
6955285809Sscottl  */
6956285809Sscottl
6957285809Sscottl
6958285809Sscottl  TI_DBG3(("tdssNewAddSASToSharedcontext: oneportContext ID %d\n", onePortContext->id));
6959285809Sscottl  /* find a device's existence */
6960285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
6961285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
6962285809Sscottl  {
6963285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
6964285809Sscottl    if (oneDeviceData == agNULL)
6965285809Sscottl    {
6966285809Sscottl      TI_DBG1(("tdssNewAddSASToSharedcontext: oneDeviceData is NULL!!!\n"));
6967285809Sscottl      return agNULL;
6968285809Sscottl    }
6969285809Sscottl    if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
6970285809Sscottl        (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
6971285809Sscottl        (oneDeviceData->tdPortContext == onePortContext)
6972285809Sscottl        )
6973285809Sscottl    {
6974285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: pid %d did %d\n", onePortContext->id, oneDeviceData->id));
6975285809Sscottl      new_device = agFALSE;
6976285809Sscottl      break;
6977285809Sscottl    }
6978285809Sscottl    DeviceListList = DeviceListList->flink;
6979285809Sscottl  }
6980285809Sscottl
6981285809Sscottl  /* new device */
6982285809Sscottl  if (new_device == agTRUE)
6983285809Sscottl  {
6984285809Sscottl    TI_DBG3(("tdssNewAddSASToSharedcontext: new device\n"));
6985285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
6986285809Sscottl    if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
6987285809Sscottl    {
6988285809Sscottl      tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6989285809Sscottl      TI_DBG1(("tdssNewAddSASToSharedcontext: empty DeviceData FreeLink\n"));
6990285809Sscottl      return agNULL;
6991285809Sscottl    }
6992285809Sscottl
6993285809Sscottl    TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
6994285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
6995285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
6996285809Sscottl
6997285809Sscottl    TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
6998285809Sscottl
6999285809Sscottl    onePortContext->Count++;
7000285809Sscottl    oneDeviceData->agRoot = agRoot;
7001285809Sscottl    /* saving sas address */
7002285809Sscottl    oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
7003285809Sscottl    oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
7004285809Sscottl    oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
7005285809Sscottl    oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
7006285809Sscottl    oneDeviceData->tdPortContext = onePortContext;
7007285809Sscottl    /* handles both SAS target and STP-target, SATA-device */
7008285809Sscottl    if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
7009285809Sscottl    {
7010285809Sscottl      oneDeviceData->DeviceType = TD_SAS_DEVICE;
7011285809Sscottl    }
7012285809Sscottl    else
7013285809Sscottl    {
7014285809Sscottl      oneDeviceData->DeviceType = TD_SATA_DEVICE;
7015285809Sscottl    }
7016285809Sscottl
7017285809Sscottl    oneDeviceData->ExpDevice = oneExpDeviceData;
7018285809Sscottl    /* set phyID only when it has initial value of 0xFF */
7019285809Sscottl    if (oneDeviceData->phyID == 0xFF)
7020285809Sscottl    {
7021285809Sscottl      oneDeviceData->phyID = phyID;
7022285809Sscottl    }
7023285809Sscottl#ifdef FDS_DM
7024285809Sscottl    oneDeviceData->valid = agTRUE;
7025285809Sscottl#else
7026285809Sscottl
7027285809Sscottl    /* incremental discovery */
7028285809Sscottl    /* add device to incremental-related link. Report using this link
7029285809Sscottl       when incremental discovery is done */
7030285809Sscottl    if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
7031285809Sscottl    {
7032285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
7033285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7034285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7035285809Sscottl      oneDeviceData->valid2 = agTRUE;
7036285809Sscottl    }
7037285809Sscottl    else
7038285809Sscottl    {
7039285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
7040285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7041285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7042285809Sscottl      oneDeviceData->valid = agTRUE;
7043285809Sscottl    }
7044285809Sscottl#endif
7045285809Sscottl    /* add the devicedata to the portcontext */
7046285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7047285809Sscottl    TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
7048285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7049285809Sscottl    TI_DBG4(("tdssNewAddSASToSharedcontext: one case pid %d did %d \n", onePortContext->id, oneDeviceData->id));
7050285809Sscottl    TI_DBG4(("tdssNewAddSASToSharedcontext: new case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
7051285809Sscottl  }
7052285809Sscottl  else /* old device */
7053285809Sscottl  {
7054285809Sscottl    TI_DBG3(("tdssNewAddSASToSharedcontext: old device\n"));
7055285809Sscottl    TI_DBG3(("tdssNewAddSASToSharedcontext: oneDeviceData %p did %d\n", oneDeviceData, oneDeviceData->id));
7056285809Sscottl
7057285809Sscottl    oneDeviceData->agRoot = agRoot;
7058285809Sscottl    /* saving sas address */
7059285809Sscottl    oneDeviceData->SASAddressID.sasAddressLo = agSASSubID->sasAddressLo;
7060285809Sscottl    oneDeviceData->SASAddressID.sasAddressHi = agSASSubID->sasAddressHi;
7061285809Sscottl    oneDeviceData->initiator_ssp_stp_smp = agSASSubID->initiator_ssp_stp_smp;
7062285809Sscottl    oneDeviceData->target_ssp_stp_smp = agSASSubID->target_ssp_stp_smp;
7063285809Sscottl    oneDeviceData->tdPortContext = onePortContext;
7064285809Sscottl    /* handles both SAS target and STP-target, SATA-device */
7065285809Sscottl    if (!DEVICE_IS_SATA_DEVICE(oneDeviceData) && !DEVICE_IS_STP_TARGET(oneDeviceData))
7066285809Sscottl    {
7067285809Sscottl      oneDeviceData->DeviceType = TD_SAS_DEVICE;
7068285809Sscottl    }
7069285809Sscottl    else
7070285809Sscottl    {
7071285809Sscottl      oneDeviceData->DeviceType = TD_SATA_DEVICE;
7072285809Sscottl    }
7073285809Sscottl
7074285809Sscottl    oneDeviceData->ExpDevice = oneExpDeviceData;
7075285809Sscottl    /* set phyID only when it has initial value of 0xFF */
7076285809Sscottl    if (oneDeviceData->phyID == 0xFF)
7077285809Sscottl    {
7078285809Sscottl      oneDeviceData->phyID = phyID;
7079285809Sscottl    }
7080285809Sscottl
7081285809Sscottl#ifdef FDS_DM
7082285809Sscottl    oneDeviceData->valid = agTRUE;
7083285809Sscottl#else
7084285809Sscottl    if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_INCREMENTAL_START)
7085285809Sscottl    {
7086285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: incremental discovery\n"));
7087285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7088285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7089285809Sscottl      oneDeviceData->valid2 = agTRUE;
7090285809Sscottl    }
7091285809Sscottl    else
7092285809Sscottl    {
7093285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: full discovery\n"));
7094285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrHi 0x%08x \n", oneDeviceData->SASAddressID.sasAddressHi));
7095285809Sscottl      TI_DBG3(("tdssNewAddSASToSharedcontext: sasAddrLo 0x%08x \n", oneDeviceData->SASAddressID.sasAddressLo));
7096285809Sscottl      oneDeviceData->valid = agTRUE;
7097285809Sscottl    }
7098285809Sscottl#endif
7099285809Sscottl    TI_DBG4(("tdssNewAddSASToSharedcontext: old case pid %d did %d phyID %d\n", onePortContext->id, oneDeviceData->id, oneDeviceData->phyID));
7100285809Sscottl
7101285809Sscottl  }
7102285809Sscottl  return oneDeviceData;
7103285809Sscottl}
7104285809Sscottl
7105285809Sscottl/*****************************************************************************
7106285809Sscottl*! \brief tdsaFindRegNValid
7107285809Sscottl*
7108285809Sscottl*  Purpose:  This function finds a device which is registered and valid in
7109285809Sscottl*            the device list. Used only in incremental discovery.
7110285809Sscottl*
7111285809Sscottl*  \param   agRoot          Pointer to chip/driver Instance.
7112285809Sscottl*  \param   onePortContext  Pointer to the target port context
7113285809Sscottl*  \param   tdsaDeviceData  Pointer to a device list header
7114285809Sscottl*  \param   agSASSubID      Pointer to the SAS identification.
7115285809Sscottl*
7116285809Sscottl*  \Return:
7117285809Sscottl*           Pointer to the device data
7118285809Sscottl*
7119285809Sscottl*****************************************************************************/
7120285809SscottlosGLOBAL tdsaDeviceData_t *
7121285809SscottltdsaFindRegNValid(
7122285809Sscottl                  agsaRoot_t           *agRoot,
7123285809Sscottl                  tdsaPortContext_t    *onePortContext,
7124285809Sscottl                  tdsaSASSubID_t       *agSASSubID
7125285809Sscottl                  )
7126285809Sscottl{
7127285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
7128285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
7129285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7130285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7131285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
7132285809Sscottl  tdList_t          *DeviceListList;
7133285809Sscottl  bit32             found = agFALSE;
7134285809Sscottl
7135285809Sscottl  TI_DBG3(("tdsaFindRegNValid: start\n"));
7136285809Sscottl
7137285809Sscottl  /* find a device's existence */
7138285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
7139285809Sscottl  if (onePortContext->discovery.type == TDSA_DISCOVERY_OPTION_FULL_START)
7140285809Sscottl  {
7141285809Sscottl    TI_DBG3(("tdsaFindRegNValid: Full discovery\n"));
7142285809Sscottl    while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7143285809Sscottl    {
7144285809Sscottl      oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7145285809Sscottl      if (oneDeviceData == agNULL)
7146285809Sscottl      {
7147285809Sscottl        TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
7148285809Sscottl        return agNULL;
7149285809Sscottl      }
7150285809Sscottl      if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7151285809Sscottl          (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7152285809Sscottl          (oneDeviceData->registered == agTRUE) &&
7153285809Sscottl          (oneDeviceData->valid == agTRUE) &&
7154285809Sscottl          (oneDeviceData->tdPortContext == onePortContext)
7155285809Sscottl          )
7156285809Sscottl      {
7157285809Sscottl        TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7158285809Sscottl        TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7159285809Sscottl        TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7160285809Sscottl        found = agTRUE;
7161285809Sscottl        break;
7162285809Sscottl      }
7163285809Sscottl      DeviceListList = DeviceListList->flink;
7164285809Sscottl    }
7165285809Sscottl  }
7166285809Sscottl  else
7167285809Sscottl  {
7168285809Sscottl    /* incremental discovery */
7169285809Sscottl    TI_DBG3(("tdsaFindRegNValid: Incremental discovery\n"));
7170285809Sscottl    while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7171285809Sscottl    {
7172285809Sscottl      oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7173285809Sscottl      if (oneDeviceData == agNULL)
7174285809Sscottl      {
7175285809Sscottl        TI_DBG1(("tdsaFindRegNValid: oneDeviceData is NULL!!!\n"));
7176285809Sscottl        return agNULL;
7177285809Sscottl      }
7178285809Sscottl      if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7179285809Sscottl          (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7180285809Sscottl          (oneDeviceData->registered == agTRUE) &&
7181285809Sscottl          (oneDeviceData->valid2 == agTRUE) &&
7182285809Sscottl          (oneDeviceData->tdPortContext == onePortContext)
7183285809Sscottl          )
7184285809Sscottl      {
7185285809Sscottl        TI_DBG3(("tdsaFindRegNValid: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7186285809Sscottl        TI_DBG3(("tdsaFindRegNValid: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7187285809Sscottl        TI_DBG3(("tdsaFindRegNValid: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7188285809Sscottl        found = agTRUE;
7189285809Sscottl        break;
7190285809Sscottl      }
7191285809Sscottl      DeviceListList = DeviceListList->flink;
7192285809Sscottl    }
7193285809Sscottl  }
7194285809Sscottl
7195285809Sscottl
7196285809Sscottl
7197285809Sscottl  if (found == agFALSE)
7198285809Sscottl  {
7199285809Sscottl    TI_DBG3(("tdsaFindRegNValid: end returning NULL\n"));
7200285809Sscottl    return agNULL;
7201285809Sscottl  }
7202285809Sscottl  else
7203285809Sscottl  {
7204285809Sscottl    TI_DBG3(("tdsaFindRegNValid: end returning NOT NULL\n"));
7205285809Sscottl    return oneDeviceData;
7206285809Sscottl  }
7207285809Sscottl
7208285809Sscottl}
7209285809Sscottl
7210285809Sscottl//registered to LL or not
7211285809Sscottl/*****************************************************************************
7212285809Sscottl*! \brief tdssNewSASorNot
7213285809Sscottl*
7214285809Sscottl*  Purpose:  This function finds whether a device is registered or not
7215285809Sscottl*
7216285809Sscottl*  \param   agRoot          Pointer to chip/driver Instance.
7217285809Sscottl*  \param   onePortContext  Pointer to the target port context
7218285809Sscottl*  \param   agSASSubID      Pointer to the SAS identification.
7219285809Sscottl*
7220285809Sscottl*  \Return:
7221285809Sscottl*           agTRUE   Device is not registered (New device).
7222285809Sscottl*           agFALSE  Device is registered (Old device).
7223285809Sscottl*
7224285809Sscottl*****************************************************************************/
7225285809Sscottlbit32
7226285809SscottltdssNewSASorNot(
7227285809Sscottl                                 agsaRoot_t           *agRoot,
7228285809Sscottl                                 tdsaPortContext_t    *onePortContext,
7229285809Sscottl                                 tdsaSASSubID_t       *agSASSubID
7230285809Sscottl                                 )
7231285809Sscottl{
7232285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
7233285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
7234285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7235285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7236285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
7237285809Sscottl  tdList_t          *DeviceListList;
7238285809Sscottl  bit32             ret = agTRUE;
7239285809Sscottl
7240285809Sscottl  TI_DBG3(("tdssNewSASorNot: start\n"));
7241285809Sscottl
7242285809Sscottl  /* find a device's existence */
7243285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
7244285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7245285809Sscottl  {
7246285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7247285809Sscottl    if ((oneDeviceData->SASAddressID.sasAddressHi == agSASSubID->sasAddressHi) &&
7248285809Sscottl        (oneDeviceData->SASAddressID.sasAddressLo == agSASSubID->sasAddressLo) &&
7249285809Sscottl        (oneDeviceData->registered == agTRUE) &&
7250285809Sscottl        (oneDeviceData->tdPortContext == onePortContext)
7251285809Sscottl        )
7252285809Sscottl    {
7253285809Sscottl      TI_DBG3(("tdssNewSASorNot: Found pid %d did %d\n", onePortContext->id, oneDeviceData->id));
7254285809Sscottl      ret = agFALSE;
7255285809Sscottl      break;
7256285809Sscottl    }
7257285809Sscottl    DeviceListList = DeviceListList->flink;
7258285809Sscottl  }
7259285809Sscottl
7260285809Sscottl
7261285809Sscottl
7262285809Sscottl  TI_DBG3(("tdssNewSASorNot: end\n"));
7263285809Sscottl
7264285809Sscottl  return ret;
7265285809Sscottl}
7266285809Sscottl
7267285809Sscottl
7268285809Sscottl
7269285809Sscottl/*****************************************************************************
7270285809Sscottl*! \brief  tdssSASDiscoveringExpanderAlloc
7271285809Sscottl*
7272285809Sscottl*  Purpose:  This function allocates an expander from the pre-allocated memory
7273285809Sscottl*            pool.
7274285809Sscottl*
7275285809Sscottl*  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7276285809Sscottl*                   instance.
7277285809Sscottl*  \param   onePortContext: Pointer to the portal context instance.
7278285809Sscottl*  \param   oneDeviceData:  Pointer to the device data.
7279285809Sscottl*
7280285809Sscottl*  \return:
7281285809Sscottl*           Pointer to expander on success
7282285809Sscottl*           agNULL              on failure
7283285809Sscottl*
7284285809Sscottl*   \note:
7285285809Sscottl*
7286285809Sscottl*****************************************************************************/
7287285809SscottlosGLOBAL tdsaExpander_t *
7288285809SscottltdssSASDiscoveringExpanderAlloc(
7289285809Sscottl                                tiRoot_t                 *tiRoot,
7290285809Sscottl                                tdsaPortContext_t        *onePortContext,
7291285809Sscottl                                tdsaDeviceData_t         *oneDeviceData
7292285809Sscottl                                )
7293285809Sscottl{
7294285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7295285809Sscottl  tdsaContext_t     *tdsaAllShared   = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7296285809Sscottl  tdsaExpander_t    *oneExpander = agNULL;
7297285809Sscottl  tdList_t          *ExpanderList;
7298285809Sscottl
7299285809Sscottl  /*
7300285809Sscottl    move the expander from freeExpanderList
7301285809Sscottl    and ground the expander by TDLIST_DEQUEUE_THIS
7302285809Sscottl  */
7303285809Sscottl
7304285809Sscottl
7305285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAlloc: start\n"));
7306285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAlloc: did %d\n", oneDeviceData->id));
7307285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressHi 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi));
7308285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAlloc: sasAddressLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressLo));
7309285809Sscottl
7310285809Sscottl  if (onePortContext->valid == agFALSE)
7311285809Sscottl  {
7312285809Sscottl    TI_DBG1(("tdssSASDiscoveringExpanderAlloc: aborting discovery\n"));
7313285809Sscottl    tdsaSASDiscoverAbort(tiRoot, onePortContext);
7314285809Sscottl    return agNULL;
7315285809Sscottl  }
7316285809Sscottl
7317285809Sscottl  tdsaDumpAllFreeExp(tiRoot);
7318285809Sscottl
7319285809Sscottl  if (TDLIST_EMPTY(&(tdsaAllShared->freeExpanderList)))
7320285809Sscottl  {
7321285809Sscottl    TI_DBG1(("tdssSASDiscoveringExpanderAlloc: no free expanders\n"));
7322285809Sscottl    return agNULL;
7323285809Sscottl  }
7324285809Sscottl
7325285809Sscottl  tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7326285809Sscottl  TDLIST_DEQUEUE_FROM_HEAD(&ExpanderList, &(tdsaAllShared->freeExpanderList));
7327285809Sscottl  tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7328285809Sscottl  //  oneExpander = TDLIST_OBJECT_BASE(tdsaContext_t, freeExpanderList, ExpanderList);
7329285809Sscottl  oneExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7330285809Sscottl
7331285809Sscottl  if (oneExpander != agNULL)
7332285809Sscottl  {
7333285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderAlloc: expander id %d\n", oneExpander->id));
7334285809Sscottl
7335285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7336285809Sscottl    TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
7337285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7338285809Sscottl
7339285809Sscottl    oneExpander->tdDevice = oneDeviceData;
7340285809Sscottl    oneExpander->tdUpStreamExpander = agNULL;
7341285809Sscottl    oneExpander->tdCurrentDownStreamExpander = agNULL;
7342285809Sscottl    oneExpander->tdReturnginExpander = agNULL;
7343285809Sscottl    oneExpander->hasUpStreamDevice = agFALSE;
7344285809Sscottl    oneExpander->numOfUpStreamPhys = 0;
7345285809Sscottl    oneExpander->currentUpStreamPhyIndex = 0;
7346285809Sscottl    oneExpander->discoveringPhyId = 0;
7347285809Sscottl    oneExpander->underDiscovering = agFALSE;
7348285809Sscottl    osti_memset( &(oneExpander->currentIndex), 0, sizeof(oneExpander->currentIndex));
7349285809Sscottl
7350285809Sscottl    oneDeviceData->tdExpander = oneExpander;
7351285809Sscottl  }
7352285809Sscottl
7353285809Sscottl  return oneExpander;
7354285809Sscottl}
7355285809Sscottl
7356285809Sscottl/*****************************************************************************
7357285809Sscottl*! \brief  tdssSASDiscoveringExpanderAdd
7358285809Sscottl*
7359285809Sscottl*  Purpose:  This function adds an expander to the expander list.
7360285809Sscottl*
7361285809Sscottl*  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7362285809Sscottl*                   instance.
7363285809Sscottl*  \param   onePortContext: Pointer to the portal context instance.
7364285809Sscottl*  \param   oneExpander: Pointer to the expander data.
7365285809Sscottl*
7366285809Sscottl*  \return:
7367285809Sscottl*           None
7368285809Sscottl*
7369285809Sscottl*   \note:
7370285809Sscottl*
7371285809Sscottl*****************************************************************************/
7372285809SscottlosGLOBAL void
7373285809SscottltdssSASDiscoveringExpanderAdd(
7374285809Sscottl                              tiRoot_t                 *tiRoot,
7375285809Sscottl                              tdsaPortContext_t        *onePortContext,
7376285809Sscottl                              tdsaExpander_t           *oneExpander
7377285809Sscottl                              )
7378285809Sscottl{
7379285809Sscottl#ifdef TD_INTERNAL_DEBUG
7380285809Sscottl  tdList_t          *ExpanderList;
7381285809Sscottl  tdsaExpander_t    *tempExpander;
7382285809Sscottl#endif
7383285809Sscottl
7384285809Sscottl  /* move the expander to discoveringExpanderList */
7385285809Sscottl
7386285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAdd: start\n"));
7387285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", oneExpander->id));
7388285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7389285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAdd: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7390285809Sscottl
7391285809Sscottl  if (onePortContext->valid == agFALSE)
7392285809Sscottl  {
7393285809Sscottl    TI_DBG1(("tdssSASDiscoveringExpanderAdd: aborting discovery\n"));
7394285809Sscottl    tdsaSASDiscoverAbort(tiRoot, onePortContext);
7395285809Sscottl    return;
7396285809Sscottl  }
7397285809Sscottl
7398285809Sscottl
7399285809Sscottl  if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
7400285809Sscottl  {
7401285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderAdd: UPSTREAM\n"));
7402285809Sscottl  }
7403285809Sscottl  else if (onePortContext->discovery.status == DISCOVERY_DOWN_STREAM)
7404285809Sscottl  {
7405285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderAdd: DOWNSTREAM\n"));
7406285809Sscottl  }
7407285809Sscottl  else
7408285809Sscottl  {
7409285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderAdd: status %d\n", onePortContext->discovery.status));
7410285809Sscottl  }
7411285809Sscottl
7412285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAdd: BEFORE\n"));
7413285809Sscottl  tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7414285809Sscottl
7415285809Sscottl
7416285809Sscottl  if ( oneExpander->underDiscovering == agFALSE)
7417285809Sscottl  {
7418285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderAdd: ADDED \n"));
7419285809Sscottl
7420285809Sscottl    oneExpander->underDiscovering = agTRUE;
7421285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7422285809Sscottl    TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(onePortContext->discovery.discoveringExpanderList));
7423285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7424285809Sscottl  }
7425285809Sscottl
7426285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderAdd: AFTER\n"));
7427285809Sscottl  tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7428285809Sscottl
7429285809Sscottl#ifdef TD_INTERNAL_DEBUG
7430285809Sscottl  /* debugging */
7431285809Sscottl  if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7432285809Sscottl  {
7433285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderAdd: empty discoveringExpanderList\n"));
7434285809Sscottl    return;
7435285809Sscottl  }
7436285809Sscottl  ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7437285809Sscottl  while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7438285809Sscottl  {
7439285809Sscottl    tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7440285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderAdd: expander id %d\n", tempExpander->id));
7441285809Sscottl    ExpanderList = ExpanderList->flink;
7442285809Sscottl  }
7443285809Sscottl#endif
7444285809Sscottl
7445285809Sscottl  return;
7446285809Sscottl}
7447285809Sscottl
7448285809Sscottl/* temp */
7449285809SscottlosGLOBAL bit32
7450285809SscottltdssSASFindDiscoveringExpander(
7451285809Sscottl               tiRoot_t                 *tiRoot,
7452285809Sscottl               tdsaPortContext_t        *onePortContext,
7453285809Sscottl               tdsaExpander_t           *oneExpander
7454285809Sscottl              )
7455285809Sscottl{
7456285809Sscottl  tdList_t          *ExpanderList;
7457285809Sscottl  tdsaExpander_t    *tempExpander;
7458285809Sscottl  tdsaPortContext_t *tmpOnePortContext = onePortContext;
7459285809Sscottl  bit32             ret = agFALSE;
7460285809Sscottl
7461285809Sscottl  TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7462285809Sscottl  TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7463285809Sscottl
7464285809Sscottl  if (TDLIST_EMPTY(&(tmpOnePortContext->discovery.discoveringExpanderList)))
7465285809Sscottl  {
7466285809Sscottl    TI_DBG1(("tdssSASFindDiscoveringExpander: empty discoveringExpanderList\n"));
7467285809Sscottl    return ret;
7468285809Sscottl  }
7469285809Sscottl  ExpanderList = tmpOnePortContext->discovery.discoveringExpanderList.flink;
7470285809Sscottl  while (ExpanderList != &(tmpOnePortContext->discovery.discoveringExpanderList))
7471285809Sscottl  {
7472285809Sscottl    tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7473285809Sscottl    if (tempExpander == oneExpander)
7474285809Sscottl    {
7475285809Sscottl      TI_DBG3(("tdssSASFindDiscoveringExpander: match!!! expander id %d\n", tempExpander->id));
7476285809Sscottl      TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrHi 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressHi));
7477285809Sscottl      TI_DBG3(("tdssSASFindDiscoveringExpander: exp addrLo 0x%08x\n", tempExpander->tdDevice->SASAddressID.sasAddressLo));
7478285809Sscottl      ret = agTRUE;
7479285809Sscottl      break;
7480285809Sscottl    }
7481285809Sscottl
7482285809Sscottl    ExpanderList = ExpanderList->flink;
7483285809Sscottl  }
7484285809Sscottl
7485285809Sscottl
7486285809Sscottl  return ret;
7487285809Sscottl
7488285809Sscottl}
7489285809Sscottl/* to be tested */
7490285809Sscottl/* move the expander to freeExpanderList */
7491285809Sscottl/*****************************************************************************
7492285809Sscottl*! \brief  tdssSASDiscoveringExpanderRemove
7493285809Sscottl*
7494285809Sscottl*  Purpose:  This function removes an expander from the expander list.
7495285809Sscottl*
7496285809Sscottl*  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7497285809Sscottl*                   instance.
7498285809Sscottl*  \param   onePortContext: Pointer to the portal context instance.
7499285809Sscottl*  \param   oneExpander: Pointer to the expander data.
7500285809Sscottl*
7501285809Sscottl*  \return:
7502285809Sscottl*           None
7503285809Sscottl*
7504285809Sscottl*   \note:
7505285809Sscottl*
7506285809Sscottl*****************************************************************************/
7507285809SscottlosGLOBAL void
7508285809SscottltdssSASDiscoveringExpanderRemove(
7509285809Sscottl                                 tiRoot_t                 *tiRoot,
7510285809Sscottl                                 tdsaPortContext_t        *onePortContext,
7511285809Sscottl                                 tdsaExpander_t           *oneExpander
7512285809Sscottl                                 )
7513285809Sscottl{
7514285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7515285809Sscottl  tdsaContext_t     *tdsaAllShared   = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7516285809Sscottl#ifdef TD_INTERNAL_DEBUG
7517285809Sscottl  tdList_t          *ExpanderList;
7518285809Sscottl  tdsaExpander_t    *tempExpander;
7519285809Sscottl#endif
7520285809Sscottl
7521285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: start\n"));
7522285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", oneExpander->id));
7523285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrHi 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressHi));
7524285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: exp addrLo 0x%08x\n", oneExpander->tdDevice->SASAddressID.sasAddressLo));
7525285809Sscottl
7526285809Sscottl
7527285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
7528285809Sscottl  tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7529285809Sscottl  tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
7530285809Sscottl  tdsaDumpAllFreeExp(tiRoot);
7531285809Sscottl
7532285809Sscottl#ifdef TD_INTERNAL_DEBUG
7533285809Sscottl  /* debugging */
7534285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: BEFORE\n"));
7535285809Sscottl  if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7536285809Sscottl  {
7537285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
7538285809Sscottl  }
7539285809Sscottl  ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7540285809Sscottl  while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7541285809Sscottl  {
7542285809Sscottl    tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7543285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
7544285809Sscottl    ExpanderList = ExpanderList->flink;
7545285809Sscottl  }
7546285809Sscottl#endif
7547285809Sscottl
7548285809Sscottl  // if is temporary till smp problem is fixed
7549285809Sscottl  if (tdssSASFindDiscoveringExpander(tiRoot, onePortContext, oneExpander) == agTRUE)
7550285809Sscottl  {
7551285809Sscottl    oneExpander->underDiscovering = agFALSE;
7552285809Sscottl    oneExpander->discoveringPhyId = 0;
7553285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DISC_LOCK);
7554285809Sscottl    TDLIST_DEQUEUE_THIS(&(oneExpander->linkNode));
7555285809Sscottl
7556285809Sscottl    if (onePortContext->discovery.status == DISCOVERY_UP_STREAM)
7557285809Sscottl    {
7558285809Sscottl      TI_DBG3(("tdssSASDiscoveringExpanderRemove: DISCOVERY_UP_STREAM\n"));
7559285809Sscottl      TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->upNode), &(onePortContext->discovery.UpdiscoveringExpanderList));
7560285809Sscottl      onePortContext->discovery.NumOfUpExp++;
7561285809Sscottl    }
7562285809Sscottl    else
7563285809Sscottl    {
7564285809Sscottl      TI_DBG3(("tdssSASDiscoveringExpanderRemove: Status %d\n", onePortContext->discovery.status));
7565285809Sscottl      TDLIST_ENQUEUE_AT_TAIL(&(oneExpander->linkNode), &(tdsaAllShared->freeExpanderList));
7566285809Sscottl    }
7567285809Sscottl
7568285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DISC_LOCK);
7569285809Sscottl  } //end temp if
7570285809Sscottl  else
7571285809Sscottl  {
7572285809Sscottl    TI_DBG1(("tdssSASDiscoveringExpanderRemove: !!! problem !!!\n"));
7573285809Sscottl  }
7574285809Sscottl
7575285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
7576285809Sscottl  tdsaDumpAllExp(tiRoot, onePortContext, oneExpander);
7577285809Sscottl  tdsaDumpAllUpExp(tiRoot, onePortContext, oneExpander);
7578285809Sscottl
7579285809Sscottl  tdsaDumpAllFreeExp(tiRoot);
7580285809Sscottl
7581285809Sscottl#ifdef TD_INTERNAL_DEBUG
7582285809Sscottl  /* debugging */
7583285809Sscottl  TI_DBG3(("tdssSASDiscoveringExpanderRemove: AFTER\n"));
7584285809Sscottl  if (TDLIST_EMPTY(&(onePortContext->discovery.discoveringExpanderList)))
7585285809Sscottl  {
7586285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderRemove: empty discoveringExpanderList\n"));
7587285809Sscottl  }
7588285809Sscottl  ExpanderList = onePortContext->discovery.discoveringExpanderList.flink;
7589285809Sscottl  while (ExpanderList != &(onePortContext->discovery.discoveringExpanderList))
7590285809Sscottl  {
7591285809Sscottl    tempExpander = TDLIST_OBJECT_BASE(tdsaExpander_t, linkNode, ExpanderList);
7592285809Sscottl    TI_DBG3(("tdssSASDiscoveringExpanderRemove: expander id %d\n", tempExpander->id));
7593285809Sscottl    ExpanderList = ExpanderList->flink;
7594285809Sscottl  }
7595285809Sscottl#endif
7596285809Sscottl
7597285809Sscottl  return;
7598285809Sscottl}
7599285809Sscottl
7600285809Sscottl#ifdef SATA_ENABLE
7601285809Sscottl
7602285809Sscottl/*****************************************************************************
7603285809Sscottl*! \brief tdssNewAddSATAToSharedcontext
7604285809Sscottl*
7605285809Sscottl*  Purpose:  This function adds a discovered SATA device to a device list of
7606285809Sscottl*            a shared context. Used only in discovery.
7607285809Sscottl*
7608285809Sscottl*  \param   tiRoot  Pointer to the OS Specific module allocated tiRoot_t
7609285809Sscottl*                   instance.
7610285809Sscottl*  \param   agRoot          Pointer to chip/driver Instance.
7611285809Sscottl*  \param   onePortContext  Pointer to the target port context
7612285809Sscottl*  \param   tdsaDeviceData  Pointer to a device list header
7613285809Sscottl*  \param   agSATADeviceInfo      Pointer to the SATA device information.
7614285809Sscottl*  \param   Signature       Pointer to SATA signature
7615285809Sscottl*  \param   pm              Port multiplier
7616285809Sscottl*  \param   pmField         Port multiplier field
7617285809Sscottl*  \param   connectionRate  Connection rate
7618285809Sscottl*
7619285809Sscottl*  \Return:
7620285809Sscottl*           Pointer to the device data
7621285809Sscottl*
7622285809Sscottl*****************************************************************************/
7623285809SscottlosGLOBAL tdsaDeviceData_t *
7624285809SscottltdssNewAddSATAToSharedcontext(tiRoot_t             *tiRoot,
7625285809Sscottl                              agsaRoot_t           *agRoot,
7626285809Sscottl                              tdsaPortContext_t    *onePortContext,
7627285809Sscottl                              agsaSATADeviceInfo_t *agSATADeviceInfo,
7628285809Sscottl                              bit8                    *Signature,
7629285809Sscottl                              bit8                    pm,
7630285809Sscottl                              bit8                    pmField,
7631285809Sscottl                              bit32                   connectionRate,
7632285809Sscottl                              tdsaDeviceData_t        *oneExpDeviceData,
7633285809Sscottl                              bit8                    phyID
7634285809Sscottl                              )
7635285809Sscottl{
7636285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
7637285809Sscottl  tdList_t          *DeviceListList;
7638285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7639285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7640285809Sscottl  int               new_device = agTRUE;
7641285809Sscottl
7642285809Sscottl  TI_DBG5(("tdssNewAddSATAToSharedcontext: start\n"));
7643285809Sscottl
7644285809Sscottl
7645285809Sscottl
7646285809Sscottl  TI_DBG5(("tdssNewAddSATAToSharedcontext: oneportContext ID %d\n", onePortContext->id));
7647285809Sscottl
7648285809Sscottl
7649285809Sscottl#ifdef RPM_SOC
7650285809Sscottl  /* Find a device's existence */
7651285809Sscottl  DeviceListList = tdsaAllShared->MainDeviceList.flink;
7652285809Sscottl  while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7653285809Sscottl  {
7654285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7655285809Sscottl
7656285809Sscottl    if ((osti_memcmp (((char *)&oneDeviceData->satDevData.satIdentifyData),
7657285809Sscottl                      ((char *)&agSATADeviceInfo->sataIdentifyData),
7658285809Sscottl                      sizeof(agsaSATAIdentifyData_t)) == 0))
7659285809Sscottl    {
7660285809Sscottl      TI_DBG5(("tdssNewAddSATAToSharedcontext: pid %d did %d\n",
7661285809Sscottl        onePortContext->id, oneDeviceData->id));
7662285809Sscottl      new_device = agFALSE;
7663285809Sscottl      break;
7664285809Sscottl    }
7665285809Sscottl    DeviceListList = DeviceListList->flink;
7666285809Sscottl  }
7667285809Sscottl#else
7668285809Sscottl
7669285809Sscottl
7670285809Sscottl#endif
7671285809Sscottl
7672285809Sscottl  /* New device */
7673285809Sscottl  if (new_device == agTRUE)
7674285809Sscottl  {
7675285809Sscottl    TI_DBG5(("tdssNewAddSATAToSharedcontext: new device\n"));
7676285809Sscottl
7677285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7678285809Sscottl    if (!TDLIST_NOT_EMPTY(&(tdsaAllShared->FreeDeviceList)))
7679285809Sscottl    {
7680285809Sscottl      tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7681285809Sscottl      TI_DBG1(("tdssNewAddSATAToSharedcontext: ERROR empty DeviceData FreeLink\n"));
7682285809Sscottl      return oneDeviceData;
7683285809Sscottl    }
7684285809Sscottl
7685285809Sscottl    TDLIST_DEQUEUE_FROM_HEAD(&DeviceListList, &(tdsaAllShared->FreeDeviceList));
7686285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7687285809Sscottl    oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, FreeLink, DeviceListList);
7688285809Sscottl
7689285809Sscottl    onePortContext->Count++;
7690285809Sscottl    oneDeviceData->DeviceType = TD_SATA_DEVICE;
7691285809Sscottl    oneDeviceData->agRoot = agRoot;
7692285809Sscottl    TI_DBG5(("tdssNewAddSATAToSharedcontext: oneDeviceData %p\n", oneDeviceData));
7693285809Sscottl    TI_DBG5(("tdssNewAddSATAToSharedcontext: pSatDevData=%p\n", &oneDeviceData->satDevData));
7694285809Sscottl
7695285809Sscottl
7696285809Sscottl    /* saving PortMultiplier(PM) field */
7697285809Sscottl    oneDeviceData->satDevData.satPMField = pmField;
7698285809Sscottl
7699285809Sscottl    /* saving signature */
7700285809Sscottl    osti_memcpy(&(oneDeviceData->satDevData.satSignature), Signature, 8);
7701285809Sscottl
7702285809Sscottl    /*
7703285809Sscottl      saving device type
7704285809Sscottl      ATA device type; here should be either ATA_ATA_DEVICE or ATA_ATAPI_DEVICE
7705285809Sscottl    */
7706285809Sscottl     oneDeviceData->satDevData.satDeviceType = tdssSATADeviceTypeDecode(agSATADeviceInfo->signature);
7707285809Sscottl     TI_DBG3(("tdssNewAddSATAToSharedcontext: device type %d\n",  oneDeviceData->satDevData.satDeviceType));
7708285809Sscottl
7709285809Sscottl#ifdef RPM_SOC_REMOVED
7710285809Sscottl    /* print device signature - Word8 */
7711285809Sscottl    TI_DBG3(("tdssNewAddSATAToSharedcontext: Word8 %x signature: %x %x %x %x %x %x %x %x\n",
7712285809Sscottl             agSATADeviceInfo->sataIdentifyData.word1_9[7],
7713285809Sscottl             agSATADeviceInfo->signature[0], agSATADeviceInfo->signature[1],
7714285809Sscottl             agSATADeviceInfo->signature[2], agSATADeviceInfo->signature[3],
7715285809Sscottl             agSATADeviceInfo->signature[4], agSATADeviceInfo->signature[5],
7716285809Sscottl             agSATADeviceInfo->signature[6], agSATADeviceInfo->signature[7] ));
7717285809Sscottl#endif
7718285809Sscottl
7719285809Sscottl
7720285809Sscottl
7721285809Sscottl    oneDeviceData->tdPortContext = onePortContext;
7722285809Sscottl    oneDeviceData->valid = agTRUE;
7723285809Sscottl
7724285809Sscottl    oneDeviceData->ExpDevice = oneExpDeviceData;
7725285809Sscottl    oneDeviceData->phyID = phyID;
7726285809Sscottl
7727285809Sscottl    /* Add the devicedata to the portcontext */
7728285809Sscottl    tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7729285809Sscottl    TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->MainLink), &(tdsaAllShared->MainDeviceList));
7730285809Sscottl    tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7731285809Sscottl    TI_DBG5(("tdssNewAddSATAToSharedcontext: one case pid %d did %d \n",
7732285809Sscottl      onePortContext->id, oneDeviceData->id));
7733285809Sscottl  }
7734285809Sscottl  else /* old device */
7735285809Sscottl  {
7736285809Sscottl    TI_DBG5(("tdssNewAddSATAToSharedcontext: old device\n"));
7737285809Sscottl
7738285809Sscottl    onePortContext->Count++;
7739285809Sscottl
7740285809Sscottl    oneDeviceData->DeviceType = TD_SATA_DEVICE;
7741285809Sscottl    oneDeviceData->agRoot = agRoot;
7742285809Sscottl
7743285809Sscottl    oneDeviceData->tdPortContext = onePortContext;
7744285809Sscottl    oneDeviceData->valid = agTRUE;
7745285809Sscottl
7746285809Sscottl    oneDeviceData->ExpDevice = oneExpDeviceData;
7747285809Sscottl    oneDeviceData->phyID = phyID;
7748285809Sscottl
7749285809Sscottl  }
7750285809Sscottl
7751285809Sscottl  return oneDeviceData;
7752285809Sscottl
7753285809Sscottl}
7754285809Sscottl#endif /* SATA_ENABLE */
7755285809Sscottl#endif /* TD_DISCOVER */
7756285809Sscottl#endif /* INITIATOR_DRIVER */
7757285809Sscottl
7758285809Sscottl#ifdef TARGET_DRIVER
7759285809Sscottl/*****************************************************************************
7760285809Sscottl*! \brief  tdssReportRemovals
7761285809Sscottl*
7762285809Sscottl*  Purpose:  This function goes through device list and removes all devices
7763285809Sscottl*            belong to the portcontext. This function also deregiters those
7764285809Sscottl*            devices. This function is called in case of incremental discovery
7765285809Sscottl*            failure.
7766285809Sscottl*
7767285809Sscottl*  \param   agRoot        :  Pointer to chip/driver Instance.
7768285809Sscottl*  \param   onePortContext: Pointer to the portal context instance.
7769285809Sscottl*  \param   oneDeviceData: Pointer to the device data.
7770285809Sscottl*
7771285809Sscottl*  \return:
7772285809Sscottl*           None
7773285809Sscottl*
7774285809Sscottl*   \note:
7775285809Sscottl*
7776285809Sscottl*****************************************************************************/
7777285809SscottlosGLOBAL void
7778285809SscottlttdssReportRemovals(
7779285809Sscottl                  agsaRoot_t           *agRoot,
7780285809Sscottl                  tdsaPortContext_t    *onePortContext,
7781285809Sscottl                  bit32                flag
7782285809Sscottl                  )
7783285809Sscottl{
7784285809Sscottl  tdsaDeviceData_t  *oneDeviceData = agNULL;
7785285809Sscottl  tdList_t          *DeviceListList;
7786285809Sscottl  tdsaRootOsData_t  *osData = (tdsaRootOsData_t *)agRoot->osData;
7787285809Sscottl  tiRoot_t          *tiRoot = (tiRoot_t *)osData->tiRoot;
7788285809Sscottl  tdsaRoot_t        *tdsaRoot        = (tdsaRoot_t *) tiRoot->tdData;
7789285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7790285809Sscottl  bit32             removed = agFALSE;
7791285809Sscottl  agsaEventSource_t *eventSource;
7792285809Sscottl  bit32             PhyID;
7793285809Sscottl  bit32             HwAckSatus;
7794285809Sscottl  tdsaDeviceData_t  *tmpDeviceData = agNULL;
7795285809Sscottl
7796285809Sscottl  TI_DBG1(("ttdssReportRemovals: start\n"));
7797285809Sscottl  /* in case nothing was registered */
7798285809Sscottl  PhyID = onePortContext->eventPhyID;
7799285809Sscottl  if (tdsaAllShared->eventSource[PhyID].EventValid == agTRUE &&
7800285809Sscottl      onePortContext->RegisteredDevNums == 0 &&
7801285809Sscottl      PhyID != 0xFF
7802285809Sscottl      )
7803285809Sscottl  {
7804285809Sscottl    TI_DBG1(("ttdssReportRemovals: calling saHwEventAck\n"));
7805285809Sscottl    eventSource = &(tdsaAllShared->eventSource[PhyID].Source);
7806285809Sscottl    HwAckSatus = saHwEventAck(
7807285809Sscottl                              agRoot,
7808285809Sscottl                              agNULL, /* agContext */
7809285809Sscottl                              0,
7810285809Sscottl                              eventSource, /* agsaEventSource_t */
7811285809Sscottl                              0,
7812285809Sscottl                              0
7813285809Sscottl                              );
7814285809Sscottl    if ( HwAckSatus != AGSA_RC_SUCCESS)
7815285809Sscottl    {
7816285809Sscottl      TI_DBG1(("ttdssReportRemovals: failing in saHwEventAck; status %d\n", HwAckSatus));
7817285809Sscottl    }
7818285809Sscottl
7819285809Sscottl    /* toggle */
7820285809Sscottl    tdsaAllShared->eventSource[PhyID].EventValid = agFALSE;
7821285809Sscottl    if (onePortContext->valid == agFALSE)
7822285809Sscottl    {
7823285809Sscottl      tdsaPortContextReInit(tiRoot, onePortContext);
7824285809Sscottl      /*
7825285809Sscottl        put all devices belonging to the onePortContext
7826285809Sscottl        back to the free link
7827285809Sscottl       */
7828285809Sscottl      tdsaSingleThreadedEnter(tiRoot, TD_PORT_LOCK);
7829285809Sscottl      TDLIST_DEQUEUE_THIS(&(onePortContext->MainLink));
7830285809Sscottl      TDLIST_ENQUEUE_AT_TAIL(&(onePortContext->FreeLink), &(tdsaAllShared->FreePortContextList));
7831285809Sscottl      tdsaSingleThreadedLeave(tiRoot, TD_PORT_LOCK);
7832285809Sscottl    }
7833285809Sscottl  }
7834285809Sscottl  else
7835285809Sscottl  {
7836285809Sscottl    if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
7837285809Sscottl    {
7838285809Sscottl      TI_DBG1(("ttdssReportRemovals: empty device list\n"));
7839285809Sscottl      return;
7840285809Sscottl    }
7841285809Sscottl
7842285809Sscottl    DeviceListList = tdsaAllShared->MainDeviceList.flink;
7843285809Sscottl    while (DeviceListList != &(tdsaAllShared->MainDeviceList))
7844285809Sscottl    {
7845285809Sscottl      oneDeviceData = TDLIST_OBJECT_BASE(tdsaDeviceData_t, MainLink, DeviceListList);
7846285809Sscottl      if( oneDeviceData == agNULL )
7847285809Sscottl      {
7848285809Sscottl        break;
7849285809Sscottl      }
7850285809Sscottl      TI_DBG1(("ttdssReportRemovals: loop did %d\n", oneDeviceData->id));
7851285809Sscottl      TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
7852285809Sscottl      TI_DBG1(("ttdssReportRemovals: valid %d valid2 %d\n", oneDeviceData->valid, oneDeviceData->valid2));
7853285809Sscottl      TI_DBG1(("ttdssReportRemovals: directlyAttached %d registered %d\n", oneDeviceData->directlyAttached, oneDeviceData->registered));
7854285809Sscottl      if ( oneDeviceData->tdPortContext == onePortContext)
7855285809Sscottl      {
7856285809Sscottl        TI_DBG1(("ttdssReportRemovals: right portcontext pid %d\n", onePortContext->id));
7857285809Sscottl        if (oneDeviceData->valid == agTRUE && oneDeviceData->registered == agTRUE)
7858285809Sscottl        {
7859285809Sscottl          TI_DBG1(("ttdssReportRemovals: removing\n"));
7860285809Sscottl
7861285809Sscottl          /* notify only reported devices to OS layer*/
7862285809Sscottl          removed = agTRUE;
7863285809Sscottl
7864285809Sscottl          /* all targets except expanders */
7865285809Sscottl          TI_DBG1(("ttdssReportRemovals: calling tdsaAbortAll\n"));
7866285809Sscottl          TI_DBG1(("ttdssReportRemovals: did %d\n", oneDeviceData->id));
7867285809Sscottl          TI_DBG1(("ttdssReportRemovals: sasAddrHi 0x%08x sasAddrLo 0x%08x\n", oneDeviceData->SASAddressID.sasAddressHi, oneDeviceData->SASAddressID.sasAddressLo));
7868285809Sscottl          tmpDeviceData = oneDeviceData;
7869285809Sscottl          ttdsaAbortAll(tiRoot, agRoot, oneDeviceData);
7870285809Sscottl
7871285809Sscottl
7872285809Sscottl          /* reset valid bit */
7873285809Sscottl          oneDeviceData->valid = agFALSE;
7874285809Sscottl          oneDeviceData->valid2 = agFALSE;
7875285809Sscottl          oneDeviceData->registered = agFALSE;
7876285809Sscottl        }
7877285809Sscottl        /* called by port invalid case */
7878285809Sscottl        if (flag == agTRUE)
7879285809Sscottl        {
7880285809Sscottl          oneDeviceData->tdPortContext = agNULL;
7881285809Sscottl        }
7882285809Sscottl#ifdef REMOVED /* removed */
7883285809Sscottl        /* directly attached SATA -> always remove it */
7884285809Sscottl        if (oneDeviceData->DeviceType == TD_SATA_DEVICE &&
7885285809Sscottl            oneDeviceData->directlyAttached == agTRUE)
7886285809Sscottl        {
7887285809Sscottl          TI_DBG1(("ttdssReportRemovals: device did %d\n", oneDeviceData->id));
7888285809Sscottl          tdsaSingleThreadedEnter(tiRoot, TD_DEVICE_LOCK);
7889285809Sscottl          TDLIST_DEQUEUE_THIS(&(oneDeviceData->MainLink));
7890285809Sscottl          TDLIST_ENQUEUE_AT_TAIL(&(oneDeviceData->FreeLink), &(tdsaAllShared->FreeDeviceLis));
7891285809Sscottl          DeviceListList = tdsaAllShared->MainDeviceList.flink;
7892285809Sscottl          if (TDLIST_EMPTY(&(tdsaAllShared->MainDeviceList)))
7893285809Sscottl          {
7894285809Sscottl            tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7895285809Sscottl            break;
7896285809Sscottl          }
7897285809Sscottl          else
7898285809Sscottl          {
7899285809Sscottl            tdsaSingleThreadedLeave(tiRoot, TD_DEVICE_LOCK);
7900285809Sscottl          }
7901285809Sscottl        }
7902285809Sscottl        else
7903285809Sscottl        {
7904285809Sscottl          DeviceListList = DeviceListList->flink;
7905285809Sscottl        }
7906285809Sscottl#endif /* REMOVED */
7907285809Sscottl        DeviceListList = DeviceListList->flink;
7908285809Sscottl      }
7909285809Sscottl      else
7910285809Sscottl      {
7911285809Sscottl        if (oneDeviceData->tdPortContext != agNULL)
7912285809Sscottl        {
7913285809Sscottl          TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid %d oneportcontext pid %d\n", oneDeviceData->tdPortContext->id, onePortContext->id));
7914285809Sscottl        }
7915285809Sscottl        else
7916285809Sscottl        {
7917285809Sscottl          TI_DBG1(("ttdssReportRemovals: different portcontext; oneDeviceData->tdPortContext pid NULL oneportcontext pid %d\n", onePortContext->id));
7918285809Sscottl        }
7919285809Sscottl        DeviceListList = DeviceListList->flink;
7920285809Sscottl      }
7921285809Sscottl    }
7922285809Sscottl
7923285809Sscottl    if (removed == agTRUE)
7924285809Sscottl    {
7925285809Sscottl      TI_DBG1(("ttdssReportRemovals: removed at the end\n"));
7926285809Sscottl      ostiTargetEvent(
7927285809Sscottl                      tiRoot,
7928285809Sscottl                      onePortContext->tiPortalContext,
7929285809Sscottl                      &(tmpDeviceData->tiDeviceHandle),
7930285809Sscottl                      tiTgtEventTypeDeviceChange,
7931285809Sscottl                      tiDeviceRemoval,
7932285809Sscottl                      agNULL
7933285809Sscottl                      );
7934285809Sscottl    }
7935285809Sscottl  } /* big else */
7936285809Sscottl  return;
7937285809Sscottl}
7938285809Sscottl#endif /* TARGET_DRIVER */
7939285809Sscottl
7940285809Sscottl
7941285809Sscottl/*****************************************************************************
7942285809Sscottl*! \brief  tdsaRotateQnumber
7943285809Sscottl*
7944285809Sscottl*  Purpose:  This function generates inbound queue number.
7945285809Sscottl*
7946285809Sscottl*  \param   tiRoot: Pointer to the OS Specific module allocated tiRoot_t
7947285809Sscottl*                   instance.
7948285809Sscottl*
7949285809Sscottl*  \return:
7950285809Sscottl*           Queue number
7951285809Sscottl*
7952285809Sscottl*   \note:
7953285809Sscottl*
7954285809Sscottl*****************************************************************************/
7955285809SscottlFORCEINLINE bit32
7956285809SscottltdsaRotateQnumber(tiRoot_t                *tiRoot,
7957285809Sscottl                  tdsaDeviceData_t        *oneDeviceData )
7958285809Sscottl{
7959285809Sscottl  bit32             ret = 0;
7960285809Sscottl
7961285809Sscottl  TI_DBG6(("tdsaRotateQnumber: start\n"));
7962285809Sscottl  if (oneDeviceData == agNULL)
7963285809Sscottl  {
7964285809Sscottl    return 0;
7965285809Sscottl  }
7966285809Sscottl  ret = (oneDeviceData->OutQID << 16) | oneDeviceData->InQID;
7967285809Sscottl  return ret;
7968285809Sscottl}
7969285809Sscottl
7970285809SscottlosGLOBAL bit32
7971285809SscottltdsaRotateQnumber1(tiRoot_t                *tiRoot,
7972285809Sscottl                  tdsaDeviceData_t        *oneDeviceData )
7973285809Sscottl{
7974285809Sscottl  tdsaRoot_t        *tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
7975285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7976285809Sscottl//  static int Last_Q;
7977285809Sscottl//  bit32             denom = tdsaAllShared->QueueConfig.numOutboundQueues;
7978285809Sscottl  bit32             ret = 0;
7979285809Sscottl  if (oneDeviceData == agNULL)
7980285809Sscottl  {
7981285809Sscottl//    Last_Q= 0;
7982285809Sscottl    return 0;
7983285809Sscottl  }
7984285809Sscottl
7985285809Sscottl/* alway use highest Q number */
7986285809Sscottl  ret = ((tdsaAllShared->QueueConfig.numOutboundQueues-1) << 16) | (tdsaAllShared->QueueConfig.numInboundQueues-1);
7987285809Sscottl
7988285809Sscottl  return(ret);
7989285809Sscottl}
7990285809Sscottl
7991285809Sscottl#ifdef REMOVED
7992285809SscottlosGLOBAL bit32
7993285809SscottltdsaRotateQnumber(tiRoot_t                *tiRoot,
7994285809Sscottl                  tdsaDeviceData_t        *oneDeviceData )
7995285809Sscottl{
7996285809Sscottl  tdsaRoot_t        *tdsaRoot      = (tdsaRoot_t *) tiRoot->tdData;
7997285809Sscottl  tdsaContext_t     *tdsaAllShared = (tdsaContext_t *)&tdsaRoot->tdsaAllShared;
7998285809Sscottl  bit32             denom = tdsaAllShared->QueueConfig.numInboundQueues;
7999285809Sscottl  bit32             ret = 0;
8000285809Sscottl
8001285809Sscottl  /* inbound queue number */
8002285809Sscottl  tdsaAllShared->IBQnumber++;
8003285809Sscottl  if (tdsaAllShared->IBQnumber % denom == 0) /* % Qnumber*/
8004285809Sscottl  {
8005285809Sscottl    tdsaAllShared->IBQnumber = 0;
8006285809Sscottl  }
8007285809Sscottl  TI_DBG6(("tdsaRotateQnumber: IBQnumber %d\n", tdsaAllShared->IBQnumber));
8008285809Sscottl
8009285809Sscottl
8010285809Sscottl  /* outbound queue number */
8011285809Sscottl  tdsaAllShared->OBQnumber++;
8012285809Sscottl  denom = tdsaAllShared->QueueConfig.numOutboundQueues;
8013285809Sscottl  if (tdsaAllShared->OBQnumber % denom == 0) /* % Qnumber*/
8014285809Sscottl  {
8015285809Sscottl    tdsaAllShared->OBQnumber = 0;
8016285809Sscottl  }
8017285809Sscottl  TI_DBG6(("tdsaRotateQnumber: OBQnumber %d\n", tdsaAllShared->OBQnumber));
8018285809Sscottl
8019285809Sscottl  ret = (tdsaAllShared->OBQnumber << 16) | tdsaAllShared->IBQnumber;
8020285809Sscottl  return ret;
8021285809Sscottl}
8022285809Sscottl#endif
8023285809Sscottl
8024285809Sscottl
8025285809Sscottlvoid t_MacroCheck(  agsaRoot_t       *agRoot)
8026285809Sscottl{
8027285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPC           %d\n",tIsSPC(agRoot)));
8028285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCHIL        %d\n",tIsSPCHIL(agRoot)));
8029285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCv          %d\n",tIsSPCv(agRoot)));
8030285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCve         %d\n",tIsSPCve(agRoot)));
8031285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCvplus      %d\n",tIsSPCvplus(agRoot)));
8032285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCveplus     %d\n",tIsSPCveplus(agRoot)));
8033285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCADAPvplus  %d\n",tIsSPCADAPvplus(agRoot)));
8034285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCADAPveplus %d\n",tIsSPCADAPveplus(agRoot)));
8035285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPC12Gv       %d\n",tIsSPC12Gv(agRoot)));
8036285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPC12Gve      %d\n",tIsSPC12Gve(agRoot)));
8037285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPC12Gvplus   %d\n",tIsSPC12Gvplus(agRoot)));
8038285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPC12Gveplus  %d\n",tIsSPC12Gveplus(agRoot)));
8039285809Sscottl  TI_DBG1(("t_MacroCheck:tiIS_SPC         %d\n",tiIS_SPC(agRoot)   ));
8040285809Sscottl  TI_DBG1(("t_MacroCheck:tiIS_HIL         %d\n",tiIS_HIL(agRoot)   ));
8041285809Sscottl  TI_DBG1(("t_MacroCheck:tiIS_SPC6V       %d\n",tiIS_SPC6V(agRoot) ));
8042285809Sscottl  TI_DBG1(("t_MacroCheck:tiIS_SPC_ENC     %d\n",tiIS_SPC_ENC(agRoot) ));
8043285809Sscottl  TI_DBG1(("t_MacroCheck:tIsSPCV12G       %d\n",tIsSPCV12G(agRoot) ));
8044285809Sscottl}
8045