18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright(c) 2009-2012 Realtek Corporation.*/ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef __RTL_DEBUG_H__ 58c2ecf20Sopenharmony_ci#define __RTL_DEBUG_H__ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/*-------------------------------------------------------------- 88c2ecf20Sopenharmony_ci Debug level 98c2ecf20Sopenharmony_ci--------------------------------------------------------------*/ 108c2ecf20Sopenharmony_ci/* 118c2ecf20Sopenharmony_ci *Fatal bug. 128c2ecf20Sopenharmony_ci *For example, Tx/Rx/IO locked up, 138c2ecf20Sopenharmony_ci *memory access violation, 148c2ecf20Sopenharmony_ci *resource allocation failed, 158c2ecf20Sopenharmony_ci *unexpected HW behavior, HW BUG 168c2ecf20Sopenharmony_ci *and so on. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci/*#define DBG_EMERG 0 */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci *Abnormal, rare, or unexpeted cases. 228c2ecf20Sopenharmony_ci *For example, Packet/IO Ctl canceled, 238c2ecf20Sopenharmony_ci *device suprisely unremoved and so on. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci#define DBG_WARNING 2 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* 288c2ecf20Sopenharmony_ci *Normal case driver developer should 298c2ecf20Sopenharmony_ci *open, we can see link status like 308c2ecf20Sopenharmony_ci *assoc/AddBA/DHCP/adapter start and 318c2ecf20Sopenharmony_ci *so on basic and useful infromations. 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_ci#define DBG_DMESG 3 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci *Normal case with useful information 378c2ecf20Sopenharmony_ci *about current SW or HW state. 388c2ecf20Sopenharmony_ci *For example, Tx/Rx descriptor to fill, 398c2ecf20Sopenharmony_ci *Tx/Rx descriptor completed status, 408c2ecf20Sopenharmony_ci *SW protocol state change, dynamic 418c2ecf20Sopenharmony_ci *mechanism state change and so on. 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_ci#define DBG_LOUD 4 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci *Normal case with detail execution 478c2ecf20Sopenharmony_ci *flow or information. 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci#define DBG_TRACE 5 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/*-------------------------------------------------------------- 528c2ecf20Sopenharmony_ci Define the rt_trace components 538c2ecf20Sopenharmony_ci--------------------------------------------------------------*/ 548c2ecf20Sopenharmony_ci#define COMP_ERR BIT(0) 558c2ecf20Sopenharmony_ci#define COMP_FW BIT(1) 568c2ecf20Sopenharmony_ci#define COMP_INIT BIT(2) /*For init/deinit */ 578c2ecf20Sopenharmony_ci#define COMP_RECV BIT(3) /*For Rx. */ 588c2ecf20Sopenharmony_ci#define COMP_SEND BIT(4) /*For Tx. */ 598c2ecf20Sopenharmony_ci#define COMP_MLME BIT(5) /*For MLME. */ 608c2ecf20Sopenharmony_ci#define COMP_SCAN BIT(6) /*For Scan. */ 618c2ecf20Sopenharmony_ci#define COMP_INTR BIT(7) /*For interrupt Related. */ 628c2ecf20Sopenharmony_ci#define COMP_LED BIT(8) /*For LED. */ 638c2ecf20Sopenharmony_ci#define COMP_SEC BIT(9) /*For sec. */ 648c2ecf20Sopenharmony_ci#define COMP_BEACON BIT(10) /*For beacon. */ 658c2ecf20Sopenharmony_ci#define COMP_RATE BIT(11) /*For rate. */ 668c2ecf20Sopenharmony_ci#define COMP_RXDESC BIT(12) /*For rx desc. */ 678c2ecf20Sopenharmony_ci#define COMP_DIG BIT(13) /*For DIG */ 688c2ecf20Sopenharmony_ci#define COMP_TXAGC BIT(14) /*For Tx power */ 698c2ecf20Sopenharmony_ci#define COMP_HIPWR BIT(15) /*For High Power Mechanism */ 708c2ecf20Sopenharmony_ci#define COMP_POWER BIT(16) /*For lps/ips/aspm. */ 718c2ecf20Sopenharmony_ci#define COMP_POWER_TRACKING BIT(17) /*For TX POWER TRACKING */ 728c2ecf20Sopenharmony_ci#define COMP_BB_POWERSAVING BIT(18) 738c2ecf20Sopenharmony_ci#define COMP_SWAS BIT(19) /*For SW Antenna Switch */ 748c2ecf20Sopenharmony_ci#define COMP_RF BIT(20) /*For RF. */ 758c2ecf20Sopenharmony_ci#define COMP_TURBO BIT(21) /*For EDCA TURBO. */ 768c2ecf20Sopenharmony_ci#define COMP_RATR BIT(22) 778c2ecf20Sopenharmony_ci#define COMP_CMD BIT(23) 788c2ecf20Sopenharmony_ci#define COMP_EFUSE BIT(24) 798c2ecf20Sopenharmony_ci#define COMP_QOS BIT(25) 808c2ecf20Sopenharmony_ci#define COMP_MAC80211 BIT(26) 818c2ecf20Sopenharmony_ci#define COMP_REGD BIT(27) 828c2ecf20Sopenharmony_ci#define COMP_CHAN BIT(28) 838c2ecf20Sopenharmony_ci#define COMP_USB BIT(29) 848c2ecf20Sopenharmony_ci#define COMP_EASY_CONCURRENT COMP_USB /* reuse of this bit is OK */ 858c2ecf20Sopenharmony_ci#define COMP_BT_COEXIST BIT(30) 868c2ecf20Sopenharmony_ci#define COMP_IQK BIT(31) 878c2ecf20Sopenharmony_ci#define COMP_TX_REPORT BIT_ULL(32) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/*-------------------------------------------------------------- 908c2ecf20Sopenharmony_ci Define the rt_print components 918c2ecf20Sopenharmony_ci--------------------------------------------------------------*/ 928c2ecf20Sopenharmony_ci/* Define EEPROM and EFUSE check module bit*/ 938c2ecf20Sopenharmony_ci#define EEPROM_W BIT(0) 948c2ecf20Sopenharmony_ci#define EFUSE_PG BIT(1) 958c2ecf20Sopenharmony_ci#define EFUSE_READ_ALL BIT(2) 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* Define init check for module bit*/ 988c2ecf20Sopenharmony_ci#define INIT_EEPROM BIT(0) 998c2ecf20Sopenharmony_ci#define INIT_TXPOWER BIT(1) 1008c2ecf20Sopenharmony_ci#define INIT_IQK BIT(2) 1018c2ecf20Sopenharmony_ci#define INIT_RF BIT(3) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* Define PHY-BB/RF/MAC check module bit */ 1048c2ecf20Sopenharmony_ci#define PHY_BBR BIT(0) 1058c2ecf20Sopenharmony_ci#define PHY_BBW BIT(1) 1068c2ecf20Sopenharmony_ci#define PHY_RFR BIT(2) 1078c2ecf20Sopenharmony_ci#define PHY_RFW BIT(3) 1088c2ecf20Sopenharmony_ci#define PHY_MACR BIT(4) 1098c2ecf20Sopenharmony_ci#define PHY_MACW BIT(5) 1108c2ecf20Sopenharmony_ci#define PHY_ALLR BIT(6) 1118c2ecf20Sopenharmony_ci#define PHY_ALLW BIT(7) 1128c2ecf20Sopenharmony_ci#define PHY_TXPWR BIT(8) 1138c2ecf20Sopenharmony_ci#define PHY_PWRDIFF BIT(9) 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* Define Dynamic Mechanism check module bit --> FDM */ 1168c2ecf20Sopenharmony_ci#define WA_IOT BIT(0) 1178c2ecf20Sopenharmony_ci#define DM_PWDB BIT(1) 1188c2ecf20Sopenharmony_ci#define DM_MONITOR BIT(2) 1198c2ecf20Sopenharmony_ci#define DM_DIG BIT(3) 1208c2ecf20Sopenharmony_ci#define DM_EDCA_TURBO BIT(4) 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define DM_PWDB BIT(1) 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cienum dbgp_flag_e { 1258c2ecf20Sopenharmony_ci FQOS = 0, 1268c2ecf20Sopenharmony_ci FTX = 1, 1278c2ecf20Sopenharmony_ci FRX = 2, 1288c2ecf20Sopenharmony_ci FSEC = 3, 1298c2ecf20Sopenharmony_ci FMGNT = 4, 1308c2ecf20Sopenharmony_ci FMLME = 5, 1318c2ecf20Sopenharmony_ci FRESOURCE = 6, 1328c2ecf20Sopenharmony_ci FBEACON = 7, 1338c2ecf20Sopenharmony_ci FISR = 8, 1348c2ecf20Sopenharmony_ci FPHY = 9, 1358c2ecf20Sopenharmony_ci FMP = 10, 1368c2ecf20Sopenharmony_ci FEEPROM = 11, 1378c2ecf20Sopenharmony_ci FPWR = 12, 1388c2ecf20Sopenharmony_ci FDM = 13, 1398c2ecf20Sopenharmony_ci FDBGCTRL = 14, 1408c2ecf20Sopenharmony_ci FC2H = 15, 1418c2ecf20Sopenharmony_ci FBT = 16, 1428c2ecf20Sopenharmony_ci FINIT = 17, 1438c2ecf20Sopenharmony_ci FIOCTL = 18, 1448c2ecf20Sopenharmony_ci DBGP_TYPE_MAX 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci#ifdef CONFIG_RTLWIFI_DEBUG 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_cistruct rtl_priv; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci__printf(4, 5) 1528c2ecf20Sopenharmony_civoid _rtl_dbg_print(struct rtl_priv *rtlpriv, u64 comp, int level, 1538c2ecf20Sopenharmony_ci const char *fmt, ...); 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_civoid _rtl_dbg_print_data(struct rtl_priv *rtlpriv, u64 comp, int level, 1568c2ecf20Sopenharmony_ci const char *titlestring, 1578c2ecf20Sopenharmony_ci const void *hexdata, int hexdatalen); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#define rtl_dbg(rtlpriv, comp, level, fmt, ...) \ 1608c2ecf20Sopenharmony_ci _rtl_dbg_print(rtlpriv, comp, level, \ 1618c2ecf20Sopenharmony_ci fmt, ##__VA_ARGS__) 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci#define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \ 1648c2ecf20Sopenharmony_ci _rtl_dbg_print(rtlpriv, dbgtype, dbgflag, fmt, ##__VA_ARGS__) 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci#define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \ 1678c2ecf20Sopenharmony_ci _hexdatalen) \ 1688c2ecf20Sopenharmony_ci _rtl_dbg_print_data(rtlpriv, _comp, _level, \ 1698c2ecf20Sopenharmony_ci _titlestring, _hexdata, _hexdatalen) 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci#else 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_cistruct rtl_priv; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci__printf(4, 5) 1768c2ecf20Sopenharmony_cistatic inline void rtl_dbg(struct rtl_priv *rtlpriv, 1778c2ecf20Sopenharmony_ci u64 comp, int level, 1788c2ecf20Sopenharmony_ci const char *fmt, ...) 1798c2ecf20Sopenharmony_ci{ 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci__printf(4, 5) 1838c2ecf20Sopenharmony_cistatic inline void RTPRINT(struct rtl_priv *rtlpriv, 1848c2ecf20Sopenharmony_ci int dbgtype, int dbgflag, 1858c2ecf20Sopenharmony_ci const char *fmt, ...) 1868c2ecf20Sopenharmony_ci{ 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistatic inline void RT_PRINT_DATA(struct rtl_priv *rtlpriv, 1908c2ecf20Sopenharmony_ci u64 comp, int level, 1918c2ecf20Sopenharmony_ci const char *titlestring, 1928c2ecf20Sopenharmony_ci const void *hexdata, size_t hexdatalen) 1938c2ecf20Sopenharmony_ci{ 1948c2ecf20Sopenharmony_ci} 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci#endif 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#ifdef CONFIG_RTLWIFI_DEBUG 1998c2ecf20Sopenharmony_civoid rtl_debug_add_one(struct ieee80211_hw *hw); 2008c2ecf20Sopenharmony_civoid rtl_debug_remove_one(struct ieee80211_hw *hw); 2018c2ecf20Sopenharmony_civoid rtl_debugfs_add_topdir(void); 2028c2ecf20Sopenharmony_civoid rtl_debugfs_remove_topdir(void); 2038c2ecf20Sopenharmony_ci#else 2048c2ecf20Sopenharmony_ci#define rtl_debug_add_one(hw) 2058c2ecf20Sopenharmony_ci#define rtl_debug_remove_one(hw) 2068c2ecf20Sopenharmony_ci#define rtl_debugfs_add_topdir() 2078c2ecf20Sopenharmony_ci#define rtl_debugfs_remove_topdir() 2088c2ecf20Sopenharmony_ci#endif 2098c2ecf20Sopenharmony_ci#endif 210