cam_debug.h revision 41546
15455Sdg/*
21541Srgrimes * Macros for tracing/loging information in the CAM layer
31541Srgrimes *
41541Srgrimes * Copyright (c) 1997 Justin T. Gibbs.
51541Srgrimes * All rights reserved.
61541Srgrimes *
71541Srgrimes * Redistribution and use in source and binary forms, with or without
81541Srgrimes * modification, are permitted provided that the following conditions
91541Srgrimes * are met:
101541Srgrimes * 1. Redistributions of source code must retain the above copyright
111541Srgrimes *    notice, this list of conditions, and the following disclaimer,
121541Srgrimes *    without modification, immediately at the beginning of the file.
131541Srgrimes * 2. The name of the author may not be used to endorse or promote products
141541Srgrimes *    derived from this software without specific prior written permission.
151541Srgrimes *
161541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
171541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
181541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
191541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
201541Srgrimes * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
211541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
221541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
231541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
241541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
251541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261541Srgrimes * SUCH DAMAGE.
271541Srgrimes *
281541Srgrimes *      $Id: cam_debug.h,v 1.2 1998/10/02 21:00:50 ken Exp $
291541Srgrimes */
301541Srgrimes#ifndef	_CAM_CAM_DEBUG_H
311541Srgrimes#define _CAM_CAM_DEBUG_H 1
321541Srgrimes
331541Srgrimes#if defined(CAMDEBUG) && defined(KERNEL)
341541Srgrimes#include <machine/clock.h>
351541Srgrimes#endif /* CAMDEBUG && KERNEL */
361817Sdg
371541Srgrimes/*
381541Srgrimes * Debugging flags.
391541Srgrimes */
401541Srgrimestypedef enum {
411541Srgrimes	CAM_DEBUG_NONE		= 0x00, /* no debugging */
421541Srgrimes	CAM_DEBUG_INFO		= 0x01,	/* scsi commands, errors, data */
435455Sdg	CAM_DEBUG_TRACE		= 0x02,	/* routine flow tracking */
441541Srgrimes	CAM_DEBUG_SUBTRACE	= 0x04,	/* internal to routine flows */
451541Srgrimes	CAM_DEBUG_CDB		= 0x08, /* print out SCSI CDBs only */
461541Srgrimes	CAM_DEBUG_XPT		= 0x10	/* print out xpt scheduling */
471541Srgrimes} cam_debug_flags;
481541Srgrimes
495455Sdg#if defined(CAMDEBUG) && defined(KERNEL)
505455Sdg
515455Sdg/* Path we want to debug */
521541Srgrimesextern struct cam_path *cam_dpath;
535455Sdg/* Current debug levels set */
541541Srgrimesextern u_int32_t cam_dflags;
551541Srgrimes
561541Srgrimes/* Debugging macros. */
571541Srgrimes#define	CAM_DEBUGGED(path, flag)			\
581541Srgrimes	((cam_dflags & (flag))				\
591541Srgrimes	 && (cam_dpath != NULL)				\
601541Srgrimes	 && (xpt_path_comp(path, cam_dpath) >= 0))
611541Srgrimes#define	CAM_DEBUG(path, flag, printfargs)		\
621541Srgrimes	if ((cam_dflags & (flag))			\
631817Sdg	 && (cam_dpath != NULL)				\
6450477Speter	 && (xpt_path_comp(path, cam_dpath) >= 0)) {	\
651541Srgrimes		xpt_print_path(path);			\
661541Srgrimes 		printf printfargs;			\
671541Srgrimes		DELAY(100000);				\
681541Srgrimes	}
691541Srgrimes#define	CAM_DEBUG_PRINT(flag, printfargs)		\
701541Srgrimes	if (cam_dflags & (flag)) {			\
711541Srgrimes		printf("cam_debug: ");			\
721541Srgrimes 		printf printfargs;			\
731541Srgrimes		DELAY(100000);				\
7444754Sjulian	}
7537282Sjmg
7644754Sjulian#else /* !CAMDEBUG || !KERNEL */
7737282Sjmg
786816Sdg#define	CAM_DEBUGGED(A, B)	0
7938517Sdfr#define	CAM_DEBUG(A, B, C)
801541Srgrimes#define	CAM_DEBUG_PRINT(A, B)
811541Srgrimes
821541Srgrimes#endif /* CAMDEBUG && KERNEL */
831541Srgrimes
841541Srgrimes#endif /* _CAM_CAM_DEBUG_H */
851541Srgrimes