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