xref: /freebsd/sys/dev/pms/RefTisa/sallsdk/spc/mpidebug.h (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
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 
24 /*******************************************************************************/
25 /*! \file mpidebug.h
26  *  \brief The file defines the debug constants and structures
27  *
28  */
29 /*******************************************************************************/
30 
31 #ifndef __MPIDEBUG_H__
32 #define __MPIDEBUG_H__
33 
34 /*******************************************************************************/
35 #define MPI_DEBUG_TRACE_BUFFER_MAX  1024
36 #define MPI_DEBUG_TRACE_OB_IOMB_SIZE   128 /* 64 */
37 #define MPI_DEBUG_TRACE_IB_IOMB_SIZE   128 /* 64 */
38 #define MPI_DEBUG_TRACE_IBQ   1
39 #define MPI_DEBUG_TRACE_OBQ   0
40 #define MPI_DEBUG_TRACE_QNUM_ERROR   100 /* Added to Qnumber to indicate error */
41 
42 typedef struct mpiObDebugTraceEntry_s
43 {
44   bit64       Time;
45   bit32       QNum;
46   bit32       pici;
47   void *      pEntry;
48   bit32       Iomb[MPI_DEBUG_TRACE_OB_IOMB_SIZE/4];
49 } mpiDebugObTraceEntry_t;
50 
51 typedef struct mpiIbDebugTraceEntry_s
52 {
53   bit64       Time;
54   bit32       QNum;
55   bit32       pici;
56   void *      pEntry;
57   bit32       Iomb[MPI_DEBUG_TRACE_IB_IOMB_SIZE/4];
58 } mpiDebugIbTraceEntry_t;
59 
60 typedef struct mpiIbDebugTrace_s
61 {
62   bit32                 Idx;
63   bit32                 Pad;
64   mpiDebugIbTraceEntry_t  Data[MPI_DEBUG_TRACE_BUFFER_MAX];
65 } mpiDebugIbTrace_t;
66 
67 typedef struct mpiObDebugTrace_s
68 {
69   bit32                 Idx;
70   bit32                 Pad;
71   mpiDebugObTraceEntry_t  Data[MPI_DEBUG_TRACE_BUFFER_MAX];
72 } mpiDebugObTrace_t;
73 
74 void mpiTraceInit(void);
75 void mpiTraceAdd(bit32 q,bit32 pici,bit32 ib, void *iomb, bit32 numBytes);
76 
77 #endif /* __MPIDEBUG_H__ */
78 
79 
80 
81 
82 /********************************************************************
83 **  File that contains debug-specific APIs ( driver tracing etc )
84 *********************************************************************/
85 
86 #ifndef __SPCDEBUG_H__
87 #define __SPCDEBUG_H__
88 
89 
90 /*
91 ** console and trace levels
92 */
93 
94 #define  hpDBG_ALWAYS     0x0000ffff
95 #define  hpDBG_IOMB       0x00000040
96 #define  hpDBG_REGISTERS  0x00000020
97 #define  hpDBG_TICK_INT   0x00000010
98 #define  hpDBG_SCREAM     0x00000008
99 #define  hpDBG_VERY_LOUD  0x00000004
100 #define  hpDBG_LOUD       0x00000002
101 #define  hpDBG_ERROR      0x00000001
102 #define  hpDBG_NEVER      0x00000000
103 
104 #define smTraceDestBuffer    0x00000001
105 #define smTraceDestRegister  0x00000002
106 #define smTraceDestDebugger  0x00000004
107 
108 
109 #define siTraceDestMask     (smTraceDestBuffer    |  \
110                              smTraceDestRegister  |  \
111                              smTraceDestDebugger)
112 
113 /* Trace buffer will continuously  */
114 /* trace and wrap-around on itself */
115 /* when it reaches the end         */
116 #define hpDBG_TraceBufferWrapAround   0x80000000
117 /* This features enables logging of trace time       */
118 /* stamps.  Only certain key routines use this       */
119 /* feature because it tends to clog up the trace     */
120 /* buffer.                                           */
121 #define hpDBG_TraceBufferUseTimeStamp 0x40000000
122 /* This features enables logging of trace sequential */
123 /* stamps.  Only certain key routines use this       */
124 /* feature because it tends to clog up the trace     */
125 /* buffer.                                           */
126 #define hpDBG_TraceBufferUseSequenceStamp 0x20000000
127 
128 /* Trace IDs of various state machines */
129 #define fiTraceSmChip   'C'
130 #define fiTraceSmPort   'P'
131 #define fiTraceSmLogin  'L'
132 #define fiTraceSmXchg   'X'
133 #define fiTraceSmFabr   'F'
134 #define fiTraceDiscFab  'D'
135 #define fiTraceDiscLoop 'M'
136 #define fiTraceFc2      'A'
137 #define fiTraceTgtState 'S'
138 #define fiTraceIniState 'I'
139 
140 /* Trace IDs of various queues  */
141 #define fiSfsFreeList   'Z'
142 #define fiSestFreeList  'W'
143 #define fiOsSfsFreeList 'G'
144 #define fiLgnFreeList   'K'
145 #define fiPortalFreeList  'l'
146 #define fiBusyList      'N'
147 #define fiOsSfsAllocList     'B'
148 #define fiTimerList         'V'
149 #define fiSfsWaitForRspList 'I'
150 #define fiLgnBusyList   'J'
151 #define fiPortalBusyList  'g'
152 #define fiWait4ErqList  'o'
153 #define fiXchgAbortList   'U'
154 #define fiXchgWaitList 'b'
155 
156 /* not used right now */
157 #define fiSfsDeferFreeList  'q'
158 #define fiDeferBusyList     'm'
159 #define fiInvalidList   'X'
160 #define fiInvalidatedList   'a'
161 #define fiTmpXchList    'n'
162 
163 #define TMP_TRACE_BUFF_SIZE  32
164 #define FC_TRACE_LINE_SIZE   70
165 /******************************************************************************/
166 /* Macro Conventions:  we are assuming that the macros will be called inside  */
167 /*                     a function that already has a workable saRoot variable */
168 /******************************************************************************/
169 
170 /******************************************************************************/
171 /* fiTraceState : ==>        _!n_        _ss: XXXXXXXX       _se: XXXXXXXX    */
172 /*              statemachine --^     currentstate--^    triggerevent--^       */
173 /*              NOTE: shorthand forms available as macros below.              */
174 /******************************************************************************/
175 #ifdef SA_ENABLE_TRACE_FUNCTIONS
176 
177 
178 void siResetTraceBuffer(agsaRoot_t  *agRoot);
179 void siTraceFuncEnter(agsaRoot_t  *agRoot, bit32 mask, bit32 fileid, char *funcid);
180 
181 
182 GLOBAL void siTraceFuncExit(   agsaRoot_t  *agRoot,  bit32   mask, char  fileid, char  * funcid, char  exitId );
183 
184 
185 void siTrace(agsaRoot_t  *agRoot, bit32 mask, char *uId, bit32 value, bit32 dataSizeInBits);
186 void siTrace64(agsaRoot_t  *agRoot, bit32 mask, char *uId, bit64 value, bit32 dataSizeInBits);
187 bit32 siGetCurrentTraceIndex(agsaRoot_t  *agRoot);
188 void siTraceListRemove(agsaRoot_t  *agRoot, bit32 mask, char listId, bitptr exchangeId);
189 void siTraceListAdd(agsaRoot_t  *agRoot, bit32 mask, char listId, bitptr exchangeId);
190 void siTraceState(agsaRoot_t  *agRoot, bit32 mask, bit32 statemachine, bit32 currentstate, bit32 triggerevent);
191 
192 #define smTraceState(L,S,C,T)     siTraceState(agRoot,L,S,C,T)
193 #define smTraceChipState(L,C,T)   siTraceState(agRoot,L,fiTraceSmChip,C,T)
194 #define smTraceFabricState(L,C,T) siTraceState(agRoot,L,fiTraceSmFabr,C,T)
195 #define smTracePortState(L,C,T)   siTraceState(agRoot,L,fiTraceSmPort,C,T)
196 #define smTraceLoginState(L,C,T)  siTraceState(agRoot,L,fiTraceSmLogin,C,T)
197 #define smTraceXchgState(L,C,T)   siTraceState(agRoot,L,fiTraceSmXchg,C,T)
198 #define smTraceDiscFabState(L,C,T)    siTraceState(agRoot,L,fiTraceDiscFab,C,T)
199 #define smTraceDiscLoopState(L,C,T)   siTraceState(agRoot,L,fiTraceDiscLoop,C,T)
200 #define smTraceFc2State(L,C,T)    siTraceState(agRoot,L,fiTraceFc2,C,T)
201 #define smTraceScsiTgtState(L,C,T)    siTraceState(agRoot,L,fiTraceTgtState,C,T)
202 #define smTraceScsiIniState(L,C,T)    siTraceState(agRoot,L,fiTraceIniState,C,T)
203 
204 #define smResetTraceBuffer(L)   siResetTraceBuffer(L)
205 #define smTraceFuncEnter(L,I)  siTraceFuncEnter(agRoot,L,siTraceFileID,I)
206 #define smTraceFuncExit(L,S,I)  siTraceFuncExit(agRoot,L,siTraceFileID,I,S)
207 #define smGetCurrentTraceIndex(L)   siGetCurrentTraceIndex(L)
208 #define smTraceListRemove(R,L,I,V)   siTraceListRemove(R,L,I,V)
209 #define smTraceListAdd(R,L,I,V)   siTraceListAdd(R,L,I,V)
210 
211 #define smTrace(L,I,V)                                        \
212     /*lint -e506 */                                           \
213     /*lint -e774 */                                           \
214     if (sizeof(V) == 8) {siTrace64(agRoot,L,I,(bit64)V,64);}  \
215     else {siTrace(agRoot,L,I,(bit32)V,32);}                   \
216     /*lint +e506 */                                           \
217     /*lint +e774 */
218 
219 
220 #else
221 
222 #define siTraceState(agRoot,L,fiTraceSmXchg,C,T)
223 
224 #define smTraceState(L,S,C,T)
225 #define smTraceChipState(L,C,T)
226 #define smTraceFabricState(L,C,T)
227 #define smTracePortState(L,C,T)
228 #define smTraceLoginState(L,C,T)
229 #define smTraceXchgState(L,C,T)
230 #define smTraceDiscFabState(L,C,T)
231 #define smTraceDiscLoopState(L,C,T)
232 #define smTraceFc2State(L,C,T)
233 #define smTraceScsiTgtState(L,C,T)
234 #define smTraceScsiIniState(L,C,T)
235 
236 #define smResetTraceBuffer(agRoot)
237 #define smTraceFuncEnter(L,I)
238 #define smTraceFuncExit(L,S,I)
239 #define smGetCurrentTraceIndex(L)
240 #define smTraceListRemove(L,I,V)
241 #define smTraceListAdd(L,I,V)
242 
243 #define smTrace(L,I,V)
244 
245 #endif
246 
247 struct hpTraceBufferParms_s {
248   bit32 TraceCompiled;
249   bit32 BufferSize;
250   bit32 CurrentTraceIndexWrapCount;
251   bit32 CurrentIndex;
252   bit32 TraceWrap;
253   bit8  * pTrace;
254   bit32 * pCurrentTraceIndex;
255   bit32 * pTraceIndexWrapCount;
256   bit32 * pTraceMask;
257 };
258 typedef struct hpTraceBufferParms_s
259                hpTraceBufferParms_t;
260 
261 #ifdef SA_ENABLE_TRACE_FUNCTIONS
262 
263 GLOBAL void siTraceGetInfo(agsaRoot_t  *agRoot, hpTraceBufferParms_t * pBParms);
264 
265 #define smTraceGetInfo(R,P)  siTraceGetInfo(R,P)
266 #else
267 #define smTraceGetInfo(R,P)
268 #endif
269 
270 
271 void siEnableTracing ( agsaRoot_t  *agRoot );
272 #ifdef SA_ENABLE_TRACE_FUNCTIONS
273 
274 GLOBAL void siTraceSetMask(agsaRoot_t  *agRoot, bit32 TraceMask  );
275 
276 #define smTraceSetMask(R,P)  siTraceSetMask(R,P)
277 #else
278 #define smTraceSetMask(R,P)
279 #endif /* SA_ENABLE_TRACE_FUNCTIONS */
280 
281 #endif /* #ifndef __SPCDEBUG_H__ */
282 
283