1 /* $MirOS: src/sys/netisdn/i4b_debug.h,v 1.2 2005/03/06 21:28:24 tg Exp $ */ 2 3 /* 4 * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 *--------------------------------------------------------------------------- 28 * 29 * i4b_debug.h - i4b debug header file 30 * 31 *---------------------------------------------------------------------------*/ 32 33 #ifndef I4B_DEBUG_H 34 #define I4B_DEBUG_H 35 36 #if !defined DO_I4B_DEBUG 37 # define DO_I4B_DEBUG 1 /* default = include debugging code */ 38 #elif DO_I4B_DEBUG != 0 39 # undef DO_I4B_DEBUG 40 # define DO_I4B_DEBUG 1 41 #endif 42 43 #undef DO_I4B_MAXDEBUG /* default = disable ALL debug messages */ 44 45 #if DO_I4B_DEBUG 46 47 extern unsigned int i4b_l1_debug; 48 extern unsigned int i4b_l2_debug; 49 extern unsigned int i4b_l3_debug; 50 extern unsigned int i4b_l4_debug; 51 52 #define NDBGL1(bits, fmt, args...) \ 53 if(bits & i4b_l1_debug) \ 54 { printf("%s (L1): %s: " fmt "\n", sc->sc_dev.dv_xname, __FUNCTION__ , ##args ); } 55 56 #define NDBGL2(bits, fmt, args...) \ 57 if(bits & i4b_l2_debug) \ 58 { printf("i4b-L2 %s: " fmt "\n", __FUNCTION__ , ##args ); } 59 60 #define NDBGL3(bits, fmt, args...) \ 61 if(bits & i4b_l3_debug) \ 62 { printf("i4b-L3 %s: " fmt "\n", __FUNCTION__ , ##args ); } 63 64 #define NDBGL4(bits, fmt, args...) \ 65 if(bits & i4b_l4_debug) \ 66 { printf("i4b-L4 %s: " fmt "\n", __FUNCTION__ , ##args ); } 67 68 #else /* !DO_I4B_DEBUG */ 69 70 #define NDBGL1(bits, fmt, args...); 71 #define NDBGL2(bits, fmt, args...); 72 #define NDBGL3(bits, fmt, args...); 73 #define NDBGL4(bits, fmt, args...); 74 75 #endif /* DO_I4B_DEBUG */ 76 77 /* Layer 1 */ 78 79 #define L1_ERROR 0x0001 /* general error message*/ 80 #define L1_PRIM 0x0002 /* interlayer primitives*/ 81 #define L1_BCHAN 0x0004 /* B channel action */ 82 #define L1_H_ERR 0x0008 /* HSCX errors */ 83 #define L1_H_IRQ 0x0010 /* HSCX IRQ messages */ 84 #define L1_I_ERR 0x0020 /* ISAC errors */ 85 #define L1_I_MSG 0x0040 /* ISAC messages */ 86 #define L1_I_SETUP 0x0080 /* ISAC setup messages */ 87 #define L1_F_MSG 0x0100 /* FSM messages */ 88 #define L1_F_ERR 0x0200 /* FSM error messages */ 89 #define L1_T_MSG 0x0400 /* Timer messages */ 90 #define L1_T_ERR 0x0800 /* Timer error messages */ 91 #define L1_H_XFRERR 0x1000 /* HSCX data xfer error */ 92 #define L1_I_CICO 0x2000 /* ISAC command in/out */ 93 #define L1_S_MSG 0x4000 /* silent messages (soft-HDLC) */ 94 #define L1_S_ERR 0x8000 /* error messages (soft-HDLC) */ 95 96 #define L1_DEBUG_MAX 0xffef /* all messages on except IRQ! */ 97 #define L1_DEBUG_ERR (L1_S_ERR | L1_H_ERR | L1_I_ERR | L1_F_ERR | L1_T_ERR | L1_ERROR) 98 99 #ifndef L1_DEBUG_DEFAULT 100 #ifdef DO_I4B_MAXDEBUG 101 #define L1_DEBUG_DEFAULT L1_DEBUG_MAX 102 #else 103 #define L1_DEBUG_DEFAULT L1_DEBUG_ERR 104 #endif 105 #endif 106 107 /* Layer 2 */ 108 109 #define L2_ERROR 0x0001 /* general error message */ 110 #define L2_PRIM 0x0002 /* interlayer primitives */ 111 #define L2_U_MSG 0x0004 /* U frame messages */ 112 #define L2_U_ERR 0x0008 /* U frame error messages */ 113 #define L2_S_MSG 0x0010 /* S frame messages */ 114 #define L2_S_ERR 0x0020 /* S frame error messages */ 115 #define L2_I_MSG 0x0040 /* I frame messages */ 116 #define L2_I_ERR 0x0080 /* I frame error messages */ 117 #define L2_F_MSG 0x0100 /* FSM messages */ 118 #define L2_F_ERR 0x0200 /* FSM error messages */ 119 #define L2_T_MSG 0x0400 /* timer messages */ 120 #define L2_T_ERR 0x0800 /* timer error messages */ 121 #define L2_TEI_MSG 0x1000 /* TEI messages */ 122 #define L2_TEI_ERR 0x2000 /* TEI error messages */ 123 124 #define L2_DEBUG_MAX 0x3fff /* all messages on */ 125 #define L2_DEBUG_ERR (L2_ERROR | L2_I_ERR | L2_F_ERR | L2_T_ERR | L2_S_ERR | L2_TEI_ERR | L2_U_ERR ) 126 127 #ifndef L2_DEBUG_DEFAULT 128 #ifdef DO_I4B_MAXDEBUG 129 #define L2_DEBUG_DEFAULT L2_DEBUG_MAX 130 #else 131 #define L2_DEBUG_DEFAULT L2_DEBUG_ERR 132 #endif 133 #endif 134 135 /* Layer 3 */ 136 137 #define L3_ERR 0x0001 /* general error message */ 138 #define L3_MSG 0x0002 /* general message */ 139 #define L3_F_MSG 0x0004 /* FSM messages */ 140 #define L3_F_ERR 0x0008 /* FSM error messages */ 141 #define L3_T_MSG 0x0010 /* timer messages */ 142 #define L3_T_ERR 0x0020 /* timer error messages */ 143 #define L3_P_MSG 0x0040 /* protocol messages */ 144 #define L3_P_ERR 0x0080 /* protocol error messages */ 145 #define L3_A_MSG 0x0100 /* AOC messages */ 146 #define L3_A_ERR 0x0200 /* AOC error messages */ 147 #define L3_PRIM 0x0400 /* messages exchanged */ 148 149 #define L3_DEBUG_MAX 0x07ff /* all messages on */ 150 #define L3_DEBUG_ERR (L3_ERR | L3_F_ERR | L3_T_ERR | L3_P_ERR | L3_A_ERR) 151 152 #ifndef L3_DEBUG_DEFAULT 153 #ifdef DO_I4B_MAXDEBUG 154 #define L3_DEBUG_DEFAULT L3_DEBUG_MAX 155 #else 156 #define L3_DEBUG_DEFAULT L3_DEBUG_ERR 157 #endif 158 #endif 159 160 /* Layer 4 */ 161 162 #define L4_ERR 0x0001 /* general error message */ 163 #define L4_MSG 0x0002 /* general message */ 164 #define L4_TIMO 0x0004 /* b channel idle timeout msgs */ 165 #define L4_DIALST 0x0008 /* network driver dial states */ 166 #define L4_IPRDBG 0x0010 /* ipr driver debug messages */ 167 #define L4_RBCHDBG 0x0020 /* rbch driver debug messages */ 168 #define L4_ISPDBG 0x0040 /* isp driver debug messages */ 169 #define L4_TELDBG 0x0080 /* tel driver debug messages */ 170 #define L4_TINADBG 0x0100 /* tina driver debug messages */ 171 #define L4_TINAMSG 0x0200 /* tina driver messages */ 172 #define L4_TINAERR 0x0400 /* tina driver error messages */ 173 #define L4_INGDBG 0x0800 /* ing driver debug messages */ 174 #define L4_IAVCDBG 0x1000 /* iavc driver debug messages */ 175 176 #define L4_DEBUG_MAX 0x0fff /* all messages on */ 177 #define L4_DEBUG_ERR (L4_ERR | L4_TINADBG | L4_TINAMSG | L4_TINAERR) 178 179 #ifndef L4_DEBUG_DEFAULT 180 #ifdef DO_I4B_MAXDEBUG 181 #define L4_DEBUG_DEFAULT L4_DEBUG_MAX 182 #else 183 #define L4_DEBUG_DEFAULT L4_DEBUG_ERR 184 #endif 185 #endif 186 187 /*---------------------------------------------------------------------------* 188 * ioctl via /dev/i4bctl: 189 * get/set current debug bits settings 190 *---------------------------------------------------------------------------*/ 191 192 typedef struct { 193 unsigned int l1; 194 unsigned int l2; 195 unsigned int l3; 196 unsigned int l4; 197 } ctl_debug_t; 198 199 #define I4B_CTL_GET_DEBUG _IOR('C', 0, ctl_debug_t) 200 201 #define I4B_CTL_SET_DEBUG _IOW('C', 1, ctl_debug_t) 202 203 /*---------------------------------------------------------------------------* 204 * generic get chipset statistics 205 *---------------------------------------------------------------------------*/ 206 207 /* for the ihfc-driver: structure for HFC-1/S/SP statistics */ 208 209 typedef struct { 210 int txframes; 211 int rxframes; 212 int xdu; 213 int rdo; 214 int crc; 215 int rab; 216 } hfcstat_t; 217 218 219 /* for the isic-driver: structure for HSCX statistics */ 220 221 typedef struct { 222 int unit; /* controller number */ 223 int chan; /* channel number */ 224 int vfr; 225 int rdo; 226 int crc; 227 int rab; 228 int xdu; 229 int rfo; 230 } hscxstat_t; 231 232 /* generic statistics structure */ 233 234 struct chipstat { 235 int driver_type; /* type, L1DRVR_XXXX */ 236 int driver_unit; /* the unit number */ 237 int driver_bchannel; /* the B-channel */ 238 union stats { /* union for all drivers */ 239 hfcstat_t hfcstat; /* for ihfc driver, L1DRVR_IHFC */ 240 hscxstat_t hscxstat; /* for isic driver, L1DRVR_ISIC */ 241 } stats; 242 }; 243 244 /* get statistics */ 245 246 #define I4B_CTL_GET_CHIPSTAT _IOWR('C', 2, struct chipstat) 247 248 /* clear statistics */ 249 250 #define I4B_CTL_CLR_CHIPSTAT _IOW('C', 3, struct chipstat) 251 252 /*---------------------------------------------------------------------------* 253 * get LAPD/Q.921 statistics 254 *---------------------------------------------------------------------------*/ 255 typedef struct { 256 257 /* transmit */ 258 259 u_long tx_i; /* I */ 260 u_long tx_rr; /* RR */ 261 u_long tx_rnr; /* RNR */ 262 u_long tx_rej; /* REJ */ 263 u_long tx_sabme; /* SABME*/ 264 u_long tx_dm; /* DM */ 265 u_long tx_disc; /* DISC */ 266 u_long tx_ua; /* UA */ 267 u_long tx_frmr; /* FRMR */ 268 u_long tx_tei; /* TEI */ 269 270 /* receive */ 271 272 u_long rx_i; /* I */ 273 u_long rx_rr; /* RR */ 274 u_long rx_rnr; /* RNR */ 275 u_long rx_rej; /* REJ */ 276 u_long rx_sabme; /* SABME*/ 277 u_long rx_tei; /* TEI */ 278 u_long rx_ui; /* UI */ 279 u_long rx_disc; /* DISC */ 280 u_long rx_xid; /* XID */ 281 u_long rx_dm; /* DM */ 282 u_long rx_ua; /* UA */ 283 u_long rx_frmr; /* FRMR */ 284 285 /* errors */ 286 287 u_long err_rx_len; /* incorrect length */ 288 u_long err_rx_badf; /* bad frame type */ 289 u_long err_rx_bads; /* bad s frame */ 290 u_long err_rx_badu; /* bad u frame */ 291 u_long err_rx_badui; /* bad ui frame */ 292 } lapdstat_t; 293 294 typedef struct { 295 int unit; 296 lapdstat_t lapdstat; 297 } l2stat_t; 298 299 #define I4B_CTL_GET_LAPDSTAT _IOWR('C', 4, l2stat_t) 300 301 #define I4B_CTL_CLR_LAPDSTAT _IOW('C', 5, int) 302 303 #endif 304 /* EOF */ 305