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, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or 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 distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _SYS_IB_IBTL_IMPL_IBTL_UTIL_H
28 #define _SYS_IB_IBTL_IMPL_IBTL_UTIL_H
29
30 #pragma ident "%Z%%M% %I% %E% SMI"
31
32 /*
33 * ibtl_util.h
34 *
35 * All data structures and function prototypes that serve as helper
36 * routines for IBTF implementation.
37 */
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 #include <sys/ib/ib_types.h>
44 #include <sys/varargs.h>
45
46 /*
47 * Time Related Functions
48 *
49 * ibt_usec2ib
50 * This function converts the standard input time in microseconds to
51 * IB's 6 bits of timeout exponent, calculated based on
52 * time = 4.096us * 2 ^ exp.
53 *
54 * ibt_ib2usec
55 * This function converts the input IB timeout exponent (6 bits) to
56 * standard time in microseconds, calculated based on
57 * time = 4.096us * 2 ^ exp.
58 */
59 ib_time_t ibt_usec2ib(clock_t microsecs);
60 clock_t ibt_ib2usec(ib_time_t ib_time);
61
62
63 /*
64 * IB logging, debug and console message handling
65 */
66
67
68 /*
69 * warnings, console & syslog buffer.
70 * For Non recoverable or Major Errors
71 */
72 #define IBTF_LOG_L0 0
73
74 /*
75 * syslog buffer or IBTF trace buffer (console if booted /w debug)
76 * For additional information on Non recoverable errors and
77 * warnings/informational message for sys-admin types.
78 */
79 #define IBTF_LOG_L1 1
80
81 /*
82 * debug only
83 * for more verbose trace than L1, for e.g. recoverable errors,
84 * or intersting trace
85 */
86 #define IBTF_LOG_L2 2
87
88 /*
89 * debug only
90 * for more verbose trace than L2, for e.g. printing function entries....
91 */
92 #define IBTF_LOG_L3 3
93
94 /*
95 * debug only
96 * for more verbose trace than L3, for e.g. printing minor function entries...
97 */
98 #define IBTF_LOG_L4 4
99
100 /*
101 * debug only
102 * most verbose level. Used only for excessive trace, for e.g.
103 * printing structures etc.
104 */
105 #define IBTF_LOG_L5 5
106
107 /*
108 * debug only
109 * for messages from softints, taskqs, intr handlers, timeout handlers etc.
110 * Only gets printed if "ibtl_allow_intr_msgs" is set
111 */
112 #define IBTF_LOG_LINTR 6
113
114
115 #ifdef DEBUG
116 #define IBTF_DPRINTF_LINTR ibtl_dprintf_intr
117 #define IBTF_DPRINTF_L5 ibtl_dprintf5
118 #define IBTF_DPRINTF_L4 ibtl_dprintf4
119 #define IBTF_DPRINTF_L3 ibtl_dprintf3
120
121 void ibtl_dprintf_intr(
122 char *name,
123 char *fmt, ...);
124 void ibtl_dprintf5(
125 char *name,
126 char *fmt, ...);
127 void ibtl_dprintf4(
128 char *name,
129 char *fmt, ...);
130 void ibtl_dprintf3(
131 char *name,
132 char *fmt, ...);
133 #else
134 #define IBTF_DPRINTF_LINTR 0 &&
135 #define IBTF_DPRINTF_L5 0 &&
136 #define IBTF_DPRINTF_L4 0 &&
137 #define IBTF_DPRINTF_L3 0 &&
138 #endif
139
140 #define IBTF_DPRINTF_L2 ibtl_dprintf2
141 #define IBTF_DPRINTF_L1 ibtl_dprintf1
142 #define IBTF_DPRINTF_L0 ibtl_dprintf0
143
144 void ibtl_dprintf2(
145 char *name,
146 char *fmt, ...);
147 void ibtl_dprintf1(
148 char *name,
149 char *fmt, ...);
150 void ibtl_dprintf0(
151 char *name,
152 char *fmt, ...);
153
154 #ifdef __cplusplus
155 }
156 #endif
157
158 #endif /* _SYS_IB_IBTL_IMPL_IBTL_UTIL_H */