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