xref: /freebsd/sys/dev/pms/RefTisa/sallsdk/spc/sautil.c (revision 95eb4b873b6a8b527c5bd78d7191975dfca38998)
1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc.  All rights reserved.
3 *
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7 *following disclaimer.
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
11 *
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20 
21 ********************************************************************************/
22 /*******************************************************************************/
23 /*! \file sautil.c
24  *  \brief The file contains general helper routines.
25  *
26  *
27  */
28 /******************************************************************************/
29 #include <sys/cdefs.h>
30 #include <dev/pms/config.h>
31 
32 #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
33 #ifdef SA_TESTBASE_EXTRA
34 #include <string.h>
35 #endif /*  SA_TESTBASE_EXTRA */
36 
37 
38 #ifdef SA_ENABLE_TRACE_FUNCTIONS
39 #ifdef siTraceFileID
40 #undef siTraceFileID
41 #endif
42 #define siTraceFileID 'S'
43 #endif
44 
45 /******************************************************************************/
46 /*! \brief Check for Hex digit
47  *
48  *
49  *  \param char value
50  *
51  *  \return -void-
52  *
53  */
54 /*******************************************************************************/
55 int siIsHexDigit(char a)
56 {
57   return (  (((a) >= 'a') && ((a) <= 'z')) ||
58             (((a) >= 'A') && ((a) <= 'Z')) ||
59             (((a) >= '0') && ((a) <= '9')) ||
60             ( (a) == '*'));
61 }
62 
63 /******************************************************************************/
64 /*! \brief memcopy
65  *
66  *
67  *  \param char value
68  *
69  *  \return -void-
70  *
71  */
72 /*******************************************************************************/
73 FORCEINLINE
74 void*
75 si_memcpy(void *dst,  void *src, bit32 count)
76 {
77 /*
78   bit32 x;
79   unsigned char *dst1 = (unsigned char *)dst;
80   unsigned char *src1 = (unsigned char *)src;
81 
82   for (x=0; x < count; x++)
83     dst1[x] = src1[x];
84 
85   return dst;
86 */
87  return memcpy(dst, src, count);
88 }
89 
90 
91 /******************************************************************************/
92 /*! \brief memset
93  *
94  *
95  *  \param char value
96  *
97  *  \return -void-
98  *
99  */
100 /*******************************************************************************/
101 FORCEINLINE
102 void*
103 si_memset(void *s, int c, bit32 n)
104 {
105 /*
106   bit32   i;
107   char *dst = (char *)s;
108   for (i=0; i < n; i++)
109   {
110     dst[i] = (char) c;
111   }
112   return (void *)(&dst[i-n]);
113 */
114   return memset(s, c, n);
115 }
116 
117 
118 /******************************************************************************/
119 /*! \brief siDumpActiveIORequests
120  *
121  *
122  *  \param char value
123  *
124  *  \return -void-
125  *
126  */
127 /*******************************************************************************/
128 GLOBAL void
129 siDumpActiveIORequests(
130   agsaRoot_t              *agRoot,
131   bit32                   count)
132 {
133   bit32                 j, num_found = 0;
134   agsaIORequestDesc_t   *pRequestDesc = agNULL;
135   agsaLLRoot_t          *saRoot = agNULL;
136   bit32 i;
137   mpiOCQueue_t          *circularQ;
138 
139   /* sanity check */
140   SA_ASSERT((agNULL != agRoot), "");
141   saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
142   SA_ASSERT((agNULL != saRoot), "");
143 
144 
145   saCountActiveIORequests(agRoot);
146   // return;
147 
148 
149   if(smIS_SPCV(agRoot))
150   {
151     bit32 sp1;
152     sp1= ossaHwRegRead(agRoot,V_Scratchpad_1_Register );
153 
154     if(SCRATCH_PAD1_V_ERROR_STATE(sp1))
155     {
156       SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD1_V_ERROR_STAT 0x%x\n",sp1 ));
157     }
158     SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_0_Register)));
159     SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_1_Register)));
160     SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_2_Register)));
161     SA_DBG1(("siDumpActiveIORequests: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_3_Register)));
162   }
163 
164   for ( i = 0; i < saRoot->QueueConfig.numOutboundQueues; i++ )
165   {
166     circularQ = &saRoot->outboundQueue[i];
167     OSSA_READ_LE_32(circularQ->agRoot, &circularQ->producerIdx, circularQ->piPointer, 0);
168     if(circularQ->producerIdx != circularQ->consumerIdx)
169     {
170       SA_DBG1(("siDumpActiveIORequests:OBQ%d PI 0x%03x CI 0x%03x\n", i,circularQ->producerIdx, circularQ->consumerIdx  ));
171     }
172   }
173 
174   pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
175   SA_DBG1(("siDumpActiveIORequests: Current Time: %d ticks (usecpertick=%d)\n",
176     saRoot->timeTick, saRoot->usecsPerTick));
177 
178   for ( j = 0; j < count; j ++ )
179   {
180     pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
181 
182     if (pRequestDesc->valid == agTRUE)
183     {
184       num_found++;
185       SA_DBG1(("siDumpActiveIORequests: IO #%4d: %p Tag=%03X  Type=%08X Device 0x%X Pending for %d seconds\n",
186         j,
187         pRequestDesc->pIORequestContext,
188         pRequestDesc->HTag,
189         pRequestDesc->requestType,
190         pRequestDesc->pDevice ? pRequestDesc->pDevice->DeviceMapIndex : 0,
191         ((saRoot->timeTick - pRequestDesc->startTick)*saRoot->usecsPerTick)/1000000 ));
192 
193     }
194   }
195   if(count)
196   {
197     SA_DBG1(("siDumpActiveIORequests: %d found active\n",num_found));
198   }
199 
200 }
201 
202 /******************************************************************************/
203 /*! \brief saCountActiveIORequests
204  *
205  *
206  *  \param char value
207  *
208  *  \return -void-
209  *
210  */
211 /*******************************************************************************/
212 GLOBAL void
213 siClearActiveIORequests(
214   agsaRoot_t              *agRoot)
215 {
216   bit32                 j;
217   bit32                 num_found = 0;
218   agsaIORequestDesc_t   *pRequestDesc = agNULL;
219   agsaLLRoot_t          *saRoot = agNULL;
220 
221   /* sanity check */
222   SA_ASSERT((agNULL != agRoot), "");
223   saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
224   SA_ASSERT((agNULL != saRoot), "");
225 
226   if(saRoot)
227   {
228     pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
229 
230     for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
231     {
232       pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
233 
234       if (pRequestDesc->valid == agTRUE)
235       {
236         num_found++;
237         pRequestDesc->valid =  agFALSE;
238       }
239     }
240     if(num_found)
241     {
242       SA_DBG1(("siClearActiveIORequests %d found active\n",num_found));
243     }
244   }
245   else
246   {
247      SA_DBG1(("siClearActiveIORequests saroot NULL\n"));
248   }
249 
250 }
251 
252 /******************************************************************************/
253 /*! \brief siCountActiveIORequestsOnDevice
254  *   count all active IO's
255  *
256  *  \param char value
257  *
258  *  \return -void-
259  *
260  */
261 /*******************************************************************************/
262 GLOBAL void
263 siClearActiveIORequestsOnDevice(
264   agsaRoot_t *agRoot,
265   bit32      device )
266 {
267   bit32                 j, num_found = 0;
268   agsaIORequestDesc_t   *pRequestDesc = agNULL;
269   agsaLLRoot_t          *saRoot = agNULL;
270 
271   /* sanity check */
272   SA_ASSERT((agNULL != agRoot), "");
273   saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
274   SA_ASSERT((agNULL != saRoot), "");
275 
276   pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
277 
278   for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
279   {
280     pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
281 
282     if (pRequestDesc->valid == agTRUE)
283     {
284       if (pRequestDesc->pDevice)
285       {
286         if (pRequestDesc->pDevice->DeviceMapIndex == device)
287         {
288           num_found++;
289           pRequestDesc->valid = agFALSE;
290         }
291       }
292     }
293   }
294   if(num_found)
295   {
296     SA_DBG1(("siClearActiveIORequestsOnDevice 0x%x %d cleared\n",device,num_found));
297   }
298 
299 }
300 
301 
302 
303 /******************************************************************************/
304 /*! \brief siCountActiveIORequestsOnDevice
305  *   count all active IO's
306  *
307  *  \param char value
308  *
309  *  \return -void-
310  *
311  */
312 /*******************************************************************************/
313 GLOBAL void
314 siCountActiveIORequestsOnDevice(
315   agsaRoot_t *agRoot,
316   bit32      device )
317 {
318   bit32                 j, num_found = 0;
319   agsaIORequestDesc_t   *pRequestDesc = agNULL;
320   agsaLLRoot_t          *saRoot = agNULL;
321 
322   /* sanity check */
323   SA_ASSERT((agNULL != agRoot), "");
324   saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
325   SA_ASSERT((agNULL != saRoot), "");
326 
327   pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
328 
329   for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
330   {
331     pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
332 
333     if (pRequestDesc->valid == agTRUE)
334     {
335       if (pRequestDesc->pDevice)
336       {
337         if (pRequestDesc->pDevice->DeviceMapIndex == device)
338         {
339           num_found++;
340           if(saRoot->ResetStartTick > pRequestDesc->startTick)
341           {
342             SA_DBG2(("siCountActiveIORequestsOnDevice: saRoot->ResetStartTick %d pRequestDesc->startTick %d\n",
343                     saRoot->ResetStartTick, pRequestDesc->startTick));
344           }
345         }
346       }
347     }
348   }
349   if(num_found)
350   {
351     SA_DBG1(("siCountActiveIORequestsOnDevice 0x%x %d found active\n",device,num_found));
352   }
353 
354 }
355 
356 
357 
358 /******************************************************************************/
359 /*! \brief saCountActiveIORequests
360  *   count all active IO's
361  *
362  *  \param char value
363  *
364  *  \return -void-
365  *
366  */
367 /*******************************************************************************/
368 GLOBAL void
369 saCountActiveIORequests(
370   agsaRoot_t              *agRoot)
371 {
372   bit32                 j, num_found = 0;
373   agsaIORequestDesc_t   *pRequestDesc = agNULL;
374   agsaLLRoot_t          *saRoot = agNULL;
375 
376   /* sanity check */
377   SA_ASSERT((agNULL != agRoot), "");
378   if( agRoot == agNULL)
379   {
380     return;
381   }
382   saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
383   if( saRoot == agNULL)
384   {
385     return;
386   }
387   pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), 0);
388 
389   for ( j = 0; j < saRoot->swConfig.maxActiveIOs; j++ )
390   {
391     pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), j);
392 
393     if (pRequestDesc->valid == agTRUE)
394     {
395       num_found++;
396       if(saRoot->ResetStartTick > pRequestDesc->startTick)
397       {
398         SA_DBG2(("saCountActiveIORequests: saRoot->ResetStartTick %d pRequestDesc->startTick %d\n",
399                 saRoot->ResetStartTick, pRequestDesc->startTick));
400       }
401     }
402   }
403   if(num_found)
404   {
405     SA_DBG1(("saCountActiveIORequests %d found active\n",num_found));
406   }
407 
408 }
409 
410 
411 GLOBAL bit32 smIsCfg_V_ANY( agsaRoot_t *agRoot)
412 {
413 
414   if(smIsCfg_V8008(agRoot) == 1) return 1;
415   if(smIsCfg_V8009(agRoot) == 1) return 1;
416   if(smIsCfg_V8018(agRoot) == 1) return 1;
417   if(smIsCfg_V8019(agRoot) == 1) return 1;
418   if(smIsCfg_V8088(agRoot) == 1) return 1;
419   if(smIsCfg_V8089(agRoot) == 1) return 1;
420   if(smIsCfg_V8070(agRoot) == 1) return 1;
421   if(smIsCfg_V8071(agRoot) == 1) return 1;
422   if(smIsCfg_V8072(agRoot) == 1) return 1;
423   if(smIsCfg_V8073(agRoot) == 1) return 1;
424   if(smIS_SPCV8074(agRoot) == 1) return 1;
425   if(smIS_SPCV8075(agRoot) == 1) return 1;
426   if(smIS_SPCV8076(agRoot) == 1) return 1;
427   if(smIS_SPCV8077(agRoot) == 1) return 1;
428   if(smIsCfg_V8025(agRoot) == 1) return 1;
429   if(smIsCfg_V9015(agRoot) == 1) return 1;
430   if(smIsCfg_V9060(agRoot) == 1) return 1;
431   if(smIsCfg_V8006(agRoot) == 1) return 1;
432 
433   return 0;
434 }
435 
436 GLOBAL bit32 smIS_SPC( agsaRoot_t *agRoot)
437 {
438   if(smIS_spc8001(agRoot)    == 1) return 1;
439   if(smIS_spc8081(agRoot)    == 1) return 1;
440   if(smIS_SFC_AS_SPC(agRoot) == 1) return 1;
441   return 0;
442 }
443 
444 
445 GLOBAL bit32 smIS_HIL( agsaRoot_t *agRoot) /* or delray */
446 {
447   if(smIS_spc8081(agRoot)  == 1) return 1;
448   if(smIS_ADAP8088(agRoot) == 1) return 1;
449   if(smIS_ADAP8089(agRoot) == 1) return 1;
450   if(smIS_SPCV8074(agRoot) == 1) return 1;
451   if(smIS_SPCV8075(agRoot) == 1) return 1;
452   if(smIS_SPCV8076(agRoot) == 1) return 1;
453   if(smIS_SPCV8077(agRoot) == 1) return 1;
454   return 0;
455 
456 }
457 
458 GLOBAL bit32 smIS_SPC6V( agsaRoot_t *agRoot)
459 {
460   if(smIS_SPCV8008(agRoot) == 1) return 1;
461   if(smIS_SPCV8009(agRoot) == 1) return 1;
462   if(smIS_SPCV8018(agRoot) == 1) return 1;
463   if(smIS_SPCV8019(agRoot) == 1) return 1;
464   if(smIS_ADAP8088(agRoot) == 1) return 1;
465   if(smIS_ADAP8089(agRoot) == 1) return 1;
466   return 0;
467 }
468 
469 GLOBAL bit32 smIS_SPC12V( agsaRoot_t *agRoot)
470 {
471   if(smIS_SPCV8070(agRoot) == 1) return 1;
472   if(smIS_SPCV8071(agRoot) == 1) return 1;
473   if(smIS_SPCV8072(agRoot) == 1) return 1;
474   if(smIS_SPCV8073(agRoot) == 1) return 1;
475   if(smIS_SPCV8074(agRoot) == 1) return 1;
476   if(smIS_SPCV8075(agRoot) == 1) return 1;
477   if(smIS_SPCV8076(agRoot) == 1) return 1;
478   if(smIS_SPCV8077(agRoot) == 1) return 1;
479   if(smIS_SPCV9015(agRoot) == 1) return 1;
480   if(smIS_SPCV9060(agRoot) == 1) return 1;
481   if(smIS_SPCV8006(agRoot) == 1) return 1;
482   return 0;
483 }
484 
485 GLOBAL bit32 smIS_SPCV_2_IOP( agsaRoot_t *agRoot)
486 {
487   if(smIS_SPCV8009(agRoot) == 1) return 1;
488   if(smIS_SPCV8018(agRoot) == 1) return 1;
489   if(smIS_SPCV8019(agRoot) == 1) return 1;
490   if(smIS_SPCV8071(agRoot) == 1) return 1;
491   if(smIS_SPCV8072(agRoot) == 1) return 1;
492   if(smIS_SPCV8073(agRoot) == 1) return 1;
493   if(smIS_SPCV8076(agRoot) == 1) return 1;
494   if(smIS_SPCV8077(agRoot) == 1) return 1;
495   if(smIS_ADAP8088(agRoot) == 1) return 1;
496   if(smIS_ADAP8089(agRoot) == 1) return 1;
497   if(smIS_SPCV8006(agRoot) == 1) return 1;
498   return 0;
499 }
500 
501 GLOBAL bit32 smIS_SPCV( agsaRoot_t *agRoot)
502 {
503   if(smIS_SPC6V(agRoot)    == 1) return 1;
504   if(smIS_SPC12V(agRoot)   == 1) return 1;
505   if(smIS_SFC_AS_V(agRoot) == 1 ) return 1;
506   return 0;
507 }
508 
509 GLOBAL bit32 smIS_ENCRYPT( agsaRoot_t *agRoot)
510 {
511   if(smIS_SPCV8009(agRoot) == 1) return 1;
512   if(smIS_ADAP8088(agRoot) == 1) return 1;
513   if(smIS_SPCV8019(agRoot) == 1) return 1;
514   if(smIS_SPCV8071(agRoot) == 1) return 1;
515   if(smIS_SPCV8073(agRoot) == 1) return 1;
516   if(smIS_SPCV8077(agRoot) == 1) return 1;
517   if(smIS_SPCV9015(agRoot) == 1) return 1;
518   if(smIS_SPCV9060(agRoot) == 1) return 1;
519   return 0;
520 }
521 
522 
523 
524 #if defined(SALLSDK_DEBUG)
525 
526 /******************************************************************************/
527 /*! \brief Routine print buffer
528  *
529  *
530  *  \param debugLevel     verbosity level
531  *  \param header         header to print
532  *  \param buffer         buffer to print
533  *  \param  length        length of buffer in bytes
534  *
535  *  \return -void-
536  *
537  */
538 /*******************************************************************************/
539 GLOBAL void siPrintBuffer(
540   bit32                 debugLevel,
541   siPrintType           type,
542   char                  *header,
543   void                  *a,
544   bit32                 length
545   )
546 {
547   bit32 x, rem;
548   bit8 *buffer = (bit8 *)a;
549   bit32 *lPtr;
550   bit8 temp[16];
551 
552   ossaLogDebugString(gLLDebugLevel, debugLevel, ("%s\n", header));
553 
554   if (type == SA_8)
555   {
556     for (x=0; x < length/16; x++)
557     {
558       ossaLogDebugString(gLLDebugLevel, debugLevel,
559         ("%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x  == "
560          "%c%c%c%c%c%c%c%c - %c%c%c%c%c%c%c%c\n",
561         *(buffer),
562         *(buffer+1),
563         *(buffer+2),
564         *(buffer+3),
565         *(buffer+4),
566         *(buffer+5),
567         *(buffer+6),
568         *(buffer+7),
569         *(buffer+8),
570         *(buffer+9),
571         *(buffer+10),
572         *(buffer+11),
573         *(buffer+12),
574         *(buffer+13),
575         *(buffer+14),
576         *(buffer+15),
577         siIsHexDigit(*(buffer)) ? *(buffer) : ' ',
578         siIsHexDigit(*(buffer+1)) ? *(buffer+1) : ' ',
579         siIsHexDigit(*(buffer+2)) ? *(buffer+2) : ' ',
580         siIsHexDigit(*(buffer+3)) ? *(buffer+3) : ' ',
581         siIsHexDigit(*(buffer+4)) ? *(buffer+4) : ' ',
582         siIsHexDigit(*(buffer+5)) ? *(buffer+5) : ' ',
583         siIsHexDigit(*(buffer+6)) ? *(buffer+6) : ' ',
584         siIsHexDigit(*(buffer+7)) ? *(buffer+7) : ' ',
585         siIsHexDigit(*(buffer+8)) ? *(buffer+8) : ' ',
586         siIsHexDigit(*(buffer+9)) ? *(buffer+9) : ' ',
587         siIsHexDigit(*(buffer+10)) ? *(buffer+10) : ' ',
588         siIsHexDigit(*(buffer+11)) ? *(buffer+11) : ' ',
589         siIsHexDigit(*(buffer+12)) ? *(buffer+12) : ' ',
590         siIsHexDigit(*(buffer+13)) ? *(buffer+13) : ' ',
591         siIsHexDigit(*(buffer+14)) ? *(buffer+14) : ' ',
592         siIsHexDigit(*(buffer+15)) ? *(buffer+15) : ' ')
593         );
594 
595       buffer += 16;
596     }
597 
598     rem = length%16;
599     if (rem)
600     {
601       for (x = 0; x < 16; x++)
602       {
603         temp[x] = ' ';
604       }
605 
606       for (x = 0; x < rem; x++)
607       {
608         temp[x] = *(buffer+x);
609       }
610 
611       buffer = temp;
612 
613       ossaLogDebugString(gLLDebugLevel, debugLevel,
614         ("%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x  == "
615          "%c%c%c%c%c%c%c%c - %c%c%c%c%c%c%c%c\n",
616         *(buffer),
617         *(buffer+1),
618         *(buffer+2),
619         *(buffer+3),
620         *(buffer+4),
621         *(buffer+5),
622         *(buffer+6),
623         *(buffer+7),
624         *(buffer+8),
625         *(buffer+9),
626         *(buffer+10),
627         *(buffer+11),
628         *(buffer+12),
629         *(buffer+13),
630         *(buffer+14),
631         *(buffer+15),
632         siIsHexDigit(*(buffer)) ? *(buffer) : ' ',
633         siIsHexDigit(*(buffer+1)) ? *(buffer+1) : ' ',
634         siIsHexDigit(*(buffer+2)) ? *(buffer+2) : ' ',
635         siIsHexDigit(*(buffer+3)) ? *(buffer+3) : ' ',
636         siIsHexDigit(*(buffer+4)) ? *(buffer+4) : ' ',
637         siIsHexDigit(*(buffer+5)) ? *(buffer+5) : ' ',
638         siIsHexDigit(*(buffer+6)) ? *(buffer+6) : ' ',
639         siIsHexDigit(*(buffer+7)) ? *(buffer+7) : ' ',
640         siIsHexDigit(*(buffer+8)) ? *(buffer+8) : ' ',
641         siIsHexDigit(*(buffer+9)) ? *(buffer+9) : ' ',
642         siIsHexDigit(*(buffer+10)) ? *(buffer+10) : ' ',
643         siIsHexDigit(*(buffer+11)) ? *(buffer+11) : ' ',
644         siIsHexDigit(*(buffer+12)) ? *(buffer+12) : ' ',
645         siIsHexDigit(*(buffer+13)) ? *(buffer+13) : ' ',
646         siIsHexDigit(*(buffer+14)) ? *(buffer+14) : ' ',
647         siIsHexDigit(*(buffer+15)) ? *(buffer+15) : ' ')
648         );
649     }
650   }
651   else
652   {
653     bit32 *ltemp = (bit32 *)temp;
654     lPtr = (bit32 *) a;
655 
656     for (x=0; x < length/4; x++)
657     {
658       ossaLogDebugString(gLLDebugLevel, debugLevel,
659         ("%08x %08x %08x %08x\n",
660         *(lPtr),
661         *(lPtr+1),
662         *(lPtr+2),
663         *(lPtr+3))
664         );
665 
666       lPtr += 4;
667     }
668 
669     rem = length%4;
670     if (rem)
671     {
672       for (x = 0; x < 4; x++)
673       {
674         ltemp[x] = 0;
675       }
676 
677       for (x = 0; x < rem; x++)
678       {
679         ltemp[x] = lPtr[x];
680       }
681 
682       lPtr = ltemp;
683 
684       ossaLogDebugString(gLLDebugLevel, debugLevel,
685         ("%08x %08x %08x %08x\n",
686         *(lPtr),
687         *(lPtr+1),
688         *(lPtr+2),
689         *(lPtr+3))
690         );
691     }
692   }
693 
694 }
695 
696 
697 
698 void sidump_hwConfig(agsaHwConfig_t  *hwConfig)
699 {
700   SA_DBG2(("sidump_hwConfig:hwConfig->hwInterruptCoalescingTimer                             0x%x\n",hwConfig->hwInterruptCoalescingTimer                            ));
701   SA_DBG2(("sidump_hwConfig:hwConfig->hwInterruptCoalescingControl                           0x%x\n",hwConfig->hwInterruptCoalescingControl                          ));
702   SA_DBG2(("sidump_hwConfig:hwConfig->intReassertionOption                                   0x%x\n",hwConfig->intReassertionOption                                  ));
703   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister0  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister0 ));
704   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister1  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister1 ));
705   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister2  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister2 ));
706   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister3  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister3 ));
707   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister4  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister4 ));
708   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister5  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister5 ));
709   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister6  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister6 ));
710   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister7  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister7 ));
711   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister8  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister8 ));
712   SA_DBG2(("sidump_hwConfig:hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister9  0x%x\n",hwConfig->phyAnalogConfig.phyAnalogSetupRegisters->spaRegister9 ));
713   SA_DBG2(("sidump_hwConfig:hwConfig->hwOption                                               0x%x\n",hwConfig->hwOption                                              ));
714 }
715 
716 void sidump_swConfig(agsaSwConfig_t  *swConfig)
717 {
718   SA_DBG2(("sidump_swConfig:swConfig->maxActiveIOs               0x%x\n",swConfig->maxActiveIOs              ));
719   SA_DBG2(("sidump_swConfig:swConfig->numDevHandles              0x%x\n",swConfig->numDevHandles             ));
720   SA_DBG2(("sidump_swConfig:swConfig->smpReqTimeout              0x%x\n",swConfig->smpReqTimeout             ));
721   SA_DBG2(("sidump_swConfig:swConfig->numberOfEventRegClients    0x%x\n",swConfig->numberOfEventRegClients   ));
722   SA_DBG2(("sidump_swConfig:swConfig->sizefEventLog1             0x%x\n",swConfig->sizefEventLog1            ));
723   SA_DBG2(("sidump_swConfig:swConfig->sizefEventLog2             0x%x\n",swConfig->sizefEventLog2            ));
724   SA_DBG2(("sidump_swConfig:swConfig->eventLog1Option            0x%x\n",swConfig->eventLog1Option           ));
725   SA_DBG2(("sidump_swConfig:swConfig->eventLog2Option            0x%x\n",swConfig->eventLog2Option           ));
726   SA_DBG2(("sidump_swConfig:swConfig->fatalErrorInterruptEnable  0x%x\n",swConfig->fatalErrorInterruptEnable ));
727   SA_DBG2(("sidump_swConfig:swConfig->fatalErrorInterruptVector  0x%x\n",swConfig->fatalErrorInterruptVector ));
728   SA_DBG2(("sidump_swConfig:swConfig->max_MSI_InterruptVectors   0x%x\n",swConfig->max_MSI_InterruptVectors  ));
729   SA_DBG2(("sidump_swConfig:swConfig->max_MSIX_InterruptVectors  0x%x\n",swConfig->max_MSIX_InterruptVectors ));
730   SA_DBG2(("sidump_swConfig:swConfig->legacyInt_X                0x%x\n",swConfig->legacyInt_X               ));
731   SA_DBG2(("sidump_swConfig:swConfig->hostDirectAccessSupport    0x%x\n",swConfig->hostDirectAccessSupport   ));
732   SA_DBG2(("sidump_swConfig:swConfig->hostDirectAccessMode       0x%x\n",swConfig->hostDirectAccessMode      ));
733   SA_DBG2(("sidump_swConfig:swConfig->param1                     0x%x\n",swConfig->param1                    ));
734   SA_DBG2(("sidump_swConfig:swConfig->param2                     0x%x\n",swConfig->param2                    ));
735   SA_DBG2(("sidump_swConfig:swConfig->param3                     %p\n",swConfig->param3                    ));
736   SA_DBG2(("sidump_swConfig:swConfig->param4                     %p\n",swConfig->param4                    ));
737 
738 }
739 
740 
741 void sidump_Q_config( agsaQueueConfig_t         *queueConfig )
742 {
743   bit32 x;
744 
745   SA_DBG2(("sidump_Q_config: queueConfig->generalEventQueue                0x%x\n", queueConfig->generalEventQueue                ));
746   SA_DBG2(("sidump_Q_config: queueConfig->numInboundQueues                 0x%x\n", queueConfig->numInboundQueues                 ));
747   SA_DBG2(("sidump_Q_config: queueConfig->numOutboundQueues                0x%x\n", queueConfig->numOutboundQueues                ));
748   SA_DBG2(("sidump_Q_config: queueConfig->iqHighPriorityProcessingDepth    0x%x\n", queueConfig->iqHighPriorityProcessingDepth    ));
749   SA_DBG2(("sidump_Q_config: queueConfig->iqNormalPriorityProcessingDepth  0x%x\n", queueConfig->iqNormalPriorityProcessingDepth  ));
750   SA_DBG2(("sidump_Q_config: queueConfig->queueOption                      0x%x\n", queueConfig->queueOption                      ));
751   SA_DBG2(("sidump_Q_config: queueConfig->tgtDeviceRemovedEventQueue       0x%x\n", queueConfig->tgtDeviceRemovedEventQueue       ));
752 
753   for(x=0;x < queueConfig->numInboundQueues;x++)
754   {
755     SA_DBG2(("sidump_Q_config: queueConfig->inboundQueues[%d].elementCount  0x%x\n",x,queueConfig->inboundQueues[x].elementCount  ));
756     SA_DBG2(("sidump_Q_config: queueConfig->inboundQueues[%d].elementSize   0x%x\n",x,queueConfig->inboundQueues[x].elementSize   ));
757   }
758 
759   for(x=0;x < queueConfig->numOutboundQueues;x++)
760   {
761 
762     SA_DBG2(("sidump_Q_config: queueConfig->outboundQueues[%d].elementCount 0x%x\n",x,queueConfig->outboundQueues[x].elementCount ));
763     SA_DBG2(("sidump_Q_config: queueConfig->outboundQueues[%d].elementSize  0x%x\n",x,queueConfig->outboundQueues[x].elementSize  ));
764   }
765 
766 }
767 #endif
768 
769 #ifdef SALL_API_TEST
770 /******************************************************************************/
771 /*! \brief Get Performance IO counters
772  *
773  *  Start/Abort SAS/SATA discovery
774  *
775  *  \param agRoot         Handles for this instance of SAS/SATA hardware
776  *  \param counters       bit map of the counters
777  *  \param LLCountInfo    pointer to the LLCounters
778  *
779  *  \return
780  *          - \e AGSA_RC_SUCCESS
781  *
782  */
783 /*******************************************************************************/
784 GLOBAL bit32 saGetLLCounters(
785                       agsaRoot_t          *agRoot,
786                       bit32               counters,
787                       agsaLLCountInfo_t   *LLCountInfo
788                       )
789 {
790   agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
791   bit32 i;
792 
793   for (i = 0; i < LL_COUNTERS; i++)
794   {
795     if (counters & (1 << i))
796       LLCountInfo->arrayIOCounter[i] = saRoot->LLCounters.arrayIOCounter[i];
797   }
798 
799   return AGSA_RC_SUCCESS;
800 }
801 
802 /******************************************************************************/
803 /*! \brief Function for target to remove stale initiator device handle
804  *
805  *  function is called to ask the LL layer to remove all LL layer and SPC firmware
806  *  internal resources associated with a device handle
807  *
808  *  \param agRoot       Handles for this instance of SAS/SATA hardware
809  *  \param counters     Bit map of the IO counters
810  *
811  *  \return
812  *          - \e AGSA_RC_SUCCESS
813  *
814  */
815 /*******************************************************************************/
816 GLOBAL bit32 saResetLLCounters(
817                       agsaRoot_t *agRoot,
818                       bit32      counters
819                       )
820 {
821   agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
822   bit32 i;
823 
824   for (i = 0; i < LL_COUNTERS; i++)
825   {
826     if (counters & (1 << i))
827       saRoot->LLCounters.arrayIOCounter[i] = 0;
828   }
829 
830   return AGSA_RC_SUCCESS;
831 }
832 #endif
833 
834