brintos

brintos / linux-shallow public Read only

0
0
Text · 3.6 KiB · 3df8778 Raw
86 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#ifndef _SCSI_LOGGING_H3#define _SCSI_LOGGING_H4 5 6/*7 * This defines the scsi logging feature.  It is a means by which the user can8 * select how much information they get about various goings on, and it can be9 * really useful for fault tracing.  The logging word is divided into 10 3-bit10 * bitfields, each of which describes a loglevel.  The division of things is11 * somewhat arbitrary, and the division of the word could be changed if it12 * were really needed for any reason.  The numbers below are the only place13 * where these are specified.  For a first go-around, 3 bits is more than14 * enough, since this gives 8 levels of logging (really 7, since 0 is always15 * off).  Cutting to 2 bits might be wise at some point.16 */17 18#define SCSI_LOG_ERROR_SHIFT              019#define SCSI_LOG_TIMEOUT_SHIFT            320#define SCSI_LOG_SCAN_SHIFT               621#define SCSI_LOG_MLQUEUE_SHIFT            922#define SCSI_LOG_MLCOMPLETE_SHIFT         1223#define SCSI_LOG_LLQUEUE_SHIFT            1524#define SCSI_LOG_LLCOMPLETE_SHIFT         1825#define SCSI_LOG_HLQUEUE_SHIFT            2126#define SCSI_LOG_HLCOMPLETE_SHIFT         2427#define SCSI_LOG_IOCTL_SHIFT              2728 29#define SCSI_LOG_ERROR_BITS               330#define SCSI_LOG_TIMEOUT_BITS             331#define SCSI_LOG_SCAN_BITS                332#define SCSI_LOG_MLQUEUE_BITS             333#define SCSI_LOG_MLCOMPLETE_BITS          334#define SCSI_LOG_LLQUEUE_BITS             335#define SCSI_LOG_LLCOMPLETE_BITS          336#define SCSI_LOG_HLQUEUE_BITS             337#define SCSI_LOG_HLCOMPLETE_BITS          338#define SCSI_LOG_IOCTL_BITS               339 40extern unsigned int scsi_logging_level;41 42#ifdef CONFIG_SCSI_LOGGING43 44#define SCSI_LOG_LEVEL(SHIFT, BITS)				\45        ((scsi_logging_level >> (SHIFT)) & ((1 << (BITS)) - 1))46 47#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD)		\48do {								\49        if (unlikely((SCSI_LOG_LEVEL(SHIFT, BITS)) > (LEVEL)))	\50		do {						\51			CMD;					\52		} while (0);					\53} while (0)54#else55#define SCSI_LOG_LEVEL(SHIFT, BITS) 056#define SCSI_CHECK_LOGGING(SHIFT, BITS, LEVEL, CMD) do { } while (0)57#endif /* CONFIG_SCSI_LOGGING */58 59/*60 * These are the macros that are actually used throughout the code to61 * log events.  If logging isn't enabled, they are no-ops and will be62 * completely absent from the user's code.63 */64#define SCSI_LOG_ERROR_RECOVERY(LEVEL,CMD)  \65        SCSI_CHECK_LOGGING(SCSI_LOG_ERROR_SHIFT, SCSI_LOG_ERROR_BITS, LEVEL,CMD);66#define SCSI_LOG_TIMEOUT(LEVEL,CMD)  \67        SCSI_CHECK_LOGGING(SCSI_LOG_TIMEOUT_SHIFT, SCSI_LOG_TIMEOUT_BITS, LEVEL,CMD);68#define SCSI_LOG_SCAN_BUS(LEVEL,CMD)  \69        SCSI_CHECK_LOGGING(SCSI_LOG_SCAN_SHIFT, SCSI_LOG_SCAN_BITS, LEVEL,CMD);70#define SCSI_LOG_MLQUEUE(LEVEL,CMD)  \71        SCSI_CHECK_LOGGING(SCSI_LOG_MLQUEUE_SHIFT, SCSI_LOG_MLQUEUE_BITS, LEVEL,CMD);72#define SCSI_LOG_MLCOMPLETE(LEVEL,CMD)  \73        SCSI_CHECK_LOGGING(SCSI_LOG_MLCOMPLETE_SHIFT, SCSI_LOG_MLCOMPLETE_BITS, LEVEL,CMD);74#define SCSI_LOG_LLQUEUE(LEVEL,CMD)  \75        SCSI_CHECK_LOGGING(SCSI_LOG_LLQUEUE_SHIFT, SCSI_LOG_LLQUEUE_BITS, LEVEL,CMD);76#define SCSI_LOG_LLCOMPLETE(LEVEL,CMD)  \77        SCSI_CHECK_LOGGING(SCSI_LOG_LLCOMPLETE_SHIFT, SCSI_LOG_LLCOMPLETE_BITS, LEVEL,CMD);78#define SCSI_LOG_HLQUEUE(LEVEL,CMD)  \79        SCSI_CHECK_LOGGING(SCSI_LOG_HLQUEUE_SHIFT, SCSI_LOG_HLQUEUE_BITS, LEVEL,CMD);80#define SCSI_LOG_HLCOMPLETE(LEVEL,CMD)  \81        SCSI_CHECK_LOGGING(SCSI_LOG_HLCOMPLETE_SHIFT, SCSI_LOG_HLCOMPLETE_BITS, LEVEL,CMD);82#define SCSI_LOG_IOCTL(LEVEL,CMD)  \83        SCSI_CHECK_LOGGING(SCSI_LOG_IOCTL_SHIFT, SCSI_LOG_IOCTL_BITS, LEVEL,CMD);84 85#endif /* _SCSI_LOGGING_H */86