brintos

brintos / linux-shallow public Read only

0
0
Text · 4.9 KiB · e94f752 Raw
198 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later */2/*3 * Driver for Broadcom MPI3 Storage Controllers4 *5 * Copyright (C) 2017-2023 Broadcom Inc.6 *  (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)7 *8 */9 10#ifndef MPI3SAS_DEBUG_H_INCLUDED11 12#define MPI3SAS_DEBUG_H_INCLUDED13 14/*15 * debug levels16 */17 18#define MPI3_DEBUG_EVENT		0x0000000119#define MPI3_DEBUG_EVENT_WORK_TASK	0x0000000220#define MPI3_DEBUG_INIT		0x0000000421#define MPI3_DEBUG_EXIT		0x0000000822#define MPI3_DEBUG_TM			0x0000001023#define MPI3_DEBUG_RESET		0x0000002024#define MPI3_DEBUG_SCSI_ERROR		0x0000004025#define MPI3_DEBUG_REPLY		0x0000008026#define MPI3_DEBUG_CFG_ERROR		0x0000010027#define MPI3_DEBUG_TRANSPORT_ERROR	0x0000020028#define MPI3_DEBUG_BSG_ERROR		0x0000800029#define MPI3_DEBUG_BSG_INFO		0x0001000030#define MPI3_DEBUG_SCSI_INFO		0x0002000031#define MPI3_DEBUG_CFG_INFO		0x0004000032#define MPI3_DEBUG_TRANSPORT_INFO	0x0008000033#define MPI3_DEBUG			0x0100000034#define MPI3_DEBUG_SG			0x0200000035 36 37/*38 * debug macros39 */40 41#define ioc_err(ioc, fmt, ...) \42	pr_err("%s: " fmt, (ioc)->name, ##__VA_ARGS__)43#define ioc_notice(ioc, fmt, ...) \44	pr_notice("%s: " fmt, (ioc)->name, ##__VA_ARGS__)45#define ioc_warn(ioc, fmt, ...) \46	pr_warn("%s: " fmt, (ioc)->name, ##__VA_ARGS__)47#define ioc_info(ioc, fmt, ...) \48	pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__)49 50#define dprint(ioc, fmt, ...) \51	do { \52		if (ioc->logging_level & MPI3_DEBUG) \53			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \54	} while (0)55 56#define dprint_event_th(ioc, fmt, ...) \57	do { \58		if (ioc->logging_level & MPI3_DEBUG_EVENT) \59			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \60	} while (0)61 62#define dprint_event_bh(ioc, fmt, ...) \63	do { \64		if (ioc->logging_level & MPI3_DEBUG_EVENT_WORK_TASK) \65			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \66	} while (0)67 68#define dprint_init(ioc, fmt, ...) \69	do { \70		if (ioc->logging_level & MPI3_DEBUG_INIT) \71			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \72	} while (0)73 74#define dprint_exit(ioc, fmt, ...) \75	do { \76		if (ioc->logging_level & MPI3_DEBUG_EXIT) \77			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \78	} while (0)79 80#define dprint_tm(ioc, fmt, ...) \81	do { \82		if (ioc->logging_level & MPI3_DEBUG_TM) \83			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \84	} while (0)85 86#define dprint_reply(ioc, fmt, ...) \87	do { \88		if (ioc->logging_level & MPI3_DEBUG_REPLY) \89			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \90	} while (0)91 92#define dprint_reset(ioc, fmt, ...) \93	do { \94		if (ioc->logging_level & MPI3_DEBUG_RESET) \95			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \96	} while (0)97 98#define dprint_scsi_info(ioc, fmt, ...) \99	do { \100		if (ioc->logging_level & MPI3_DEBUG_SCSI_INFO) \101			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \102	} while (0)103 104#define dprint_scsi_err(ioc, fmt, ...) \105	do { \106		if (ioc->logging_level & MPI3_DEBUG_SCSI_ERROR) \107			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \108	} while (0)109 110#define dprint_scsi_command(ioc, SCMD, LOG_LEVEL) \111	do { \112		if (ioc->logging_level & LOG_LEVEL) \113			scsi_print_command(SCMD); \114	} while (0)115 116 117#define dprint_bsg_info(ioc, fmt, ...) \118	do { \119		if (ioc->logging_level & MPI3_DEBUG_BSG_INFO) \120			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \121	} while (0)122 123#define dprint_bsg_err(ioc, fmt, ...) \124	do { \125		if (ioc->logging_level & MPI3_DEBUG_BSG_ERROR) \126			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \127	} while (0)128 129#define dprint_cfg_info(ioc, fmt, ...) \130	do { \131		if (ioc->logging_level & MPI3_DEBUG_CFG_INFO) \132			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \133	} while (0)134 135#define dprint_cfg_err(ioc, fmt, ...) \136	do { \137		if (ioc->logging_level & MPI3_DEBUG_CFG_ERROR) \138			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \139	} while (0)140#define dprint_transport_info(ioc, fmt, ...) \141	do { \142		if (ioc->logging_level & MPI3_DEBUG_TRANSPORT_INFO) \143			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \144	} while (0)145 146#define dprint_transport_err(ioc, fmt, ...) \147	do { \148		if (ioc->logging_level & MPI3_DEBUG_TRANSPORT_ERROR) \149			pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \150	} while (0)151 152#endif /* MPT3SAS_DEBUG_H_INCLUDED */153 154/**155 * dprint_dump - print contents of a memory buffer156 * @req: Pointer to a memory buffer157 * @sz: Memory buffer size158 * @namestr: Name String to identify the buffer type159 */160static inline void161dprint_dump(void *req, int sz, const char *name_string)162{163	int i;164	__le32 *mfp = (__le32 *)req;165 166	sz = sz/4;167	if (name_string)168		pr_info("%s:\n\t", name_string);169	else170		pr_info("request:\n\t");171	for (i = 0; i < sz; i++) {172		if (i && ((i % 8) == 0))173			pr_info("\n\t");174		pr_info("%08x ", le32_to_cpu(mfp[i]));175	}176	pr_info("\n");177}178 179/**180 * dprint_dump_req - print message frame contents181 * @req: pointer to message frame182 * @sz: number of dwords183 */184static inline void185dprint_dump_req(void *req, int sz)186{187	int i;188	__le32 *mfp = (__le32 *)req;189 190	pr_info("request:\n\t");191	for (i = 0; i < sz; i++) {192		if (i && ((i % 8) == 0))193			pr_info("\n\t");194		pr_info("%08x ", le32_to_cpu(mfp[i]));195	}196	pr_info("\n");197}198