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* $FreeBSD$ 22285809Sscottl* 23285809Sscottl********************************************************************************/ 24285809Sscottl 25285809Sscottl/*******************************************************************************/ 26285809Sscottl/*! \file mpidebug.h 27285809Sscottl * \brief The file defines the debug constants and structures 28285809Sscottl * 29285809Sscottl */ 30285809Sscottl/*******************************************************************************/ 31285809Sscottl 32285809Sscottl#ifndef __MPIDEBUG_H__ 33285809Sscottl#define __MPIDEBUG_H__ 34285809Sscottl 35285809Sscottl/*******************************************************************************/ 36285809Sscottl#define MPI_DEBUG_TRACE_BUFFER_MAX 1024 37285809Sscottl#define MPI_DEBUG_TRACE_OB_IOMB_SIZE 128 /* 64 */ 38285809Sscottl#define MPI_DEBUG_TRACE_IB_IOMB_SIZE 128 /* 64 */ 39285809Sscottl#define MPI_DEBUG_TRACE_IBQ 1 40285809Sscottl#define MPI_DEBUG_TRACE_OBQ 0 41285809Sscottl#define MPI_DEBUG_TRACE_QNUM_ERROR 100 /* Added to Qnumber to indicate error */ 42285809Sscottl 43285809Sscottltypedef struct mpiObDebugTraceEntry_s 44285809Sscottl{ 45285809Sscottl bit64 Time; 46285809Sscottl bit32 QNum; 47285809Sscottl bit32 pici; 48285809Sscottl void * pEntry; 49285809Sscottl bit32 Iomb[MPI_DEBUG_TRACE_OB_IOMB_SIZE/4]; 50285809Sscottl} mpiDebugObTraceEntry_t; 51285809Sscottl 52285809Sscottltypedef struct mpiIbDebugTraceEntry_s 53285809Sscottl{ 54285809Sscottl bit64 Time; 55285809Sscottl bit32 QNum; 56285809Sscottl bit32 pici; 57285809Sscottl void * pEntry; 58285809Sscottl bit32 Iomb[MPI_DEBUG_TRACE_IB_IOMB_SIZE/4]; 59285809Sscottl} mpiDebugIbTraceEntry_t; 60285809Sscottl 61285809Sscottltypedef struct mpiIbDebugTrace_s 62285809Sscottl{ 63285809Sscottl bit32 Idx; 64285809Sscottl bit32 Pad; 65285809Sscottl mpiDebugIbTraceEntry_t Data[MPI_DEBUG_TRACE_BUFFER_MAX]; 66285809Sscottl} mpiDebugIbTrace_t; 67285809Sscottl 68285809Sscottltypedef struct mpiObDebugTrace_s 69285809Sscottl{ 70285809Sscottl bit32 Idx; 71285809Sscottl bit32 Pad; 72285809Sscottl mpiDebugObTraceEntry_t Data[MPI_DEBUG_TRACE_BUFFER_MAX]; 73285809Sscottl} mpiDebugObTrace_t; 74285809Sscottl 75285809Sscottlvoid mpiTraceInit(void); 76285809Sscottlvoid mpiTraceAdd(bit32 q,bit32 pici,bit32 ib, void *iomb, bit32 numBytes); 77285809Sscottl 78285809Sscottl#endif /* __MPIDEBUG_H__ */ 79285809Sscottl 80285809Sscottl 81285809Sscottl 82285809Sscottl 83285809Sscottl/******************************************************************** 84285809Sscottl** File that contains debug-specific APIs ( driver tracing etc ) 85285809Sscottl*********************************************************************/ 86285809Sscottl 87285809Sscottl#ifndef __SPCDEBUG_H__ 88285809Sscottl#define __SPCDEBUG_H__ 89285809Sscottl 90285809Sscottl 91285809Sscottl/* 92285809Sscottl** console and trace levels 93285809Sscottl*/ 94285809Sscottl 95285809Sscottl#define hpDBG_ALWAYS 0x0000ffff 96285809Sscottl#define hpDBG_IOMB 0x00000040 97285809Sscottl#define hpDBG_REGISTERS 0x00000020 98285809Sscottl#define hpDBG_TICK_INT 0x00000010 99285809Sscottl#define hpDBG_SCREAM 0x00000008 100285809Sscottl#define hpDBG_VERY_LOUD 0x00000004 101285809Sscottl#define hpDBG_LOUD 0x00000002 102285809Sscottl#define hpDBG_ERROR 0x00000001 103285809Sscottl#define hpDBG_NEVER 0x00000000 104285809Sscottl 105285809Sscottl#define smTraceDestBuffer 0x00000001 106285809Sscottl#define smTraceDestRegister 0x00000002 107285809Sscottl#define smTraceDestDebugger 0x00000004 108285809Sscottl 109285809Sscottl 110285809Sscottl#define siTraceDestMask (smTraceDestBuffer | \ 111285809Sscottl smTraceDestRegister | \ 112285809Sscottl smTraceDestDebugger) 113285809Sscottl 114285809Sscottl/* Trace buffer will continuously */ 115285809Sscottl/* trace and wrap-around on itself */ 116285809Sscottl/* when it reaches the end */ 117285809Sscottl#define hpDBG_TraceBufferWrapAround 0x80000000 118285809Sscottl/* This features enables logging of trace time */ 119285809Sscottl/* stamps. Only certain key routines use this */ 120285809Sscottl/* feature because it tends to clog up the trace */ 121285809Sscottl/* buffer. */ 122285809Sscottl#define hpDBG_TraceBufferUseTimeStamp 0x40000000 123285809Sscottl/* This features enables logging of trace sequential */ 124285809Sscottl/* stamps. Only certain key routines use this */ 125285809Sscottl/* feature because it tends to clog up the trace */ 126285809Sscottl/* buffer. */ 127285809Sscottl#define hpDBG_TraceBufferUseSequenceStamp 0x20000000 128285809Sscottl 129285809Sscottl/* Trace IDs of various state machines */ 130285809Sscottl#define fiTraceSmChip 'C' 131285809Sscottl#define fiTraceSmPort 'P' 132285809Sscottl#define fiTraceSmLogin 'L' 133285809Sscottl#define fiTraceSmXchg 'X' 134285809Sscottl#define fiTraceSmFabr 'F' 135285809Sscottl#define fiTraceDiscFab 'D' 136285809Sscottl#define fiTraceDiscLoop 'M' 137285809Sscottl#define fiTraceFc2 'A' 138285809Sscottl#define fiTraceTgtState 'S' 139285809Sscottl#define fiTraceIniState 'I' 140285809Sscottl 141285809Sscottl/* Trace IDs of various queues */ 142285809Sscottl#define fiSfsFreeList 'Z' 143285809Sscottl#define fiSestFreeList 'W' 144285809Sscottl#define fiOsSfsFreeList 'G' 145285809Sscottl#define fiLgnFreeList 'K' 146285809Sscottl#define fiPortalFreeList 'l' 147285809Sscottl#define fiBusyList 'N' 148285809Sscottl#define fiOsSfsAllocList 'B' 149285809Sscottl#define fiTimerList 'V' 150285809Sscottl#define fiSfsWaitForRspList 'I' 151285809Sscottl#define fiLgnBusyList 'J' 152285809Sscottl#define fiPortalBusyList 'g' 153285809Sscottl#define fiWait4ErqList 'o' 154285809Sscottl#define fiXchgAbortList 'U' 155285809Sscottl#define fiXchgWaitList 'b' 156285809Sscottl 157285809Sscottl/* not used right now */ 158285809Sscottl#define fiSfsDeferFreeList 'q' 159285809Sscottl#define fiDeferBusyList 'm' 160285809Sscottl#define fiInvalidList 'X' 161285809Sscottl#define fiInvalidatedList 'a' 162285809Sscottl#define fiTmpXchList 'n' 163285809Sscottl 164285809Sscottl#define TMP_TRACE_BUFF_SIZE 32 165285809Sscottl#define FC_TRACE_LINE_SIZE 70 166285809Sscottl/******************************************************************************/ 167285809Sscottl/* Macro Conventions: we are assuming that the macros will be called inside */ 168285809Sscottl/* a function that already has a workable saRoot variable */ 169285809Sscottl/******************************************************************************/ 170285809Sscottl 171285809Sscottl/******************************************************************************/ 172285809Sscottl/* fiTraceState : ==> _!n_ _ss: XXXXXXXX _se: XXXXXXXX */ 173285809Sscottl/* statemachine --^ currentstate--^ triggerevent--^ */ 174285809Sscottl/* NOTE: shorthand forms available as macros below. */ 175285809Sscottl/******************************************************************************/ 176285809Sscottl#ifdef SA_ENABLE_TRACE_FUNCTIONS 177285809Sscottl 178285809Sscottl 179285809Sscottlvoid siResetTraceBuffer(agsaRoot_t *agRoot); 180285809Sscottlvoid siTraceFuncEnter(agsaRoot_t *agRoot, bit32 mask, bit32 fileid, char *funcid); 181285809Sscottl 182285809Sscottl 183285809SscottlGLOBAL void siTraceFuncExit( agsaRoot_t *agRoot, bit32 mask, char fileid, char * funcid, char exitId ); 184285809Sscottl 185285809Sscottl 186285809Sscottlvoid siTrace(agsaRoot_t *agRoot, bit32 mask, char *uId, bit32 value, bit32 dataSizeInBits); 187285809Sscottlvoid siTrace64(agsaRoot_t *agRoot, bit32 mask, char *uId, bit64 value, bit32 dataSizeInBits); 188285809Sscottlbit32 siGetCurrentTraceIndex(agsaRoot_t *agRoot); 189285809Sscottlvoid siTraceListRemove(agsaRoot_t *agRoot, bit32 mask, char listId, bitptr exchangeId); 190285809Sscottlvoid siTraceListAdd(agsaRoot_t *agRoot, bit32 mask, char listId, bitptr exchangeId); 191285809Sscottlvoid siTraceState(agsaRoot_t *agRoot, bit32 mask, bit32 statemachine, bit32 currentstate, bit32 triggerevent); 192285809Sscottl 193285809Sscottl#define smTraceState(L,S,C,T) siTraceState(agRoot,L,S,C,T) 194285809Sscottl#define smTraceChipState(L,C,T) siTraceState(agRoot,L,fiTraceSmChip,C,T) 195285809Sscottl#define smTraceFabricState(L,C,T) siTraceState(agRoot,L,fiTraceSmFabr,C,T) 196285809Sscottl#define smTracePortState(L,C,T) siTraceState(agRoot,L,fiTraceSmPort,C,T) 197285809Sscottl#define smTraceLoginState(L,C,T) siTraceState(agRoot,L,fiTraceSmLogin,C,T) 198285809Sscottl#define smTraceXchgState(L,C,T) siTraceState(agRoot,L,fiTraceSmXchg,C,T) 199285809Sscottl#define smTraceDiscFabState(L,C,T) siTraceState(agRoot,L,fiTraceDiscFab,C,T) 200285809Sscottl#define smTraceDiscLoopState(L,C,T) siTraceState(agRoot,L,fiTraceDiscLoop,C,T) 201285809Sscottl#define smTraceFc2State(L,C,T) siTraceState(agRoot,L,fiTraceFc2,C,T) 202285809Sscottl#define smTraceScsiTgtState(L,C,T) siTraceState(agRoot,L,fiTraceTgtState,C,T) 203285809Sscottl#define smTraceScsiIniState(L,C,T) siTraceState(agRoot,L,fiTraceIniState,C,T) 204285809Sscottl 205285809Sscottl#define smResetTraceBuffer(L) siResetTraceBuffer(L) 206285809Sscottl#define smTraceFuncEnter(L,I) siTraceFuncEnter(agRoot,L,siTraceFileID,I) 207285809Sscottl#define smTraceFuncExit(L,S,I) siTraceFuncExit(agRoot,L,siTraceFileID,I,S) 208285809Sscottl#define smGetCurrentTraceIndex(L) siGetCurrentTraceIndex(L) 209285809Sscottl#define smTraceListRemove(R,L,I,V) siTraceListRemove(R,L,I,V) 210285809Sscottl#define smTraceListAdd(R,L,I,V) siTraceListAdd(R,L,I,V) 211285809Sscottl 212285809Sscottl#define smTrace(L,I,V) \ 213285809Sscottl /*lint -e506 */ \ 214285809Sscottl /*lint -e774 */ \ 215285809Sscottl if (sizeof(V) == 8) {siTrace64(agRoot,L,I,(bit64)V,64);} \ 216285809Sscottl else {siTrace(agRoot,L,I,(bit32)V,32);} \ 217285809Sscottl /*lint +e506 */ \ 218285809Sscottl /*lint +e774 */ 219285809Sscottl 220285809Sscottl 221285809Sscottl#else 222285809Sscottl 223285809Sscottl#define siTraceState(agRoot,L,fiTraceSmXchg,C,T) 224285809Sscottl 225285809Sscottl#define smTraceState(L,S,C,T) 226285809Sscottl#define smTraceChipState(L,C,T) 227285809Sscottl#define smTraceFabricState(L,C,T) 228285809Sscottl#define smTracePortState(L,C,T) 229285809Sscottl#define smTraceLoginState(L,C,T) 230285809Sscottl#define smTraceXchgState(L,C,T) 231285809Sscottl#define smTraceDiscFabState(L,C,T) 232285809Sscottl#define smTraceDiscLoopState(L,C,T) 233285809Sscottl#define smTraceFc2State(L,C,T) 234285809Sscottl#define smTraceScsiTgtState(L,C,T) 235285809Sscottl#define smTraceScsiIniState(L,C,T) 236285809Sscottl 237285809Sscottl#define smResetTraceBuffer(agRoot) 238285809Sscottl#define smTraceFuncEnter(L,I) 239285809Sscottl#define smTraceFuncExit(L,S,I) 240285809Sscottl#define smGetCurrentTraceIndex(L) 241285809Sscottl#define smTraceListRemove(L,I,V) 242285809Sscottl#define smTraceListAdd(L,I,V) 243285809Sscottl 244285809Sscottl#define smTrace(L,I,V) 245285809Sscottl 246285809Sscottl#endif 247285809Sscottl 248285809Sscottlstruct hpTraceBufferParms_s { 249285809Sscottl bit32 TraceCompiled; 250285809Sscottl bit32 BufferSize; 251285809Sscottl bit32 CurrentTraceIndexWrapCount; 252285809Sscottl bit32 CurrentIndex; 253285809Sscottl bit32 TraceWrap; 254285809Sscottl bit8 * pTrace; 255285809Sscottl bit32 * pCurrentTraceIndex; 256285809Sscottl bit32 * pTraceIndexWrapCount; 257285809Sscottl bit32 * pTraceMask; 258285809Sscottl}; 259285809Sscottltypedef struct hpTraceBufferParms_s 260285809Sscottl hpTraceBufferParms_t; 261285809Sscottl 262285809Sscottl#ifdef SA_ENABLE_TRACE_FUNCTIONS 263285809Sscottl 264285809SscottlGLOBAL void siTraceGetInfo(agsaRoot_t *agRoot, hpTraceBufferParms_t * pBParms); 265285809Sscottl 266285809Sscottl#define smTraceGetInfo(R,P) siTraceGetInfo(R,P) 267285809Sscottl#else 268285809Sscottl#define smTraceGetInfo(R,P) 269285809Sscottl#endif 270285809Sscottl 271285809Sscottl 272285809Sscottlvoid siEnableTracing ( agsaRoot_t *agRoot ); 273285809Sscottl#ifdef SA_ENABLE_TRACE_FUNCTIONS 274285809Sscottl 275285809SscottlGLOBAL void siTraceSetMask(agsaRoot_t *agRoot, bit32 TraceMask ); 276285809Sscottl 277285809Sscottl#define smTraceSetMask(R,P) siTraceSetMask(R,P) 278285809Sscottl#else 279285809Sscottl#define smTraceSetMask(R,P) 280285809Sscottl#endif /* SA_ENABLE_TRACE_FUNCTIONS */ 281285809Sscottl 282285809Sscottl#endif /* #ifndef __SPCDEBUG_H__ */ 283285809Sscottl 284