phydm_dig.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 __PHYDMDIG_H__
  26. #define __PHYDMDIG_H__
  27. #define DIG_VERSION "2.3"
  28. #define DIG_HW 0
  29. #define DIG_LIMIT_PERIOD 60 /*@60 sec*/
  30. /*@--------------------Define ---------------------------------------*/
  31. /*@=== [DIG Boundary] ========================================*/
  32. /*@DIG coverage mode*/
  33. #define DIG_MAX_COVERAGR 0x26
  34. #define DIG_MIN_COVERAGE 0x1c
  35. #define DIG_MAX_OF_MIN_COVERAGE 0x22
  36. /*@[DIG Balance mode]*/
  37. #if (DIG_HW == 1)
  38. #define DIG_MAX_BALANCE_MODE 0x32
  39. #else
  40. #define DIG_MAX_BALANCE_MODE 0x3e
  41. #endif
  42. #define DIG_MAX_OF_MIN_BALANCE_MODE 0x2a
  43. /*@[DIG Performance mode]*/
  44. #define DIG_MAX_PERFORMANCE_MODE 0x5a
  45. #define DIG_MAX_OF_MIN_PERFORMANCE_MODE 0x40 /*@[WLANBB-871]*/
  46. #define DIG_MIN_PERFORMANCE 0x20
  47. /*@DIG DFS function*/
  48. #define DIG_MAX_DFS 0x28
  49. #define DIG_MIN_DFS 0x20
  50. /*@DIG LPS function*/
  51. #define DIG_MAX_LPS 0x3e
  52. #define DIG_MIN_LPS 0x20
  53. #ifdef PHYDM_TDMA_DIG_SUPPORT
  54. #define DIG_NUM_OF_TDMA_STATES 2 /*@L, H state*/
  55. #endif
  56. /*@=== [DIG FA Threshold] ======================================*/
  57. /*Normal*/
  58. #define DM_DIG_FA_TH0 500
  59. #define DM_DIG_FA_TH1 750
  60. /*@LPS*/
  61. #define DM_DIG_FA_TH0_LPS 4 /* @-> 4 lps */
  62. #define DM_DIG_FA_TH1_LPS 15 /* @-> 15 lps */
  63. #define DM_DIG_FA_TH2_LPS 30 /* @-> 30 lps */
  64. #define RSSI_OFFSET_DIG_LPS 5
  65. #define DIG_RECORD_NUM 4
  66. /*@--------------------Enum-----------------------------------*/
  67. enum dig_goupcheck_level {
  68. DIG_GOUPCHECK_LEVEL_0,
  69. DIG_GOUPCHECK_LEVEL_1,
  70. DIG_GOUPCHECK_LEVEL_2
  71. };
  72. enum phydm_dig_mode {
  73. PHYDM_DIG_PERFORAMNCE_MODE = 0,
  74. PHYDM_DIG_COVERAGE_MODE = 1,
  75. };
  76. #ifdef IS_USE_NEW_TDMA
  77. enum tdma_dig_timer {
  78. INIT_TDMA_DIG_TIMMER,
  79. CANCEL_TDMA_DIG_TIMMER,
  80. RELEASE_TDMA_DIG_TIMMER
  81. };
  82. enum tdma_dig_state {
  83. TDMA_DIG_LOW_STATE = 0,
  84. TDMA_DIG_HIGH_STATE = 1,
  85. NORMAL_DIG = 2
  86. };
  87. #endif
  88. /*@--------------------Define Struct-----------------------------------*/
  89. #ifdef CFG_DIG_DAMPING_CHK
  90. struct phydm_dig_recorder_strcut {
  91. u8 igi_bitmap; /*@Don't add any new parameter before this*/
  92. u8 igi_history[DIG_RECORD_NUM];
  93. u32 fa_history[DIG_RECORD_NUM];
  94. u8 damping_limit_en;
  95. u8 damping_limit_val; /*@Limit IGI_dyn_min*/
  96. u32 limit_time;
  97. u8 limit_rssi;
  98. };
  99. #endif
  100. struct phydm_mcc_dig {
  101. u8 mcc_rssi_A;
  102. u8 mcc_rssi_B;
  103. };
  104. struct phydm_dig_struct {
  105. #ifdef CFG_DIG_DAMPING_CHK
  106. struct phydm_dig_recorder_strcut dig_recorder_t;
  107. u8 dig_dl_en; /*@damping limit function enable*/
  108. #endif
  109. boolean is_dbg_fa_th;
  110. u8 cur_ig_value;
  111. u8 rvrt_val;
  112. u8 igi_backup;
  113. u8 rx_gain_range_max; /*@dig_dynamic_max*/
  114. u8 rx_gain_range_min; /*@dig_dynamic_min*/
  115. u8 dm_dig_max; /*@Absolutly upper bound*/
  116. u8 dm_dig_min; /*@Absolutly lower bound*/
  117. u8 dig_max_of_min; /*@Absolutly max of min*/
  118. boolean is_media_connect;
  119. u32 ant_div_rssi_max;
  120. u8 *is_p2p_in_process;
  121. enum dig_goupcheck_level go_up_chk_lv;
  122. u16 fa_th[3];
  123. #if (RTL8822B_SUPPORT || RTL8197F_SUPPORT || RTL8821C_SUPPORT ||\
  124. RTL8198F_SUPPORT || RTL8192F_SUPPORT || RTL8195B_SUPPORT ||\
  125. RTL8822C_SUPPORT || RTL8814B_SUPPORT)
  126. u8 rf_gain_idx;
  127. u8 agc_table_idx;
  128. u8 big_jump_lmt[16];
  129. u8 enable_adjust_big_jump:1;
  130. u8 big_jump_step1:3;
  131. u8 big_jump_step2:2;
  132. u8 big_jump_step3:2;
  133. #endif
  134. u8 upcheck_init_val;
  135. u8 lv0_ratio_reciprocal;
  136. u8 lv1_ratio_reciprocal;
  137. #ifdef PHYDM_TDMA_DIG_SUPPORT
  138. u8 cur_ig_value_tdma;
  139. u8 low_ig_value;
  140. u8 tdma_dig_state; /*@To distinguish which state is now.(L-sate or H-state)*/
  141. u8 tdma_dig_cnt; /*@for phydm_tdma_dig_timer_check use*/
  142. u8 pre_tdma_dig_cnt;
  143. u8 sec_factor;
  144. u32 cur_timestamp;
  145. u32 pre_timestamp;
  146. u32 fa_start_timestamp;
  147. u32 fa_end_timestamp;
  148. u32 fa_acc_1sec_timestamp;
  149. #ifdef IS_USE_NEW_TDMA
  150. u8 tdma_dig_block_cnt;/*@for 1 second dump indicator use*/
  151. /*@dynamic upper bound for L/H state*/
  152. u8 tdma_rx_gain_max[DIG_NUM_OF_TDMA_STATES];
  153. /*@dynamic lower bound for L/H state*/
  154. u8 tdma_rx_gain_min[DIG_NUM_OF_TDMA_STATES];
  155. /*To distinguish current state(L-sate or H-state)*/
  156. #endif
  157. #endif
  158. };
  159. struct phydm_fa_struct {
  160. u32 cnt_parity_fail;
  161. u32 cnt_rate_illegal;
  162. u32 cnt_crc8_fail;
  163. u32 cnt_crc8_fail_vht;
  164. u32 cnt_mcs_fail;
  165. u32 cnt_mcs_fail_vht;
  166. u32 cnt_ofdm_fail;
  167. u32 cnt_ofdm_fail_pre; /* @For RTL8881A */
  168. u32 cnt_cck_fail;
  169. u32 cnt_all;
  170. u32 cnt_all_pre;
  171. u32 cnt_fast_fsync;
  172. u32 cnt_sb_search_fail;
  173. u32 cnt_ofdm_cca;
  174. u32 cnt_cck_cca;
  175. u32 cnt_cca_all;
  176. u32 cnt_bw_usc;
  177. u32 cnt_bw_lsc;
  178. u32 cnt_cck_crc32_error;
  179. u32 cnt_cck_crc32_ok;
  180. u32 cnt_ofdm_crc32_error;
  181. u32 cnt_ofdm_crc32_ok;
  182. u32 cnt_ht_crc32_error;
  183. u32 cnt_ht_crc32_ok;
  184. u32 cnt_ht_crc32_error_agg;
  185. u32 cnt_ht_crc32_ok_agg;
  186. u32 cnt_vht_crc32_error;
  187. u32 cnt_vht_crc32_ok;
  188. u32 cnt_crc32_error_all;
  189. u32 cnt_crc32_ok_all;
  190. u32 time_fa_all;
  191. boolean cck_block_enable;
  192. boolean ofdm_block_enable;
  193. u32 dbg_port0;
  194. boolean edcca_flag;
  195. };
  196. #ifdef PHYDM_TDMA_DIG_SUPPORT
  197. struct phydm_fa_acc_struct {
  198. u32 cnt_parity_fail;
  199. u32 cnt_rate_illegal;
  200. u32 cnt_crc8_fail;
  201. u32 cnt_mcs_fail;
  202. u32 cnt_ofdm_fail;
  203. u32 cnt_ofdm_fail_pre; /*@For RTL8881A*/
  204. u32 cnt_cck_fail;
  205. u32 cnt_all;
  206. u32 cnt_all_pre;
  207. u32 cnt_fast_fsync;
  208. u32 cnt_sb_search_fail;
  209. u32 cnt_ofdm_cca;
  210. u32 cnt_cck_cca;
  211. u32 cnt_cca_all;
  212. u32 cnt_cck_crc32_error;
  213. u32 cnt_cck_crc32_ok;
  214. u32 cnt_ofdm_crc32_error;
  215. u32 cnt_ofdm_crc32_ok;
  216. u32 cnt_ht_crc32_error;
  217. u32 cnt_ht_crc32_ok;
  218. u32 cnt_vht_crc32_error;
  219. u32 cnt_vht_crc32_ok;
  220. u32 cnt_crc32_error_all;
  221. u32 cnt_crc32_ok_all;
  222. u32 cnt_all_1sec;
  223. u32 cnt_cca_all_1sec;
  224. u32 cnt_cck_fail_1sec;
  225. };
  226. #endif /*@#ifdef PHYDM_TDMA_DIG_SUPPORT*/
  227. /*@--------------------Function declaration-----------------------------*/
  228. void odm_write_dig(void *dm_void, u8 current_igi);
  229. u8 phydm_get_igi(void *dm_void, enum bb_path path);
  230. void phydm_set_dig_val(void *dm_void, u32 *val_buf, u8 val_len);
  231. void odm_pause_dig(void *dm_void, enum phydm_pause_type pause_type,
  232. enum phydm_pause_level pause_level, u8 igi_value);
  233. void phydm_dig_init(void *dm_void);
  234. void phydm_dig(void *dm_void);
  235. void phydm_dig_lps_32k(void *dm_void);
  236. void phydm_dig_by_rssi_lps(void *dm_void);
  237. void phydm_false_alarm_counter_statistics(void *dm_void);
  238. #ifdef PHYDM_TDMA_DIG_SUPPORT
  239. void phydm_set_tdma_dig_timer(void *dm_void);
  240. void phydm_tdma_dig_timer_check(void *dm_void);
  241. void phydm_tdma_dig(void *dm_void);
  242. void phydm_tdma_false_alarm_counter_check(void *dm_void);
  243. void phydm_tdma_dig_add_interrupt_mask_handler(void *dm_void);
  244. void phydm_false_alarm_counter_reset(void *dm_void);
  245. void phydm_false_alarm_counter_acc(void *dm_void, boolean rssi_dump_en);
  246. void phydm_false_alarm_counter_acc_reset(void *dm_void);
  247. #ifdef IS_USE_NEW_TDMA
  248. void phydm_tdma_dig_timers(void *dm_void, u8 state);
  249. void phydm_tdma_dig_cbk(void *dm_void);
  250. void phydm_tdma_fa_cnt_chk(void *dm_void);
  251. void phydm_tdma_low_dig(void *dm_void);
  252. void phydm_tdma_high_dig(void *dm_void);
  253. void phydm_fa_cnt_acc(void *dm_void, boolean rssi_dump_en,
  254. u8 cur_tdma_dig_state);
  255. #endif /*@#ifdef IS_USE_NEW_TDMA*/
  256. #endif /*@#ifdef PHYDM_TDMA_DIG_SUPPORT*/
  257. void phydm_set_ofdm_agc_tab(void *dm_void, u8 tab_sel);
  258. void phydm_dig_debug(void *dm_void, char input[][16], u32 *_used, char *output,
  259. u32 *_out_len);
  260. #ifdef CONFIG_MCC_DM
  261. void phydm_mcc_igi_cal(void *dm_void);
  262. #endif
  263. #endif