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 sautil.c
24285809Sscottl *  \brief The file contains general helper routines.
25285809Sscottl *
26285809Sscottl *
27285809Sscottl */
28285809Sscottl/******************************************************************************/
29285809Sscottl#include <sys/cdefs.h>
30285809Sscottl__FBSDID("$FreeBSD$");
31285809Sscottl#include <dev/pms/config.h>
32285809Sscottl
33285809Sscottl#include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
34285809Sscottl#ifdef SA_TESTBASE_EXTRA
35285809Sscottl#include <string.h>
36285809Sscottl#endif /*  SA_TESTBASE_EXTRA */
37285809Sscottl
38285809Sscottl
39285809Sscottl#ifdef SA_ENABLE_TRACE_FUNCTIONS
40285809Sscottl#ifdef siTraceFileID
41285809Sscottl#undef siTraceFileID
42285809Sscottl#endif
43285809Sscottl#define siTraceFileID 'S'
44285809Sscottl#endif
45285809Sscottl
46285809Sscottl/******************************************************************************/
47285809Sscottl/*! \brief Check for Hex digit
48285809Sscottl *
49285809Sscottl *
50285809Sscottl *  \param char value
51285809Sscottl *
52285809Sscottl *  \return -void-
53285809Sscottl *
54285809Sscottl */
55285809Sscottl/*******************************************************************************/
56285809Sscottlint siIsHexDigit(char a)
57285809Sscottl{
58285809Sscottl  return (  (((a) >= 'a') && ((a) <= 'z')) ||
59285809Sscottl            (((a) >= 'A') && ((a) <= 'Z')) ||
60285809Sscottl            (((a) >= '0') && ((a) <= '9')) ||
61285809Sscottl            ( (a) == '*'));
62285809Sscottl}
63285809Sscottl
64285809Sscottl/******************************************************************************/
65285809Sscottl/*! \brief memcopy
66285809Sscottl *
67285809Sscottl *
68285809Sscottl *  \param char value
69285809Sscottl *
70285809Sscottl *  \return -void-
71285809Sscottl *
72285809Sscottl */
73285809Sscottl/*******************************************************************************/
74285809SscottlFORCEINLINE
75285809Sscottlvoid*
76285809Sscottlsi_memcpy(void *dst,  void *src, bit32 count)
77285809Sscottl{
78285809Sscottl/*
79285809Sscottl  bit32 x;
80285809Sscottl  unsigned char *dst1 = (unsigned char *)dst;
81285809Sscottl  unsigned char *src1 = (unsigned char *)src;
82285809Sscottl
83285809Sscottl  for (x=0; x < count; x++)
84285809Sscottl    dst1[x] = src1[x];
85285809Sscottl
86285809Sscottl  return dst;
87285809Sscottl*/
88285809Sscottl return memcpy(dst, src, count);
89285809Sscottl}
90285809Sscottl
91285809Sscottl
92285809Sscottl/******************************************************************************/
93285809Sscottl/*! \brief memset
94285809Sscottl *
95285809Sscottl *
96285809Sscottl *  \param char value
97285809Sscottl *
98285809Sscottl *  \return -void-
99285809Sscottl *
100285809Sscottl */
101285809Sscottl/*******************************************************************************/
102285809SscottlFORCEINLINE
103285809Sscottlvoid*
104285809Sscottlsi_memset(void *s, int c, bit32 n)
105285809Sscottl{
106285809Sscottl/*
107285809Sscottl  bit32   i;
108285809Sscottl  char *dst = (char *)s;
109285809Sscottl  for (i=0; i < n; i++)
110285809Sscottl  {
111285809Sscottl    dst[i] = (char) c;
112285809Sscottl  }
113285809Sscottl  return (void *)(&dst[i-n]);
114285809Sscottl*/
115285809Sscottl  return memset(s, c, n);
116285809Sscottl}
117285809Sscottl
118285809Sscottl
119285809Sscottl/******************************************************************************/
120285809Sscottl/*! \brief siDumpActiveIORequests
121285809Sscottl *
122285809Sscottl *
123285809Sscottl *  \param char value
124285809Sscottl *
125285809Sscottl *  \return -void-
126285809Sscottl *
127285809Sscottl */
128285809Sscottl/*******************************************************************************/
129285809SscottlGLOBAL void
130285809SscottlsiDumpActiveIORequests(
131285809Sscottl  agsaRoot_t              *agRoot,
132285809Sscottl  bit32                   count)
133285809Sscottl{
134285809Sscottl  bit32                 j, num_found = 0;
135285809Sscottl  agsaIORequestDesc_t   *pRequestDesc = agNULL;
136285809Sscottl  agsaLLRoot_t          *saRoot = agNULL;
137285809Sscottl  bit32 i;
138285809Sscottl  mpiOCQueue_t          *circularQ;
139285809Sscottl
140285809Sscottl  /* sanity check */
141285809Sscottl  SA_ASSERT((agNULL != agRoot), "");
142285809Sscottl  saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
143285809Sscottl  SA_ASSERT((agNULL != saRoot), "");
144285809Sscottl
145285809Sscottl
146285809Sscottl  saCountActiveIORequests(agRoot);
147285809Sscottl  // return;
148285809Sscottl
149285809Sscottl
150285809Sscottl  if(smIS_SPCV(agRoot))
151285809Sscottl  {
152285809Sscottl    bit32 sp1;
153285809Sscottl    sp1= ossaHwRegRead(agRoot,V_Scratchpad_1_Register );
154285809Sscottl
155285809Sscottl    if(SCRATCH_PAD1_V_ERROR_STATE(sp1))
156285809Sscottl    {
157285809Sscottl      SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD1_V_ERROR_STAT 0x%x\n",sp1 ));
158285809Sscottl    }
159285809Sscottl    SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_0_Register)));
160285809Sscottl    SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_1_Register)));
161285809Sscottl    SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_2_Register)));
162285809Sscottl    SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_3_Register)));
163285809Sscottl  }
164285809Sscottl
165285809Sscottl  for ( i = 0; i < saRoot->QueueConfig.numOutboundQueues; i++ )
166285809Sscottl  {
167285809Sscottl    circularQ = &saRoot->outboundQueue[i];
168285809Sscottl    OSSA_READ_LE_32(circularQ->agRoot, &circularQ->producerIdx, circularQ->piPointer, 0);
169285809Sscottl    if(circularQ->producerIdx != circularQ->consumerIdx)
170285809Sscottl    {
171285809Sscottl      SA_DBG1(("siDumpActiveIORequests:OBQ%d PI 0x%03x CI 0x%03x\n", i,circularQ->producerIdx, circularQ->consumerIdx  ));
172285809Sscottl    }
173285809Sscottl  }
174285809Sscottl
175285809Sscottl  pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
176285809Sscottl  SA_DBG1(("siDumpActiveIORequests: Current Time: %d ticks (usecpertick=%d)\n",
177285809Sscottl    saRoot->timeTick, saRoot->usecsPerTick));
178285809Sscottl
179285809Sscottl  for ( j = 0; j < count; j ++ )
180285809Sscottl  {
181285809Sscottl    pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
182285809Sscottl
183285809Sscottl    if (pRequestDesc->valid == agTRUE)
184285809Sscottl    {
185285809Sscottl      num_found++;
186285809Sscottl      SA_DBG1(("siDumpActiveIORequests: IO #%4d: %p Tag=%03X  Type=%08X Device 0x%X Pending for %d seconds\n",
187285809Sscottl        j,
188285809Sscottl        pRequestDesc->pIORequestContext,
189285809Sscottl        pRequestDesc->HTag,
190285809Sscottl        pRequestDesc->requestType,
191285809Sscottl        pRequestDesc->pDevice ? pRequestDesc->pDevice->DeviceMapIndex : 0,
192285809Sscottl        ((saRoot->timeTick - pRequestDesc->startTick)*saRoot->usecsPerTick)/1000000 ));
193285809Sscottl
194285809Sscottl    }
195285809Sscottl  }
196285809Sscottl  if(count)
197285809Sscottl  {
198285809Sscottl    SA_DBG1(("siDumpActiveIORequests: %d found active\n",num_found));
199285809Sscottl  }
200285809Sscottl
201285809Sscottl}
202285809Sscottl
203285809Sscottl/******************************************************************************/
204285809Sscottl/*! \brief saCountActiveIORequests
205285809Sscottl *
206285809Sscottl *
207285809Sscottl *  \param char value
208285809Sscottl *
209285809Sscottl *  \return -void-
210285809Sscottl *
211285809Sscottl */
212285809Sscottl/*******************************************************************************/
213285809SscottlGLOBAL void
214285809SscottlsiClearActiveIORequests(
215285809Sscottl  agsaRoot_t              *agRoot)
216285809Sscottl{
217285809Sscottl  bit32                 j;
218285809Sscottl  bit32                 num_found = 0;
219285809Sscottl  agsaIORequestDesc_t   *pRequestDesc = agNULL;
220285809Sscottl  agsaLLRoot_t          *saRoot = agNULL;
221285809Sscottl
222285809Sscottl  /* sanity check */
223285809Sscottl  SA_ASSERT((agNULL != agRoot), "");
224285809Sscottl  saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
225285809Sscottl  SA_ASSERT((agNULL != saRoot), "");
226285809Sscottl
227285809Sscottl  if(saRoot)
228285809Sscottl  {
229285809Sscottl    pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
230285809Sscottl
231285809Sscottl    for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
232285809Sscottl    {
233285809Sscottl      pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
234285809Sscottl
235285809Sscottl      if (pRequestDesc->valid == agTRUE)
236285809Sscottl      {
237285809Sscottl        num_found++;
238285809Sscottl        pRequestDesc->valid =  agFALSE;
239285809Sscottl      }
240285809Sscottl    }
241285809Sscottl    if(num_found)
242285809Sscottl    {
243285809Sscottl      SA_DBG1(("siClearActiveIORequests %d found active\n",num_found));
244285809Sscottl    }
245285809Sscottl  }
246285809Sscottl  else
247285809Sscottl  {
248285809Sscottl     SA_DBG1(("siClearActiveIORequests saroot NULL\n"));
249285809Sscottl  }
250285809Sscottl
251285809Sscottl}
252285809Sscottl
253285809Sscottl/******************************************************************************/
254285809Sscottl/*! \brief siCountActiveIORequestsOnDevice
255285809Sscottl *   count all active IO's
256285809Sscottl *
257285809Sscottl *  \param char value
258285809Sscottl *
259285809Sscottl *  \return -void-
260285809Sscottl *
261285809Sscottl */
262285809Sscottl/*******************************************************************************/
263285809SscottlGLOBAL void
264285809SscottlsiClearActiveIORequestsOnDevice(
265285809Sscottl  agsaRoot_t *agRoot,
266285809Sscottl  bit32      device )
267285809Sscottl{
268285809Sscottl  bit32                 j, num_found = 0;
269285809Sscottl  agsaIORequestDesc_t   *pRequestDesc = agNULL;
270285809Sscottl  agsaLLRoot_t          *saRoot = agNULL;
271285809Sscottl
272285809Sscottl  /* sanity check */
273285809Sscottl  SA_ASSERT((agNULL != agRoot), "");
274285809Sscottl  saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
275285809Sscottl  SA_ASSERT((agNULL != saRoot), "");
276285809Sscottl
277285809Sscottl  pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
278285809Sscottl
279285809Sscottl  for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
280285809Sscottl  {
281285809Sscottl    pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
282285809Sscottl
283285809Sscottl    if (pRequestDesc->valid == agTRUE)
284285809Sscottl    {
285285809Sscottl      if (pRequestDesc->pDevice)
286285809Sscottl      {
287285809Sscottl        if (pRequestDesc->pDevice->DeviceMapIndex == device)
288285809Sscottl        {
289285809Sscottl          num_found++;
290285809Sscottl          pRequestDesc->valid = agFALSE;
291285809Sscottl        }
292285809Sscottl      }
293285809Sscottl    }
294285809Sscottl  }
295285809Sscottl  if(num_found)
296285809Sscottl  {
297285809Sscottl    SA_DBG1(("siClearActiveIORequestsOnDevice 0x%x %d cleared\n",device,num_found));
298285809Sscottl  }
299285809Sscottl
300285809Sscottl}
301285809Sscottl
302285809Sscottl
303285809Sscottl
304285809Sscottl/******************************************************************************/
305285809Sscottl/*! \brief siCountActiveIORequestsOnDevice
306285809Sscottl *   count all active IO's
307285809Sscottl *
308285809Sscottl *  \param char value
309285809Sscottl *
310285809Sscottl *  \return -void-
311285809Sscottl *
312285809Sscottl */
313285809Sscottl/*******************************************************************************/
314285809SscottlGLOBAL void
315285809SscottlsiCountActiveIORequestsOnDevice(
316285809Sscottl  agsaRoot_t *agRoot,
317285809Sscottl  bit32      device )
318285809Sscottl{
319285809Sscottl  bit32                 j, num_found = 0;
320285809Sscottl  agsaIORequestDesc_t   *pRequestDesc = agNULL;
321285809Sscottl  agsaLLRoot_t          *saRoot = agNULL;
322285809Sscottl
323285809Sscottl  /* sanity check */
324285809Sscottl  SA_ASSERT((agNULL != agRoot), "");
325285809Sscottl  saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
326285809Sscottl  SA_ASSERT((agNULL != saRoot), "");
327285809Sscottl
328285809Sscottl  pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
329285809Sscottl
330285809Sscottl  for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
331285809Sscottl  {
332285809Sscottl    pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
333285809Sscottl
334285809Sscottl    if (pRequestDesc->valid == agTRUE)
335285809Sscottl    {
336285809Sscottl      if (pRequestDesc->pDevice)
337285809Sscottl      {
338285809Sscottl        if (pRequestDesc->pDevice->DeviceMapIndex == device)
339285809Sscottl        {
340285809Sscottl          num_found++;
341285809Sscottl          if(saRoot->ResetStartTick > pRequestDesc->startTick)
342285809Sscottl          {
343285809Sscottl            SA_DBG2(("siCountActiveIORequestsOnDevice: saRoot->ResetStartTick %d pRequestDesc->startTick %d\n",
344285809Sscottl                    saRoot->ResetStartTick, pRequestDesc->startTick));
345285809Sscottl          }
346285809Sscottl        }
347285809Sscottl      }
348285809Sscottl    }
349285809Sscottl  }
350285809Sscottl  if(num_found)
351285809Sscottl  {
352285809Sscottl    SA_DBG1(("siCountActiveIORequestsOnDevice 0x%x %d found active\n",device,num_found));
353285809Sscottl  }
354285809Sscottl
355285809Sscottl}
356285809Sscottl
357285809Sscottl
358285809Sscottl
359285809Sscottl/******************************************************************************/
360285809Sscottl/*! \brief saCountActiveIORequests
361285809Sscottl *   count all active IO's
362285809Sscottl *
363285809Sscottl *  \param char value
364285809Sscottl *
365285809Sscottl *  \return -void-
366285809Sscottl *
367285809Sscottl */
368285809Sscottl/*******************************************************************************/
369285809SscottlGLOBAL void
370285809SscottlsaCountActiveIORequests(
371285809Sscottl  agsaRoot_t              *agRoot)
372285809Sscottl{
373285809Sscottl  bit32                 j, num_found = 0;
374285809Sscottl  agsaIORequestDesc_t   *pRequestDesc = agNULL;
375285809Sscottl  agsaLLRoot_t          *saRoot = agNULL;
376285809Sscottl
377285809Sscottl  /* sanity check */
378285809Sscottl  SA_ASSERT((agNULL != agRoot), "");
379285809Sscottl  if( agRoot == agNULL)
380285809Sscottl  {
381285809Sscottl    return;
382285809Sscottl  }
383285809Sscottl  saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
384285809Sscottl  if( saRoot == agNULL)
385285809Sscottl  {
386285809Sscottl    return;
387285809Sscottl  }
388285809Sscottl  pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
389285809Sscottl
390285809Sscottl  for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
391285809Sscottl  {
392285809Sscottl    pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
393285809Sscottl
394285809Sscottl    if (pRequestDesc->valid == agTRUE)
395285809Sscottl    {
396285809Sscottl      num_found++;
397285809Sscottl      if(saRoot->ResetStartTick > pRequestDesc->startTick)
398285809Sscottl      {
399285809Sscottl        SA_DBG2(("saCountActiveIORequests: saRoot->ResetStartTick %d pRequestDesc->startTick %d\n",
400285809Sscottl                saRoot->ResetStartTick, pRequestDesc->startTick));
401285809Sscottl      }
402285809Sscottl    }
403285809Sscottl  }
404285809Sscottl  if(num_found)
405285809Sscottl  {
406285809Sscottl    SA_DBG1(("saCountActiveIORequests %d found active\n",num_found));
407285809Sscottl  }
408285809Sscottl
409285809Sscottl}
410285809Sscottl
411285809Sscottl
412285809SscottlGLOBAL bit32 smIsCfg_V_ANY( agsaRoot_t *agRoot)
413285809Sscottl{
414285809Sscottl
415285809Sscottl  if(smIsCfg_V8008(agRoot) == 1) return 1;
416285809Sscottl  if(smIsCfg_V8009(agRoot) == 1) return 1;
417285809Sscottl  if(smIsCfg_V8018(agRoot) == 1) return 1;
418285809Sscottl  if(smIsCfg_V8019(agRoot) == 1) return 1;
419285809Sscottl  if(smIsCfg_V8088(agRoot) == 1) return 1;
420285809Sscottl  if(smIsCfg_V8089(agRoot) == 1) return 1;
421285809Sscottl  if(smIsCfg_V8070(agRoot) == 1) return 1;
422285809Sscottl  if(smIsCfg_V8071(agRoot) == 1) return 1;
423285809Sscottl  if(smIsCfg_V8072(agRoot) == 1) return 1;
424285809Sscottl  if(smIsCfg_V8073(agRoot) == 1) return 1;
425285809Sscottl  if(smIS_SPCV8074(agRoot) == 1) return 1;
426285809Sscottl  if(smIS_SPCV8075(agRoot) == 1) return 1;
427285809Sscottl  if(smIS_SPCV8076(agRoot) == 1) return 1;
428285809Sscottl  if(smIS_SPCV8077(agRoot) == 1) return 1;
429285809Sscottl  if(smIsCfg_V8025(agRoot) == 1) return 1;
430285809Sscottl  if(smIsCfg_V9015(agRoot) == 1) return 1;
431285809Sscottl  if(smIsCfg_V9060(agRoot) == 1) return 1;
432285809Sscottl  if(smIsCfg_V8006(agRoot) == 1) return 1;
433285809Sscottl
434285809Sscottl  return 0;
435285809Sscottl}
436285809Sscottl
437285809SscottlGLOBAL bit32 smIS_SPC( agsaRoot_t *agRoot)
438285809Sscottl{
439285809Sscottl  if(smIS_spc8001(agRoot)    == 1) return 1;
440285809Sscottl  if(smIS_spc8081(agRoot)    == 1) return 1;
441285809Sscottl  if(smIS_SFC_AS_SPC(agRoot) == 1) return 1;
442285809Sscottl  return 0;
443285809Sscottl}
444285809Sscottl
445285809Sscottl
446285809SscottlGLOBAL bit32 smIS_HIL( agsaRoot_t *agRoot) /* or delray */
447285809Sscottl{
448285809Sscottl  if(smIS_spc8081(agRoot)  == 1) return 1;
449285809Sscottl  if(smIS_ADAP8088(agRoot) == 1) return 1;
450285809Sscottl  if(smIS_ADAP8089(agRoot) == 1) return 1;
451285809Sscottl  if(smIS_SPCV8074(agRoot) == 1) return 1;
452285809Sscottl  if(smIS_SPCV8075(agRoot) == 1) return 1;
453285809Sscottl  if(smIS_SPCV8076(agRoot) == 1) return 1;
454285809Sscottl  if(smIS_SPCV8077(agRoot) == 1) return 1;
455285809Sscottl  return 0;
456285809Sscottl
457285809Sscottl}
458285809Sscottl
459285809SscottlGLOBAL bit32 smIS_SPC6V( agsaRoot_t *agRoot)
460285809Sscottl{
461285809Sscottl  if(smIS_SPCV8008(agRoot) == 1) return 1;
462285809Sscottl  if(smIS_SPCV8009(agRoot) == 1) return 1;
463285809Sscottl  if(smIS_SPCV8018(agRoot) == 1) return 1;
464285809Sscottl  if(smIS_SPCV8019(agRoot) == 1) return 1;
465285809Sscottl  if(smIS_ADAP8088(agRoot) == 1) return 1;
466285809Sscottl  if(smIS_ADAP8089(agRoot) == 1) return 1;
467285809Sscottl  return 0;
468285809Sscottl}
469285809Sscottl
470285809SscottlGLOBAL bit32 smIS_SPC12V( agsaRoot_t *agRoot)
471285809Sscottl{
472285809Sscottl  if(smIS_SPCV8070(agRoot) == 1) return 1;
473285809Sscottl  if(smIS_SPCV8071(agRoot) == 1) return 1;
474285809Sscottl  if(smIS_SPCV8072(agRoot) == 1) return 1;
475285809Sscottl  if(smIS_SPCV8073(agRoot) == 1) return 1;
476285809Sscottl  if(smIS_SPCV8074(agRoot) == 1) return 1;
477285809Sscottl  if(smIS_SPCV8075(agRoot) == 1) return 1;
478285809Sscottl  if(smIS_SPCV8076(agRoot) == 1) return 1;
479285809Sscottl  if(smIS_SPCV8077(agRoot) == 1) return 1;
480285809Sscottl  if(smIS_SPCV9015(agRoot) == 1) return 1;
481285809Sscottl  if(smIS_SPCV9060(agRoot) == 1) return 1;
482285809Sscottl  if(smIS_SPCV8006(agRoot) == 1) return 1;
483285809Sscottl  return 0;
484285809Sscottl}
485285809Sscottl
486285809SscottlGLOBAL bit32 smIS_SPCV_2_IOP( agsaRoot_t *agRoot)
487285809Sscottl{
488285809Sscottl  if(smIS_SPCV8009(agRoot) == 1) return 1;
489285809Sscottl  if(smIS_SPCV8018(agRoot) == 1) return 1;
490285809Sscottl  if(smIS_SPCV8019(agRoot) == 1) return 1;
491285809Sscottl  if(smIS_SPCV8071(agRoot) == 1) return 1;
492285809Sscottl  if(smIS_SPCV8072(agRoot) == 1) return 1;
493285809Sscottl  if(smIS_SPCV8073(agRoot) == 1) return 1;
494285809Sscottl  if(smIS_SPCV8076(agRoot) == 1) return 1;
495285809Sscottl  if(smIS_SPCV8077(agRoot) == 1) return 1;
496285809Sscottl  if(smIS_ADAP8088(agRoot) == 1) return 1;
497285809Sscottl  if(smIS_ADAP8089(agRoot) == 1) return 1;
498285809Sscottl  if(smIS_SPCV8006(agRoot) == 1) return 1;
499285809Sscottl  return 0;
500285809Sscottl}
501285809Sscottl
502285809SscottlGLOBAL bit32 smIS_SPCV( agsaRoot_t *agRoot)
503285809Sscottl{
504285809Sscottl  if(smIS_SPC6V(agRoot)    == 1) return 1;
505285809Sscottl  if(smIS_SPC12V(agRoot)   == 1) return 1;
506285809Sscottl  if(smIS_SFC_AS_V(agRoot) == 1 ) return 1;
507285809Sscottl  return 0;
508285809Sscottl}
509285809Sscottl
510285809SscottlGLOBAL bit32 smIS_ENCRYPT( agsaRoot_t *agRoot)
511285809Sscottl{
512285809Sscottl  if(smIS_SPCV8009(agRoot) == 1) return 1;
513285809Sscottl  if(smIS_ADAP8088(agRoot) == 1) return 1;
514285809Sscottl  if(smIS_SPCV8019(agRoot) == 1) return 1;
515285809Sscottl  if(smIS_SPCV8071(agRoot) == 1) return 1;
516285809Sscottl  if(smIS_SPCV8073(agRoot) == 1) return 1;
517285809Sscottl  if(smIS_SPCV8077(agRoot) == 1) return 1;
518285809Sscottl  if(smIS_SPCV9015(agRoot) == 1) return 1;
519285809Sscottl  if(smIS_SPCV9060(agRoot) == 1) return 1;
520285809Sscottl  return 0;
521285809Sscottl}
522285809Sscottl
523285809Sscottl
524285809Sscottl
525285809Sscottl#if defined(SALLSDK_DEBUG)
526285809Sscottl
527285809Sscottl/******************************************************************************/
528285809Sscottl/*! \brief Routine print buffer
529285809Sscottl *
530285809Sscottl *
531285809Sscottl *  \param debugLevel     verbosity level
532285809Sscottl *  \param header         header to print
533285809Sscottl *  \param buffer         buffer to print
534285809Sscottl *  \param  length        length of buffer in bytes
535285809Sscottl *
536285809Sscottl *  \return -void-
537285809Sscottl *
538285809Sscottl */
539285809Sscottl/*******************************************************************************/
540285809SscottlGLOBAL void siPrintBuffer(
541285809Sscottl  bit32                 debugLevel,
542285809Sscottl  siPrintType           type,
543285809Sscottl  char                  *header,
544285809Sscottl  void                  *a,
545285809Sscottl  bit32                 length
546285809Sscottl  )
547285809Sscottl{
548285809Sscottl  bit32 x, rem;
549285809Sscottl  bit8 *buffer = (bit8 *)a;
550285809Sscottl  bit32 *lPtr;
551285809Sscottl  bit8 temp[16];
552285809Sscottl
553285809Sscottl  ossaLogDebugString(gLLDebugLevel, debugLevel, ("%s\n", header));
554285809Sscottl
555285809Sscottl  if (type == SA_8)
556285809Sscottl  {
557285809Sscottl    for (x=0; x < length/16; x++)
558285809Sscottl    {
559285809Sscottl      ossaLogDebugString(gLLDebugLevel, debugLevel,
560285809Sscottl        ("%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x  == "
561285809Sscottl         "%c%c%c%c%c%c%c%c - %c%c%c%c%c%c%c%c\n",
562285809Sscottl        *(buffer),
563285809Sscottl        *(buffer+1),
564285809Sscottl        *(buffer+2),
565285809Sscottl        *(buffer+3),
566285809Sscottl        *(buffer+4),
567285809Sscottl        *(buffer+5),
568285809Sscottl        *(buffer+6),
569285809Sscottl        *(buffer+7),
570285809Sscottl        *(buffer+8),
571285809Sscottl        *(buffer+9),
572285809Sscottl        *(buffer+10),
573285809Sscottl        *(buffer+11),
574285809Sscottl        *(buffer+12),
575285809Sscottl        *(buffer+13),
576285809Sscottl        *(buffer+14),
577285809Sscottl        *(buffer+15),
578285809Sscottl        siIsHexDigit(*(buffer)) ? *(buffer) : ' ',
579285809Sscottl        siIsHexDigit(*(buffer+1)) ? *(buffer+1) : ' ',
580285809Sscottl        siIsHexDigit(*(buffer+2)) ? *(buffer+2) : ' ',
581285809Sscottl        siIsHexDigit(*(buffer+3)) ? *(buffer+3) : ' ',
582285809Sscottl        siIsHexDigit(*(buffer+4)) ? *(buffer+4) : ' ',
583285809Sscottl        siIsHexDigit(*(buffer+5)) ? *(buffer+5) : ' ',
584285809Sscottl        siIsHexDigit(*(buffer+6)) ? *(buffer+6) : ' ',
585285809Sscottl        siIsHexDigit(*(buffer+7)) ? *(buffer+7) : ' ',
586285809Sscottl        siIsHexDigit(*(buffer+8)) ? *(buffer+8) : ' ',
587285809Sscottl        siIsHexDigit(*(buffer+9)) ? *(buffer+9) : ' ',
588285809Sscottl        siIsHexDigit(*(buffer+10)) ? *(buffer+10) : ' ',
589285809Sscottl        siIsHexDigit(*(buffer+11)) ? *(buffer+11) : ' ',
590285809Sscottl        siIsHexDigit(*(buffer+12)) ? *(buffer+12) : ' ',
591285809Sscottl        siIsHexDigit(*(buffer+13)) ? *(buffer+13) : ' ',
592285809Sscottl        siIsHexDigit(*(buffer+14)) ? *(buffer+14) : ' ',
593285809Sscottl        siIsHexDigit(*(buffer+15)) ? *(buffer+15) : ' ')
594285809Sscottl        );
595285809Sscottl
596285809Sscottl      buffer += 16;
597285809Sscottl    }
598285809Sscottl
599285809Sscottl    rem = length%16;
600285809Sscottl    if (rem)
601285809Sscottl    {
602285809Sscottl      for (x = 0; x < 16; x++)
603285809Sscottl      {
604285809Sscottl        temp[x] = ' ';
605285809Sscottl      }
606285809Sscottl
607285809Sscottl      for (x = 0; x < rem; x++)
608285809Sscottl      {
609285809Sscottl        temp[x] = *(buffer+x);
610285809Sscottl      }
611285809Sscottl
612285809Sscottl      buffer = temp;
613285809Sscottl
614285809Sscottl      ossaLogDebugString(gLLDebugLevel, debugLevel,
615285809Sscottl        ("%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x  == "
616285809Sscottl         "%c%c%c%c%c%c%c%c - %c%c%c%c%c%c%c%c\n",
617285809Sscottl        *(buffer),
618285809Sscottl        *(buffer+1),
619285809Sscottl        *(buffer+2),
620285809Sscottl        *(buffer+3),
621285809Sscottl        *(buffer+4),
622285809Sscottl        *(buffer+5),
623285809Sscottl        *(buffer+6),
624285809Sscottl        *(buffer+7),
625285809Sscottl        *(buffer+8),
626285809Sscottl        *(buffer+9),
627285809Sscottl        *(buffer+10),
628285809Sscottl        *(buffer+11),
629285809Sscottl        *(buffer+12),
630285809Sscottl        *(buffer+13),
631285809Sscottl        *(buffer+14),
632285809Sscottl        *(buffer+15),
633285809Sscottl        siIsHexDigit(*(buffer)) ? *(buffer) : ' ',
634285809Sscottl        siIsHexDigit(*(buffer+1)) ? *(buffer+1) : ' ',
635285809Sscottl        siIsHexDigit(*(buffer+2)) ? *(buffer+2) : ' ',
636285809Sscottl        siIsHexDigit(*(buffer+3)) ? *(buffer+3) : ' ',
637285809Sscottl        siIsHexDigit(*(buffer+4)) ? *(buffer+4) : ' ',
638285809Sscottl        siIsHexDigit(*(buffer+5)) ? *(buffer+5) : ' ',
639285809Sscottl        siIsHexDigit(*(buffer+6)) ? *(buffer+6) : ' ',
640285809Sscottl        siIsHexDigit(*(buffer+7)) ? *(buffer+7) : ' ',
641285809Sscottl        siIsHexDigit(*(buffer+8)) ? *(buffer+8) : ' ',
642285809Sscottl        siIsHexDigit(*(buffer+9)) ? *(buffer+9) : ' ',
643285809Sscottl        siIsHexDigit(*(buffer+10)) ? *(buffer+10) : ' ',
644285809Sscottl        siIsHexDigit(*(buffer+11)) ? *(buffer+11) : ' ',
645285809Sscottl        siIsHexDigit(*(buffer+12)) ? *(buffer+12) : ' ',
646285809Sscottl        siIsHexDigit(*(buffer+13)) ? *(buffer+13) : ' ',
647285809Sscottl        siIsHexDigit(*(buffer+14)) ? *(buffer+14) : ' ',
648285809Sscottl        siIsHexDigit(*(buffer+15)) ? *(buffer+15) : ' ')
649285809Sscottl        );
650285809Sscottl    }
651285809Sscottl  }
652285809Sscottl  else
653285809Sscottl  {
654285809Sscottl    bit32 *ltemp = (bit32 *)temp;
655285809Sscottl    lPtr = (bit32 *) a;
656285809Sscottl
657285809Sscottl    for (x=0; x < length/4; x++)
658285809Sscottl    {
659285809Sscottl      ossaLogDebugString(gLLDebugLevel, debugLevel,
660285809Sscottl        ("%08x %08x %08x %08x\n",
661285809Sscottl        *(lPtr),
662285809Sscottl        *(lPtr+1),
663285809Sscottl        *(lPtr+2),
664285809Sscottl        *(lPtr+3))
665285809Sscottl        );
666285809Sscottl
667285809Sscottl      lPtr += 4;
668285809Sscottl    }
669285809Sscottl
670285809Sscottl    rem = length%4;
671285809Sscottl    if (rem)
672285809Sscottl    {
673285809Sscottl      for (x = 0; x < 4; x++)
674285809Sscottl      {
675285809Sscottl        ltemp[x] = 0;
676285809Sscottl      }
677285809Sscottl
678285809Sscottl      for (x = 0; x < rem; x++)
679285809Sscottl      {
680285809Sscottl        ltemp[x] = lPtr[x];
681285809Sscottl      }
682285809Sscottl
683285809Sscottl      lPtr = ltemp;
684285809Sscottl
685285809Sscottl      ossaLogDebugString(gLLDebugLevel, debugLevel,
686285809Sscottl        ("%08x %08x %08x %08x\n",
687285809Sscottl        *(lPtr),
688285809Sscottl        *(lPtr+1),
689285809Sscottl        *(lPtr+2),
690285809Sscottl        *(lPtr+3))
691285809Sscottl        );
692285809Sscottl    }
693285809Sscottl  }
694285809Sscottl
695285809Sscottl}
696285809Sscottl
697285809Sscottl
698285809Sscottl
699285809Sscottlvoid sidump_hwConfig(agsaHwConfig_t  *hwConfig)
700285809Sscottl{
701285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->hwInterruptCoalescingTimer                             0x%x\n",hwConfig->hwInterruptCoalescingTimer                            ));
702285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->hwInterruptCoalescingControl                           0x%x\n",hwConfig->hwInterruptCoalescingControl                          ));
703285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->intReassertionOption                                   0x%x\n",hwConfig->intReassertionOption                                  ));
704285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister0  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister0 ));
705285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister1  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister1 ));
706285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister2  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister2 ));
707285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister3  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister3 ));
708285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister4  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister4 ));
709285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister5  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister5 ));
710285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister6  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister6 ));
711285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister7  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister7 ));
712285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister8  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister8 ));
713285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister9  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister9 ));
714285809Sscottl  SA_DBG2(("sidump_hwConfig:hwConfig->hwOption                                               0x%x\n",hwConfig->hwOption                                              ));
715285809Sscottl}
716285809Sscottl
717285809Sscottlvoid sidump_swConfig(agsaSwConfig_t  *swConfig)
718285809Sscottl{
719285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->maxActiveIOs               0x%x\n",swConfig->maxActiveIOs              ));
720285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->numDevHandles              0x%x\n",swConfig->numDevHandles             ));
721285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->smpReqTimeout              0x%x\n",swConfig->smpReqTimeout             ));
722285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->numberOfEventRegClients    0x%x\n",swConfig->numberOfEventRegClients   ));
723285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->sizefEventLog1             0x%x\n",swConfig->sizefEventLog1            ));
724285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->sizefEventLog2             0x%x\n",swConfig->sizefEventLog2            ));
725285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->eventLog1Option            0x%x\n",swConfig->eventLog1Option           ));
726285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->eventLog2Option            0x%x\n",swConfig->eventLog2Option           ));
727285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->fatalErrorInterruptEnable  0x%x\n",swConfig->fatalErrorInterruptEnable ));
728285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->fatalErrorInterruptVector  0x%x\n",swConfig->fatalErrorInterruptVector ));
729285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->max_MSI_InterruptVectors   0x%x\n",swConfig->max_MSI_InterruptVectors  ));
730285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->max_MSIX_InterruptVectors  0x%x\n",swConfig->max_MSIX_InterruptVectors ));
731285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->legacyInt_X                0x%x\n",swConfig->legacyInt_X               ));
732285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->hostDirectAccessSupport    0x%x\n",swConfig->hostDirectAccessSupport   ));
733285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->hostDirectAccessMode       0x%x\n",swConfig->hostDirectAccessMode      ));
734285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->param1                     0x%x\n",swConfig->param1                    ));
735285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->param2                     0x%x\n",swConfig->param2                    ));
736285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->param3                     %p\n",swConfig->param3                    ));
737285809Sscottl  SA_DBG2(("sidump_swConfig:swConfig->param4                     %p\n",swConfig->param4                    ));
738285809Sscottl
739285809Sscottl}
740285809Sscottl
741285809Sscottl
742285809Sscottlvoid sidump_Q_config( agsaQueueConfig_t         *queueConfig )
743285809Sscottl{
744285809Sscottl  bit32 x;
745285809Sscottl
746285809Sscottl  SA_DBG2(("sidump_Q_config: queueConfig->generalEventQueue                0x%x\n", queueConfig->generalEventQueue                ));
747285809Sscottl  SA_DBG2(("sidump_Q_config: queueConfig->numInboundQueues                 0x%x\n", queueConfig->numInboundQueues                 ));
748285809Sscottl  SA_DBG2(("sidump_Q_config: queueConfig->numOutboundQueues                0x%x\n", queueConfig->numOutboundQueues                ));
749285809Sscottl  SA_DBG2(("sidump_Q_config: queueConfig->iqHighPriorityProcessingDepth    0x%x\n", queueConfig->iqHighPriorityProcessingDepth    ));
750285809Sscottl  SA_DBG2(("sidump_Q_config: queueConfig->iqNormalPriorityProcessingDepth  0x%x\n", queueConfig->iqNormalPriorityProcessingDepth  ));
751285809Sscottl  SA_DBG2(("sidump_Q_config: queueConfig->queueOption                      0x%x\n", queueConfig->queueOption                      ));
752285809Sscottl  SA_DBG2(("sidump_Q_config: queueConfig->tgtDeviceRemovedEventQueue       0x%x\n", queueConfig->tgtDeviceRemovedEventQueue       ));
753285809Sscottl
754285809Sscottl  for(x=0;x < queueConfig->numInboundQueues;x++)
755285809Sscottl  {
756285809Sscottl    SA_DBG2(("sidump_Q_config: queueConfig->inboundQueues[%d].elementCount  0x%x\n",x,queueConfig->inboundQueues[x].elementCount  ));
757285809Sscottl    SA_DBG2(("sidump_Q_config: queueConfig->inboundQueues[%d].elementSize   0x%x\n",x,queueConfig->inboundQueues[x].elementSize   ));
758285809Sscottl  }
759285809Sscottl
760285809Sscottl  for(x=0;x < queueConfig->numOutboundQueues;x++)
761285809Sscottl  {
762285809Sscottl
763285809Sscottl    SA_DBG2(("sidump_Q_config: queueConfig->outboundQueues[%d].elementCount 0x%x\n",x,queueConfig->outboundQueues[x].elementCount ));
764285809Sscottl    SA_DBG2(("sidump_Q_config: queueConfig->outboundQueues[%d].elementSize  0x%x\n",x,queueConfig->outboundQueues[x].elementSize  ));
765285809Sscottl  }
766285809Sscottl
767285809Sscottl}
768285809Sscottl#endif
769285809Sscottl
770285809Sscottl#ifdef SALL_API_TEST
771285809Sscottl/******************************************************************************/
772285809Sscottl/*! \brief Get Performance IO counters
773285809Sscottl *
774285809Sscottl *  Start/Abort SAS/SATA discovery
775285809Sscottl *
776285809Sscottl *  \param agRoot         Handles for this instance of SAS/SATA hardware
777285809Sscottl *  \param counters       bit map of the counters
778285809Sscottl *  \param LLCountInfo    pointer to the LLCounters
779285809Sscottl *
780285809Sscottl *  \return
781285809Sscottl *          - \e AGSA_RC_SUCCESS
782285809Sscottl *
783285809Sscottl */
784285809Sscottl/*******************************************************************************/
785285809SscottlGLOBAL bit32 saGetLLCounters(
786285809Sscottl                      agsaRoot_t          *agRoot,
787285809Sscottl                      bit32               counters,
788285809Sscottl                      agsaLLCountInfo_t   *LLCountInfo
789285809Sscottl                      )
790285809Sscottl{
791285809Sscottl  agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
792285809Sscottl  bit32 i;
793285809Sscottl
794285809Sscottl  for (i = 0; i < LL_COUNTERS; i++)
795285809Sscottl  {
796285809Sscottl    if (counters & (1 << i))
797285809Sscottl      LLCountInfo->arrayIOCounter[i] = saRoot->LLCounters.arrayIOCounter[i];
798285809Sscottl  }
799285809Sscottl
800285809Sscottl  return AGSA_RC_SUCCESS;
801285809Sscottl}
802285809Sscottl
803285809Sscottl/******************************************************************************/
804285809Sscottl/*! \brief Function for target to remove stale initiator device handle
805285809Sscottl *
806285809Sscottl *  function is called to ask the LL layer to remove all LL layer and SPC firmware
807285809Sscottl *  internal resources associated with a device handle
808285809Sscottl *
809285809Sscottl *  \param agRoot       Handles for this instance of SAS/SATA hardware
810285809Sscottl *  \param counters     Bit map of the IO counters
811285809Sscottl *
812285809Sscottl *  \return
813285809Sscottl *          - \e AGSA_RC_SUCCESS
814285809Sscottl *
815285809Sscottl */
816285809Sscottl/*******************************************************************************/
817285809SscottlGLOBAL bit32 saResetLLCounters(
818285809Sscottl                      agsaRoot_t *agRoot,
819285809Sscottl                      bit32      counters
820285809Sscottl                      )
821285809Sscottl{
822285809Sscottl  agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
823285809Sscottl  bit32 i;
824285809Sscottl
825285809Sscottl  for (i = 0; i < LL_COUNTERS; i++)
826285809Sscottl  {
827285809Sscottl    if (counters & (1 << i))
828285809Sscottl      saRoot->LLCounters.arrayIOCounter[i] = 0;
829285809Sscottl  }
830285809Sscottl
831285809Sscottl  return AGSA_RC_SUCCESS;
832285809Sscottl}
833285809Sscottl#endif
834285809Sscottl
835