1 /*
2 * CDDL HEADER START
3 *
4 * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
8 *
9 * You can obtain a copy of the license at:
10 * http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When using or redistributing this file, you may do so under the
15 * License only. No other modification of this header is permitted.
16 *
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
20 *
21 * CDDL HEADER END
22 */
23
24 /*
25 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
27 */
28
29 /*
30 * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
31 */
32
33 #ifndef _IXGBE_DEBUG_H
34 #define _IXGBE_DEBUG_H
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40
41 #ifdef DEBUG
42 #define IXGBE_DEBUG
43 #endif
44
45 #ifdef IXGBE_DEBUG
46
47 #define IXGBE_DEBUGLOG_0(adapter, fmt) \
48 ixgbe_log((adapter), (fmt))
49 #define IXGBE_DEBUGLOG_1(adapter, fmt, d1) \
50 ixgbe_log((adapter), (fmt), (d1))
51 #define IXGBE_DEBUGLOG_2(adapter, fmt, d1, d2) \
52 ixgbe_log((adapter), (fmt), (d1), (d2))
53 #define IXGBE_DEBUGLOG_3(adapter, fmt, d1, d2, d3) \
54 ixgbe_log((adapter), (fmt), (d1), (d2), (d3))
55 #define IXGBE_DEBUGLOG_6(adapter, fmt, d1, d2, d3, d4, d5, d6) \
56 ixgbe_log((adapter), (fmt), (d1), (d2), (d3), (d4), (d5), (d6))
57
58 #define IXGBE_DEBUG_STAT_COND(val, cond) if (cond) (val)++;
59 #define IXGBE_DEBUG_STAT(val) (val)++;
60
61 #else
62
63 #define IXGBE_DEBUGLOG_0(adapter, fmt)
64 #define IXGBE_DEBUGLOG_1(adapter, fmt, d1)
65 #define IXGBE_DEBUGLOG_2(adapter, fmt, d1, d2)
66 #define IXGBE_DEBUGLOG_3(adapter, fmt, d1, d2, d3)
67 #define IXGBE_DEBUGLOG_6(adapter, fmt, d1, d2, d3, d4, d5, d6)
68
69 #define IXGBE_DEBUG_STAT_COND(val, cond)
70 #define IXGBE_DEBUG_STAT(val)
71
72 #endif /* IXGBE_DEBUG */
73
74 #define IXGBE_STAT(val) (val)++;
75
76 #ifdef IXGBE_DEBUG
77
78 void ixgbe_pci_dump(void *);
79 void ixgbe_dump_interrupt(void *, char *);
80 void ixgbe_dump_addr(void *, char *, const uint8_t *);
81
82 #endif /* IXGBE_DEBUG */
83
84 #ifdef IXGBE_DEBUG
85
86 #define DEBUGOUT(S) \
87 IXGBE_DEBUGLOG_0(NULL, S)
88 #define DEBUGOUT1(S, A) \
89 IXGBE_DEBUGLOG_1(NULL, S, A)
90 #define DEBUGOUT2(S, A, B) \
91 IXGBE_DEBUGLOG_2(NULL, S, A, B)
92 #define DEBUGOUT3(S, A, B, C) \
93 IXGBE_DEBUGLOG_3(NULL, S, A, B, C)
94 #define DEBUGOUT6(S, A, B, C, D, E, F) \
95 IXGBE_DEBUGLOG_6(NULL, S, A, B, C, D, E, F)
96
97 #define ERROR_REPORT1(S, A) DEBUGOUT1(S, A)
98 #define ERROR_REPORT2(S, A, B) DEBUGOUT2(S, A, B)
99 #define ERROR_REPORT3(S, A, B, C) DEBUGOUT3(S, A, B, C)
100
101 /*
102 * DEBUGFUNC() is used to print the function call information, however since
103 * Dtrace in illumos can be used to trace function calls, this function is
104 * not useful in illumos, and DEBUGFUNC() can spam a large number of
105 * function call system logs (see CR6918426). We sould eliminate
106 * DEBUGFUNC(), but since DEBUGFUNC() is used by the shared code
107 * (maintained by Intel) which is used and shared by ixgbe drivers in
108 * different OSes, we can not remove it, so in illumos just simply define
109 * it as blank.
110 */
111 #define DEBUGFUNC(F)
112
113 #else
114
115 #define DEBUGOUT(S)
116 #define DEBUGOUT1(S, A)
117 #define DEBUGOUT2(S, A, B)
118 #define DEBUGOUT3(S, A, B, C)
119 #define DEBUGOUT6(S, A, B, C, D, E, F)
120
121 #define ERROR_REPORT1(S, A)
122 #define ERROR_REPORT2(S, A, B)
123 #define ERROR_REPORT3(S, A, B, C)
124
125 #define DEBUGFUNC(F)
126
127 #endif /* IXGBE_DEBUG */
128
129 extern void ixgbe_log(void *, const char *, ...);
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* _IXGBE_DEBUG_H */