cam_debug.h revision 49926
175584Sru/* 2114402Sru * Macros for tracing/loging information in the CAM layer 375584Sru * 475584Sru * Copyright (c) 1997 Justin T. Gibbs. 575584Sru * All rights reserved. 675584Sru * 775584Sru * Redistribution and use in source and binary forms, with or without 875584Sru * modification, are permitted provided that the following conditions 975584Sru * are met: 1075584Sru * 1. Redistributions of source code must retain the above copyright 1175584Sru * notice, this list of conditions, and the following disclaimer, 1275584Sru * without modification, immediately at the beginning of the file. 1375584Sru * 2. The name of the author may not be used to endorse or promote products 1475584Sru * derived from this software without specific prior written permission. 1575584Sru * 1675584Sru * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1775584Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1875584Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1975584Sru * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 20151497Sru * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2175584Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2275584Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2375584Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2475584Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2575584Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2675584Sru * SUCH DAMAGE. 2775584Sru * 2875584Sru * $Id: cam_debug.h,v 1.3 1998/12/05 23:55:48 mjacob Exp $ 2975584Sru */ 3075584Sru#ifndef _CAM_CAM_DEBUG_H 3175584Sru#define _CAM_CAM_DEBUG_H 1 3275584Sru 3375584Sru#if defined(CAMDEBUG) && defined(KERNEL) 3475584Sru#include <machine/clock.h> 3575584Sru#endif /* CAMDEBUG && KERNEL */ 3675584Sru 3775584Sru/* 3875584Sru * Debugging flags. 3975584Sru */ 4075584Srutypedef enum { 4175584Sru CAM_DEBUG_NONE = 0x00, /* no debugging */ 4275584Sru CAM_DEBUG_INFO = 0x01, /* scsi commands, errors, data */ 4375584Sru CAM_DEBUG_TRACE = 0x02, /* routine flow tracking */ 4475584Sru CAM_DEBUG_SUBTRACE = 0x04, /* internal to routine flows */ 4575584Sru CAM_DEBUG_CDB = 0x08, /* print out SCSI CDBs only */ 4675584Sru CAM_DEBUG_XPT = 0x10, /* print out xpt scheduling */ 4775584Sru CAM_DEBUG_PERIPH = 0x20 /* print out peripheral calls */ 4875584Sru} cam_debug_flags; 4975584Sru 5075584Sru#if defined(CAMDEBUG) && defined(KERNEL) 5175584Sru 5275584Sru/* Path we want to debug */ 5375584Sruextern struct cam_path *cam_dpath; 5475584Sru/* Current debug levels set */ 5575584Sruextern u_int32_t cam_dflags; 5675584Sru/* Printf delay value (to prevent scrolling */ 5775584Sruextern u_int32_t cam_debug_delay; 5875584Sru 5975584Sru/* Debugging macros. */ 6075584Sru#define CAM_DEBUGGED(path, flag) \ 6175584Sru ((cam_dflags & (flag)) \ 6275584Sru && (cam_dpath != NULL) \ 6375584Sru && (xpt_path_comp(cam_dpath, path) >= 0) \ 6475584Sru && (xpt_path_comp(cam_dpath, path) < 2)) 6575584Sru#define CAM_DEBUG(path, flag, printfargs) \ 6675584Sru if ((cam_dflags & (flag)) \ 6775584Sru && (cam_dpath != NULL) \ 6875584Sru && (xpt_path_comp(cam_dpath, path) >= 0) \ 6975584Sru && (xpt_path_comp(cam_dpath, path) < 2)) { \ 7075584Sru xpt_print_path(path); \ 71114402Sru printf printfargs; \ 7275584Sru if (cam_debug_delay != 0) \ 7375584Sru DELAY(cam_debug_delay); \ 7475584Sru } 7575584Sru#define CAM_DEBUG_PRINT(flag, printfargs) \ 7675584Sru if (cam_dflags & (flag)) { \ 77 printf("cam_debug: "); \ 78 printf printfargs; \ 79 if (cam_debug_delay != 0) \ 80 DELAY(cam_debug_delay); \ 81 } 82 83#else /* !CAMDEBUG || !KERNEL */ 84 85#define CAM_DEBUGGED(A, B) 0 86#define CAM_DEBUG(A, B, C) 87#define CAM_DEBUG_PRINT(A, B) 88 89#endif /* CAMDEBUG && KERNEL */ 90 91#endif /* _CAM_CAM_DEBUG_H */ 92