phydm_ccx.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 __PHYDMCCX_H__
  26. #define __PHYDMCCX_H__
  27. /* @1 ============================================================
  28. * 1 Definition
  29. * 1 ============================================================
  30. */
  31. #define ENV_MNTR_DBG 0 /*@debug for the HW processing time from NHM/CLM trigger and get result*/
  32. #define ENV_MNTR_DBG_1 1 /*@debug 8812A & 8821A P2P Fail to get result*/
  33. #define ENV_MNTR_DBG_2 1 /*@debug for read reister*/
  34. #define CCX_EN 1
  35. #define MAX_ENV_MNTR_TIME 8 /*second*/
  36. #define IGI_TO_NHM_TH_MULTIPLIER 2
  37. #define MS_TO_4US_RATIO 250
  38. #define CCA_CAP 14
  39. #define CLM_MAX_REPORT_TIME 10
  40. #define DEVIDER_ERROR 0xffff
  41. #define CLM_PERIOD_MAX 65535
  42. #define NHM_PERIOD_MAX 65534
  43. #define NHM_TH_NUM 11 /*threshold number of NHM*/
  44. #define NHM_RPT_NUM 12
  45. #define IGI_2_NHM_TH(igi) ((igi) << 1)/*NHM_threshold = IGI * 2*/
  46. #define NTH_TH_2_RSSI(th) ((th >> 1) - 10)
  47. /*@FAHM*/
  48. #define FAHM_INCLD_FA BIT(0)
  49. #define FAHM_INCLD_CRC_OK BIT(1)
  50. #define FAHM_INCLD_CRC_ER BIT(2)
  51. #define NHM_SUCCESS BIT(0)
  52. #define CLM_SUCCESS BIT(1)
  53. #define FAHM_SUCCESS BIT(2)
  54. #define ENV_MNTR_FAIL 0xff
  55. /* @1 ============================================================
  56. * 1 enumrate
  57. * 1 ============================================================
  58. */
  59. enum phydm_clm_level {
  60. CLM_RELEASE = 0,
  61. CLM_LV_1 = 1, /* @Low Priority function */
  62. CLM_LV_2 = 2, /* @Middle Priority function */
  63. CLM_LV_3 = 3, /* @High priority function (ex: Check hang function) */
  64. CLM_LV_4 = 4, /* @Debug function (the highest priority) */
  65. CLM_MAX_NUM = 5
  66. };
  67. enum phydm_nhm_level {
  68. NHM_RELEASE = 0,
  69. NHM_LV_1 = 1, /* @Low Priority function */
  70. NHM_LV_2 = 2, /* @Middle Priority function */
  71. NHM_LV_3 = 3, /* @High priority function (ex: Check hang function) */
  72. NHM_LV_4 = 4, /* @Debug function (the highest priority) */
  73. NHM_MAX_NUM = 5
  74. };
  75. enum nhm_divider_opt_all {
  76. NHM_CNT_ALL = 0, /*nhm SUM report <= 255*/
  77. NHM_VALID = 1, /*nhm SUM report = 255*/
  78. NHM_CNT_INIT
  79. };
  80. enum nhm_setting {
  81. SET_NHM_SETTING,
  82. STORE_NHM_SETTING,
  83. RESTORE_NHM_SETTING
  84. };
  85. enum nhm_option_cca_all {
  86. NHM_EXCLUDE_CCA = 0,
  87. NHM_INCLUDE_CCA = 1,
  88. NHM_CCA_INIT
  89. };
  90. enum nhm_option_txon_all {
  91. NHM_EXCLUDE_TXON = 0,
  92. NHM_INCLUDE_TXON = 1,
  93. NHM_TXON_INIT
  94. };
  95. enum nhm_application {
  96. NHM_BACKGROUND = 0,/*@default*/
  97. NHM_ACS = 1,
  98. IEEE_11K_HIGH = 2,
  99. IEEE_11K_LOW = 3,
  100. INTEL_XBOX = 4,
  101. NHM_DBG = 5, /*@manual trigger*/
  102. };
  103. enum clm_application {
  104. CLM_BACKGROUND = 0,/*@default*/
  105. CLM_ACS = 1,
  106. };
  107. enum clm_monitor_mode {
  108. CLM_DRIVER_MNTR = 1,
  109. CLM_FW_MNTR = 2
  110. };
  111. /* @1 ============================================================
  112. * 1 structure
  113. * 1 ============================================================
  114. */
  115. struct env_trig_rpt {
  116. u8 nhm_rpt_stamp;
  117. u8 clm_rpt_stamp;
  118. };
  119. struct env_mntr_rpt {
  120. u8 nhm_ratio;
  121. u8 nhm_result[NHM_RPT_NUM];
  122. u8 clm_ratio;
  123. u8 nhm_rpt_stamp;
  124. u8 clm_rpt_stamp;
  125. };
  126. struct nhm_para_info {
  127. enum nhm_option_txon_all incld_txon; /*@Include TX on*/
  128. enum nhm_option_cca_all incld_cca; /*@Include CCA*/
  129. enum nhm_divider_opt_all div_opt; /*@divider option*/
  130. enum nhm_application nhm_app;
  131. enum phydm_nhm_level nhm_lv;
  132. u16 mntr_time; /*@0~262 unit ms*/
  133. };
  134. struct clm_para_info {
  135. enum clm_application clm_app;
  136. enum phydm_clm_level clm_lv;
  137. u16 mntr_time; /*@0~262 unit ms*/
  138. };
  139. struct ccx_info {
  140. u32 nhm_trigger_time;
  141. u32 clm_trigger_time;
  142. u64 start_time; /*@monitor for the test duration*/
  143. #ifdef NHM_SUPPORT
  144. enum nhm_application nhm_app;
  145. enum nhm_option_txon_all nhm_include_txon;
  146. enum nhm_option_cca_all nhm_include_cca;
  147. enum nhm_divider_opt_all nhm_divider_opt;
  148. /*Report*/
  149. u8 nhm_th[NHM_TH_NUM];
  150. u8 nhm_result[NHM_RPT_NUM];
  151. u16 nhm_period; /* @4us per unit */
  152. u8 nhm_igi;
  153. u8 nhm_manual_ctrl;
  154. u8 nhm_ratio; /*@1% per nuit, it means the interference igi can't overcome.*/
  155. u8 nhm_rpt_sum;
  156. u16 nhm_duration; /*@Real time of NHM_VALID */
  157. u8 nhm_set_lv;
  158. boolean nhm_ongoing;
  159. u8 nhm_rpt_stamp;
  160. #endif
  161. #ifdef CLM_SUPPORT
  162. enum clm_application clm_app;
  163. u8 clm_manual_ctrl;
  164. u8 clm_set_lv;
  165. boolean clm_ongoing;
  166. u16 clm_period; /* @4us per unit */
  167. u16 clm_result;
  168. u8 clm_ratio;
  169. u32 clm_fw_result_acc;
  170. u8 clm_fw_result_cnt;
  171. enum clm_monitor_mode clm_mntr_mode;
  172. u8 clm_rpt_stamp;
  173. #endif
  174. #ifdef FAHM_SUPPORT
  175. boolean fahm_ongoing;
  176. u8 env_mntr_igi;
  177. u8 fahm_nume_sel; /*@fahm_numerator_sel: select {FA, CRCOK, CRC_fail} */
  178. u8 fahm_denom_sel; /*@fahm_denominator_sel: select {FA, CRCOK, CRC_fail} */
  179. u16 fahm_period; /*unit: 4us*/
  180. #endif
  181. };
  182. /* @1 ============================================================
  183. * 1 Function Prototype
  184. * 1 ============================================================
  185. */
  186. #ifdef FAHM_SUPPORT
  187. void phydm_fahm_init(void *dm_void);
  188. void phydm_fahm_dbg(void *dm_void, char input[][16], u32 *_used, char *output,
  189. u32 *_out_len);
  190. #endif
  191. /*@NHM*/
  192. #ifdef NHM_SUPPORT
  193. void phydm_nhm_trigger(void *dm_void);
  194. void phydm_nhm_init(void *dm_void);
  195. void phydm_nhm_dbg(void *dm_void, char input[][16], u32 *_used, char *output,
  196. u32 *_out_len);
  197. u8 phydm_get_igi(void *dm_void, enum bb_path path);
  198. #endif
  199. /*@CLM*/
  200. #ifdef CLM_SUPPORT
  201. void phydm_clm_c2h_report_handler(void *dm_void, u8 *cmd_buf, u8 cmd_len);
  202. void phydm_clm_h2c(void *dm_void, u16 obs_time, u8 fw_clm_en);
  203. void phydm_clm_setting(void *dm_void, u16 clm_period);
  204. void phydm_clm_trigger(void *dm_void);
  205. boolean phydm_clm_check_rdy(void *dm_void);
  206. void phydm_clm_get_utility(void *dm_void);
  207. boolean phydm_clm_get_result(void *dm_void);
  208. u8 phydm_clm_mntr_set(void *dm_void, struct clm_para_info *clm_para);
  209. void phydm_set_clm_mntr_mode(void *dm_void, enum clm_monitor_mode mode);
  210. void phydm_clm_dbg(void *dm_void, char input[][16], u32 *_used, char *output,
  211. u32 *_out_len);
  212. #endif
  213. u8 phydm_env_mntr_trigger(void *dm_void, struct nhm_para_info *nhm_para,
  214. struct clm_para_info *clm_para,
  215. struct env_trig_rpt *rpt);
  216. u8 phydm_env_mntr_result(void *dm_void, struct env_mntr_rpt *rpt);
  217. void phydm_env_mntr_watchdog(void *dm_void);
  218. void phydm_env_monitor_init(void *dm_void);
  219. void phydm_env_mntr_dbg(void *dm_void, char input[][16], u32 *_used,
  220. char *output, u32 *_out_len);
  221. #endif