/*-1* Macros for tracing/loging information in the CAM layer2*3* SPDX-License-Identifier: BSD-2-Clause4*5* Copyright (c) 1997 Justin T. Gibbs.6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions, and the following disclaimer,13* without modification, immediately at the beginning of the file.14* 2. The name of the author may not be used to endorse or promote products15* derived from this software without specific prior written permission.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR21* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*/29#ifndef _CAM_CAM_DEBUG_H30#define _CAM_CAM_DEBUG_H 13132/*33* Debugging flags.34*/35typedef enum {36CAM_DEBUG_NONE = 0x00, /* no debugging */37CAM_DEBUG_INFO = 0x01, /* scsi commands, errors, data */38CAM_DEBUG_TRACE = 0x02, /* routine flow tracking */39CAM_DEBUG_SUBTRACE = 0x04, /* internal to routine flows */40CAM_DEBUG_CDB = 0x08, /* print out SCSI CDBs only */41CAM_DEBUG_XPT = 0x10, /* print out xpt scheduling */42CAM_DEBUG_PERIPH = 0x20, /* print out peripheral calls */43CAM_DEBUG_PROBE = 0x40 /* print out probe actions */44} cam_debug_flags;4546#if defined(_KERNEL)4748#ifndef CAM_DEBUG_FLAGS49#define CAM_DEBUG_FLAGS CAM_DEBUG_NONE50#endif5152#ifndef CAM_DEBUG_COMPILE53#ifdef CAMDEBUG54#define CAM_DEBUG_COMPILE (-1)55#else56#define CAM_DEBUG_COMPILE (CAM_DEBUG_INFO | CAM_DEBUG_CDB | \57CAM_DEBUG_PERIPH | CAM_DEBUG_PROBE | \58CAM_DEBUG_FLAGS)59#endif60#endif6162#ifndef CAM_DEBUG_BUS63#define CAM_DEBUG_BUS CAM_BUS_WILDCARD64#endif65#ifndef CAM_DEBUG_TARGET66#define CAM_DEBUG_TARGET CAM_TARGET_WILDCARD67#endif68#ifndef CAM_DEBUG_LUN69#define CAM_DEBUG_LUN CAM_LUN_WILDCARD70#endif7172#ifndef CAM_DEBUG_DELAY73#define CAM_DEBUG_DELAY 074#endif7576/* Path we want to debug */77extern struct cam_path *cam_dpath;78/* Current debug levels set */79extern uint32_t cam_dflags;80/* Printf delay value (to prevent scrolling) */81extern uint32_t cam_debug_delay;8283/* Helper routines -- helps conserve stack */84struct cam_ed;85void xpt_cam_path_debug(struct cam_path *path, const char *fmt, ...);86void xpt_cam_dev_debug(struct cam_ed *dev, const char *fmt, ...);87void xpt_cam_debug(const char *fmt, ...);8889/* Stupid macro to remove a layer of parens */90#define _CAM_X(...) __VA_ARGS__9192/* Debugging macros. */93#define CAM_DEBUGGED(path, flag) \94(((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \95&& (cam_dpath != NULL) \96&& (xpt_path_comp(cam_dpath, (path)) >= 0) \97&& (xpt_path_comp(cam_dpath, (path)) < 2))9899#define CAM_DEBUG(path, flag, printfargs) \100if (CAM_DEBUGGED(path, flag)) { \101xpt_cam_path_debug(path, _CAM_X printfargs); \102}103104#define CAM_DEBUG_DEV(dev, flag, printfargs) \105if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \106&& (cam_dpath != NULL) \107&& (xpt_path_comp_dev(cam_dpath, (dev)) >= 0) \108&& (xpt_path_comp_dev(cam_dpath, (dev)) < 2)) { \109xpt_cam_dev_debug(dev, _CAM_X printfargs); \110}111112#define CAM_DEBUG_PRINT(flag, printfargs) \113if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) { \114xpt_cam_debug(_CAM_X printfargs); \115}116117#else /* !_KERNEL */118119#define CAM_DEBUGGED(A, B) 0120#define CAM_DEBUG(A, B, C)121#define CAM_DEBUG_DEV(A, B, C)122#define CAM_DEBUG_PRINT(A, B)123124#endif /* _KERNEL */125126#endif /* _CAM_CAM_DEBUG_H */127128129