18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: ISC 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2010 Broadcom Corporation 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef BRCMFMAC_DEBUG_H 78c2ecf20Sopenharmony_ci#define BRCMFMAC_DEBUG_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/net.h> /* net_ratelimit() */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* message levels */ 128c2ecf20Sopenharmony_ci#define BRCMF_TRACE_VAL 0x00000002 138c2ecf20Sopenharmony_ci#define BRCMF_INFO_VAL 0x00000004 148c2ecf20Sopenharmony_ci#define BRCMF_DATA_VAL 0x00000008 158c2ecf20Sopenharmony_ci#define BRCMF_CTL_VAL 0x00000010 168c2ecf20Sopenharmony_ci#define BRCMF_TIMER_VAL 0x00000020 178c2ecf20Sopenharmony_ci#define BRCMF_HDRS_VAL 0x00000040 188c2ecf20Sopenharmony_ci#define BRCMF_BYTES_VAL 0x00000080 198c2ecf20Sopenharmony_ci#define BRCMF_INTR_VAL 0x00000100 208c2ecf20Sopenharmony_ci#define BRCMF_GLOM_VAL 0x00000200 218c2ecf20Sopenharmony_ci#define BRCMF_EVENT_VAL 0x00000400 228c2ecf20Sopenharmony_ci#define BRCMF_BTA_VAL 0x00000800 238c2ecf20Sopenharmony_ci#define BRCMF_FIL_VAL 0x00001000 248c2ecf20Sopenharmony_ci#define BRCMF_USB_VAL 0x00002000 258c2ecf20Sopenharmony_ci#define BRCMF_SCAN_VAL 0x00004000 268c2ecf20Sopenharmony_ci#define BRCMF_CONN_VAL 0x00008000 278c2ecf20Sopenharmony_ci#define BRCMF_BCDC_VAL 0x00010000 288c2ecf20Sopenharmony_ci#define BRCMF_SDIO_VAL 0x00020000 298c2ecf20Sopenharmony_ci#define BRCMF_MSGBUF_VAL 0x00040000 308c2ecf20Sopenharmony_ci#define BRCMF_PCIE_VAL 0x00080000 318c2ecf20Sopenharmony_ci#define BRCMF_FWCON_VAL 0x00100000 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* set default print format */ 348c2ecf20Sopenharmony_ci#undef pr_fmt 358c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistruct brcmf_bus; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci__printf(3, 4) 408c2ecf20Sopenharmony_civoid __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...); 418c2ecf20Sopenharmony_ci/* Macro for error messages. When debugging / tracing the driver all error 428c2ecf20Sopenharmony_ci * messages are important to us. 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci#ifndef brcmf_err 458c2ecf20Sopenharmony_ci#define brcmf_err(fmt, ...) \ 468c2ecf20Sopenharmony_ci do { \ 478c2ecf20Sopenharmony_ci if (IS_ENABLED(CONFIG_BRCMDBG) || \ 488c2ecf20Sopenharmony_ci IS_ENABLED(CONFIG_BRCM_TRACING) || \ 498c2ecf20Sopenharmony_ci net_ratelimit()) \ 508c2ecf20Sopenharmony_ci __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\ 518c2ecf20Sopenharmony_ci } while (0) 528c2ecf20Sopenharmony_ci#endif 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define bphy_err(drvr, fmt, ...) \ 558c2ecf20Sopenharmony_ci do { \ 568c2ecf20Sopenharmony_ci if (IS_ENABLED(CONFIG_BRCMDBG) || \ 578c2ecf20Sopenharmony_ci IS_ENABLED(CONFIG_BRCM_TRACING) || \ 588c2ecf20Sopenharmony_ci net_ratelimit()) \ 598c2ecf20Sopenharmony_ci wiphy_err((drvr)->wiphy, "%s: " fmt, __func__, \ 608c2ecf20Sopenharmony_ci ##__VA_ARGS__); \ 618c2ecf20Sopenharmony_ci } while (0) 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#if defined(DEBUG) || defined(CONFIG_BRCM_TRACING) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* For debug/tracing purposes treat info messages as errors */ 668c2ecf20Sopenharmony_ci#define brcmf_info brcmf_err 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci__printf(3, 4) 698c2ecf20Sopenharmony_civoid __brcmf_dbg(u32 level, const char *func, const char *fmt, ...); 708c2ecf20Sopenharmony_ci#define brcmf_dbg(level, fmt, ...) \ 718c2ecf20Sopenharmony_cido { \ 728c2ecf20Sopenharmony_ci __brcmf_dbg(BRCMF_##level##_VAL, __func__, \ 738c2ecf20Sopenharmony_ci fmt, ##__VA_ARGS__); \ 748c2ecf20Sopenharmony_ci} while (0) 758c2ecf20Sopenharmony_ci#define BRCMF_DATA_ON() (brcmf_msg_level & BRCMF_DATA_VAL) 768c2ecf20Sopenharmony_ci#define BRCMF_CTL_ON() (brcmf_msg_level & BRCMF_CTL_VAL) 778c2ecf20Sopenharmony_ci#define BRCMF_HDRS_ON() (brcmf_msg_level & BRCMF_HDRS_VAL) 788c2ecf20Sopenharmony_ci#define BRCMF_BYTES_ON() (brcmf_msg_level & BRCMF_BYTES_VAL) 798c2ecf20Sopenharmony_ci#define BRCMF_GLOM_ON() (brcmf_msg_level & BRCMF_GLOM_VAL) 808c2ecf20Sopenharmony_ci#define BRCMF_EVENT_ON() (brcmf_msg_level & BRCMF_EVENT_VAL) 818c2ecf20Sopenharmony_ci#define BRCMF_FIL_ON() (brcmf_msg_level & BRCMF_FIL_VAL) 828c2ecf20Sopenharmony_ci#define BRCMF_FWCON_ON() (brcmf_msg_level & BRCMF_FWCON_VAL) 838c2ecf20Sopenharmony_ci#define BRCMF_SCAN_ON() (brcmf_msg_level & BRCMF_SCAN_VAL) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#else /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */ 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define brcmf_info(fmt, ...) \ 888c2ecf20Sopenharmony_ci do { \ 898c2ecf20Sopenharmony_ci pr_info("%s: " fmt, __func__, ##__VA_ARGS__); \ 908c2ecf20Sopenharmony_ci } while (0) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define brcmf_dbg(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define BRCMF_DATA_ON() 0 958c2ecf20Sopenharmony_ci#define BRCMF_CTL_ON() 0 968c2ecf20Sopenharmony_ci#define BRCMF_HDRS_ON() 0 978c2ecf20Sopenharmony_ci#define BRCMF_BYTES_ON() 0 988c2ecf20Sopenharmony_ci#define BRCMF_GLOM_ON() 0 998c2ecf20Sopenharmony_ci#define BRCMF_EVENT_ON() 0 1008c2ecf20Sopenharmony_ci#define BRCMF_FIL_ON() 0 1018c2ecf20Sopenharmony_ci#define BRCMF_FWCON_ON() 0 1028c2ecf20Sopenharmony_ci#define BRCMF_SCAN_ON() 0 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#endif /* defined(DEBUG) || defined(CONFIG_BRCM_TRACING) */ 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci#define brcmf_dbg_hex_dump(test, data, len, fmt, ...) \ 1078c2ecf20Sopenharmony_cido { \ 1088c2ecf20Sopenharmony_ci trace_brcmf_hexdump((void *)data, len); \ 1098c2ecf20Sopenharmony_ci if (test) \ 1108c2ecf20Sopenharmony_ci brcmu_dbg_hex_dump(data, len, fmt, ##__VA_ARGS__); \ 1118c2ecf20Sopenharmony_ci} while (0) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciextern int brcmf_msg_level; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct brcmf_bus; 1168c2ecf20Sopenharmony_cistruct brcmf_pub; 1178c2ecf20Sopenharmony_ci#ifdef DEBUG 1188c2ecf20Sopenharmony_cistruct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr); 1198c2ecf20Sopenharmony_civoid brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn, 1208c2ecf20Sopenharmony_ci int (*read_fn)(struct seq_file *seq, void *data)); 1218c2ecf20Sopenharmony_ciint brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, 1228c2ecf20Sopenharmony_ci size_t len); 1238c2ecf20Sopenharmony_ci#else 1248c2ecf20Sopenharmony_cistatic inline struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr) 1258c2ecf20Sopenharmony_ci{ 1268c2ecf20Sopenharmony_ci return ERR_PTR(-ENOENT); 1278c2ecf20Sopenharmony_ci} 1288c2ecf20Sopenharmony_cistatic inline 1298c2ecf20Sopenharmony_civoid brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn, 1308c2ecf20Sopenharmony_ci int (*read_fn)(struct seq_file *seq, void *data)) 1318c2ecf20Sopenharmony_ci{ } 1328c2ecf20Sopenharmony_cistatic inline 1338c2ecf20Sopenharmony_ciint brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data, 1348c2ecf20Sopenharmony_ci size_t len) 1358c2ecf20Sopenharmony_ci{ 1368c2ecf20Sopenharmony_ci return 0; 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci#endif 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#endif /* BRCMFMAC_DEBUG_H */ 141