18b8a9b1dSJustin T. Gibbs /* 28b8a9b1dSJustin T. Gibbs * Macros for tracing/loging information in the CAM layer 38b8a9b1dSJustin T. Gibbs * 48b8a9b1dSJustin T. Gibbs * Copyright (c) 1997 Justin T. Gibbs. 58b8a9b1dSJustin T. Gibbs * All rights reserved. 68b8a9b1dSJustin T. Gibbs * 78b8a9b1dSJustin T. Gibbs * Redistribution and use in source and binary forms, with or without 88b8a9b1dSJustin T. Gibbs * modification, are permitted provided that the following conditions 98b8a9b1dSJustin T. Gibbs * are met: 108b8a9b1dSJustin T. Gibbs * 1. Redistributions of source code must retain the above copyright 118b8a9b1dSJustin T. Gibbs * notice, this list of conditions, and the following disclaimer, 128b8a9b1dSJustin T. Gibbs * without modification, immediately at the beginning of the file. 138b8a9b1dSJustin T. Gibbs * 2. The name of the author may not be used to endorse or promote products 148b8a9b1dSJustin T. Gibbs * derived from this software without specific prior written permission. 158b8a9b1dSJustin T. Gibbs * 168b8a9b1dSJustin T. Gibbs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 178b8a9b1dSJustin T. Gibbs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 188b8a9b1dSJustin T. Gibbs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 198b8a9b1dSJustin T. Gibbs * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 208b8a9b1dSJustin T. Gibbs * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 218b8a9b1dSJustin T. Gibbs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 228b8a9b1dSJustin T. Gibbs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 238b8a9b1dSJustin T. Gibbs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 248b8a9b1dSJustin T. Gibbs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 258b8a9b1dSJustin T. Gibbs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 268b8a9b1dSJustin T. Gibbs * SUCH DAMAGE. 278b8a9b1dSJustin T. Gibbs * 28b8b98bc3SJustin T. Gibbs * $Id: cam_debug.h,v 1.3 1998/12/05 23:55:48 mjacob Exp $ 298b8a9b1dSJustin T. Gibbs */ 308b8a9b1dSJustin T. Gibbs #ifndef _CAM_CAM_DEBUG_H 318b8a9b1dSJustin T. Gibbs #define _CAM_CAM_DEBUG_H 1 328b8a9b1dSJustin T. Gibbs 338b8a9b1dSJustin T. Gibbs #if defined(CAMDEBUG) && defined(KERNEL) 348b8a9b1dSJustin T. Gibbs #include <machine/clock.h> 358b8a9b1dSJustin T. Gibbs #endif /* CAMDEBUG && KERNEL */ 368b8a9b1dSJustin T. Gibbs 378b8a9b1dSJustin T. Gibbs /* 388b8a9b1dSJustin T. Gibbs * Debugging flags. 398b8a9b1dSJustin T. Gibbs */ 408b8a9b1dSJustin T. Gibbs typedef enum { 418b8a9b1dSJustin T. Gibbs CAM_DEBUG_NONE = 0x00, /* no debugging */ 428b8a9b1dSJustin T. Gibbs CAM_DEBUG_INFO = 0x01, /* scsi commands, errors, data */ 438b8a9b1dSJustin T. Gibbs CAM_DEBUG_TRACE = 0x02, /* routine flow tracking */ 448b8a9b1dSJustin T. Gibbs CAM_DEBUG_SUBTRACE = 0x04, /* internal to routine flows */ 45c7f682dbSMatt Jacob CAM_DEBUG_CDB = 0x08, /* print out SCSI CDBs only */ 46b8b98bc3SJustin T. Gibbs CAM_DEBUG_XPT = 0x10, /* print out xpt scheduling */ 47b8b98bc3SJustin T. Gibbs CAM_DEBUG_PERIPH = 0x20 /* print out peripheral calls */ 488b8a9b1dSJustin T. Gibbs } cam_debug_flags; 498b8a9b1dSJustin T. Gibbs 508b8a9b1dSJustin T. Gibbs #if defined(CAMDEBUG) && defined(KERNEL) 518b8a9b1dSJustin T. Gibbs 528b8a9b1dSJustin T. Gibbs /* Path we want to debug */ 538b8a9b1dSJustin T. Gibbs extern struct cam_path *cam_dpath; 548b8a9b1dSJustin T. Gibbs /* Current debug levels set */ 558b8a9b1dSJustin T. Gibbs extern u_int32_t cam_dflags; 56b8b98bc3SJustin T. Gibbs /* Printf delay value (to prevent scrolling */ 57b8b98bc3SJustin T. Gibbs extern u_int32_t cam_debug_delay; 588b8a9b1dSJustin T. Gibbs 598b8a9b1dSJustin T. Gibbs /* Debugging macros. */ 60c7f682dbSMatt Jacob #define CAM_DEBUGGED(path, flag) \ 61c7f682dbSMatt Jacob ((cam_dflags & (flag)) \ 62c7f682dbSMatt Jacob && (cam_dpath != NULL) \ 63b8b98bc3SJustin T. Gibbs && (xpt_path_comp(cam_dpath, path) >= 0) \ 64b8b98bc3SJustin T. Gibbs && (xpt_path_comp(cam_dpath, path) < 2)) 658b8a9b1dSJustin T. Gibbs #define CAM_DEBUG(path, flag, printfargs) \ 668b8a9b1dSJustin T. Gibbs if ((cam_dflags & (flag)) \ 678b8a9b1dSJustin T. Gibbs && (cam_dpath != NULL) \ 68b8b98bc3SJustin T. Gibbs && (xpt_path_comp(cam_dpath, path) >= 0) \ 69b8b98bc3SJustin T. Gibbs && (xpt_path_comp(cam_dpath, path) < 2)) { \ 708b8a9b1dSJustin T. Gibbs xpt_print_path(path); \ 718b8a9b1dSJustin T. Gibbs printf printfargs; \ 72b8b98bc3SJustin T. Gibbs if (cam_debug_delay != 0) \ 73b8b98bc3SJustin T. Gibbs DELAY(cam_debug_delay); \ 748b8a9b1dSJustin T. Gibbs } 758b8a9b1dSJustin T. Gibbs #define CAM_DEBUG_PRINT(flag, printfargs) \ 768b8a9b1dSJustin T. Gibbs if (cam_dflags & (flag)) { \ 778b8a9b1dSJustin T. Gibbs printf("cam_debug: "); \ 788b8a9b1dSJustin T. Gibbs printf printfargs; \ 79b8b98bc3SJustin T. Gibbs if (cam_debug_delay != 0) \ 80b8b98bc3SJustin T. Gibbs DELAY(cam_debug_delay); \ 818b8a9b1dSJustin T. Gibbs } 828b8a9b1dSJustin T. Gibbs 838b8a9b1dSJustin T. Gibbs #else /* !CAMDEBUG || !KERNEL */ 848b8a9b1dSJustin T. Gibbs 85c7f682dbSMatt Jacob #define CAM_DEBUGGED(A, B) 0 868b8a9b1dSJustin T. Gibbs #define CAM_DEBUG(A, B, C) 878b8a9b1dSJustin T. Gibbs #define CAM_DEBUG_PRINT(A, B) 888b8a9b1dSJustin T. Gibbs 898b8a9b1dSJustin T. Gibbs #endif /* CAMDEBUG && KERNEL */ 908b8a9b1dSJustin T. Gibbs 918b8a9b1dSJustin T. Gibbs #endif /* _CAM_CAM_DEBUG_H */ 92