Merge from vendor branch SENDMAIL:
[dragonfly.git] / sys / dev / netif / ray / if_raydbg.h
1 /*
2  * Copyright (C) 2000
3  * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
4  *
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the author nor the names of any co-contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL DUNCAN BARCLAY OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * $FreeBSD: src/sys/dev/ray/if_raydbg.h,v 1.10.2.2 2001/08/14 22:54:07 dmlb Exp $
32  * $DragonFly: src/sys/dev/netif/ray/Attic/if_raydbg.h,v 1.3 2005/02/17 13:59:36 joerg Exp $
33  *
34  */
35
36 /*
37  * Debugging odds and odds
38  */
39
40 /*
41  * RAY_DEBUG settings
42  *
43  *      AUTH            Authentication
44  *      SUBR            Subroutine entry
45  *      BOOTPARAM       Startup CM dump
46  *      STARTJOIN       State transitions for start/join
47  *      CCS             CCS info
48  *      IOCTL           IOCTL calls
49  *      MBUF            MBUFs dumped - needs one of TX, RX, MGT, or CTL
50  *      RX              packet types reported
51  *      CM              common memory re-mapping
52  *      COM             new command sleep/wakeup
53  *      STOP            driver detaching
54  *      CTL             CTL packets
55  *      MGT             MGT packets
56  *      TX              TX routine info
57  *      DCOM            dump comq entries
58  */
59 #define RAY_DBG_AUTH            0x0001
60 #define RAY_DBG_SUBR            0x0002
61 #define RAY_DBG_BOOTPARAM       0x0004
62 #define RAY_DBG_STARTJOIN       0x0008
63 #define RAY_DBG_CCS             0x0010
64 #define RAY_DBG_IOCTL           0x0020
65 #define RAY_DBG_MBUF            0x0080
66 #define RAY_DBG_RX              0x0100
67 #define RAY_DBG_CM              0x0200
68 #define RAY_DBG_COM             0x0400
69 #define RAY_DBG_STOP            0x0800
70 #define RAY_DBG_CTL             0x1000
71 #define RAY_DBG_MGT             0x2000
72 #define RAY_DBG_TX              0x4000
73 #define RAY_DBG_DCOM            0x8000
74 /* Cut and paste this into a kernel configuration file */
75 #if 0
76 #define RAY_DEBUG       (                               \
77                         /* RAY_DBG_SUBR         | */    \
78                         /* RAY_DBG_BOOTPARAM    | */    \
79                         /* RAY_DBG_STARTJOIN    | */    \
80                         /* RAY_DBG_CCS          | */    \
81                         /* RAY_DBG_IOCTL        | */    \
82                         /* RAY_DBG_MBUF         | */    \
83                         /* RAY_DBG_RX           | */    \
84                         /* RAY_DBG_CM           | */    \
85                         /* RAY_DBG_COM          | */    \
86                         /* RAY_DBG_STOP         | */    \
87                         /* RAY_DBG_CTL          | */    \
88                         /* RAY_DBG_MGT          | */    \
89                         /* RAY_DBG_TX           | */    \
90                         /* RAY_DBG_DCOM         | */    \
91                         0                               \
92                         )
93 #endif
94
95 #if RAY_DEBUG
96
97 #define RAY_DPRINTF(sc, mask, fmt, args...) do {if (RAY_DEBUG & (mask)) {\
98     device_printf((sc)->dev, "%s(%d) " fmt "\n",                        \
99         __func__ , __LINE__ , ##args);                          \
100 } } while (0)
101
102 /* This macro assumes that common memory is mapped into kernel space */
103 #define RAY_DHEX8(sc, mask, off, len, s) do { if (RAY_DEBUG & (mask)) { \
104     int i, j;                                                           \
105     device_printf((sc)->dev, "%s(%d) %s\n",                             \
106         __func__ , __LINE__ , (s));                                     \
107     for (i = (off); i < (off)+(len); i += 8) {                          \
108             printf(".  0x%04x ", i);                                    \
109             for (j = 0; j < 8; j++)                                     \
110                     printf("%02x ", SRAM_READ_1((sc), i+j));            \
111             printf("\n");                                               \
112     }                                                                   \
113 } } while (0)
114
115 #define RAY_DCOM(sc, mask, com, s) do { if (RAY_DEBUG & (mask)) {       \
116     device_printf((sc)->dev, "%s(%d) %s com entry 0x%p\n",              \
117         __func__ , __LINE__ , (s) , (com));                             \
118     printf(".  c_mesg %s\n", (com)->c_mesg);                            \
119     printf(".  c_flags 0x%b\n", (com)->c_flags, RAY_COM_FLAGS_PRINTFB); \
120     printf(".  c_retval 0x%x\n", (com)->c_retval);                      \
121     printf(".  c_ccs 0x%0x index 0x%02x\n",                             \
122         (com)->c_ccs, RAY_CCS_INDEX((com)->c_ccs));                     \
123 } } while (0)
124
125 #else
126 #define RAY_DPRINTF(sc, mask, fmt, args...)
127 #define RAY_DHEX8(sc, mask, off, len, s)
128 #define RAY_DCOM(sc, mask, com, s)
129 #endif /* RAY_DEBUG > 0 */
130
131 /*
132  * These override macros defined in if_ray.c to turn them into
133  * debugging ones.
134  */
135 #if RAY_DEBUG
136 #define RAY_RECERR(sc, fmt, args...) do {                               \
137     device_printf((sc)->dev, "%s(%d) " fmt "\n",                        \
138         __func__ , __LINE__ , ##args);                          \
139 } while (0)
140 #endif /* RAY_DEBUG */
141
142 #if RAY_DEBUG & RAY_DBG_COM
143 #define RAY_COM_CHECK(sc, com) do { if (RAY_DEBUG & RAY_DBG_COM) {      \
144     ray_com_ecf_check((sc), (com), __func__ );                  \
145 } } while (0)
146 #endif /* RAY_DEBUG & RAY_DBG_COM */
147
148 #if RAY_DEBUG & RAY_DBG_MBUF
149 #define RAY_MBUF_DUMP(sc, mask, m, s)   do { if (RAY_DEBUG & (mask)) {  \
150     ray_dump_mbuf((sc), (m), (s));                                      \
151 } } while (0)
152 #endif /* RAY_DEBUG & RAY_DBG_MBUF */