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 /*
  28  * Copyright 2019, Joyent, Inc.
  29  */
  30 
  31 #ifndef _SYS_IB_IBTL_IMPL_IBTL_UTIL_H
  32 #define _SYS_IB_IBTL_IMPL_IBTL_UTIL_H
  33 
  34 /*
  35  * ibtl_util.h
  36  *
  37  * All data structures and function prototypes that serve as helper
  38  * routines for IBTF implementation.
  39  */
  40 
  41 #ifdef __cplusplus
  42 extern "C" {
  43 #endif
  44 
  45 #include <sys/ib/ib_types.h>
  46 #include <sys/varargs.h>
  47 
  48 /*
  49  * Time Related Functions
  50  *
  51  *   ibt_usec2ib
  52  *      This function converts the standard input time in microseconds to
  53  *      IB's 6 bits of timeout exponent, calculated based on
  54  *      time = 4.096us * 2 ^ exp.
  55  *
  56  *   ibt_ib2usec
  57  *      This function converts the input IB timeout exponent (6 bits) to
  58  *      standard time in microseconds, calculated based on
  59  *      time = 4.096us * 2 ^ exp.
  60  */
  61 ib_time_t       ibt_usec2ib(clock_t microsecs);
  62 clock_t         ibt_ib2usec(ib_time_t ib_time);
  63 
  64 
  65 /*
  66  * IB logging, debug and console message handling
  67  */
  68 
  69 
  70 /*
  71  * warnings, console & syslog buffer.
  72  * For Non recoverable or Major Errors
  73  */
  74 #define IBTF_LOG_L0     0
  75 
  76 /*
  77  * syslog buffer or IBTF trace buffer (console if booted /w debug)
  78  * For additional information on Non recoverable errors and
  79  * warnings/informational message for sys-admin types.
  80  */
  81 #define IBTF_LOG_L1     1
  82 
  83 /*
  84  * debug only
  85  * for more verbose trace than L1, for e.g. recoverable errors,
  86  * or intersting trace
  87  */
  88 #define IBTF_LOG_L2     2
  89 
  90 /*
  91  * debug only
  92  * for more verbose trace than L2, for e.g. printing function entries....
  93  */
  94 #define IBTF_LOG_L3     3
  95 
  96 /*
  97  * debug only
  98  * for more verbose trace than L3, for e.g. printing minor function entries...
  99  */
 100 #define IBTF_LOG_L4     4
 101 
 102 /*
 103  * debug only
 104  * most verbose level. Used only for  excessive trace, for e.g.
 105  * printing structures etc.
 106  */
 107 #define IBTF_LOG_L5     5
 108 
 109 /*
 110  * debug only
 111  * for messages from softints, taskqs, intr handlers, timeout handlers etc.
 112  * Only gets printed if "ibtl_allow_intr_msgs" is set
 113  */
 114 #define IBTF_LOG_LINTR  6
 115 
 116 
 117 #ifdef DEBUG
 118 #define IBTF_DPRINTF_LINTR      ibtl_dprintf_intr
 119 #define IBTF_DPRINTF_L5         ibtl_dprintf5
 120 #define IBTF_DPRINTF_L4         ibtl_dprintf4
 121 #define IBTF_DPRINTF_L3         ibtl_dprintf3
 122 
 123 void ibtl_dprintf_intr(
 124                 char            *name,
 125                 char            *fmt, ...);
 126 void ibtl_dprintf5(
 127                 char            *name,
 128                 char            *fmt, ...);
 129 void ibtl_dprintf4(
 130                 char            *name,
 131                 char            *fmt, ...);
 132 void ibtl_dprintf3(
 133                 char            *name,
 134                 char            *fmt, ...);
 135 #else
 136 #define IBTF_DPRINTF_LINTR(...)
 137 #define IBTF_DPRINTF_L5(...)
 138 #define IBTF_DPRINTF_L4(...)
 139 #define IBTF_DPRINTF_L3(...)
 140 #endif
 141 
 142 #define IBTF_DPRINTF_L2 ibtl_dprintf2
 143 #define IBTF_DPRINTF_L1 ibtl_dprintf1
 144 #define IBTF_DPRINTF_L0 ibtl_dprintf0
 145 
 146 void ibtl_dprintf2(
 147                 char            *name,
 148                 char            *fmt, ...);
 149 void ibtl_dprintf1(
 150                 char            *name,
 151                 char            *fmt, ...);
 152 void ibtl_dprintf0(
 153                 char            *name,
 154                 char            *fmt, ...);
 155 
 156 #ifdef __cplusplus
 157 }
 158 #endif
 159 
 160 #endif /* _SYS_IB_IBTL_IMPL_IBTL_UTIL_H */