phydm_rainfo.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 __PHYDMRAINFO_H__
  26. #define __PHYDMRAINFO_H__
  27. #define RAINFO_VERSION "8.0"
  28. #define FORCED_UPDATE_RAMASK_PERIOD 5
  29. #define H2C_MAX_LENGTH 7
  30. #define RA_FLOOR_UP_GAP 3
  31. #define RA_FLOOR_TABLE_SIZE 7
  32. #define ACTIVE_TP_THRESHOLD 1
  33. #define RA_RETRY_DESCEND_NUM 2
  34. #define RA_RETRY_LIMIT_LOW 4
  35. #define RA_RETRY_LIMIT_HIGH 32
  36. #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
  37. #define FIRST_MACID 1
  38. #else
  39. #define FIRST_MACID 0
  40. #endif
  41. /* @1 ============================================================
  42. * 1 enumrate
  43. * 1 ============================================================
  44. */
  45. enum phydm_ra_dbg_para {
  46. RADBG_PCR_TH_OFFSET = 0,
  47. RADBG_RTY_PENALTY = 1,
  48. RADBG_N_HIGH = 2,
  49. RADBG_N_LOW = 3,
  50. RADBG_TRATE_UP_TABLE = 4,
  51. RADBG_TRATE_DOWN_TABLE = 5,
  52. RADBG_TRYING_NECESSARY = 6,
  53. RADBG_TDROPING_NECESSARY = 7,
  54. RADBG_RATE_UP_RTY_RATIO = 8,
  55. RADBG_RATE_DOWN_RTY_RATIO = 9, /* u8 */
  56. RADBG_DEBUG_MONITOR1 = 0xc,
  57. RADBG_DEBUG_MONITOR2 = 0xd,
  58. RADBG_DEBUG_MONITOR3 = 0xe,
  59. RADBG_DEBUG_MONITOR4 = 0xf,
  60. RADBG_DEBUG_MONITOR5 = 0x10,
  61. NUM_RA_PARA
  62. };
  63. enum phydm_wireless_mode {
  64. PHYDM_WIRELESS_MODE_UNKNOWN = 0x00,
  65. PHYDM_WIRELESS_MODE_A = 0x01,
  66. PHYDM_WIRELESS_MODE_B = 0x02,
  67. PHYDM_WIRELESS_MODE_G = 0x04,
  68. PHYDM_WIRELESS_MODE_AUTO = 0x08,
  69. PHYDM_WIRELESS_MODE_N_24G = 0x10,
  70. PHYDM_WIRELESS_MODE_N_5G = 0x20,
  71. PHYDM_WIRELESS_MODE_AC_5G = 0x40,
  72. PHYDM_WIRELESS_MODE_AC_24G = 0x80,
  73. PHYDM_WIRELESS_MODE_AC_ONLY = 0x100,
  74. PHYDM_WIRELESS_MODE_MAX = 0x800,
  75. PHYDM_WIRELESS_MODE_ALL = 0xFFFF
  76. };
  77. enum phydm_rateid_idx {
  78. PHYDM_BGN_40M_2SS = 0,
  79. PHYDM_BGN_40M_1SS = 1,
  80. PHYDM_BGN_20M_2SS = 2,
  81. PHYDM_BGN_20M_1SS = 3,
  82. PHYDM_GN_N2SS = 4,
  83. PHYDM_GN_N1SS = 5,
  84. PHYDM_BG = 6,
  85. PHYDM_G = 7,
  86. PHYDM_B_20M = 8,
  87. PHYDM_ARFR0_AC_2SS = 9,
  88. PHYDM_ARFR1_AC_1SS = 10,
  89. PHYDM_ARFR2_AC_2G_1SS = 11,
  90. PHYDM_ARFR3_AC_2G_2SS = 12,
  91. PHYDM_ARFR4_AC_3SS = 13,
  92. PHYDM_ARFR5_N_3SS = 14,
  93. PHYDM_ARFR7_N_4SS = 15,
  94. PHYDM_ARFR6_AC_4SS = 16
  95. };
  96. #if (RATE_ADAPTIVE_SUPPORT == 1)/* @88E RA */
  97. struct _phydm_txstatistic_ {
  98. u32 hw_total_tx;
  99. u32 hw_tx_success;
  100. u32 hw_tx_rty;
  101. u32 hw_tx_drop;
  102. };
  103. /* @1 ============================================================
  104. * 1 structure
  105. * 1 ============================================================
  106. */
  107. struct _odm_ra_info_ {
  108. u8 rate_id;
  109. u32 rate_mask;
  110. u32 ra_use_rate;
  111. u8 rate_sgi;
  112. u8 rssi_sta_ra;
  113. u8 pre_rssi_sta_ra;
  114. u8 sgi_enable;
  115. u8 decision_rate;
  116. u8 pre_rate;
  117. u8 highest_rate;
  118. u8 lowest_rate;
  119. u32 nsc_up;
  120. u32 nsc_down;
  121. u16 RTY[5];
  122. u32 TOTAL;
  123. u16 DROP;
  124. u8 active;
  125. u16 rpt_time;
  126. u8 ra_waiting_counter;
  127. u8 ra_pending_counter;
  128. u8 ra_drop_after_down;
  129. #if 1 /* POWER_TRAINING_ACTIVE == 1 */ /* For compile pass only~! */
  130. u8 pt_active; /* on or off */
  131. u8 pt_try_state; /* @0 trying state, 1 for decision state */
  132. u8 pt_stage; /* @0~6 */
  133. u8 pt_stop_count; /* Stop PT counter */
  134. u8 pt_pre_rate; /* @if rate change do PT */
  135. u8 pt_pre_rssi; /* @if RSSI change 5% do PT */
  136. u8 pt_mode_ss; /* @decide whitch rate should do PT */
  137. u8 ra_stage; /* @StageRA, decide how many times RA will be done between PT */
  138. u8 pt_smooth_factor;
  139. #endif
  140. #if (DM_ODM_SUPPORT_TYPE == ODM_AP) && ((DEV_BUS_TYPE == RT_USB_INTERFACE) || (DEV_BUS_TYPE == RT_SDIO_INTERFACE))
  141. u8 rate_down_counter;
  142. u8 rate_up_counter;
  143. u8 rate_direction;
  144. u8 bounding_type;
  145. u8 bounding_counter;
  146. u8 bounding_learning_time;
  147. u8 rate_down_start_time;
  148. #endif
  149. };
  150. #endif
  151. struct ra_table {
  152. u8 firstconnect;
  153. /*@u8 link_tx_rate[ODM_ASSOCIATE_ENTRY_NUM];*/
  154. u8 mu1_rate[30];
  155. u8 highest_client_tx_order;
  156. u16 highest_client_tx_rate_order;
  157. u8 power_tracking_flag;
  158. u8 ra_th_ofst; /*RA_threshold_offset*/
  159. u8 ra_ofst_direc; /*RA_offset_direction*/
  160. u8 up_ramask_cnt; /*@force update_ra_mask counter*/
  161. u8 up_ramask_cnt_tmp; /*@Just for debug, should be removed latter*/
  162. #if 0 /*@CONFIG_RA_DYNAMIC_RTY_LIMIT*/
  163. u8 per_rate_retrylimit_20M[ODM_NUM_RATE_IDX];
  164. u8 per_rate_retrylimit_40M[ODM_NUM_RATE_IDX];
  165. u8 retry_descend_num;
  166. u8 retrylimit_low;
  167. u8 retrylimit_high;
  168. #endif
  169. u8 ldpc_thres; /* @if RSSI > ldpc_th => switch from LPDC to BCC */
  170. void (*record_ra_info)(void *dm_void, u8 macid,
  171. struct cmn_sta_info *sta, u64 ra_mask);
  172. };
  173. /* @1 ============================================================
  174. * 1 Function Prototype
  175. * 1 ============================================================
  176. */
  177. boolean phydm_is_cck_rate(void *dm_void, u8 rate);
  178. boolean phydm_is_ofdm_rate(void *dm_void, u8 rate);
  179. boolean phydm_is_ht_rate(void *dm_void, u8 rate);
  180. boolean phydm_is_vht_rate(void *dm_void, u8 rate);
  181. u8 phydm_rate_type_2_num_ss(void *dm_void, enum PDM_RATE_TYPE type);
  182. u8 phydm_rate_to_num_ss(void *dm_void, u8 data_rate);
  183. void phydm_h2C_debug(void *dm_void, char input[][16], u32 *_used,
  184. char *output, u32 *_out_len);
  185. void phydm_ra_debug(void *dm_void, char input[][16], u32 *_used, char *output,
  186. u32 *_out_len);
  187. void odm_c2h_ra_para_report_handler(void *dm_void, u8 *cmd_buf, u8 cmd_len);
  188. void phydm_ra_dynamic_retry_count(void *dm_void);
  189. void phydm_print_rate(void *dm_void, u8 rate, u32 dbg_component);
  190. void phydm_print_rate_2_buff(void *dm_void, u8 rate, char *buf, u16 buf_size);
  191. void phydm_c2h_ra_report_handler(void *dm_void, u8 *cmd_buf, u8 cmd_len);
  192. u8 phydm_rate_order_compute(void *dm_void, u8 rate_idx);
  193. void phydm_ra_info_watchdog(void *dm_void);
  194. void phydm_ra_info_init(void *dm_void);
  195. void phydm_modify_RA_PCR_threshold(void *dm_void, u8 ra_ofst_direc,
  196. u8 ra_th_ofst);
  197. u8 phydm_vht_en_mapping(void *dm_void, u32 wireless_mode);
  198. u8 phydm_rate_id_mapping(void *dm_void, u32 wireless_mode, u8 rf_type, u8 bw);
  199. #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
  200. void phydm_update_hal_ra_mask(
  201. void *dm_void,
  202. u32 wireless_mode,
  203. u8 rf_type,
  204. u8 BW,
  205. u8 mimo_ps_enable,
  206. u8 disable_cck_rate,
  207. u32 *ratr_bitmap_msb_in,
  208. u32 *ratr_bitmap_in,
  209. u8 tx_rate_level);
  210. #endif
  211. #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
  212. u8 phydm_get_plcp(void *dm_void, u16 macid);
  213. #endif
  214. void phydm_refresh_rate_adaptive_mask(void *dm_void);
  215. u8 phydm_rssi_lv_dec(void *dm_void, u32 rssi, u8 ratr_state);
  216. void odm_ra_post_action_on_assoc(void *dm);
  217. u8 odm_find_rts_rate(void *dm_void, u8 tx_rate, boolean is_erp_protect);
  218. void phydm_show_sta_info(void *dm_void, char input[][16], u32 *_used,
  219. char *output, u32 *_out_len);
  220. u8 phydm_get_rate_from_rssi_lv(void *dm_void, u8 sta_idx);
  221. void phydm_ra_registed(void *dm_void, u8 macid, u8 rssi_from_assoc);
  222. void phydm_ra_offline(void *dm_void, u8 macid);
  223. void phydm_ra_mask_watchdog(void *dm_void);
  224. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  225. void odm_refresh_basic_rate_mask(
  226. void *dm_void);
  227. #endif
  228. #endif /*@#ifndef __PHYDMRAINFO_H__*/