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