diff mbox series

[RFC,v1,054/256] cl8k: add debug.h

Message ID 20210617160223.160998-55-viktor.barna@celeno.com
State New
Headers show
Series wireless: cl8k driver for Celeno IEEE 802.11ax devices | expand

Commit Message

Viktor Barna June 17, 2021, 3:59 p.m. UTC
From: Viktor Barna <viktor.barna@celeno.com>

(Part of the split. Please, take a look at the cover letter for more
details).

Signed-off-by: Viktor Barna <viktor.barna@celeno.com>
---
 drivers/net/wireless/celeno/cl8k/debug.h | 121 +++++++++++++++++++++++
 1 file changed, 121 insertions(+)
 create mode 100644 drivers/net/wireless/celeno/cl8k/debug.h

--
2.30.0
diff mbox series

Patch

diff --git a/drivers/net/wireless/celeno/cl8k/debug.h b/drivers/net/wireless/celeno/cl8k/debug.h
new file mode 100644
index 000000000000..f51591755051
--- /dev/null
+++ b/drivers/net/wireless/celeno/cl8k/debug.h
@@ -0,0 +1,121 @@ 
+/* SPDX-License-Identifier: MIT */
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#ifndef CL_DEBUG_H
+#define CL_DEBUG_H
+
+#include <linux/string.h>
+
+enum cl_dbg_level {
+       DBG_LVL_VERBOSE,
+       DBG_LVL_ERROR,
+       DBG_LVL_WARNING,
+       DBG_LVL_TRACE,
+       DBG_LVL_INFO,
+
+       DBG_LVL_MAX,
+};
+
+#define CL_DBG(cl_hw, lvl, fmt, ...) \
+do { \
+       if ((lvl) <= (cl_hw)->conf->ce_debug_level) \
+               pr_debug("[tcv%u][%s][%d] " fmt, (cl_hw)->idx, __func__, __LINE__, ##__VA_ARGS__); \
+} while (0)
+
+#define CL_DBG_CHIP(chip, lvl, fmt, ...) \
+do { \
+       if ((lvl) <= (chip)->conf->ce_debug_level) \
+               pr_debug("[chip%u][%s][%d] " fmt, (chip)->idx, __func__, __LINE__, ##__VA_ARGS__); \
+} while (0)
+
+#define cl_dbg_verbose(cl_hw, ...) CL_DBG((cl_hw), DBG_LVL_VERBOSE, ##__VA_ARGS__)
+#define cl_dbg_err(cl_hw, ...)     CL_DBG((cl_hw), DBG_LVL_ERROR, ##__VA_ARGS__)
+#define cl_dbg_warn(cl_hw, ...)    CL_DBG((cl_hw), DBG_LVL_WARNING, ##__VA_ARGS__)
+#define cl_dbg_trace(cl_hw, ...)   CL_DBG((cl_hw), DBG_LVL_TRACE, ##__VA_ARGS__)
+#define cl_dbg_info(cl_hw, ...)    CL_DBG((cl_hw), DBG_LVL_INFO, ##__VA_ARGS__)
+
+#define cl_dbg_chip_verbose(chip, ...) CL_DBG_CHIP((chip), DBG_LVL_VERBOSE, ##__VA_ARGS__)
+#define cl_dbg_chip_err(chip, ...)     CL_DBG_CHIP((chip), DBG_LVL_ERROR, ##__VA_ARGS__)
+#define cl_dbg_chip_warn(chip, ...)    CL_DBG_CHIP((chip), DBG_LVL_WARNING, ##__VA_ARGS__)
+#define cl_dbg_chip_trace(chip, ...)   CL_DBG_CHIP((chip), DBG_LVL_TRACE, ##__VA_ARGS__)
+#define cl_dbg_chip_info(chip, ...)    CL_DBG_CHIP((chip), DBG_LVL_INFO, ##__VA_ARGS__)
+
+static inline char *basename(const char *filename)
+{
+       char *p = strrchr(filename, '/');
+
+       return p ? p + 1 : (char *)filename;
+}
+
+#define TXT_ERROR \
+       do { \
+               pr_debug("\n"); \
+               pr_debug("#######  #####    #####     #####   #####\n"); \
+               pr_debug("#        #    #   #    #   #     #  #    #\n"); \
+               pr_debug("#        #    #   #    #   #     #  #    #\n"); \
+               pr_debug("#######  #####    #####    #     #  #####\n"); \
+               pr_debug("#        #    #   #    #   #     #  #    #\n"); \
+               pr_debug("#        #     #  #     #  #     #  #     #\n"); \
+               pr_debug("#######  #     #  #     #   #####   #     #\n"); \
+       } while (0)
+
+#define TXT_WARNING \
+       do { \
+               pr_debug("\n"); \
+               pr_debug("#       #   #####   #####    #     #  ###  #     #   #####\n"); \
+               pr_debug("#       #  #     #  #    #   ##    #   #   ##    #  #     #\n"); \
+               pr_debug("#       #  #     #  #    #   # #   #   #   # #   #  #\n"); \
+               pr_debug("#   #   #  #######  #####    #  #  #   #   #  #  #  #    ###\n"); \
+               pr_debug("#  # #  #  #     #  #    #   #   # #   #   #   # #  #     #\n"); \
+               pr_debug("# #   # #  #     #  #     #  #    ##   #   #    ##  #     #\n"); \
+               pr_debug(" #     #   #     #  #     #  #     #  ###  #     #   #####\n"); \
+       } while (0)
+
+#define INFO_CL_HW(cl_hw, ...) \
+       do { \
+               pr_debug("\n"); \
+               pr_debug("CHIP:        %u\n", (cl_hw)->chip->idx); \
+               pr_debug("TCV:         %u\n", (cl_hw)->idx); \
+               pr_debug("FILE:        %s\n", basename(__FILE__)); \
+               pr_debug("FUNCTION:    %s\n", __func__); \
+               pr_debug("LINE:        %u\n", __LINE__); \
+               pr_debug("DESCRIPTION: " __VA_ARGS__); \
+               pr_debug("\n"); \
+       } while (0)
+
+#define INFO_CHIP(chip, ...) \
+       do { \
+               pr_debug("\n"); \
+               pr_debug("CHIP:        %u\n", (chip)->idx); \
+               pr_debug("FILE:        %s\n", basename(__FILE__)); \
+               pr_debug("FUNCTION:    %s\n", __func__); \
+               pr_debug("LINE:        %u\n", __LINE__); \
+               pr_debug("DESCRIPTION: " __VA_ARGS__); \
+               pr_debug("\n"); \
+       } while (0)
+
+#define CL_DBG_ERROR(cl_hw, ...) \
+       do { \
+               TXT_ERROR; \
+               INFO_CL_HW(cl_hw, __VA_ARGS__); \
+       } while (0)
+
+#define CL_DBG_ERROR_CHIP(chip, ...) \
+       do { \
+               TXT_ERROR; \
+               INFO_CHIP(chip, __VA_ARGS__); \
+       } while (0)
+
+#define CL_DBG_WARNING(cl_hw, ...) \
+       do { \
+               TXT_WARNING; \
+               INFO_CL_HW(cl_hw, __VA_ARGS__); \
+       } while (0)
+
+#define CL_DBG_WARNING_CHIP(chip, ...) \
+       do { \
+               TXT_WARNING; \
+               INFO_CHIP(chip, __VA_ARGS__); \
+       } while (0)
+
+#endif /* CL_DEBUG_H */