dm.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2014 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. #include "../wifi.h"
  26. #include "../base.h"
  27. #include "../pci.h"
  28. #include "../core.h"
  29. #include "reg.h"
  30. #include "def.h"
  31. #include "phy.h"
  32. #include "dm.h"
  33. #include "../rtl8723com/dm_common.h"
  34. #include "fw.h"
  35. #include "trx.h"
  36. #include "../btcoexist/rtl_btc.h"
  37. static const u32 ofdmswing_table[] = {
  38. 0x0b40002d, /* 0, -15.0dB */
  39. 0x0c000030, /* 1, -14.5dB */
  40. 0x0cc00033, /* 2, -14.0dB */
  41. 0x0d800036, /* 3, -13.5dB */
  42. 0x0e400039, /* 4, -13.0dB */
  43. 0x0f00003c, /* 5, -12.5dB */
  44. 0x10000040, /* 6, -12.0dB */
  45. 0x11000044, /* 7, -11.5dB */
  46. 0x12000048, /* 8, -11.0dB */
  47. 0x1300004c, /* 9, -10.5dB */
  48. 0x14400051, /* 10, -10.0dB */
  49. 0x15800056, /* 11, -9.5dB */
  50. 0x16c0005b, /* 12, -9.0dB */
  51. 0x18000060, /* 13, -8.5dB */
  52. 0x19800066, /* 14, -8.0dB */
  53. 0x1b00006c, /* 15, -7.5dB */
  54. 0x1c800072, /* 16, -7.0dB */
  55. 0x1e400079, /* 17, -6.5dB */
  56. 0x20000080, /* 18, -6.0dB */
  57. 0x22000088, /* 19, -5.5dB */
  58. 0x24000090, /* 20, -5.0dB */
  59. 0x26000098, /* 21, -4.5dB */
  60. 0x288000a2, /* 22, -4.0dB */
  61. 0x2ac000ab, /* 23, -3.5dB */
  62. 0x2d4000b5, /* 24, -3.0dB */
  63. 0x300000c0, /* 25, -2.5dB */
  64. 0x32c000cb, /* 26, -2.0dB */
  65. 0x35c000d7, /* 27, -1.5dB */
  66. 0x390000e4, /* 28, -1.0dB */
  67. 0x3c8000f2, /* 29, -0.5dB */
  68. 0x40000100, /* 30, +0dB */
  69. 0x43c0010f, /* 31, +0.5dB */
  70. 0x47c0011f, /* 32, +1.0dB */
  71. 0x4c000130, /* 33, +1.5dB */
  72. 0x50800142, /* 34, +2.0dB */
  73. 0x55400155, /* 35, +2.5dB */
  74. 0x5a400169, /* 36, +3.0dB */
  75. 0x5fc0017f, /* 37, +3.5dB */
  76. 0x65400195, /* 38, +4.0dB */
  77. 0x6b8001ae, /* 39, +4.5dB */
  78. 0x71c001c7, /* 40, +5.0dB */
  79. 0x788001e2, /* 41, +5.5dB */
  80. 0x7f8001fe /* 42, +6.0dB */
  81. };
  82. static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE][8] = {
  83. {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}, /* 0, -16.0dB */
  84. {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 1, -15.5dB */
  85. {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 2, -15.0dB */
  86. {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 3, -14.5dB */
  87. {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 4, -14.0dB */
  88. {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 5, -13.5dB */
  89. {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 6, -13.0dB */
  90. {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 7, -12.5dB */
  91. {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 8, -12.0dB */
  92. {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 9, -11.5dB */
  93. {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 10, -11.0dB */
  94. {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 11, -10.5dB */
  95. {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 12, -10.0dB */
  96. {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 13, -9.5dB */
  97. {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 14, -9.0dB */
  98. {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 15, -8.5dB */
  99. {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */
  100. {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 17, -7.5dB */
  101. {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 18, -7.0dB */
  102. {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 19, -6.5dB */
  103. {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 20, -6.0dB */
  104. {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 21, -5.5dB */
  105. {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 22, -5.0dB */
  106. {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 23, -4.5dB */
  107. {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 24, -4.0dB */
  108. {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 25, -3.5dB */
  109. {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 26, -3.0dB */
  110. {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 27, -2.5dB */
  111. {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 28, -2.0dB */
  112. {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 29, -1.5dB */
  113. {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 30, -1.0dB */
  114. {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 31, -0.5dB */
  115. {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04} /* 32, +0dB */
  116. };
  117. static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
  118. {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}, /* 0, -16.0dB */
  119. {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 1, -15.5dB */
  120. {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 2, -15.0dB */
  121. {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 3, -14.5dB */
  122. {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 4, -14.0dB */
  123. {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 5, -13.5dB */
  124. {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 6, -13.0dB */
  125. {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 7, -12.5dB */
  126. {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 8, -12.0dB */
  127. {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 9, -11.5dB */
  128. {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 10, -11.0dB */
  129. {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 11, -10.5dB */
  130. {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 12, -10.0dB */
  131. {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 13, -9.5dB */
  132. {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 14, -9.0dB */
  133. {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 15, -8.5dB */
  134. {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */
  135. {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 17, -7.5dB */
  136. {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 18, -7.0dB */
  137. {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 19, -6.5dB */
  138. {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 20, -6.0dB */
  139. {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 21, -5.5dB */
  140. {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 22, -5.0dB */
  141. {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 23, -4.5dB */
  142. {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 24, -4.0dB */
  143. {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 25, -3.5dB */
  144. {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 26, -3.0dB */
  145. {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 27, -2.5dB */
  146. {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 28, -2.0dB */
  147. {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 29, -1.5dB */
  148. {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 30, -1.0dB */
  149. {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 31, -0.5dB */
  150. {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00} /* 32, +0dB */
  151. };
  152. static const u32 edca_setting_dl[PEER_MAX] = {
  153. 0xa44f, /* 0 UNKNOWN */
  154. 0x5ea44f, /* 1 REALTEK_90 */
  155. 0x5e4322, /* 2 REALTEK_92SE */
  156. 0x5ea42b, /* 3 BROAD */
  157. 0xa44f, /* 4 RAL */
  158. 0xa630, /* 5 ATH */
  159. 0x5ea630, /* 6 CISCO */
  160. 0x5ea42b, /* 7 MARVELL */
  161. };
  162. static const u32 edca_setting_ul[PEER_MAX] = {
  163. 0x5e4322, /* 0 UNKNOWN */
  164. 0xa44f, /* 1 REALTEK_90 */
  165. 0x5ea44f, /* 2 REALTEK_92SE */
  166. 0x5ea32b, /* 3 BROAD */
  167. 0x5ea422, /* 4 RAL */
  168. 0x5ea322, /* 5 ATH */
  169. 0x3ea430, /* 6 CISCO */
  170. 0x5ea44f, /* 7 MARV */
  171. };
  172. void rtl8723be_dm_txpower_track_adjust(struct ieee80211_hw *hw, u8 type,
  173. u8 *pdirection, u32 *poutwrite_val)
  174. {
  175. struct rtl_priv *rtlpriv = rtl_priv(hw);
  176. struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw));
  177. u8 pwr_val = 0;
  178. u8 ofdm_base = rtlpriv->dm.swing_idx_ofdm_base[RF90_PATH_A];
  179. u8 ofdm_val = rtlpriv->dm.swing_idx_ofdm[RF90_PATH_A];
  180. u8 cck_base = rtldm->swing_idx_cck_base;
  181. u8 cck_val = rtldm->swing_idx_cck;
  182. if (type == 0) {
  183. if (ofdm_val <= ofdm_base) {
  184. *pdirection = 1;
  185. pwr_val = ofdm_base - ofdm_val;
  186. } else {
  187. *pdirection = 2;
  188. pwr_val = ofdm_val - ofdm_base;
  189. }
  190. } else if (type == 1) {
  191. if (cck_val <= cck_base) {
  192. *pdirection = 1;
  193. pwr_val = cck_base - cck_val;
  194. } else {
  195. *pdirection = 2;
  196. pwr_val = cck_val - cck_base;
  197. }
  198. }
  199. if (pwr_val >= TXPWRTRACK_MAX_IDX && (*pdirection == 1))
  200. pwr_val = TXPWRTRACK_MAX_IDX;
  201. *poutwrite_val = pwr_val | (pwr_val << 8) |
  202. (pwr_val << 16) | (pwr_val << 24);
  203. }
  204. void rtl8723be_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw)
  205. {
  206. struct rtl_priv *rtlpriv = rtl_priv(hw);
  207. struct rate_adaptive *p_ra = &rtlpriv->ra;
  208. p_ra->ratr_state = DM_RATR_STA_INIT;
  209. p_ra->pre_ratr_state = DM_RATR_STA_INIT;
  210. if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER)
  211. rtlpriv->dm.useramask = true;
  212. else
  213. rtlpriv->dm.useramask = false;
  214. p_ra->high_rssi_thresh_for_ra = 50;
  215. p_ra->low_rssi_thresh_for_ra40m = 20;
  216. }
  217. static void rtl8723be_dm_init_txpower_tracking(struct ieee80211_hw *hw)
  218. {
  219. struct rtl_priv *rtlpriv = rtl_priv(hw);
  220. rtlpriv->dm.txpower_tracking = true;
  221. rtlpriv->dm.txpower_track_control = true;
  222. rtlpriv->dm.thermalvalue = 0;
  223. rtlpriv->dm.ofdm_index[0] = 30;
  224. rtlpriv->dm.cck_index = 20;
  225. rtlpriv->dm.swing_idx_cck_base = rtlpriv->dm.cck_index;
  226. rtlpriv->dm.swing_idx_ofdm_base[0] = rtlpriv->dm.ofdm_index[0];
  227. rtlpriv->dm.delta_power_index[RF90_PATH_A] = 0;
  228. rtlpriv->dm.delta_power_index_last[RF90_PATH_A] = 0;
  229. rtlpriv->dm.power_index_offset[RF90_PATH_A] = 0;
  230. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
  231. " rtlpriv->dm.txpower_tracking = %d\n",
  232. rtlpriv->dm.txpower_tracking);
  233. }
  234. static void rtl8723be_dm_init_dynamic_atc_switch(struct ieee80211_hw *hw)
  235. {
  236. struct rtl_priv *rtlpriv = rtl_priv(hw);
  237. rtlpriv->dm.crystal_cap = rtlpriv->efuse.crystalcap;
  238. rtlpriv->dm.atc_status = rtl_get_bbreg(hw, ROFDM1_CFOTRACKING, 0x800);
  239. rtlpriv->dm.cfo_threshold = CFO_THRESHOLD_XTAL;
  240. }
  241. void rtl8723be_dm_init(struct ieee80211_hw *hw)
  242. {
  243. struct rtl_priv *rtlpriv = rtl_priv(hw);
  244. u32 cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
  245. rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
  246. rtl_dm_diginit(hw, cur_igvalue);
  247. rtl8723be_dm_init_rate_adaptive_mask(hw);
  248. rtl8723_dm_init_edca_turbo(hw);
  249. rtl8723_dm_init_dynamic_bb_powersaving(hw);
  250. rtl8723_dm_init_dynamic_txpower(hw);
  251. rtl8723be_dm_init_txpower_tracking(hw);
  252. rtl8723be_dm_init_dynamic_atc_switch(hw);
  253. }
  254. static void rtl8723be_dm_find_minimum_rssi(struct ieee80211_hw *hw)
  255. {
  256. struct rtl_priv *rtlpriv = rtl_priv(hw);
  257. struct dig_t *rtl_dm_dig = &rtlpriv->dm_digtable;
  258. struct rtl_mac *mac = rtl_mac(rtlpriv);
  259. /* Determine the minimum RSSI */
  260. if ((mac->link_state < MAC80211_LINKED) &&
  261. (rtlpriv->dm.entry_min_undec_sm_pwdb == 0)) {
  262. rtl_dm_dig->min_undec_pwdb_for_dm = 0;
  263. RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
  264. "Not connected to any\n");
  265. }
  266. if (mac->link_state >= MAC80211_LINKED) {
  267. if (mac->opmode == NL80211_IFTYPE_AP ||
  268. mac->opmode == NL80211_IFTYPE_ADHOC) {
  269. rtl_dm_dig->min_undec_pwdb_for_dm =
  270. rtlpriv->dm.entry_min_undec_sm_pwdb;
  271. RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
  272. "AP Client PWDB = 0x%lx\n",
  273. rtlpriv->dm.entry_min_undec_sm_pwdb);
  274. } else {
  275. rtl_dm_dig->min_undec_pwdb_for_dm =
  276. rtlpriv->dm.undec_sm_pwdb;
  277. RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
  278. "STA Default Port PWDB = 0x%x\n",
  279. rtl_dm_dig->min_undec_pwdb_for_dm);
  280. }
  281. } else {
  282. rtl_dm_dig->min_undec_pwdb_for_dm =
  283. rtlpriv->dm.entry_min_undec_sm_pwdb;
  284. RT_TRACE(rtlpriv, COMP_BB_POWERSAVING, DBG_LOUD,
  285. "AP Ext Port or disconnect PWDB = 0x%x\n",
  286. rtl_dm_dig->min_undec_pwdb_for_dm);
  287. }
  288. RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "MinUndecoratedPWDBForDM =%d\n",
  289. rtl_dm_dig->min_undec_pwdb_for_dm);
  290. }
  291. static void rtl8723be_dm_check_rssi_monitor(struct ieee80211_hw *hw)
  292. {
  293. struct rtl_priv *rtlpriv = rtl_priv(hw);
  294. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  295. struct rtl_sta_info *drv_priv;
  296. u8 h2c_parameter[3] = { 0 };
  297. long tmp_entry_max_pwdb = 0, tmp_entry_min_pwdb = 0xff;
  298. /* AP & ADHOC & MESH */
  299. spin_lock_bh(&rtlpriv->locks.entry_list_lock);
  300. list_for_each_entry(drv_priv, &rtlpriv->entry_list, list) {
  301. if (drv_priv->rssi_stat.undec_sm_pwdb <
  302. tmp_entry_min_pwdb)
  303. tmp_entry_min_pwdb =
  304. drv_priv->rssi_stat.undec_sm_pwdb;
  305. if (drv_priv->rssi_stat.undec_sm_pwdb >
  306. tmp_entry_max_pwdb)
  307. tmp_entry_max_pwdb =
  308. drv_priv->rssi_stat.undec_sm_pwdb;
  309. }
  310. spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
  311. /* If associated entry is found */
  312. if (tmp_entry_max_pwdb != 0) {
  313. rtlpriv->dm.entry_max_undec_sm_pwdb =
  314. tmp_entry_max_pwdb;
  315. RTPRINT(rtlpriv, FDM, DM_PWDB,
  316. "EntryMaxPWDB = 0x%lx(%ld)\n",
  317. tmp_entry_max_pwdb, tmp_entry_max_pwdb);
  318. } else {
  319. rtlpriv->dm.entry_max_undec_sm_pwdb = 0;
  320. }
  321. /* If associated entry is found */
  322. if (tmp_entry_min_pwdb != 0xff) {
  323. rtlpriv->dm.entry_min_undec_sm_pwdb =
  324. tmp_entry_min_pwdb;
  325. RTPRINT(rtlpriv, FDM, DM_PWDB,
  326. "EntryMinPWDB = 0x%lx(%ld)\n",
  327. tmp_entry_min_pwdb, tmp_entry_min_pwdb);
  328. } else {
  329. rtlpriv->dm.entry_min_undec_sm_pwdb = 0;
  330. }
  331. /* Indicate Rx signal strength to FW. */
  332. if (rtlpriv->dm.useramask) {
  333. h2c_parameter[2] =
  334. (u8)(rtlpriv->dm.undec_sm_pwdb & 0xFF);
  335. h2c_parameter[1] = 0x20;
  336. h2c_parameter[0] = 0;
  337. rtl8723be_fill_h2c_cmd(hw, H2C_RSSIBE_REPORT, 3, h2c_parameter);
  338. } else {
  339. rtl_write_byte(rtlpriv, 0x4fe,
  340. rtlpriv->dm.undec_sm_pwdb);
  341. }
  342. rtl8723be_dm_find_minimum_rssi(hw);
  343. dm_digtable->rssi_val_min =
  344. rtlpriv->dm_digtable.min_undec_pwdb_for_dm;
  345. }
  346. void rtl8723be_dm_write_dig(struct ieee80211_hw *hw, u8 current_igi)
  347. {
  348. struct rtl_priv *rtlpriv = rtl_priv(hw);
  349. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  350. if (dm_digtable->stop_dig)
  351. return;
  352. if (dm_digtable->cur_igvalue != current_igi) {
  353. rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, current_igi);
  354. if (rtlpriv->phy.rf_type != RF_1T1R)
  355. rtl_set_bbreg(hw, ROFDM0_XBAGCCORE1,
  356. 0x7f, current_igi);
  357. }
  358. dm_digtable->pre_igvalue = dm_digtable->cur_igvalue;
  359. dm_digtable->cur_igvalue = current_igi;
  360. }
  361. static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
  362. {
  363. struct rtl_priv *rtlpriv = rtl_priv(hw);
  364. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  365. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  366. u8 dig_min_0, dig_maxofmin;
  367. bool bfirstconnect, bfirstdisconnect;
  368. u8 dm_dig_max, dm_dig_min;
  369. u8 current_igi = dm_digtable->cur_igvalue;
  370. u8 offset;
  371. /* AP,BT */
  372. if (mac->act_scanning)
  373. return;
  374. dig_min_0 = dm_digtable->dig_min_0;
  375. bfirstconnect = (mac->link_state >= MAC80211_LINKED) &&
  376. !dm_digtable->media_connect_0;
  377. bfirstdisconnect = (mac->link_state < MAC80211_LINKED) &&
  378. (dm_digtable->media_connect_0);
  379. dm_dig_max = 0x5a;
  380. dm_dig_min = DM_DIG_MIN;
  381. dig_maxofmin = DM_DIG_MAX_AP;
  382. if (mac->link_state >= MAC80211_LINKED) {
  383. if ((dm_digtable->rssi_val_min + 10) > dm_dig_max)
  384. dm_digtable->rx_gain_max = dm_dig_max;
  385. else if ((dm_digtable->rssi_val_min + 10) < dm_dig_min)
  386. dm_digtable->rx_gain_max = dm_dig_min;
  387. else
  388. dm_digtable->rx_gain_max =
  389. dm_digtable->rssi_val_min + 10;
  390. if (rtlpriv->dm.one_entry_only) {
  391. offset = 12;
  392. if (dm_digtable->rssi_val_min - offset < dm_dig_min)
  393. dig_min_0 = dm_dig_min;
  394. else if (dm_digtable->rssi_val_min - offset >
  395. dig_maxofmin)
  396. dig_min_0 = dig_maxofmin;
  397. else
  398. dig_min_0 =
  399. dm_digtable->rssi_val_min - offset;
  400. } else {
  401. dig_min_0 = dm_dig_min;
  402. }
  403. } else {
  404. dm_digtable->rx_gain_max = dm_dig_max;
  405. dig_min_0 = dm_dig_min;
  406. RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "no link\n");
  407. }
  408. if (rtlpriv->falsealm_cnt.cnt_all > 10000) {
  409. if (dm_digtable->large_fa_hit != 3)
  410. dm_digtable->large_fa_hit++;
  411. if (dm_digtable->forbidden_igi < current_igi) {
  412. dm_digtable->forbidden_igi = current_igi;
  413. dm_digtable->large_fa_hit = 1;
  414. }
  415. if (dm_digtable->large_fa_hit >= 3) {
  416. if ((dm_digtable->forbidden_igi + 1) >
  417. dm_digtable->rx_gain_max)
  418. dm_digtable->rx_gain_min =
  419. dm_digtable->rx_gain_max;
  420. else
  421. dm_digtable->rx_gain_min =
  422. dm_digtable->forbidden_igi + 1;
  423. dm_digtable->recover_cnt = 3600;
  424. }
  425. } else {
  426. if (dm_digtable->recover_cnt != 0) {
  427. dm_digtable->recover_cnt--;
  428. } else {
  429. if (dm_digtable->large_fa_hit < 3) {
  430. if ((dm_digtable->forbidden_igi - 1) <
  431. dig_min_0) {
  432. dm_digtable->forbidden_igi =
  433. dig_min_0;
  434. dm_digtable->rx_gain_min =
  435. dig_min_0;
  436. } else {
  437. dm_digtable->forbidden_igi--;
  438. dm_digtable->rx_gain_min =
  439. dm_digtable->forbidden_igi + 1;
  440. }
  441. } else {
  442. dm_digtable->large_fa_hit = 0;
  443. }
  444. }
  445. }
  446. if (dm_digtable->rx_gain_min > dm_digtable->rx_gain_max)
  447. dm_digtable->rx_gain_min = dm_digtable->rx_gain_max;
  448. if (mac->link_state >= MAC80211_LINKED) {
  449. if (bfirstconnect) {
  450. if (dm_digtable->rssi_val_min <= dig_maxofmin)
  451. current_igi = dm_digtable->rssi_val_min;
  452. else
  453. current_igi = dig_maxofmin;
  454. dm_digtable->large_fa_hit = 0;
  455. } else {
  456. if (rtlpriv->falsealm_cnt.cnt_all > DM_DIG_FA_TH2)
  457. current_igi += 4;
  458. else if (rtlpriv->falsealm_cnt.cnt_all > DM_DIG_FA_TH1)
  459. current_igi += 2;
  460. else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH0)
  461. current_igi -= 2;
  462. }
  463. } else {
  464. if (bfirstdisconnect) {
  465. current_igi = dm_digtable->rx_gain_min;
  466. } else {
  467. if (rtlpriv->falsealm_cnt.cnt_all > 10000)
  468. current_igi += 4;
  469. else if (rtlpriv->falsealm_cnt.cnt_all > 8000)
  470. current_igi += 2;
  471. else if (rtlpriv->falsealm_cnt.cnt_all < 500)
  472. current_igi -= 2;
  473. }
  474. }
  475. if (current_igi > dm_digtable->rx_gain_max)
  476. current_igi = dm_digtable->rx_gain_max;
  477. else if (current_igi < dm_digtable->rx_gain_min)
  478. current_igi = dm_digtable->rx_gain_min;
  479. rtl8723be_dm_write_dig(hw, current_igi);
  480. dm_digtable->media_connect_0 =
  481. ((mac->link_state >= MAC80211_LINKED) ? true : false);
  482. dm_digtable->dig_min_0 = dig_min_0;
  483. }
  484. static void rtl8723be_dm_false_alarm_counter_statistics(
  485. struct ieee80211_hw *hw)
  486. {
  487. u32 ret_value;
  488. struct rtl_priv *rtlpriv = rtl_priv(hw);
  489. struct false_alarm_statistics *falsealm_cnt = &rtlpriv->falsealm_cnt;
  490. rtl_set_bbreg(hw, DM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1);
  491. rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(31), 1);
  492. ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE1_11N, MASKDWORD);
  493. falsealm_cnt->cnt_fast_fsync_fail = ret_value & 0xffff;
  494. falsealm_cnt->cnt_sb_search_fail = (ret_value & 0xffff0000) >> 16;
  495. ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE2_11N, MASKDWORD);
  496. falsealm_cnt->cnt_ofdm_cca = ret_value & 0xffff;
  497. falsealm_cnt->cnt_parity_fail = (ret_value & 0xffff0000) >> 16;
  498. ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE3_11N, MASKDWORD);
  499. falsealm_cnt->cnt_rate_illegal = ret_value & 0xffff;
  500. falsealm_cnt->cnt_crc8_fail = (ret_value & 0xffff0000) >> 16;
  501. ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE4_11N, MASKDWORD);
  502. falsealm_cnt->cnt_mcs_fail = ret_value & 0xffff;
  503. falsealm_cnt->cnt_ofdm_fail = falsealm_cnt->cnt_parity_fail +
  504. falsealm_cnt->cnt_rate_illegal +
  505. falsealm_cnt->cnt_crc8_fail +
  506. falsealm_cnt->cnt_mcs_fail +
  507. falsealm_cnt->cnt_fast_fsync_fail +
  508. falsealm_cnt->cnt_sb_search_fail;
  509. rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(12), 1);
  510. rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(14), 1);
  511. ret_value = rtl_get_bbreg(hw, DM_REG_CCK_FA_RST_11N, MASKBYTE0);
  512. falsealm_cnt->cnt_cck_fail = ret_value;
  513. ret_value = rtl_get_bbreg(hw, DM_REG_CCK_FA_MSB_11N, MASKBYTE3);
  514. falsealm_cnt->cnt_cck_fail += (ret_value & 0xff) << 8;
  515. ret_value = rtl_get_bbreg(hw, DM_REG_CCK_CCA_CNT_11N, MASKDWORD);
  516. falsealm_cnt->cnt_cck_cca = ((ret_value & 0xff) << 8) |
  517. ((ret_value & 0xff00) >> 8);
  518. falsealm_cnt->cnt_all = falsealm_cnt->cnt_fast_fsync_fail +
  519. falsealm_cnt->cnt_sb_search_fail +
  520. falsealm_cnt->cnt_parity_fail +
  521. falsealm_cnt->cnt_rate_illegal +
  522. falsealm_cnt->cnt_crc8_fail +
  523. falsealm_cnt->cnt_mcs_fail +
  524. falsealm_cnt->cnt_cck_fail;
  525. falsealm_cnt->cnt_cca_all = falsealm_cnt->cnt_ofdm_cca +
  526. falsealm_cnt->cnt_cck_cca;
  527. rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTC_11N, BIT(31), 1);
  528. rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTC_11N, BIT(31), 0);
  529. rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(27), 1);
  530. rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(27), 0);
  531. rtl_set_bbreg(hw, DM_REG_OFDM_FA_HOLDC_11N, BIT(31), 0);
  532. rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(31), 0);
  533. rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(13) | BIT(12), 0);
  534. rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(13) | BIT(12), 2);
  535. rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(15) | BIT(14), 0);
  536. rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(15) | BIT(14), 2);
  537. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  538. "cnt_parity_fail = %d, cnt_rate_illegal = %d, cnt_crc8_fail = %d, cnt_mcs_fail = %d\n",
  539. falsealm_cnt->cnt_parity_fail,
  540. falsealm_cnt->cnt_rate_illegal,
  541. falsealm_cnt->cnt_crc8_fail,
  542. falsealm_cnt->cnt_mcs_fail);
  543. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  544. "cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n",
  545. falsealm_cnt->cnt_ofdm_fail,
  546. falsealm_cnt->cnt_cck_fail,
  547. falsealm_cnt->cnt_all);
  548. }
  549. static void rtl8723be_dm_dynamic_txpower(struct ieee80211_hw *hw)
  550. {
  551. /* 8723BE does not support ODM_BB_DYNAMIC_TXPWR*/
  552. return;
  553. }
  554. static void rtl8723be_set_iqk_matrix(struct ieee80211_hw *hw, u8 ofdm_index,
  555. u8 rfpath, long iqk_result_x,
  556. long iqk_result_y)
  557. {
  558. long ele_a = 0, ele_d, ele_c = 0, value32;
  559. if (ofdm_index >= 43)
  560. ofdm_index = 43 - 1;
  561. ele_d = (ofdmswing_table[ofdm_index] & 0xFFC00000) >> 22;
  562. if (iqk_result_x != 0) {
  563. if ((iqk_result_x & 0x00000200) != 0)
  564. iqk_result_x = iqk_result_x | 0xFFFFFC00;
  565. ele_a = ((iqk_result_x * ele_d) >> 8) & 0x000003FF;
  566. if ((iqk_result_y & 0x00000200) != 0)
  567. iqk_result_y = iqk_result_y | 0xFFFFFC00;
  568. ele_c = ((iqk_result_y * ele_d) >> 8) & 0x000003FF;
  569. switch (rfpath) {
  570. case RF90_PATH_A:
  571. value32 = (ele_d << 22) |
  572. ((ele_c & 0x3F) << 16) | ele_a;
  573. rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, MASKDWORD,
  574. value32);
  575. value32 = (ele_c & 0x000003C0) >> 6;
  576. rtl_set_bbreg(hw, ROFDM0_XCTXAFE, MASKH4BITS, value32);
  577. value32 = ((iqk_result_x * ele_d) >> 7) & 0x01;
  578. rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24),
  579. value32);
  580. break;
  581. default:
  582. break;
  583. }
  584. } else {
  585. switch (rfpath) {
  586. case RF90_PATH_A:
  587. rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, MASKDWORD,
  588. ofdmswing_table[ofdm_index]);
  589. rtl_set_bbreg(hw, ROFDM0_XCTXAFE, MASKH4BITS, 0x00);
  590. rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24), 0x00);
  591. break;
  592. default:
  593. break;
  594. }
  595. }
  596. }
  597. static void rtl8723be_dm_tx_power_track_set_power(struct ieee80211_hw *hw,
  598. enum pwr_track_control_method method,
  599. u8 rfpath, u8 idx)
  600. {
  601. struct rtl_priv *rtlpriv = rtl_priv(hw);
  602. struct rtl_phy *rtlphy = &rtlpriv->phy;
  603. struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw));
  604. u8 swing_idx_ofdm_limit = 36;
  605. if (method == TXAGC) {
  606. rtl8723be_phy_set_txpower_level(hw, rtlphy->current_channel);
  607. } else if (method == BBSWING) {
  608. if (rtldm->swing_idx_cck >= CCK_TABLE_SIZE)
  609. rtldm->swing_idx_cck = CCK_TABLE_SIZE - 1;
  610. if (!rtldm->cck_inch14) {
  611. rtl_write_byte(rtlpriv, 0xa22,
  612. cckswing_table_ch1ch13[rtldm->swing_idx_cck][0]);
  613. rtl_write_byte(rtlpriv, 0xa23,
  614. cckswing_table_ch1ch13[rtldm->swing_idx_cck][1]);
  615. rtl_write_byte(rtlpriv, 0xa24,
  616. cckswing_table_ch1ch13[rtldm->swing_idx_cck][2]);
  617. rtl_write_byte(rtlpriv, 0xa25,
  618. cckswing_table_ch1ch13[rtldm->swing_idx_cck][3]);
  619. rtl_write_byte(rtlpriv, 0xa26,
  620. cckswing_table_ch1ch13[rtldm->swing_idx_cck][4]);
  621. rtl_write_byte(rtlpriv, 0xa27,
  622. cckswing_table_ch1ch13[rtldm->swing_idx_cck][5]);
  623. rtl_write_byte(rtlpriv, 0xa28,
  624. cckswing_table_ch1ch13[rtldm->swing_idx_cck][6]);
  625. rtl_write_byte(rtlpriv, 0xa29,
  626. cckswing_table_ch1ch13[rtldm->swing_idx_cck][7]);
  627. } else {
  628. rtl_write_byte(rtlpriv, 0xa22,
  629. cckswing_table_ch14[rtldm->swing_idx_cck][0]);
  630. rtl_write_byte(rtlpriv, 0xa23,
  631. cckswing_table_ch14[rtldm->swing_idx_cck][1]);
  632. rtl_write_byte(rtlpriv, 0xa24,
  633. cckswing_table_ch14[rtldm->swing_idx_cck][2]);
  634. rtl_write_byte(rtlpriv, 0xa25,
  635. cckswing_table_ch14[rtldm->swing_idx_cck][3]);
  636. rtl_write_byte(rtlpriv, 0xa26,
  637. cckswing_table_ch14[rtldm->swing_idx_cck][4]);
  638. rtl_write_byte(rtlpriv, 0xa27,
  639. cckswing_table_ch14[rtldm->swing_idx_cck][5]);
  640. rtl_write_byte(rtlpriv, 0xa28,
  641. cckswing_table_ch14[rtldm->swing_idx_cck][6]);
  642. rtl_write_byte(rtlpriv, 0xa29,
  643. cckswing_table_ch14[rtldm->swing_idx_cck][7]);
  644. }
  645. if (rfpath == RF90_PATH_A) {
  646. if (rtldm->swing_idx_ofdm[RF90_PATH_A] <
  647. swing_idx_ofdm_limit)
  648. swing_idx_ofdm_limit =
  649. rtldm->swing_idx_ofdm[RF90_PATH_A];
  650. rtl8723be_set_iqk_matrix(hw,
  651. rtldm->swing_idx_ofdm[rfpath], rfpath,
  652. rtlphy->iqk_matrix[idx].value[0][0],
  653. rtlphy->iqk_matrix[idx].value[0][1]);
  654. } else if (rfpath == RF90_PATH_B) {
  655. if (rtldm->swing_idx_ofdm[RF90_PATH_B] <
  656. swing_idx_ofdm_limit)
  657. swing_idx_ofdm_limit =
  658. rtldm->swing_idx_ofdm[RF90_PATH_B];
  659. rtl8723be_set_iqk_matrix(hw,
  660. rtldm->swing_idx_ofdm[rfpath], rfpath,
  661. rtlphy->iqk_matrix[idx].value[0][4],
  662. rtlphy->iqk_matrix[idx].value[0][5]);
  663. }
  664. } else {
  665. return;
  666. }
  667. }
  668. static void rtl8723be_dm_txpower_tracking_callback_thermalmeter(
  669. struct ieee80211_hw *hw)
  670. {
  671. struct rtl_priv *rtlpriv = rtl_priv(hw);
  672. struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
  673. struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw));
  674. u8 thermalvalue = 0, delta, delta_lck, delta_iqk;
  675. u8 thermalvalue_avg_count = 0;
  676. u32 thermalvalue_avg = 0;
  677. int i = 0;
  678. u8 ofdm_min_index = 6;
  679. u8 index_for_channel = 0;
  680. char delta_swing_table_idx_tup_a[TXSCALE_TABLE_SIZE] = {
  681. 0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5,
  682. 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10,
  683. 10, 11, 11, 12, 12, 13, 14, 15};
  684. char delta_swing_table_idx_tdown_a[TXSCALE_TABLE_SIZE] = {
  685. 0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5,
  686. 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9,
  687. 9, 10, 10, 11, 12, 13, 14, 15};
  688. /*Initilization ( 7 steps in total )*/
  689. rtlpriv->dm.txpower_trackinginit = true;
  690. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
  691. "rtl8723be_dm_txpower_tracking_callback_thermalmeter\n");
  692. thermalvalue = (u8)rtl_get_rfreg(hw,
  693. RF90_PATH_A, RF_T_METER, 0xfc00);
  694. if (!rtlpriv->dm.txpower_track_control || thermalvalue == 0 ||
  695. rtlefuse->eeprom_thermalmeter == 0xFF)
  696. return;
  697. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
  698. "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x\n",
  699. thermalvalue, rtldm->thermalvalue,
  700. rtlefuse->eeprom_thermalmeter);
  701. /*3 Initialize ThermalValues of RFCalibrateInfo*/
  702. if (!rtldm->thermalvalue) {
  703. rtlpriv->dm.thermalvalue_lck = thermalvalue;
  704. rtlpriv->dm.thermalvalue_iqk = thermalvalue;
  705. }
  706. /*4 Calculate average thermal meter*/
  707. rtldm->thermalvalue_avg[rtldm->thermalvalue_avg_index] = thermalvalue;
  708. rtldm->thermalvalue_avg_index++;
  709. if (rtldm->thermalvalue_avg_index == AVG_THERMAL_NUM_8723BE)
  710. rtldm->thermalvalue_avg_index = 0;
  711. for (i = 0; i < AVG_THERMAL_NUM_8723BE; i++) {
  712. if (rtldm->thermalvalue_avg[i]) {
  713. thermalvalue_avg += rtldm->thermalvalue_avg[i];
  714. thermalvalue_avg_count++;
  715. }
  716. }
  717. if (thermalvalue_avg_count)
  718. thermalvalue = (u8)(thermalvalue_avg / thermalvalue_avg_count);
  719. /* 5 Calculate delta, delta_LCK, delta_IQK.*/
  720. delta = (thermalvalue > rtlpriv->dm.thermalvalue) ?
  721. (thermalvalue - rtlpriv->dm.thermalvalue) :
  722. (rtlpriv->dm.thermalvalue - thermalvalue);
  723. delta_lck = (thermalvalue > rtlpriv->dm.thermalvalue_lck) ?
  724. (thermalvalue - rtlpriv->dm.thermalvalue_lck) :
  725. (rtlpriv->dm.thermalvalue_lck - thermalvalue);
  726. delta_iqk = (thermalvalue > rtlpriv->dm.thermalvalue_iqk) ?
  727. (thermalvalue - rtlpriv->dm.thermalvalue_iqk) :
  728. (rtlpriv->dm.thermalvalue_iqk - thermalvalue);
  729. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
  730. "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x delta 0x%x delta_lck 0x%x delta_iqk 0x%x\n",
  731. thermalvalue, rtlpriv->dm.thermalvalue,
  732. rtlefuse->eeprom_thermalmeter, delta, delta_lck, delta_iqk);
  733. /* 6 If necessary, do LCK.*/
  734. if (delta_lck >= IQK_THRESHOLD) {
  735. rtlpriv->dm.thermalvalue_lck = thermalvalue;
  736. rtl8723be_phy_lc_calibrate(hw);
  737. }
  738. /* 7 If necessary, move the index of
  739. * swing table to adjust Tx power.
  740. */
  741. if (delta > 0 && rtlpriv->dm.txpower_track_control) {
  742. delta = (thermalvalue > rtlefuse->eeprom_thermalmeter) ?
  743. (thermalvalue - rtlefuse->eeprom_thermalmeter) :
  744. (rtlefuse->eeprom_thermalmeter - thermalvalue);
  745. if (delta >= TXSCALE_TABLE_SIZE)
  746. delta = TXSCALE_TABLE_SIZE - 1;
  747. /* 7.1 Get the final CCK_index and
  748. * OFDM_index for each swing table.
  749. */
  750. if (thermalvalue > rtlefuse->eeprom_thermalmeter) {
  751. rtldm->delta_power_index_last[RF90_PATH_A] =
  752. rtldm->delta_power_index[RF90_PATH_A];
  753. rtldm->delta_power_index[RF90_PATH_A] =
  754. delta_swing_table_idx_tup_a[delta];
  755. } else {
  756. rtldm->delta_power_index_last[RF90_PATH_A] =
  757. rtldm->delta_power_index[RF90_PATH_A];
  758. rtldm->delta_power_index[RF90_PATH_A] =
  759. -1 * delta_swing_table_idx_tdown_a[delta];
  760. }
  761. /* 7.2 Handle boundary conditions of index.*/
  762. if (rtldm->delta_power_index[RF90_PATH_A] ==
  763. rtldm->delta_power_index_last[RF90_PATH_A])
  764. rtldm->power_index_offset[RF90_PATH_A] = 0;
  765. else
  766. rtldm->power_index_offset[RF90_PATH_A] =
  767. rtldm->delta_power_index[RF90_PATH_A] -
  768. rtldm->delta_power_index_last[RF90_PATH_A];
  769. rtldm->ofdm_index[0] =
  770. rtldm->swing_idx_ofdm_base[RF90_PATH_A] +
  771. rtldm->power_index_offset[RF90_PATH_A];
  772. rtldm->cck_index = rtldm->swing_idx_cck_base +
  773. rtldm->power_index_offset[RF90_PATH_A];
  774. rtldm->swing_idx_cck = rtldm->cck_index;
  775. rtldm->swing_idx_ofdm[0] = rtldm->ofdm_index[0];
  776. if (rtldm->ofdm_index[0] > OFDM_TABLE_SIZE - 1)
  777. rtldm->ofdm_index[0] = OFDM_TABLE_SIZE - 1;
  778. else if (rtldm->ofdm_index[0] < ofdm_min_index)
  779. rtldm->ofdm_index[0] = ofdm_min_index;
  780. if (rtldm->cck_index > CCK_TABLE_SIZE - 1)
  781. rtldm->cck_index = CCK_TABLE_SIZE - 1;
  782. else if (rtldm->cck_index < 0)
  783. rtldm->cck_index = 0;
  784. } else {
  785. rtldm->power_index_offset[RF90_PATH_A] = 0;
  786. }
  787. if ((rtldm->power_index_offset[RF90_PATH_A] != 0) &&
  788. (rtldm->txpower_track_control)) {
  789. rtldm->done_txpower = true;
  790. if (thermalvalue > rtlefuse->eeprom_thermalmeter)
  791. rtl8723be_dm_tx_power_track_set_power(hw, BBSWING, 0,
  792. index_for_channel);
  793. else
  794. rtl8723be_dm_tx_power_track_set_power(hw, BBSWING, 0,
  795. index_for_channel);
  796. rtldm->swing_idx_cck_base = rtldm->swing_idx_cck;
  797. rtldm->swing_idx_ofdm_base[RF90_PATH_A] =
  798. rtldm->swing_idx_ofdm[0];
  799. rtldm->thermalvalue = thermalvalue;
  800. }
  801. if (delta_iqk >= IQK_THRESHOLD) {
  802. rtldm->thermalvalue_iqk = thermalvalue;
  803. rtl8723be_phy_iq_calibrate(hw, false);
  804. }
  805. rtldm->txpowercount = 0;
  806. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "end\n");
  807. }
  808. void rtl8723be_dm_check_txpower_tracking(struct ieee80211_hw *hw)
  809. {
  810. struct rtl_priv *rtlpriv = rtl_priv(hw);
  811. if (!rtlpriv->dm.txpower_tracking)
  812. return;
  813. if (!rtlpriv->dm.tm_trigger) {
  814. rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, BIT(17) | BIT(16),
  815. 0x03);
  816. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
  817. "Trigger 8723be Thermal Meter!!\n");
  818. rtlpriv->dm.tm_trigger = 1;
  819. return;
  820. } else {
  821. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
  822. "Schedule TxPowerTracking !!\n");
  823. rtl8723be_dm_txpower_tracking_callback_thermalmeter(hw);
  824. rtlpriv->dm.tm_trigger = 0;
  825. }
  826. }
  827. static void rtl8723be_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw)
  828. {
  829. struct rtl_priv *rtlpriv = rtl_priv(hw);
  830. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  831. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  832. struct rate_adaptive *p_ra = &rtlpriv->ra;
  833. u32 low_rssithresh_for_ra = p_ra->low2high_rssi_thresh_for_ra40m;
  834. u32 high_rssithresh_for_ra = p_ra->high_rssi_thresh_for_ra;
  835. u8 go_up_gap = 5;
  836. struct ieee80211_sta *sta = NULL;
  837. if (is_hal_stop(rtlhal)) {
  838. RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
  839. "driver is going to unload\n");
  840. return;
  841. }
  842. if (!rtlpriv->dm.useramask) {
  843. RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
  844. "driver does not control rate adaptive mask\n");
  845. return;
  846. }
  847. if (mac->link_state == MAC80211_LINKED &&
  848. mac->opmode == NL80211_IFTYPE_STATION) {
  849. switch (p_ra->pre_ratr_state) {
  850. case DM_RATR_STA_MIDDLE:
  851. high_rssithresh_for_ra += go_up_gap;
  852. break;
  853. case DM_RATR_STA_LOW:
  854. high_rssithresh_for_ra += go_up_gap;
  855. low_rssithresh_for_ra += go_up_gap;
  856. break;
  857. default:
  858. break;
  859. }
  860. if (rtlpriv->dm.undec_sm_pwdb >
  861. (long)high_rssithresh_for_ra)
  862. p_ra->ratr_state = DM_RATR_STA_HIGH;
  863. else if (rtlpriv->dm.undec_sm_pwdb >
  864. (long)low_rssithresh_for_ra)
  865. p_ra->ratr_state = DM_RATR_STA_MIDDLE;
  866. else
  867. p_ra->ratr_state = DM_RATR_STA_LOW;
  868. if (p_ra->pre_ratr_state != p_ra->ratr_state) {
  869. RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
  870. "RSSI = %ld\n",
  871. rtlpriv->dm.undec_sm_pwdb);
  872. RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
  873. "RSSI_LEVEL = %d\n", p_ra->ratr_state);
  874. RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD,
  875. "PreState = %d, CurState = %d\n",
  876. p_ra->pre_ratr_state, p_ra->ratr_state);
  877. rcu_read_lock();
  878. sta = rtl_find_sta(hw, mac->bssid);
  879. if (sta)
  880. rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
  881. p_ra->ratr_state);
  882. rcu_read_unlock();
  883. p_ra->pre_ratr_state = p_ra->ratr_state;
  884. }
  885. }
  886. }
  887. static bool rtl8723be_dm_is_edca_turbo_disable(struct ieee80211_hw *hw)
  888. {
  889. struct rtl_priv *rtlpriv = rtl_priv(hw);
  890. if (rtlpriv->mac80211.mode == WIRELESS_MODE_B)
  891. return true;
  892. return false;
  893. }
  894. static void rtl8723be_dm_check_edca_turbo(struct ieee80211_hw *hw)
  895. {
  896. struct rtl_priv *rtlpriv = rtl_priv(hw);
  897. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  898. static u64 last_txok_cnt;
  899. static u64 last_rxok_cnt;
  900. u64 cur_txok_cnt = 0;
  901. u64 cur_rxok_cnt = 0;
  902. u32 edca_be_ul = 0x6ea42b;
  903. u32 edca_be_dl = 0x6ea42b;/*not sure*/
  904. u32 edca_be = 0x5ea42b;
  905. u32 iot_peer = 0;
  906. bool b_is_cur_rdlstate;
  907. bool b_last_is_cur_rdlstate = false;
  908. bool b_bias_on_rx = false;
  909. bool b_edca_turbo_on = false;
  910. b_last_is_cur_rdlstate = rtlpriv->dm.is_cur_rdlstate;
  911. cur_txok_cnt = rtlpriv->stats.txbytesunicast - last_txok_cnt;
  912. cur_rxok_cnt = rtlpriv->stats.rxbytesunicast - last_rxok_cnt;
  913. iot_peer = rtlpriv->mac80211.vendor;
  914. b_bias_on_rx = (iot_peer == PEER_RAL || iot_peer == PEER_ATH) ?
  915. true : false;
  916. b_edca_turbo_on = ((!rtlpriv->dm.is_any_nonbepkts) &&
  917. (!rtlpriv->dm.disable_framebursting)) ?
  918. true : false;
  919. if ((iot_peer == PEER_CISCO) &&
  920. (mac->mode == WIRELESS_MODE_N_24G)) {
  921. edca_be_dl = edca_setting_dl[iot_peer];
  922. edca_be_ul = edca_setting_ul[iot_peer];
  923. }
  924. if (rtl8723be_dm_is_edca_turbo_disable(hw))
  925. goto exit;
  926. if (b_edca_turbo_on) {
  927. if (b_bias_on_rx)
  928. b_is_cur_rdlstate = (cur_txok_cnt > cur_rxok_cnt * 4) ?
  929. false : true;
  930. else
  931. b_is_cur_rdlstate = (cur_rxok_cnt > cur_txok_cnt * 4) ?
  932. true : false;
  933. edca_be = (b_is_cur_rdlstate) ? edca_be_dl : edca_be_ul;
  934. rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, edca_be);
  935. rtlpriv->dm.is_cur_rdlstate = b_is_cur_rdlstate;
  936. rtlpriv->dm.current_turbo_edca = true;
  937. } else {
  938. if (rtlpriv->dm.current_turbo_edca) {
  939. u8 tmp = AC0_BE;
  940. rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AC_PARAM,
  941. (u8 *)(&tmp));
  942. }
  943. rtlpriv->dm.current_turbo_edca = false;
  944. }
  945. exit:
  946. rtlpriv->dm.is_any_nonbepkts = false;
  947. last_txok_cnt = rtlpriv->stats.txbytesunicast;
  948. last_rxok_cnt = rtlpriv->stats.rxbytesunicast;
  949. }
  950. static void rtl8723be_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
  951. {
  952. struct rtl_priv *rtlpriv = rtl_priv(hw);
  953. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  954. u8 cur_cck_cca_thresh;
  955. if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) {
  956. if (dm_digtable->rssi_val_min > 25) {
  957. cur_cck_cca_thresh = 0xcd;
  958. } else if ((dm_digtable->rssi_val_min <= 25) &&
  959. (dm_digtable->rssi_val_min > 10)) {
  960. cur_cck_cca_thresh = 0x83;
  961. } else {
  962. if (rtlpriv->falsealm_cnt.cnt_cck_fail > 1000)
  963. cur_cck_cca_thresh = 0x83;
  964. else
  965. cur_cck_cca_thresh = 0x40;
  966. }
  967. } else {
  968. if (rtlpriv->falsealm_cnt.cnt_cck_fail > 1000)
  969. cur_cck_cca_thresh = 0x83;
  970. else
  971. cur_cck_cca_thresh = 0x40;
  972. }
  973. if (dm_digtable->cur_cck_cca_thres != cur_cck_cca_thresh)
  974. rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, cur_cck_cca_thresh);
  975. dm_digtable->pre_cck_cca_thres = dm_digtable->cur_cck_cca_thres;
  976. dm_digtable->cur_cck_cca_thres = cur_cck_cca_thresh;
  977. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  978. "CCK cca thresh hold =%x\n", dm_digtable->cur_cck_cca_thres);
  979. }
  980. static void rtl8723be_dm_dynamic_edcca(struct ieee80211_hw *hw)
  981. {
  982. struct rtl_priv *rtlpriv = rtl_priv(hw);
  983. u8 reg_c50, reg_c58;
  984. bool fw_current_in_ps_mode = false;
  985. rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS,
  986. (u8 *)(&fw_current_in_ps_mode));
  987. if (fw_current_in_ps_mode)
  988. return;
  989. reg_c50 = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, MASKBYTE0);
  990. reg_c58 = rtl_get_bbreg(hw, ROFDM0_XBAGCCORE1, MASKBYTE0);
  991. if (reg_c50 > 0x28 && reg_c58 > 0x28) {
  992. if (!rtlpriv->rtlhal.pre_edcca_enable) {
  993. rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD, 0x03);
  994. rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD + 2, 0x00);
  995. }
  996. } else if (reg_c50 < 0x25 && reg_c58 < 0x25) {
  997. if (rtlpriv->rtlhal.pre_edcca_enable) {
  998. rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD, 0x7f);
  999. rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD + 2, 0x7f);
  1000. }
  1001. }
  1002. }
  1003. static void rtl8723be_dm_dynamic_atc_switch(struct ieee80211_hw *hw)
  1004. {
  1005. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1006. struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw));
  1007. u8 crystal_cap;
  1008. u32 packet_count;
  1009. int cfo_khz_a, cfo_khz_b, cfo_ave = 0, adjust_xtal = 0;
  1010. int cfo_ave_diff;
  1011. if (rtlpriv->mac80211.link_state < MAC80211_LINKED) {
  1012. if (rtldm->atc_status == ATC_STATUS_OFF) {
  1013. rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(11),
  1014. ATC_STATUS_ON);
  1015. rtldm->atc_status = ATC_STATUS_ON;
  1016. }
  1017. if (rtlpriv->cfg->ops->get_btc_status()) {
  1018. if (!rtlpriv->btcoexist.btc_ops->btc_is_bt_disabled(rtlpriv)) {
  1019. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
  1020. "odm_DynamicATCSwitch(): Disable CFO tracking for BT!!\n");
  1021. return;
  1022. }
  1023. }
  1024. if (rtldm->crystal_cap != rtlpriv->efuse.crystalcap) {
  1025. rtldm->crystal_cap = rtlpriv->efuse.crystalcap;
  1026. crystal_cap = rtldm->crystal_cap & 0x3f;
  1027. rtl_set_bbreg(hw, REG_MAC_PHY_CTRL, 0xFFF000,
  1028. (crystal_cap | (crystal_cap << 6)));
  1029. }
  1030. } else {
  1031. cfo_khz_a = (int)(rtldm->cfo_tail[0] * 3125) / 1280;
  1032. cfo_khz_b = (int)(rtldm->cfo_tail[1] * 3125) / 1280;
  1033. packet_count = rtldm->packet_count;
  1034. if (packet_count == rtldm->packet_count_pre)
  1035. return;
  1036. rtldm->packet_count_pre = packet_count;
  1037. if (rtlpriv->phy.rf_type == RF_1T1R)
  1038. cfo_ave = cfo_khz_a;
  1039. else
  1040. cfo_ave = (int)(cfo_khz_a + cfo_khz_b) >> 1;
  1041. cfo_ave_diff = (rtldm->cfo_ave_pre >= cfo_ave) ?
  1042. (rtldm->cfo_ave_pre - cfo_ave) :
  1043. (cfo_ave - rtldm->cfo_ave_pre);
  1044. if (cfo_ave_diff > 20 && rtldm->large_cfo_hit == 0) {
  1045. rtldm->large_cfo_hit = 1;
  1046. return;
  1047. } else
  1048. rtldm->large_cfo_hit = 0;
  1049. rtldm->cfo_ave_pre = cfo_ave;
  1050. if (cfo_ave >= -rtldm->cfo_threshold &&
  1051. cfo_ave <= rtldm->cfo_threshold && rtldm->is_freeze == 0) {
  1052. if (rtldm->cfo_threshold == CFO_THRESHOLD_XTAL) {
  1053. rtldm->cfo_threshold = CFO_THRESHOLD_XTAL + 10;
  1054. rtldm->is_freeze = 1;
  1055. } else {
  1056. rtldm->cfo_threshold = CFO_THRESHOLD_XTAL;
  1057. }
  1058. }
  1059. if (cfo_ave > rtldm->cfo_threshold && rtldm->crystal_cap < 0x3f)
  1060. adjust_xtal = ((cfo_ave - CFO_THRESHOLD_XTAL) >> 1) + 1;
  1061. else if ((cfo_ave < -rtlpriv->dm.cfo_threshold) &&
  1062. rtlpriv->dm.crystal_cap > 0)
  1063. adjust_xtal = ((cfo_ave + CFO_THRESHOLD_XTAL) >> 1) - 1;
  1064. if (adjust_xtal != 0) {
  1065. rtldm->is_freeze = 0;
  1066. rtldm->crystal_cap += adjust_xtal;
  1067. if (rtldm->crystal_cap > 0x3f)
  1068. rtldm->crystal_cap = 0x3f;
  1069. else if (rtldm->crystal_cap < 0)
  1070. rtldm->crystal_cap = 0;
  1071. crystal_cap = rtldm->crystal_cap & 0x3f;
  1072. rtl_set_bbreg(hw, REG_MAC_PHY_CTRL, 0xFFF000,
  1073. (crystal_cap | (crystal_cap << 6)));
  1074. }
  1075. if (cfo_ave < CFO_THRESHOLD_ATC &&
  1076. cfo_ave > -CFO_THRESHOLD_ATC) {
  1077. if (rtldm->atc_status == ATC_STATUS_ON) {
  1078. rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(11),
  1079. ATC_STATUS_OFF);
  1080. rtldm->atc_status = ATC_STATUS_OFF;
  1081. }
  1082. } else {
  1083. if (rtldm->atc_status == ATC_STATUS_OFF) {
  1084. rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(11),
  1085. ATC_STATUS_ON);
  1086. rtldm->atc_status = ATC_STATUS_ON;
  1087. }
  1088. }
  1089. }
  1090. }
  1091. static void rtl8723be_dm_common_info_self_update(struct ieee80211_hw *hw)
  1092. {
  1093. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1094. u8 cnt = 0;
  1095. struct rtl_sta_info *drv_priv;
  1096. rtlpriv->dm.one_entry_only = false;
  1097. if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_STATION &&
  1098. rtlpriv->mac80211.link_state >= MAC80211_LINKED) {
  1099. rtlpriv->dm.one_entry_only = true;
  1100. return;
  1101. }
  1102. if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP ||
  1103. rtlpriv->mac80211.opmode == NL80211_IFTYPE_ADHOC ||
  1104. rtlpriv->mac80211.opmode == NL80211_IFTYPE_MESH_POINT) {
  1105. spin_lock_bh(&rtlpriv->locks.entry_list_lock);
  1106. list_for_each_entry(drv_priv, &rtlpriv->entry_list, list) {
  1107. cnt++;
  1108. }
  1109. spin_unlock_bh(&rtlpriv->locks.entry_list_lock);
  1110. if (cnt == 1)
  1111. rtlpriv->dm.one_entry_only = true;
  1112. }
  1113. }
  1114. void rtl8723be_dm_watchdog(struct ieee80211_hw *hw)
  1115. {
  1116. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1117. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  1118. bool fw_current_inpsmode = false;
  1119. bool fw_ps_awake = true;
  1120. rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS,
  1121. (u8 *)(&fw_current_inpsmode));
  1122. rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FWLPS_RF_ON,
  1123. (u8 *)(&fw_ps_awake));
  1124. if (ppsc->p2p_ps_info.p2p_ps_mode)
  1125. fw_ps_awake = false;
  1126. if ((ppsc->rfpwr_state == ERFON) &&
  1127. ((!fw_current_inpsmode) && fw_ps_awake) &&
  1128. (!ppsc->rfchange_inprogress)) {
  1129. rtl8723be_dm_common_info_self_update(hw);
  1130. rtl8723be_dm_false_alarm_counter_statistics(hw);
  1131. rtl8723be_dm_check_rssi_monitor(hw);
  1132. rtl8723be_dm_dig(hw);
  1133. rtl8723be_dm_dynamic_edcca(hw);
  1134. rtl8723be_dm_cck_packet_detection_thresh(hw);
  1135. rtl8723be_dm_refresh_rate_adaptive_mask(hw);
  1136. rtl8723be_dm_check_edca_turbo(hw);
  1137. rtl8723be_dm_dynamic_atc_switch(hw);
  1138. rtl8723be_dm_check_txpower_tracking(hw);
  1139. rtl8723be_dm_dynamic_txpower(hw);
  1140. }
  1141. rtlpriv->dm.dbginfo.num_qry_beacon_pkt = 0;
  1142. }