1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /* Copyright 2015 QLogic Corporation */
  23 
  24 /*
  25  * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  26  */
  27 
  28 #ifndef _QL_DEBUG_H
  29 #define _QL_DEBUG_H
  30 
  31 /*
  32  * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver header file.
  33  *
  34  * ***********************************************************************
  35  * *                                                                    **
  36  * *                            NOTICE                                  **
  37  * *            COPYRIGHT (C) 1996-2015 QLOGIC CORPORATION              **
  38  * *                    ALL RIGHTS RESERVED                             **
  39  * *                                                                    **
  40  * ***********************************************************************
  41  *
  42  */
  43 
  44 #ifdef  __cplusplus
  45 extern "C" {
  46 #endif
  47 
  48 /*
  49  * Driver debug definitions in makefile.
  50  *
  51  * QL_DEBUG_LEVEL_1=0x1
  52  * QL_DEBUG_LEVEL_2=0x2         Output error msgs.
  53  * QL_DEBUG_LEVEL_3=0x4         Output function trace msgs.
  54  * QL_DEBUG_LEVEL_4=0x8         Output NVRAM trace msgs.
  55  * QL_DEBUG_LEVEL_5=0x10        Output ring trace msgs.
  56  * QL_DEBUG_LEVEL_6=0x20        Output WATCHDOG timer trace.
  57  * QL_DEBUG_LEVEL_7=0x40
  58  * QL_DEBUG_LEVEL_8=0x80        Output ring staturation msgs.
  59  * QL_DEBUG_LEVEL_9=0x100       Output IOCTL trace.
  60  * QL_DEBUG_LEVEL_10=0x200
  61  * QL_DEBUG_LEVEL_11=0x400
  62  * QL_DEBUG_LEVEL_12=0x1000
  63  * QL_DEBUG_LEVEL_13=0x2000
  64  * QL_DEBUG_LEVEL_14=0x4000
  65  * QL_DEBUG_LEVEL_15=0x8000
  66  */
  67 
  68 void ql_dump_buffer(uint8_t *, uint8_t, uint32_t);
  69 void ql_el_msg(ql_adapter_state_t *, const char *, int, ...);
  70 void ql_dbg_msg(ql_adapter_state_t *, const char *, int, ...);
  71 int ql_flash_errlog(ql_adapter_state_t *, uint16_t, uint16_t, uint16_t,
  72     uint16_t);
  73 void ql_dump_el_trace_buffer(ql_adapter_state_t *);
  74 
  75 #if (QL_DEBUG & 0xffff)
  76 #define QL_DEBUG_ROUTINES
  77 #define QL_BANG
  78 #define QL_QUESTION
  79 #define QL_CAROT
  80 #else
  81 #define QL_BANG         "!"
  82 #define QL_QUESTION     "?"
  83 #define QL_CAROT        "^"
  84 #endif
  85 
  86 /*
  87  * Macros.
  88  */
  89 #define GLOBAL_EL_LOCK()        mutex_enter(&ql_global_el_mutex)
  90 #define GLOBAL_EL_UNLOCK()      mutex_exit(&ql_global_el_mutex)
  91 
  92 #define TRACE_BUFFER_LOCK(ha)   mutex_enter(&ha->ql_trace_desc->mutex)
  93 #define TRACE_BUFFER_UNLOCK(ha) mutex_exit(&ha->ql_trace_desc->mutex)
  94 
  95 #define EL(ha, ...)             ql_el_msg(ha, __func__, CE_CONT, __VA_ARGS__);
  96 
  97 #define ER(s)                   cmn_err(CE_CONT, QL_BANG "%s", s);
  98 #define ERV(s, ...)             cmn_err(CE_CONT, QL_BANG s, __VA_ARGS__);
  99 
 100 #define EL_BUFFER_RESERVE       256
 101 #define DEBUG_STK_DEPTH         24
 102 
 103 #if QL_DEBUG & 1
 104 #define QL_DEBUG_LEVEL_1
 105 #define QL_PRINT_1(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 106 #define QL_DUMP_1(bp, wdsize, count) \
 107         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 108 #else
 109 #define QL_PRINT_1(...)
 110 #define QL_DUMP_1(bp, wdsize, count)
 111 #endif
 112 
 113 #ifdef QL_DEBUG_ROUTINES
 114 #define QL_DEBUG_LEVEL_2
 115 #define QL_PRINT_2(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 116 #define QL_DUMP_2(bp, wdsize, count) \
 117         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 118 #else
 119 #define QL_PRINT_2(...)
 120 #define QL_DUMP_2(bp, wdsize, count)
 121 #endif
 122 
 123 #if QL_DEBUG & 4
 124 #define QL_DEBUG_LEVEL_3
 125 #define QL_PRINT_3(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 126 #define QL_DUMP_3(bp, wdsize, count) \
 127         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 128 #else
 129 #define QL_PRINT_3(...)
 130 #define QL_DUMP_3(bp, wdsize, count)
 131 #endif
 132 
 133 #if QL_DEBUG & 8
 134 #define QL_DEBUG_LEVEL_4
 135 #define QL_PRINT_4(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 136 #define QL_DUMP_4(bp, wdsize, count) \
 137         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 138 #else
 139 #define QL_PRINT_4(...)
 140 #define QL_DUMP_4(bp, wdsize, count)
 141 #endif
 142 
 143 #if QL_DEBUG & 0x10
 144 #define QL_DEBUG_LEVEL_5
 145 #define QL_PRINT_5(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 146 #define QL_DUMP_5(bp, wdsize, count) \
 147         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 148 #else
 149 #define QL_PRINT_5(...)
 150 #define QL_DUMP_5(bp, wdsize, count)
 151 #endif
 152 
 153 #if QL_DEBUG & 0x20
 154 #define QL_DEBUG_LEVEL_6
 155 #define QL_PRINT_6(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 156 #define QL_DUMP_6(bp, wdsize, count) \
 157         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 158 #else
 159 #define QL_PRINT_6(...)
 160 #define QL_DUMP_6(bp, wdsize, count)
 161 #endif
 162 
 163 #if QL_DEBUG & 0x40
 164 #define QL_DEBUG_LEVEL_7
 165 #define QL_PRINT_7(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 166 #define QL_DUMP_7(bp, wdsize, count) \
 167         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 168 #else
 169 #define QL_PRINT_7(...)
 170 #define QL_DUMP_7(bp, wdsize, count)
 171 #endif
 172 
 173 #if QL_DEBUG & 0x80
 174 #define QL_DEBUG_LEVEL_8
 175 #define QL_PRINT_8(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 176 #define QL_DUMP_8(bp, wdsize, count) \
 177         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 178 #else
 179 #define QL_PRINT_8(...)
 180 #define QL_DUMP_8(bp, wdsize, count)
 181 #endif
 182 
 183 #if QL_DEBUG & 0x104
 184 #define QL_PRINT_9(ha, ...)     ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 185 #define QL_DUMP_9(bp, wdsize, count) \
 186         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 187 #else
 188 #define QL_PRINT_9(...)
 189 #define QL_DUMP_9(bp, wdsize, count)
 190 #endif
 191 
 192 #if QL_DEBUG & 0x200
 193 #define QL_DEBUG_LEVEL_10
 194 #define QL_PRINT_10(ha, ...)    ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 195 #define QL_DUMP_10(bp, wdsize, count) \
 196         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 197 #else
 198 #define QL_PRINT_10(...)
 199 #define QL_DUMP_10(bp, wdsize, count)
 200 #endif
 201 
 202 #if QL_DEBUG & 0x400
 203 #define QL_DEBUG_LEVEL_11
 204 #define QL_PRINT_11(ha, ...)    ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 205 #define QL_DUMP_11(bp, wdsize, count) \
 206         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 207 #else
 208 #define QL_PRINT_11(...)
 209 #define QL_DUMP_11(bp, wdsize, count)
 210 #endif
 211 
 212 #if QL_DEBUG & 0x800
 213 #define QL_DEBUG_LEVEL_12
 214 #define QL_PRINT_12(ha, ...)    ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 215 #define QL_DUMP_12(bp, wdsize, count) \
 216         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 217 #else
 218 #define QL_PRINT_12(...)
 219 #define QL_DUMP_12(bp, wdsize, count)
 220 #endif
 221 
 222 #if QL_DEBUG & 0x1000
 223 #define QL_DEBUG_LEVEL_13
 224 #define QL_PRINT_13(ha, ...)    ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 225 #define QL_DUMP_13(bp, wdsize, count) \
 226         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 227 #else
 228 #define QL_PRINT_13(...)
 229 #define QL_DUMP_13(bp, wdsize, count)
 230 #endif
 231 
 232 #if QL_DEBUG & 0x2000
 233 #define QL_DEBUG_LEVEL_14
 234 #define QL_PRINT_14(ha, ...)    ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 235 #define QL_DUMP_14(bp, wdsize, count) \
 236         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 237 #else
 238 #define QL_PRINT_14(...)
 239 #define QL_DUMP_14(bp, wdsize, count)
 240 #endif
 241 
 242 #if QL_DEBUG & 0x4000
 243 #define QL_DEBUG_LEVEL_15
 244 #define QL_PRINT_15(ha, ...)    ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 245 #define QL_DUMP_15(bp, wdsize, count) \
 246         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 247 #else
 248 #define QL_PRINT_15(...)
 249 #define QL_DUMP_15(bp, wdsize, count)
 250 #endif
 251 
 252 #if QL_DEBUG & 0x8000
 253 #define QL_DEBUG_LEVEL_16
 254 #define QL_PRINT_16(ha, ...)    ql_dbg_msg(ha, __func__, CE_CONT, __VA_ARGS__)
 255 #define QL_DUMP_16(bp, wdsize, count) \
 256         ql_dump_buffer((uint8_t *)bp, (uint8_t)wdsize, (uint32_t)count)
 257 #else
 258 #define QL_PRINT_16(...)
 259 #define QL_DUMP_16(bp, wdsize, count)
 260 #endif
 261 
 262 #ifdef  __cplusplus
 263 }
 264 #endif
 265 
 266 #endif /* _QL_DEBUG_H */