phydm_debug.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #ifndef __ODM_DBG_H__
  26. #define __ODM_DBG_H__
  27. /*@#define DEBUG_VERSION "1.1"*/ /*@2015.07.29 YuChen*/
  28. /*@#define DEBUG_VERSION "1.2"*/ /*@2015.08.28 Dino*/
  29. /*@#define DEBUG_VERSION "1.3"*/ /*@2016.04.28 YuChen*/
  30. /*@#define DEBUG_VERSION "1.4"*/ /*@2017.03.13 Dino*/
  31. #define DEBUG_VERSION "2.0" /*@2018.01.10 Dino*/
  32. /*@
  33. * ============================================================
  34. * Definition
  35. * ============================================================
  36. */
  37. /*@FW DBG MSG*/
  38. #define RATE_DECISION 1
  39. #define INIT_RA_TABLE 2
  40. #define RATE_UP 4
  41. #define RATE_DOWN 8
  42. #define TRY_DONE 16
  43. #define RA_H2C 32
  44. #define F_RATE_AP_RPT 64
  45. #define DBC_FW_CLM 9
  46. #define PHYDM_SNPRINT_SIZE 64
  47. /* @----------------------------------------------------------------------------
  48. * Define the tracing components
  49. *
  50. * -----------------------------------------------------------------------------
  51. * BB FW Functions
  52. */
  53. #define PHYDM_FW_COMP_RA BIT(0)
  54. #define PHYDM_FW_COMP_MU BIT(1)
  55. #define PHYDM_FW_COMP_PATH_DIV BIT(2)
  56. #define PHYDM_FW_COMP_PT BIT(3)
  57. /*@------------------------Export Marco Definition---------------------------*/
  58. #define config_phydm_read_txagc_check(data) (data != INVALID_TXAGC_DATA)
  59. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  60. #if (DBG_CMD_SUPPORT == 1)
  61. extern VOID DCMD_Printf(const char *pMsg);
  62. #else
  63. #define DCMD_Printf(_pMsg)
  64. #endif
  65. #define pr_debug DbgPrint
  66. #define dcmd_printf DCMD_Printf
  67. #define dcmd_scanf DCMD_Scanf
  68. #define RT_PRINTK pr_debug
  69. #define PRINT_MAX_SIZE 512
  70. #define PHYDM_SNPRINTF RT_SPRINTF
  71. #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211)
  72. #define PHYDM_SNPRINTF snprintf
  73. #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
  74. #undef pr_debug
  75. #define pr_debug printk
  76. #define RT_PRINTK(fmt, args...) pr_debug(fmt, ## args)
  77. #define RT_DISP(dbgtype, dbgflag, printstr)
  78. #define RT_TRACE(adapter, comp, drv_level, fmt, args...) \
  79. RTW_INFO(fmt, ## args)
  80. #define PHYDM_SNPRINTF snprintf
  81. #elif (DM_ODM_SUPPORT_TYPE == ODM_IOT)
  82. #define pr_debug(fmt, args...) RTW_PRINT_MSG(fmt, ## args)
  83. #define RT_DEBUG(comp, drv_level, fmt, args...) \
  84. RTW_PRINT_MSG(fmt, ## args)
  85. #define PHYDM_SNPRINTF snprintf
  86. #else
  87. #define pr_debug panic_printk
  88. /*@#define RT_PRINTK(fmt, args...) pr_debug("%s(): " fmt, __FUNCTION__, ## args);*/
  89. #define RT_PRINTK(fmt, args...) pr_debug(fmt, ## args)
  90. #define PHYDM_SNPRINTF snprintf
  91. #endif
  92. #ifndef ASSERT
  93. #define ASSERT(expr)
  94. #endif
  95. #if DBG
  96. #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
  97. #define PHYDM_DBG(dm, comp, fmt, args...) \
  98. do { \
  99. if ((comp) & dm->debug_components) { \
  100. pr_debug("[PHYDM] "); \
  101. RT_PRINTK(fmt, ## args); \
  102. } \
  103. } while (0)
  104. #define PHYDM_DBG_F(dm, comp, fmt, args...) \
  105. do { \
  106. if ((comp) & dm->debug_components) { \
  107. RT_PRINTK(fmt, ## args); \
  108. } \
  109. } while (0)
  110. #define PHYDM_PRINT_ADDR(dm, comp, title_str, addr) \
  111. do { \
  112. if ((comp) & dm->debug_components) { \
  113. int __i; \
  114. u8 *__ptr = (u8 *)addr; \
  115. pr_debug("[PHYDM] "); \
  116. pr_debug(title_str); \
  117. pr_debug(" "); \
  118. for (__i = 0; __i < 6; __i++) \
  119. pr_debug("%02X%s", __ptr[__i], (__i == 5) ? "" : "-");\
  120. pr_debug("\n"); \
  121. } \
  122. } while (0)
  123. #elif (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  124. static __inline void PHYDM_DBG(PDM_ODM_T dm, int comp, char *fmt, ...)
  125. {
  126. RT_STATUS rt_status;
  127. va_list args;
  128. char buf[PRINT_MAX_SIZE] = {0};
  129. if ((comp & dm->debug_components) == 0)
  130. return;
  131. if (fmt == NULL)
  132. return;
  133. va_start(args, fmt);
  134. rt_status = (RT_STATUS)RtlStringCbVPrintfA(buf, PRINT_MAX_SIZE, fmt, args);
  135. va_end(args);
  136. if (rt_status != RT_STATUS_SUCCESS) {
  137. DbgPrint("Failed (%d) to print message to buffer\n", rt_status);
  138. return;
  139. }
  140. DbgPrint("[PHYDM] %s", buf);
  141. }
  142. static __inline void PHYDM_DBG_F(PDM_ODM_T dm, int comp, char *fmt, ...)
  143. {
  144. RT_STATUS rt_status;
  145. va_list args;
  146. char buf[PRINT_MAX_SIZE] = {0};
  147. if ((comp & dm->debug_components) == 0)
  148. return;
  149. if (fmt == NULL)
  150. return;
  151. va_start(args, fmt);
  152. rt_status = (RT_STATUS)RtlStringCbVPrintfA(buf, PRINT_MAX_SIZE, fmt, args);
  153. va_end(args);
  154. if (rt_status != RT_STATUS_SUCCESS) {
  155. /*@DbgPrint("DM Print Fail\n");*/
  156. return;
  157. }
  158. DbgPrint("%s", buf);
  159. }
  160. #define PHYDM_PRINT_ADDR(p_dm, comp, title_str, ptr) \
  161. do { \
  162. if ((comp) & p_dm->debug_components) { \
  163. \
  164. int __i; \
  165. u8 *__ptr = (u8 *)ptr; \
  166. pr_debug("[PHYDM] "); \
  167. pr_debug(title_str); \
  168. pr_debug(" "); \
  169. for (__i = 0; __i < 6; __i++) \
  170. pr_debug("%02X%s", __ptr[__i], (__i == 5) ? "" : "-"); \
  171. pr_debug("\n"); \
  172. } \
  173. } while (0)
  174. #elif (DM_ODM_SUPPORT_TYPE == ODM_IOT)
  175. #define PHYDM_DBG(dm, comp, fmt, args...) \
  176. do { \
  177. if ((comp) & dm->debug_components) { \
  178. RT_DEBUG(COMP_PHYDM, \
  179. DBG_DMESG, "[PHYDM] " fmt, ##args); \
  180. } \
  181. } while (0)
  182. #define PHYDM_DBG_F(dm, comp, fmt, args...) \
  183. do { \
  184. if ((comp) & dm->debug_components) { \
  185. RT_DEBUG(COMP_PHYDM, \
  186. DBG_DMESG, fmt, ##args); \
  187. } \
  188. } while (0)
  189. #define PHYDM_PRINT_ADDR(dm, comp, title_str, addr) \
  190. do { \
  191. if ((comp) & dm->debug_components) { \
  192. RT_DEBUG(COMP_PHYDM, \
  193. DBG_DMESG, "[PHYDM] " title_str "%pM\n", \
  194. addr); \
  195. } \
  196. } while (0)
  197. #elif defined(DM_ODM_CE_MAC80211_V2)
  198. #define PHYDM_DBG(dm, comp, fmt, args...)
  199. #define PHYDM_DBG_F(dm, comp, fmt, args...)
  200. #define PHYDM_PRINT_ADDR(dm, comp, title_str, addr)
  201. #else
  202. #define PHYDM_DBG(dm, comp, fmt, args...) \
  203. do { \
  204. struct dm_struct *__dm = (dm); \
  205. if ((comp) & __dm->debug_components) { \
  206. RT_TRACE(((struct rtl_priv *)__dm->adapter),\
  207. COMP_PHYDM, DBG_DMESG, \
  208. "[PHYDM] " fmt, ##args); \
  209. } \
  210. } while (0)
  211. #define PHYDM_DBG_F(dm, comp, fmt, args...) \
  212. do { \
  213. struct dm_struct *__dm = (dm); \
  214. if ((comp) & __dm->debug_components) { \
  215. RT_TRACE(((struct rtl_priv *)__dm->adapter),\
  216. COMP_PHYDM, DBG_DMESG, fmt, ##args); \
  217. } \
  218. } while (0)
  219. #define PHYDM_PRINT_ADDR(dm, comp, title_str, addr) \
  220. do { \
  221. struct dm_struct *__dm = (dm); \
  222. if ((comp) & __dm->debug_components) { \
  223. RT_TRACE(((struct rtl_priv *)__dm->adapter),\
  224. COMP_PHYDM, DBG_DMESG, \
  225. "[PHYDM] " title_str "%pM\n", addr);\
  226. } \
  227. } while (0)
  228. #endif
  229. #else /*@#if DBG*/
  230. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  231. static __inline void PHYDM_DBG(struct dm_struct *dm, int comp, char *fmt, ...)
  232. {
  233. }
  234. static __inline void PHYDM_DBG_F(struct dm_struct *dm, int comp, char *fmt, ...)
  235. {
  236. }
  237. #else
  238. #define PHYDM_DBG(dm, comp, fmt, args...)
  239. #define PHYDM_DBG_F(dm, comp, fmt, args...)
  240. #endif
  241. #define PHYDM_PRINT_ADDR(dm, comp, title_str, ptr)
  242. #endif
  243. #define DBGPORT_PRI_3 3 /*@Debug function (the highest priority)*/
  244. #define DBGPORT_PRI_2 2 /*@Check hang function & Strong function*/
  245. #define DBGPORT_PRI_1 1 /*Watch dog function*/
  246. #define DBGPORT_RELEASE 0 /*@Init value (the lowest priority)*/
  247. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  248. #define PHYDM_DBGPRINT 0
  249. #define PHYDM_SSCANF(x, y, z) dcmd_scanf(x, y, z)
  250. #define PDM_VAST_SNPF PDM_SNPF
  251. #if (PHYDM_DBGPRINT == 1)
  252. #define PDM_SNPF(msg) \
  253. do {\
  254. rsprintf msg;\
  255. pr_debug("%s", output);\
  256. } while (0)
  257. #else
  258. static __inline void PDM_SNPF(u32 out_len, u32 used, char *buff, int len,
  259. char *fmt, ...)
  260. {
  261. RT_STATUS rt_status;
  262. va_list args;
  263. char buf[PRINT_MAX_SIZE] = {0};
  264. if (fmt == NULL)
  265. return;
  266. va_start(args, fmt);
  267. rt_status = (RT_STATUS)RtlStringCbVPrintfA(buf, PRINT_MAX_SIZE, fmt, args);
  268. va_end(args);
  269. if (rt_status != RT_STATUS_SUCCESS) {
  270. /*@DbgPrint("DM Print Fail\n");*/
  271. return;
  272. }
  273. DCMD_Printf(buf);
  274. }
  275. #endif /*@#if (PHYDM_DBGPRINT == 1)*/
  276. #else /*@(DM_ODM_SUPPORT_TYPE & (ODM_CE | ODM_AP))*/
  277. #if (DM_ODM_SUPPORT_TYPE == ODM_CE) || defined(__OSK__)
  278. #define PHYDM_DBGPRINT 0
  279. #else
  280. #define PHYDM_DBGPRINT 1
  281. #endif
  282. #define MAX_ARGC 20
  283. #define MAX_ARGV 16
  284. #define DCMD_DECIMAL "%d"
  285. #define DCMD_CHAR "%c"
  286. #define DCMD_HEX "%x"
  287. #define PHYDM_SSCANF(x, y, z) sscanf(x, y, z)
  288. #if (DM_ODM_SUPPORT_TYPE & ODM_AP)
  289. #define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...) RT_PRINTK(fmt, ## args)
  290. #elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
  291. #define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...) \
  292. do { \
  293. RT_DEBUG(COMP_PHYDM, DBG_DMESG, fmt, ##args); \
  294. } while (0)
  295. #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
  296. #define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...)
  297. #else
  298. #define PDM_VAST_SNPF(out_len, used, buff, len, fmt, args...) \
  299. RT_TRACE(((struct rtl_priv *)dm->adapter), COMP_PHYDM, \
  300. DBG_DMESG, fmt, ##args)
  301. #endif
  302. #if (PHYDM_DBGPRINT == 1)
  303. #define PDM_SNPF(out_len, used, buff, len, fmt, args...) \
  304. do { \
  305. snprintf(buff, len, fmt, ##args); \
  306. pr_debug("%s", output); \
  307. } while (0)
  308. #else
  309. #define PDM_SNPF(out_len, used, buff, len, fmt, args...) \
  310. do { \
  311. u32 *__pdm_snpf_u = &(used); \
  312. if (out_len > *__pdm_snpf_u) \
  313. *__pdm_snpf_u += snprintf(buff, len, fmt, ##args);\
  314. } while (0)
  315. #endif
  316. #endif
  317. /* @1 ============================================================
  318. * 1 enumeration
  319. * 1 ============================================================
  320. */
  321. enum auto_detection_state { /*@Fast antenna training*/
  322. AD_LEGACY_MODE = 0,
  323. AD_HT_MODE = 1,
  324. AD_VHT_MODE = 2
  325. };
  326. /*@
  327. * ============================================================
  328. * 1 structure
  329. * ============================================================
  330. */
  331. #ifdef CONFIG_PHYDM_DEBUG_FUNCTION
  332. u8 phydm_get_l_sig_rate(void *dm_void, u8 rate_idx_l_sig);
  333. #endif
  334. void phydm_init_debug_setting(struct dm_struct *dm);
  335. void phydm_bb_dbg_port_header_sel(void *dm_void, u32 header_idx);
  336. u8 phydm_set_bb_dbg_port(void *dm_void, u8 curr_dbg_priority, u32 debug_port);
  337. void phydm_release_bb_dbg_port(void *dm_void);
  338. u32 phydm_get_bb_dbg_port_val(void *dm_void);
  339. void phydm_reset_rx_rate_distribution(struct dm_struct *dm);
  340. void phydm_rx_rate_distribution(void *dm_void);
  341. void phydm_show_phy_hitogram(void *dm_void);
  342. void phydm_get_avg_phystatus_val(void *dm_void);
  343. void phydm_get_phy_statistic(void *dm_void);
  344. void phydm_dm_summary(void *dm_void, u8 macid);
  345. void phydm_basic_dbg_message(void *dm_void);
  346. void phydm_basic_profile(void *dm_void, u32 *_used, char *output,
  347. u32 *_out_len);
  348. #if (DM_ODM_SUPPORT_TYPE & (ODM_CE | ODM_AP))
  349. s32 phydm_cmd(struct dm_struct *dm, char *input, u32 in_len, u8 flag,
  350. char *output, u32 out_len);
  351. #endif
  352. void phydm_cmd_parser(struct dm_struct *dm, char input[][16], u32 input_num,
  353. u8 flag, char *output, u32 out_len);
  354. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  355. void phydm_basic_dbg_msg_cli_win(void *dm_void, char *buf);
  356. void phydm_sbd_check(
  357. struct dm_struct *dm);
  358. void phydm_sbd_callback(
  359. struct phydm_timer_list *timer);
  360. void phydm_sbd_workitem_callback(
  361. void *context);
  362. #endif
  363. void phydm_fw_trace_en_h2c(void *dm_void, boolean enable,
  364. u32 fw_debug_component, u32 monitor_mode, u32 macid);
  365. void phydm_fw_trace_handler(void *dm_void, u8 *cmd_buf, u8 cmd_len);
  366. void phydm_fw_trace_handler_code(void *dm_void, u8 *buffer, u8 cmd_len);
  367. void phydm_fw_trace_handler_8051(void *dm_void, u8 *cmd_buf, u8 cmd_len);
  368. #endif /* @__ODM_DBG_H__ */