xref: /netbsd-src/sys/dev/scsipi/scsipi_debug.h (revision ce099b40997c43048fb78bd578195f81d2456523)
1*ce099b40Smartin /*	$NetBSD: scsipi_debug.h,v 1.17 2008/04/28 20:23:58 martin Exp $	*/
2fccfa11aScgd 
3937a7a3eSbouyer /*-
4937a7a3eSbouyer  * Copyright (c) 1999 The NetBSD Foundation, Inc.
5937a7a3eSbouyer  * All rights reserved.
6937a7a3eSbouyer  *
7937a7a3eSbouyer  * This code is derived from software contributed to The NetBSD Foundation
8937a7a3eSbouyer  * by by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9937a7a3eSbouyer  * NASA Ames Research Center.
10937a7a3eSbouyer  *
11937a7a3eSbouyer  * Redistribution and use in source and binary forms, with or without
12937a7a3eSbouyer  * modification, are permitted provided that the following conditions
13937a7a3eSbouyer  * are met:
14937a7a3eSbouyer  * 1. Redistributions of source code must retain the above copyright
15937a7a3eSbouyer  *    notice, this list of conditions and the following disclaimer.
16937a7a3eSbouyer  * 2. Redistributions in binary form must reproduce the above copyright
17937a7a3eSbouyer  *    notice, this list of conditions and the following disclaimer in the
18937a7a3eSbouyer  *    documentation and/or other materials provided with the distribution.
19937a7a3eSbouyer  *
20937a7a3eSbouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21937a7a3eSbouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22937a7a3eSbouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23937a7a3eSbouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24937a7a3eSbouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25937a7a3eSbouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26937a7a3eSbouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27937a7a3eSbouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28937a7a3eSbouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29937a7a3eSbouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30937a7a3eSbouyer  * POSSIBILITY OF SUCH DAMAGE.
3137548328Smycroft  */
32ef09ae65Senami 
33c13e3a66Smrg #if defined(_KERNEL_OPT)
34937a7a3eSbouyer #include "opt_scsipi_debug.h"
35937a7a3eSbouyer #endif
3637548328Smycroft 
3737548328Smycroft /*
38937a7a3eSbouyer  * Originally written by Julian Elischer (julian@tfs.com)
3937548328Smycroft  */
40937a7a3eSbouyer 
41937a7a3eSbouyer #define	SCSIPI_DB1	0x0001		/* scsi commands, errors, data */
42937a7a3eSbouyer #define	SCSIPI_DB2	0x0002		/* routine flow tracking */
43937a7a3eSbouyer #define	SCSIPI_DB3	0x0004		/* internal to routine flows */
44937a7a3eSbouyer #define	SCSIPI_DB4	0x0008		/* level 4 debugging for this dev */
45937a7a3eSbouyer 
46937a7a3eSbouyer /*
47937a7a3eSbouyer  * The following options allow us to build a kernel with debugging on
48937a7a3eSbouyer  * by default for a certain type of device.  We can always enable
49937a7a3eSbouyer  * debugging on a specific device using an ioctl.
50937a7a3eSbouyer  */
51937a7a3eSbouyer #ifndef SCSIPI_DEBUG_TYPE
52937a7a3eSbouyer #define	SCSIPI_DEBUG_TYPE	SCSIPI_BUSTYPE_ATAPI
53937a7a3eSbouyer #endif
54937a7a3eSbouyer 
55937a7a3eSbouyer #ifndef SCSIPI_DEBUG_TARGET
56937a7a3eSbouyer #define	SCSIPI_DEBUG_TARGET	-1	/* disabled */
57937a7a3eSbouyer #endif
58937a7a3eSbouyer 
59937a7a3eSbouyer #ifndef	SCSIPI_DEBUG_LUN
60937a7a3eSbouyer #define	SCSIPI_DEBUG_LUN	0
61937a7a3eSbouyer #endif
62937a7a3eSbouyer 
63937a7a3eSbouyer /*
64937a7a3eSbouyer  * Default debugging flags for above.
65937a7a3eSbouyer  */
66937a7a3eSbouyer #ifndef SCSIPI_DEBUG_FLAGS
67937a7a3eSbouyer #define	SCSIPI_DEBUG_FLAGS	(SCSIPI_DB1|SCSIPI_DB2|SCSIPI_DB3)
68937a7a3eSbouyer #endif
69937a7a3eSbouyer 
70937a7a3eSbouyer #ifdef SCSIPI_DEBUG
71937a7a3eSbouyer #define	SC_DEBUG(periph, flags, x)					\
726f3bab1fSbouyer do {									\
73937a7a3eSbouyer 	if ((periph)->periph_dbflags & (flags)) {			\
74937a7a3eSbouyer 		scsipi_printaddr((periph));				\
75937a7a3eSbouyer 		printf x ;						\
766f3bab1fSbouyer 	}								\
7715839e5dSchristos } while (0)
786f3bab1fSbouyer 
79937a7a3eSbouyer #define	SC_DEBUGN(periph, flags, x)					\
806f3bab1fSbouyer do {									\
81937a7a3eSbouyer 	if ((periph)->periph_dbflags & (flags))				\
82937a7a3eSbouyer 		printf x ;						\
8315839e5dSchristos } while (0)
8437548328Smycroft #else
85937a7a3eSbouyer #define	SC_DEBUG(periph, flags, x)	/* nothing */
86937a7a3eSbouyer #define	SC_DEBUGN(periph, flags, x)	/* nothing */
8737548328Smycroft #endif
88