49 static const u32 edca_setting_dl_gmode[
PEER_MAX] = {
76 static u64 last_txok_cnt;
77 static u64 last_rxok_cnt;
81 u32 edca_be_ul = edca_setting_ul[mac->
vendor];
82 u32 edca_be_dl = edca_setting_dl[mac->
vendor];
83 u32 edca_gmode = edca_setting_dl_gmode[mac->
vendor];
86 rtlpriv->
dm.current_turbo_edca =
false;
87 goto dm_checkedcaturbo_exit;
90 if ((!rtlpriv->
dm.is_any_nonbepkts) &&
91 (!rtlpriv->
dm.disable_framebursting)) {
92 cur_txok_cnt = rtlpriv->
stats.txbytesunicast - last_txok_cnt;
93 cur_rxok_cnt = rtlpriv->
stats.rxbytesunicast - last_rxok_cnt;
96 if (cur_txok_cnt > 4 * cur_rxok_cnt) {
98 if (rtlpriv->
dm.is_cur_rdlstate ||
99 !rtlpriv->
dm.current_turbo_edca) {
102 rtlpriv->
dm.is_cur_rdlstate =
false;
105 if (!rtlpriv->
dm.is_cur_rdlstate ||
106 !rtlpriv->
dm.current_turbo_edca) {
109 rtl_write_dword(rtlpriv,
113 rtl_write_dword(rtlpriv,
116 rtlpriv->
dm.is_cur_rdlstate =
true;
119 rtlpriv->
dm.current_turbo_edca =
true;
121 if (cur_rxok_cnt > 4 * cur_txok_cnt) {
122 if (!rtlpriv->
dm.is_cur_rdlstate ||
123 !rtlpriv->
dm.current_turbo_edca) {
126 rtl_write_dword(rtlpriv,
130 rtl_write_dword(rtlpriv,
133 rtlpriv->
dm.is_cur_rdlstate =
true;
136 if (rtlpriv->
dm.is_cur_rdlstate ||
137 !rtlpriv->
dm.current_turbo_edca) {
140 rtlpriv->
dm.is_cur_rdlstate =
false;
143 rtlpriv->
dm.current_turbo_edca =
true;
146 if (rtlpriv->
dm.current_turbo_edca) {
150 rtlpriv->
dm.current_turbo_edca =
false;
154 dm_checkedcaturbo_exit:
155 rtlpriv->
dm.is_any_nonbepkts =
false;
156 last_txok_cnt = rtlpriv->
stats.txbytesunicast;
157 last_rxok_cnt = rtlpriv->
stats.rxbytesunicast;
160 static void _rtl92s_dm_txpowertracking_callback_thermalmeter(
167 rtlpriv->
dm.txpower_trackinginit =
true;
172 "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermal meter 0x%x\n",
177 rtlpriv->
dm.thermalvalue = thermalvalue;
181 rtlpriv->
dm.txpowercount = 0;
184 static void _rtl92s_dm_check_txpowertracking_thermalmeter(
189 static u8 tm_trigger;
190 u8 tx_power_checkcnt = 5;
196 if (!rtlpriv->
dm.txpower_tracking)
199 if (rtlpriv->
dm.txpowercount <= tx_power_checkcnt) {
200 rtlpriv->
dm.txpowercount++;
209 _rtl92s_dm_txpowertracking_callback_thermalmeter(hw);
214 static void _rtl92s_dm_refresh_rateadaptive_mask(
struct ieee80211_hw *hw)
221 u32 low_rssi_thresh = 0;
222 u32 middle_rssi_thresh = 0;
223 u32 high_rssi_thresh = 0;
226 if (is_hal_stop(rtlhal))
229 if (!rtlpriv->
dm.useramask)
232 if (!rtlpriv->
dm.inform_fw_driverctrldm) {
234 rtlpriv->
dm.inform_fw_driverctrldm =
true;
239 sta = get_sta(hw, mac->
vif, mac->
bssid);
244 high_rssi_thresh = 40;
245 middle_rssi_thresh = 30;
246 low_rssi_thresh = 20;
249 high_rssi_thresh = 44;
250 middle_rssi_thresh = 30;
251 low_rssi_thresh = 20;
254 high_rssi_thresh = 44;
255 middle_rssi_thresh = 34;
256 low_rssi_thresh = 20;
259 high_rssi_thresh = 44;
260 middle_rssi_thresh = 34;
261 low_rssi_thresh = 24;
264 high_rssi_thresh = 44;
265 middle_rssi_thresh = 34;
266 low_rssi_thresh = 24;
270 if (rtlpriv->
dm.undecorated_smoothed_pwdb >
271 (
long)high_rssi_thresh) {
273 }
else if (rtlpriv->
dm.undecorated_smoothed_pwdb >
274 (
long)middle_rssi_thresh) {
276 }
else if (rtlpriv->
dm.undecorated_smoothed_pwdb >
277 (
long)low_rssi_thresh) {
285 "RSSI = %ld RSSI_LEVEL = %d PreState = %d, CurState = %d\n",
286 rtlpriv->
dm.undecorated_smoothed_pwdb,
290 rtlpriv->
cfg->ops->update_rate_tbl(hw, sta,
298 static void _rtl92s_dm_switch_baseband_mrc(
struct ieee80211_hw *hw)
305 bool enable_mrc =
true;
306 long tmpentry_maxpwdb = 0;
310 if (is_hal_stop(rtlhal))
319 if (rtlpriv->
dm.undecorated_smoothed_pwdb > tmpentry_maxpwdb) {
327 if ((rssi_a == 0) && (rssi_b == 0)) {
329 }
else if (rssi_b > 30) {
332 }
else if (rssi_b < 5) {
336 }
else if (rssi_a > 15 && (rssi_a >= rssi_b)) {
337 if ((rssi_a - rssi_b) > 15)
340 else if ((rssi_a - rssi_b) < 10)
344 enable_mrc = current_mrc;
352 if (enable_mrc != current_mrc)
362 rtlpriv->
dm.current_turbo_edca =
false;
363 rtlpriv->
dm.is_any_nonbepkts =
false;
364 rtlpriv->
dm.is_cur_rdlstate =
false;
367 static void _rtl92s_dm_init_rate_adaptive_mask(
struct ieee80211_hw *hw)
376 rtlpriv->
dm.useramask =
true;
378 rtlpriv->
dm.useramask =
false;
380 rtlpriv->
dm.useramask =
false;
381 rtlpriv->
dm.inform_fw_driverctrldm =
false;
384 static void _rtl92s_dm_init_txpowertracking_thermalmeter(
389 rtlpriv->
dm.txpower_tracking =
true;
390 rtlpriv->
dm.txpowercount = 0;
391 rtlpriv->
dm.txpower_trackinginit =
false;
394 static void _rtl92s_dm_false_alarm_counter_statistics(
struct ieee80211_hw *hw)
405 falsealm_cnt->
cnt_crc8_fail = ((ret_value & 0xffff0000) >> 16);
414 ret_value = rtl_get_bbreg(hw, 0xc64,
MASKDWORD);
420 static void rtl92s_backoff_enable_flag(
struct ieee80211_hw *hw)
442 static void _rtl92s_dm_initial_gain_sta_beforeconnect(
struct ieee80211_hw *hw)
453 if (rtlpriv->
psc.rfpwr_state !=
ERFON)
457 rtl92s_backoff_enable_flag(hw);
473 if (falsealm_cnt->
cnt_all > 10000)
505 !initialized || force_write) {
520 static void _rtl92s_dm_ctrl_initgain_bytwoport(
struct ieee80211_hw *hw)
535 digtable->
rssi_val = rtlpriv->
dm.undecorated_smoothed_pwdb;
546 _rtl92s_dm_false_alarm_counter_statistics(hw);
547 _rtl92s_dm_initial_gain_sta_beforeconnect(hw);
552 static void _rtl92s_dm_ctrl_initgain_byrssi(
struct ieee80211_hw *hw)
562 if (!rtlpriv->
dm.dm_initialgain_enable)
568 _rtl92s_dm_ctrl_initgain_bytwoport(hw);
571 static void _rtl92s_dm_dynamic_txpower(
struct ieee80211_hw *hw)
576 long undecorated_smoothed_pwdb;
577 long txpwr_threshold_lv1, txpwr_threshold_lv2;
583 if (!rtlpriv->
dm.dynamic_txpower_enable ||
590 (rtlpriv->
dm.entry_min_undecoratedsmoothed_pwdb == 0)) {
592 "Not connected to any\n");
602 undecorated_smoothed_pwdb =
603 rtlpriv->
dm.entry_min_undecoratedsmoothed_pwdb;
605 "AP Client PWDB = 0x%lx\n",
606 undecorated_smoothed_pwdb);
608 undecorated_smoothed_pwdb =
609 rtlpriv->
dm.undecorated_smoothed_pwdb;
611 "STA Default Port PWDB = 0x%lx\n",
612 undecorated_smoothed_pwdb);
615 undecorated_smoothed_pwdb =
616 rtlpriv->
dm.entry_min_undecoratedsmoothed_pwdb;
619 "AP Ext Port PWDB = 0x%lx\n",
620 undecorated_smoothed_pwdb);
626 if (rtl_get_bbreg(hw, 0xc90,
MASKBYTE0) == 1)
628 else if (undecorated_smoothed_pwdb >= txpwr_threshold_lv2)
630 else if ((undecorated_smoothed_pwdb < (txpwr_threshold_lv2 - 3)) &&
631 (undecorated_smoothed_pwdb >= txpwr_threshold_lv1))
633 else if (undecorated_smoothed_pwdb < (txpwr_threshold_lv1 - 3))
636 if ((rtlpriv->
dm.dynamic_txhighpower_lvl != rtlpriv->
dm.last_dtp_lvl))
639 rtlpriv->
dm.last_dtp_lvl = rtlpriv->
dm.dynamic_txhighpower_lvl;
642 static void _rtl92s_dm_init_dig(
struct ieee80211_hw *hw)
693 static void _rtl92s_dm_init_dynamic_txpower(
struct ieee80211_hw *hw)
699 rtlpriv->
dm.dynamic_txpower_enable =
true;
701 rtlpriv->
dm.dynamic_txpower_enable =
false;
712 rtlpriv->
dm.undecorated_smoothed_pwdb = -1;
714 _rtl92s_dm_init_dynamic_txpower(hw);
716 _rtl92s_dm_init_rate_adaptive_mask(hw);
717 _rtl92s_dm_init_txpowertracking_thermalmeter(hw);
718 _rtl92s_dm_init_dig(hw);
725 _rtl92s_dm_check_edca_turbo(hw);
726 _rtl92s_dm_check_txpowertracking_thermalmeter(hw);
727 _rtl92s_dm_ctrl_initgain_byrssi(hw);
728 _rtl92s_dm_dynamic_txpower(hw);
729 _rtl92s_dm_refresh_rateadaptive_mask(hw);
730 _rtl92s_dm_switch_baseband_mrc(hw);