Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: ISC
0002 /*
0003  * Copyright (c) 2010 Broadcom Corporation
0004  */
0005 
0006 #ifndef BRCMFMAC_DEBUG_H
0007 #define BRCMFMAC_DEBUG_H
0008 
0009 #include <linux/net.h>  /* net_ratelimit() */
0010 
0011 /* message levels */
0012 #define BRCMF_TRACE_VAL     0x00000002
0013 #define BRCMF_INFO_VAL      0x00000004
0014 #define BRCMF_DATA_VAL      0x00000008
0015 #define BRCMF_CTL_VAL       0x00000010
0016 #define BRCMF_TIMER_VAL     0x00000020
0017 #define BRCMF_HDRS_VAL      0x00000040
0018 #define BRCMF_BYTES_VAL     0x00000080
0019 #define BRCMF_INTR_VAL      0x00000100
0020 #define BRCMF_GLOM_VAL      0x00000200
0021 #define BRCMF_EVENT_VAL     0x00000400
0022 #define BRCMF_BTA_VAL       0x00000800
0023 #define BRCMF_FIL_VAL       0x00001000
0024 #define BRCMF_USB_VAL       0x00002000
0025 #define BRCMF_SCAN_VAL      0x00004000
0026 #define BRCMF_CONN_VAL      0x00008000
0027 #define BRCMF_BCDC_VAL      0x00010000
0028 #define BRCMF_SDIO_VAL      0x00020000
0029 #define BRCMF_MSGBUF_VAL    0x00040000
0030 #define BRCMF_PCIE_VAL      0x00080000
0031 #define BRCMF_FWCON_VAL     0x00100000
0032 
0033 /* set default print format */
0034 #undef pr_fmt
0035 #define pr_fmt(fmt)     KBUILD_MODNAME ": " fmt
0036 
0037 struct brcmf_bus;
0038 
0039 __printf(3, 4)
0040 void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
0041 /* Macro for error messages. When debugging / tracing the driver all error
0042  * messages are important to us.
0043  */
0044 #ifndef brcmf_err
0045 #define brcmf_err(fmt, ...)                     \
0046     do {                                \
0047         if (IS_ENABLED(CONFIG_BRCMDBG) ||           \
0048             IS_ENABLED(CONFIG_BRCM_TRACING) ||          \
0049             net_ratelimit())                    \
0050             __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
0051     } while (0)
0052 #endif
0053 
0054 #define bphy_err(drvr, fmt, ...)                    \
0055     do {                                \
0056         if (IS_ENABLED(CONFIG_BRCMDBG) ||           \
0057             IS_ENABLED(CONFIG_BRCM_TRACING) ||          \
0058             net_ratelimit())                    \
0059             wiphy_err((drvr)->wiphy, "%s: " fmt, __func__,  \
0060                   ##__VA_ARGS__);           \
0061     } while (0)
0062 
0063 #define bphy_info_once(drvr, fmt, ...)                  \
0064     wiphy_info_once((drvr)->wiphy, "%s: " fmt, __func__,        \
0065             ##__VA_ARGS__)
0066 
0067 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
0068 
0069 /* For debug/tracing purposes treat info messages as errors */
0070 #define brcmf_info brcmf_err
0071 
0072 __printf(3, 4)
0073 void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...);
0074 #define brcmf_dbg(level, fmt, ...)              \
0075 do {                                \
0076     __brcmf_dbg(BRCMF_##level##_VAL, __func__,      \
0077             fmt, ##__VA_ARGS__);            \
0078 } while (0)
0079 #define BRCMF_DATA_ON()     (brcmf_msg_level & BRCMF_DATA_VAL)
0080 #define BRCMF_CTL_ON()      (brcmf_msg_level & BRCMF_CTL_VAL)
0081 #define BRCMF_HDRS_ON()     (brcmf_msg_level & BRCMF_HDRS_VAL)
0082 #define BRCMF_BYTES_ON()    (brcmf_msg_level & BRCMF_BYTES_VAL)
0083 #define BRCMF_GLOM_ON()     (brcmf_msg_level & BRCMF_GLOM_VAL)
0084 #define BRCMF_EVENT_ON()    (brcmf_msg_level & BRCMF_EVENT_VAL)
0085 #define BRCMF_FIL_ON()      (brcmf_msg_level & BRCMF_FIL_VAL)
0086 #define BRCMF_FWCON_ON()    (brcmf_msg_level & BRCMF_FWCON_VAL)
0087 #define BRCMF_SCAN_ON()     (brcmf_msg_level & BRCMF_SCAN_VAL)
0088 
0089 #else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
0090 
0091 #define brcmf_info(fmt, ...)                        \
0092     do {                                \
0093         pr_info("%s: " fmt, __func__, ##__VA_ARGS__);       \
0094     } while (0)
0095 
0096 #define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
0097 
0098 #define BRCMF_DATA_ON()     0
0099 #define BRCMF_CTL_ON()      0
0100 #define BRCMF_HDRS_ON()     0
0101 #define BRCMF_BYTES_ON()    0
0102 #define BRCMF_GLOM_ON()     0
0103 #define BRCMF_EVENT_ON()    0
0104 #define BRCMF_FIL_ON()      0
0105 #define BRCMF_FWCON_ON()    0
0106 #define BRCMF_SCAN_ON()     0
0107 
0108 #endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */
0109 
0110 #define brcmf_dbg_hex_dump(test, data, len, fmt, ...)           \
0111 do {                                    \
0112     trace_brcmf_hexdump((void *)data, len);             \
0113     if (test)                           \
0114         brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__);  \
0115 } while (0)
0116 
0117 extern int brcmf_msg_level;
0118 
0119 struct brcmf_pub;
0120 #ifdef DEBUG
0121 struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
0122 void brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
0123                  int (*read_fn)(struct seq_file *seq, void *data));
0124 int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
0125                    size_t len);
0126 #else
0127 static inline struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr)
0128 {
0129     return ERR_PTR(-ENOENT);
0130 }
0131 static inline
0132 void brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
0133                  int (*read_fn)(struct seq_file *seq, void *data))
0134 { }
0135 static inline
0136 int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
0137                    size_t len)
0138 {
0139     return 0;
0140 }
0141 #endif
0142 
0143 #endif /* BRCMFMAC_DEBUG_H */