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