aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2013-03-24 23:06:38 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-04-01 16:19:58 -0400
commit2455c92c318182deda2f9789fd60792402ebc089 (patch)
treebcd44ea342d7175deb24038940c7672a216821b0
parent26634c4b1868323f49f8cd24c3493b57819867fd (diff)
rtlwifi: rtl8192se: Update driver to match vendor driver of 2013.02.07
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Cc: jcheung@suse.com Cc: machen@suse.com Cc: mmarek@suse.cz Cc: zhiyuan_yang@realsil.com.cn Cc: page_he@realsil.com.cn Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/def.h7
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/dm.c35
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/hw.c124
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/hw.h3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/phy.c61
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/phy.h1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c296
8 files changed, 181 insertions, 347 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/def.h b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
index 2d255e02d795..83c98674bfd3 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
@@ -36,9 +36,6 @@
36#define SHORT_SLOT_TIME 9 36#define SHORT_SLOT_TIME 9
37#define NON_SHORT_SLOT_TIME 20 37#define NON_SHORT_SLOT_TIME 20
38 38
39/* Rx smooth factor */
40#define RX_SMOOTH_FACTOR 20
41
42/* Queue Select Value in TxDesc */ 39/* Queue Select Value in TxDesc */
43#define QSLT_BK 0x2 40#define QSLT_BK 0x2
44#define QSLT_BE 0x0 41#define QSLT_BE 0x0
@@ -49,10 +46,6 @@
49#define QSLT_MGNT 0x12 46#define QSLT_MGNT 0x12
50#define QSLT_CMD 0x13 47#define QSLT_CMD 0x13
51 48
52#define PHY_RSSI_SLID_WIN_MAX 100
53#define PHY_LINKQUALITY_SLID_WIN_MAX 20
54#define PHY_BEACON_RSSI_SLID_WIN_MAX 10
55
56/* Tx Desc */ 49/* Tx Desc */
57#define TX_DESC_SIZE_RTL8192S (16 * 4) 50#define TX_DESC_SIZE_RTL8192S (16 * 4)
58#define TX_CMDDESC_SIZE_RTL8192S (16 * 4) 51#define TX_CMDDESC_SIZE_RTL8192S (16 * 4)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
index e551fe5f9ccd..e2a0faadc2b0 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
@@ -163,6 +163,7 @@ static void _rtl92s_dm_txpowertracking_callback_thermalmeter(
163 struct rtl_priv *rtlpriv = rtl_priv(hw); 163 struct rtl_priv *rtlpriv = rtl_priv(hw);
164 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 164 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
165 u8 thermalvalue = 0; 165 u8 thermalvalue = 0;
166 u32 fw_cmd = 0;
166 167
167 rtlpriv->dm.txpower_trackinginit = true; 168 rtlpriv->dm.txpower_trackinginit = true;
168 169
@@ -175,7 +176,19 @@ static void _rtl92s_dm_txpowertracking_callback_thermalmeter(
175 176
176 if (thermalvalue) { 177 if (thermalvalue) {
177 rtlpriv->dm.thermalvalue = thermalvalue; 178 rtlpriv->dm.thermalvalue = thermalvalue;
178 rtl92s_phy_set_fw_cmd(hw, FW_CMD_TXPWR_TRACK_THERMAL); 179 if (hal_get_firmwareversion(rtlpriv) >= 0x35) {
180 rtl92s_phy_set_fw_cmd(hw, FW_CMD_TXPWR_TRACK_THERMAL);
181 } else {
182 fw_cmd = (FW_TXPWR_TRACK_THERMAL |
183 (rtlpriv->efuse.thermalmeter[0] << 8) |
184 (thermalvalue << 16));
185
186 RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
187 "Write to FW Thermal Val = 0x%x\n", fw_cmd);
188
189 rtl_write_dword(rtlpriv, WFM5, fw_cmd);
190 rtl92s_phy_chk_fwcmd_iodone(hw);
191 }
179 } 192 }
180 193
181 rtlpriv->dm.txpowercount = 0; 194 rtlpriv->dm.txpowercount = 0;
@@ -217,11 +230,10 @@ static void _rtl92s_dm_refresh_rateadaptive_mask(struct ieee80211_hw *hw)
217 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); 230 struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
218 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 231 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
219 struct rate_adaptive *ra = &(rtlpriv->ra); 232 struct rate_adaptive *ra = &(rtlpriv->ra);
220 233 struct ieee80211_sta *sta = NULL;
221 u32 low_rssi_thresh = 0; 234 u32 low_rssi_thresh = 0;
222 u32 middle_rssi_thresh = 0; 235 u32 middle_rssi_thresh = 0;
223 u32 high_rssi_thresh = 0; 236 u32 high_rssi_thresh = 0;
224 struct ieee80211_sta *sta = NULL;
225 237
226 if (is_hal_stop(rtlhal)) 238 if (is_hal_stop(rtlhal))
227 return; 239 return;
@@ -229,14 +241,12 @@ static void _rtl92s_dm_refresh_rateadaptive_mask(struct ieee80211_hw *hw)
229 if (!rtlpriv->dm.useramask) 241 if (!rtlpriv->dm.useramask)
230 return; 242 return;
231 243
232 if (!rtlpriv->dm.inform_fw_driverctrldm) { 244 if (hal_get_firmwareversion(rtlpriv) >= 61 &&
245 !rtlpriv->dm.inform_fw_driverctrldm) {
233 rtl92s_phy_set_fw_cmd(hw, FW_CMD_CTRL_DM_BY_DRIVER); 246 rtl92s_phy_set_fw_cmd(hw, FW_CMD_CTRL_DM_BY_DRIVER);
234 rtlpriv->dm.inform_fw_driverctrldm = true; 247 rtlpriv->dm.inform_fw_driverctrldm = true;
235 } 248 }
236 249
237 rcu_read_lock();
238 if (mac->opmode == NL80211_IFTYPE_STATION)
239 sta = get_sta(hw, mac->vif, mac->bssid);
240 if ((mac->link_state == MAC80211_LINKED) && 250 if ((mac->link_state == MAC80211_LINKED) &&
241 (mac->opmode == NL80211_IFTYPE_STATION)) { 251 (mac->opmode == NL80211_IFTYPE_STATION)) {
242 switch (ra->pre_ratr_state) { 252 switch (ra->pre_ratr_state) {
@@ -285,12 +295,16 @@ static void _rtl92s_dm_refresh_rateadaptive_mask(struct ieee80211_hw *hw)
285 rtlpriv->dm.undec_sm_pwdb, ra->ratr_state, 295 rtlpriv->dm.undec_sm_pwdb, ra->ratr_state,
286 ra->pre_ratr_state, ra->ratr_state); 296 ra->pre_ratr_state, ra->ratr_state);
287 297
288 rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 298 rcu_read_lock();
299 sta = rtl_find_sta(hw, mac->bssid);
300 if (sta)
301 rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
289 ra->ratr_state); 302 ra->ratr_state);
303 rcu_read_unlock();
304
290 ra->pre_ratr_state = ra->ratr_state; 305 ra->pre_ratr_state = ra->ratr_state;
291 } 306 }
292 } 307 }
293 rcu_read_unlock();
294} 308}
295 309
296static void _rtl92s_dm_switch_baseband_mrc(struct ieee80211_hw *hw) 310static void _rtl92s_dm_switch_baseband_mrc(struct ieee80211_hw *hw)
@@ -370,7 +384,8 @@ static void _rtl92s_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw)
370 ra->ratr_state = DM_RATR_STA_MAX; 384 ra->ratr_state = DM_RATR_STA_MAX;
371 ra->pre_ratr_state = DM_RATR_STA_MAX; 385 ra->pre_ratr_state = DM_RATR_STA_MAX;
372 386
373 if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER) 387 if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER &&
388 hal_get_firmwareversion(rtlpriv) >= 60)
374 rtlpriv->dm.useramask = true; 389 rtlpriv->dm.useramask = true;
375 else 390 else
376 rtlpriv->dm.useramask = false; 391 rtlpriv->dm.useramask = false;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
index 084e7773bce2..a4f41b1eef52 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
@@ -400,6 +400,39 @@ void rtl92se_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
400 400
401 break; 401 break;
402 } 402 }
403 case HW_VAR_FW_LPS_ACTION: {
404 bool enter_fwlps = *((bool *)val);
405 u8 rpwm_val, fw_pwrmode;
406 bool fw_current_inps;
407
408 if (enter_fwlps) {
409 rpwm_val = 0x02; /* RF off */
410 fw_current_inps = true;
411 rtlpriv->cfg->ops->set_hw_reg(hw,
412 HW_VAR_FW_PSMODE_STATUS,
413 (u8 *)(&fw_current_inps));
414 rtlpriv->cfg->ops->set_hw_reg(hw,
415 HW_VAR_H2C_FW_PWRMODE,
416 (u8 *)(&ppsc->fwctrl_psmode));
417
418 rtlpriv->cfg->ops->set_hw_reg(hw,
419 HW_VAR_SET_RPWM,
420 (u8 *)(&rpwm_val));
421 } else {
422 rpwm_val = 0x0C; /* RF on */
423 fw_pwrmode = FW_PS_ACTIVE_MODE;
424 fw_current_inps = false;
425 rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM,
426 (u8 *)(&rpwm_val));
427 rtlpriv->cfg->ops->set_hw_reg(hw,
428 HW_VAR_H2C_FW_PWRMODE,
429 (u8 *)(&fw_pwrmode));
430
431 rtlpriv->cfg->ops->set_hw_reg(hw,
432 HW_VAR_FW_PSMODE_STATUS,
433 (u8 *)(&fw_current_inps));
434 }
435 break; }
403 default: 436 default:
404 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 437 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
405 "switch case not processed\n"); 438 "switch case not processed\n");
@@ -438,7 +471,7 @@ void rtl92se_enable_hw_security_config(struct ieee80211_hw *hw)
438 471
439} 472}
440 473
441static u8 _rtl92ce_halset_sysclk(struct ieee80211_hw *hw, u8 data) 474static u8 _rtl92se_halset_sysclk(struct ieee80211_hw *hw, u8 data)
442{ 475{
443 struct rtl_priv *rtlpriv = rtl_priv(hw); 476 struct rtl_priv *rtlpriv = rtl_priv(hw);
444 u8 waitcount = 100; 477 u8 waitcount = 100;
@@ -547,7 +580,7 @@ static void _rtl92se_macconfig_before_fwdownload(struct ieee80211_hw *hw)
547 tmpu1b &= ~(BIT(6) | BIT(7)); 580 tmpu1b &= ~(BIT(6) | BIT(7));
548 581
549 /* Set failed, return to prevent hang. */ 582 /* Set failed, return to prevent hang. */
550 if (!_rtl92ce_halset_sysclk(hw, tmpu1b)) 583 if (!_rtl92se_halset_sysclk(hw, tmpu1b))
551 return; 584 return;
552 } 585 }
553 586
@@ -650,7 +683,7 @@ static void _rtl92se_macconfig_before_fwdownload(struct ieee80211_hw *hw)
650 683
651 tmpu1b = rtl_read_byte(rtlpriv, (SYS_CLKR + 1)); 684 tmpu1b = rtl_read_byte(rtlpriv, (SYS_CLKR + 1));
652 tmpu1b = ((tmpu1b | BIT(7)) & (~BIT(6))); 685 tmpu1b = ((tmpu1b | BIT(7)) & (~BIT(6)));
653 if (!_rtl92ce_halset_sysclk(hw, tmpu1b)) 686 if (!_rtl92se_halset_sysclk(hw, tmpu1b))
654 return; /* Set failed, return to prevent hang. */ 687 return; /* Set failed, return to prevent hang. */
655 688
656 rtl_write_word(rtlpriv, CMDR, 0x07FC); 689 rtl_write_word(rtlpriv, CMDR, 0x07FC);
@@ -967,6 +1000,15 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
967 return rtstatus; 1000 return rtstatus;
968 } 1001 }
969 1002
1003 /* because last function modify RCR, so we update
1004 * rcr var here, or TP will unstable for receive_config
1005 * is wrong, RX RCR_ACRC32 will cause TP unstabel & Rx
1006 * RCR_APP_ICV will cause mac80211 unassoc for cisco 1252
1007 */
1008 rtlpci->receive_config = rtl_read_dword(rtlpriv, RCR);
1009 rtlpci->receive_config &= ~(RCR_ACRC32 | RCR_AICV);
1010 rtl_write_dword(rtlpriv, RCR, rtlpci->receive_config);
1011
970 /* Make sure BB/RF write OK. We should prevent enter IPS. radio off. */ 1012 /* Make sure BB/RF write OK. We should prevent enter IPS. radio off. */
971 /* We must set flag avoid BB/RF config period later!! */ 1013 /* We must set flag avoid BB/RF config period later!! */
972 rtl_write_dword(rtlpriv, CMDR, 0x37FC); 1014 rtl_write_dword(rtlpriv, CMDR, 0x37FC);
@@ -982,25 +1024,6 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
982 1024
983 rtlphy->rf_mode = RF_OP_BY_SW_3WIRE; 1025 rtlphy->rf_mode = RF_OP_BY_SW_3WIRE;
984 1026
985 /* RF Power Save */
986#if 0
987 /* H/W or S/W RF OFF before sleep. */
988 if (rtlpriv->psc.rfoff_reason > RF_CHANGE_BY_PS) {
989 u32 rfoffreason = rtlpriv->psc.rfoff_reason;
990
991 rtlpriv->psc.rfoff_reason = RF_CHANGE_BY_INIT;
992 rtlpriv->psc.rfpwr_state = ERFON;
993 /* FIXME: check spinlocks if this block is uncommented */
994 rtl_ps_set_rf_state(hw, ERFOFF, rfoffreason);
995 } else {
996 /* gpio radio on/off is out of adapter start */
997 if (rtlpriv->psc.hwradiooff == false) {
998 rtlpriv->psc.rfpwr_state = ERFON;
999 rtlpriv->psc.rfoff_reason = 0;
1000 }
1001 }
1002#endif
1003
1004 /* Before RF-R/W we must execute the IO from Scott's suggestion. */ 1027 /* Before RF-R/W we must execute the IO from Scott's suggestion. */
1005 rtl_write_byte(rtlpriv, AFE_XTAL_CTRL + 1, 0xDB); 1028 rtl_write_byte(rtlpriv, AFE_XTAL_CTRL + 1, 0xDB);
1006 if (rtlhal->version == VERSION_8192S_ACUT) 1029 if (rtlhal->version == VERSION_8192S_ACUT)
@@ -1058,7 +1081,22 @@ int rtl92se_hw_init(struct ieee80211_hw *hw)
1058 1081
1059 /* We enable high power and RA related mechanism after NIC 1082 /* We enable high power and RA related mechanism after NIC
1060 * initialized. */ 1083 * initialized. */
1061 rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_INIT); 1084 if (hal_get_firmwareversion(rtlpriv) >= 0x35) {
1085 /* Fw v.53 and later. */
1086 rtl92s_phy_set_fw_cmd(hw, FW_CMD_RA_INIT);
1087 } else if (hal_get_firmwareversion(rtlpriv) == 0x34) {
1088 /* Fw v.52. */
1089 rtl_write_dword(rtlpriv, WFM5, FW_RA_INIT);
1090 rtl92s_phy_chk_fwcmd_iodone(hw);
1091 } else {
1092 /* Compatible earlier FW version. */
1093 rtl_write_dword(rtlpriv, WFM5, FW_RA_RESET);
1094 rtl92s_phy_chk_fwcmd_iodone(hw);
1095 rtl_write_dword(rtlpriv, WFM5, FW_RA_ACTIVE);
1096 rtl92s_phy_chk_fwcmd_iodone(hw);
1097 rtl_write_dword(rtlpriv, WFM5, FW_RA_REFRESH);
1098 rtl92s_phy_chk_fwcmd_iodone(hw);
1099 }
1062 1100
1063 /* Add to prevent ASPM bug. */ 1101 /* Add to prevent ASPM bug. */
1064 /* Always enable hst and NIC clock request. */ 1102 /* Always enable hst and NIC clock request. */
@@ -1229,7 +1267,6 @@ void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
1229 synchronize_irq(rtlpci->pdev->irq); 1267 synchronize_irq(rtlpci->pdev->irq);
1230} 1268}
1231 1269
1232
1233static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data) 1270static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data)
1234{ 1271{
1235 struct rtl_priv *rtlpriv = rtl_priv(hw); 1272 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -1999,6 +2036,8 @@ static void rtl92se_update_hal_rate_table(struct ieee80211_hw *hw,
1999 ratr_value = sta->supp_rates[1] << 4; 2036 ratr_value = sta->supp_rates[1] << 4;
2000 else 2037 else
2001 ratr_value = sta->supp_rates[0]; 2038 ratr_value = sta->supp_rates[0];
2039 if (mac->opmode == NL80211_IFTYPE_ADHOC)
2040 ratr_value = 0xfff;
2002 ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 | 2041 ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
2003 sta->ht_cap.mcs.rx_mask[0] << 12); 2042 sta->ht_cap.mcs.rx_mask[0] << 12);
2004 switch (wirelessmode) { 2043 switch (wirelessmode) {
@@ -2112,6 +2151,8 @@ static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw,
2112 ratr_bitmap = sta->supp_rates[1] << 4; 2151 ratr_bitmap = sta->supp_rates[1] << 4;
2113 else 2152 else
2114 ratr_bitmap = sta->supp_rates[0]; 2153 ratr_bitmap = sta->supp_rates[0];
2154 if (mac->opmode == NL80211_IFTYPE_ADHOC)
2155 ratr_bitmap = 0xfff;
2115 ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 | 2156 ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
2116 sta->ht_cap.mcs.rx_mask[0] << 12); 2157 sta->ht_cap.mcs.rx_mask[0] << 12);
2117 switch (wirelessmode) { 2158 switch (wirelessmode) {
@@ -2200,6 +2241,7 @@ static void rtl92se_update_hal_rate_mask(struct ieee80211_hw *hw,
2200 ratr_bitmap &= 0x0f8ff0ff; 2241 ratr_bitmap &= 0x0f8ff0ff;
2201 break; 2242 break;
2202 } 2243 }
2244 sta_entry->ratr_index = ratr_index;
2203 2245
2204 if (rtlpriv->rtlhal.version >= VERSION_8192S_BCUT) 2246 if (rtlpriv->rtlhal.version >= VERSION_8192S_BCUT)
2205 ratr_bitmap &= 0x0FFFFFFF; 2247 ratr_bitmap &= 0x0FFFFFFF;
@@ -2438,23 +2480,9 @@ void rtl92se_set_key(struct ieee80211_hw *hw, u32 key_index, u8 *p_macaddr,
2438 rtl_cam_del_entry(hw, p_macaddr); 2480 rtl_cam_del_entry(hw, p_macaddr);
2439 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); 2481 rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
2440 } else { 2482 } else {
2441 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2442 "The insert KEY length is %d\n",
2443 rtlpriv->sec.key_len[PAIRWISE_KEYIDX]);
2444 RT_TRACE(rtlpriv, COMP_SEC, DBG_LOUD,
2445 "The insert KEY is %x %x\n",
2446 rtlpriv->sec.key_buf[0][0],
2447 rtlpriv->sec.key_buf[0][1]);
2448
2449 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2483 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2450 "add one entry\n"); 2484 "add one entry\n");
2451 if (is_pairwise) { 2485 if (is_pairwise) {
2452 RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_LOUD,
2453 "Pairwise Key content",
2454 rtlpriv->sec.pairwise_key,
2455 rtlpriv->sec.
2456 key_len[PAIRWISE_KEYIDX]);
2457
2458 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, 2486 RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
2459 "set Pairwise key\n"); 2487 "set Pairwise key\n");
2460 2488
@@ -2502,3 +2530,23 @@ void rtl92se_resume(struct ieee80211_hw *hw)
2502 pci_write_config_dword(rtlpci->pdev, 0x40, 2530 pci_write_config_dword(rtlpci->pdev, 0x40,
2503 val & 0xffff00ff); 2531 val & 0xffff00ff);
2504} 2532}
2533
2534/* Turn on AAP (RCR:bit 0) for promicuous mode. */
2535void rtl92se_allow_all_destaddr(struct ieee80211_hw *hw,
2536 bool allow_all_da, bool write_into_reg)
2537{
2538 struct rtl_priv *rtlpriv = rtl_priv(hw);
2539 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
2540
2541 if (allow_all_da) /* Set BIT0 */
2542 rtlpci->receive_config |= RCR_AAP;
2543 else /* Clear BIT0 */
2544 rtlpci->receive_config &= ~RCR_AAP;
2545
2546 if (write_into_reg)
2547 rtl_write_dword(rtlpriv, RCR, rtlpci->receive_config);
2548
2549 RT_TRACE(rtlpriv, COMP_TURBO | COMP_INIT, DBG_LOUD,
2550 "receive_config=0x%08X, write_into_reg=%d\n",
2551 rtlpci->receive_config, write_into_reg);
2552}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.h b/drivers/net/wireless/rtlwifi/rtl8192se/hw.h
index a8e068c76e47..da48aa8cbe6f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.h
@@ -74,6 +74,7 @@ void rtl92se_set_key(struct ieee80211_hw *hw,
74 u8 enc_algo, bool is_wepkey, bool clear_all); 74 u8 enc_algo, bool is_wepkey, bool clear_all);
75void rtl92se_suspend(struct ieee80211_hw *hw); 75void rtl92se_suspend(struct ieee80211_hw *hw);
76void rtl92se_resume(struct ieee80211_hw *hw); 76void rtl92se_resume(struct ieee80211_hw *hw);
77void rtl92se_allow_all_destaddr(struct ieee80211_hw *hw,
78 bool allow_all_da, bool write_into_reg);
77 79
78#endif 80#endif
79
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
index 67404975e00b..9c092e6eb3fe 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
@@ -1307,6 +1307,8 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw)
1307 if (is_hal_stop(rtlhal)) 1307 if (is_hal_stop(rtlhal))
1308 return; 1308 return;
1309 1309
1310 if (hal_get_firmwareversion(rtlpriv) < 0x34)
1311 goto skip;
1310 /* We re-map RA related CMD IO to combinational ones */ 1312 /* We re-map RA related CMD IO to combinational ones */
1311 /* if FW version is v.52 or later. */ 1313 /* if FW version is v.52 or later. */
1312 switch (rtlhal->current_fwcmd_io) { 1314 switch (rtlhal->current_fwcmd_io) {
@@ -1320,6 +1322,7 @@ static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw *hw)
1320 break; 1322 break;
1321 } 1323 }
1322 1324
1325skip:
1323 switch (rtlhal->current_fwcmd_io) { 1326 switch (rtlhal->current_fwcmd_io) {
1324 case FW_CMD_RA_RESET: 1327 case FW_CMD_RA_RESET:
1325 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_RESET\n"); 1328 RT_TRACE(rtlpriv, COMP_CMD, DBG_DMESG, "FW_CMD_RA_RESET\n");
@@ -1440,7 +1443,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1440 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); 1443 struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
1441 u32 fw_param = FW_CMD_IO_PARA_QUERY(rtlpriv); 1444 u32 fw_param = FW_CMD_IO_PARA_QUERY(rtlpriv);
1442 u16 fw_cmdmap = FW_CMD_IO_QUERY(rtlpriv); 1445 u16 fw_cmdmap = FW_CMD_IO_QUERY(rtlpriv);
1443 bool bPostProcessing = false; 1446 bool postprocessing = false;
1444 1447
1445 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, 1448 RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD,
1446 "Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n", 1449 "Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n",
@@ -1449,15 +1452,24 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1449 do { 1452 do {
1450 /* We re-map to combined FW CMD ones if firmware version */ 1453 /* We re-map to combined FW CMD ones if firmware version */
1451 /* is v.53 or later. */ 1454 /* is v.53 or later. */
1452 switch (fw_cmdio) { 1455 if (hal_get_firmwareversion(rtlpriv) >= 0x35) {
1453 case FW_CMD_RA_REFRESH_N: 1456 switch (fw_cmdio) {
1454 fw_cmdio = FW_CMD_RA_REFRESH_N_COMB; 1457 case FW_CMD_RA_REFRESH_N:
1455 break; 1458 fw_cmdio = FW_CMD_RA_REFRESH_N_COMB;
1456 case FW_CMD_RA_REFRESH_BG: 1459 break;
1457 fw_cmdio = FW_CMD_RA_REFRESH_BG_COMB; 1460 case FW_CMD_RA_REFRESH_BG:
1458 break; 1461 fw_cmdio = FW_CMD_RA_REFRESH_BG_COMB;
1459 default: 1462 break;
1460 break; 1463 default:
1464 break;
1465 }
1466 } else {
1467 if ((fw_cmdio == FW_CMD_IQK_ENABLE) ||
1468 (fw_cmdio == FW_CMD_RA_REFRESH_N) ||
1469 (fw_cmdio == FW_CMD_RA_REFRESH_BG)) {
1470 postprocessing = true;
1471 break;
1472 }
1461 } 1473 }
1462 1474
1463 /* If firmware version is v.62 or later, 1475 /* If firmware version is v.62 or later,
@@ -1588,19 +1600,19 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1588 fw_cmdmap &= ~FW_DIG_ENABLE_CTL; 1600 fw_cmdmap &= ~FW_DIG_ENABLE_CTL;
1589 1601
1590 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1602 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1591 bPostProcessing = true; 1603 postprocessing = true;
1592 break; 1604 break;
1593 case FW_CMD_PAUSE_DM_BY_SCAN: 1605 case FW_CMD_PAUSE_DM_BY_SCAN:
1594 fw_cmdmap &= ~(FW_DIG_ENABLE_CTL | 1606 fw_cmdmap &= ~(FW_DIG_ENABLE_CTL |
1595 FW_HIGH_PWR_ENABLE_CTL | 1607 FW_HIGH_PWR_ENABLE_CTL |
1596 FW_SS_CTL); 1608 FW_SS_CTL);
1597 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1609 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1598 bPostProcessing = true; 1610 postprocessing = true;
1599 break; 1611 break;
1600 case FW_CMD_HIGH_PWR_DISABLE: 1612 case FW_CMD_HIGH_PWR_DISABLE:
1601 fw_cmdmap &= ~FW_HIGH_PWR_ENABLE_CTL; 1613 fw_cmdmap &= ~FW_HIGH_PWR_ENABLE_CTL;
1602 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1614 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1603 bPostProcessing = true; 1615 postprocessing = true;
1604 break; 1616 break;
1605 case FW_CMD_HIGH_PWR_ENABLE: 1617 case FW_CMD_HIGH_PWR_ENABLE:
1606 if (!(rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) && 1618 if (!(rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) &&
@@ -1608,7 +1620,7 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1608 fw_cmdmap |= (FW_HIGH_PWR_ENABLE_CTL | 1620 fw_cmdmap |= (FW_HIGH_PWR_ENABLE_CTL |
1609 FW_SS_CTL); 1621 FW_SS_CTL);
1610 FW_CMD_IO_SET(rtlpriv, fw_cmdmap); 1622 FW_CMD_IO_SET(rtlpriv, fw_cmdmap);
1611 bPostProcessing = true; 1623 postprocessing = true;
1612 } 1624 }
1613 break; 1625 break;
1614 case FW_CMD_DIG_MODE_FA: 1626 case FW_CMD_DIG_MODE_FA:
@@ -1629,14 +1641,15 @@ bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw *hw, enum fwcmd_iotype fw_cmdio)
1629 default: 1641 default:
1630 /* Pass to original FW CMD processing callback 1642 /* Pass to original FW CMD processing callback
1631 * routine. */ 1643 * routine. */
1632 bPostProcessing = true; 1644 postprocessing = true;
1633 break; 1645 break;
1634 } 1646 }
1635 } while (false); 1647 } while (false);
1636 1648
1637 /* We shall post processing these FW CMD if 1649 /* We shall post processing these FW CMD if
1638 * variable bPostProcessing is set. */ 1650 * variable postprocessing is set.
1639 if (bPostProcessing && !rtlhal->set_fwcmd_inprogress) { 1651 */
1652 if (postprocessing && !rtlhal->set_fwcmd_inprogress) {
1640 rtlhal->set_fwcmd_inprogress = true; 1653 rtlhal->set_fwcmd_inprogress = true;
1641 /* Update current FW Cmd for callback use. */ 1654 /* Update current FW Cmd for callback use. */
1642 rtlhal->current_fwcmd_io = fw_cmdio; 1655 rtlhal->current_fwcmd_io = fw_cmdio;
@@ -1697,8 +1710,18 @@ void rtl92s_phy_switch_ephy_parameter(struct ieee80211_hw *hw)
1697 1710
1698} 1711}
1699 1712
1700void rtl92s_phy_set_beacon_hwreg(struct ieee80211_hw *hw, u16 BeaconInterval) 1713void rtl92s_phy_set_beacon_hwreg(struct ieee80211_hw *hw, u16 beaconinterval)
1701{ 1714{
1702 struct rtl_priv *rtlpriv = rtl_priv(hw); 1715 struct rtl_priv *rtlpriv = rtl_priv(hw);
1703 rtl_write_dword(rtlpriv, WFM5, 0xF1000000 | (BeaconInterval << 8)); 1716 u32 new_bcn_num = 0;
1717
1718 if (hal_get_firmwareversion(rtlpriv) >= 0x33) {
1719 /* Fw v.51 and later. */
1720 rtl_write_dword(rtlpriv, WFM5, 0xF1000000 |
1721 (beaconinterval << 8));
1722 } else {
1723 new_bcn_num = beaconinterval * 32 - 64;
1724 rtl_write_dword(rtlpriv, WFM3 + 4, new_bcn_num);
1725 rtl_write_dword(rtlpriv, WFM3, 0xB026007C);
1726 }
1704} 1727}
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.h b/drivers/net/wireless/rtlwifi/rtl8192se/phy.h
index ac0387770630..8acf4765a7a6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.h
@@ -39,6 +39,7 @@
39#define MAX_POSTCMD_CNT 16 39#define MAX_POSTCMD_CNT 16
40 40
41#define RF90_PATH_MAX 4 41#define RF90_PATH_MAX 4
42#define RF6052_MAX_PATH 2
42 43
43enum version_8192s { 44enum version_8192s {
44 VERSION_8192S_ACUT, 45 VERSION_8192S_ACUT,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index cecc377e9e61..2c115b0c4b6f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -290,6 +290,7 @@ static struct rtl_hal_ops rtl8192se_hal_ops = {
290 .enable_hw_sec = rtl92se_enable_hw_security_config, 290 .enable_hw_sec = rtl92se_enable_hw_security_config,
291 .set_key = rtl92se_set_key, 291 .set_key = rtl92se_set_key,
292 .init_sw_leds = rtl92se_init_sw_leds, 292 .init_sw_leds = rtl92se_init_sw_leds,
293 .allow_all_destaddr = rtl92se_allow_all_destaddr,
293 .get_bbreg = rtl92s_phy_query_bb_reg, 294 .get_bbreg = rtl92s_phy_query_bb_reg,
294 .set_bbreg = rtl92s_phy_set_bb_reg, 295 .set_bbreg = rtl92s_phy_set_bb_reg,
295 .get_rfreg = rtl92s_phy_query_rf_reg, 296 .get_rfreg = rtl92s_phy_query_rf_reg,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index 7b0a2e75b8b8..960bc28cc51e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -30,6 +30,7 @@
30#include "../wifi.h" 30#include "../wifi.h"
31#include "../pci.h" 31#include "../pci.h"
32#include "../base.h" 32#include "../base.h"
33#include "../stats.h"
33#include "reg.h" 34#include "reg.h"
34#include "def.h" 35#include "def.h"
35#include "phy.h" 36#include "phy.h"
@@ -43,7 +44,7 @@ static u8 _rtl92se_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 skb_queue)
43 44
44 if (unlikely(ieee80211_is_beacon(fc))) 45 if (unlikely(ieee80211_is_beacon(fc)))
45 return QSLT_BEACON; 46 return QSLT_BEACON;
46 if (ieee80211_is_mgmt(fc)) 47 if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc))
47 return QSLT_MGNT; 48 return QSLT_MGNT;
48 if (ieee80211_is_nullfunc(fc)) 49 if (ieee80211_is_nullfunc(fc))
49 return QSLT_HIGH; 50 return QSLT_HIGH;
@@ -51,65 +52,6 @@ static u8 _rtl92se_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 skb_queue)
51 return skb->priority; 52 return skb->priority;
52} 53}
53 54
54static u8 _rtl92s_query_rxpwrpercentage(char antpower)
55{
56 if ((antpower <= -100) || (antpower >= 20))
57 return 0;
58 else if (antpower >= 0)
59 return 100;
60 else
61 return 100 + antpower;
62}
63
64static u8 _rtl92s_evm_db_to_percentage(char value)
65{
66 char ret_val;
67 ret_val = value;
68
69 if (ret_val >= 0)
70 ret_val = 0;
71
72 if (ret_val <= -33)
73 ret_val = -33;
74
75 ret_val = 0 - ret_val;
76 ret_val *= 3;
77
78 if (ret_val == 99)
79 ret_val = 100;
80
81 return ret_val;
82}
83
84static long _rtl92se_translate_todbm(struct ieee80211_hw *hw,
85 u8 signal_strength_index)
86{
87 long signal_power;
88
89 signal_power = (long)((signal_strength_index + 1) >> 1);
90 signal_power -= 95;
91 return signal_power;
92}
93
94static long _rtl92se_signal_scale_mapping(struct ieee80211_hw *hw,
95 long currsig)
96{
97 long retsig = 0;
98
99 /* Step 1. Scale mapping. */
100 if (currsig > 47)
101 retsig = 100;
102 else if (currsig > 14 && currsig <= 47)
103 retsig = 100 - ((47 - currsig) * 3) / 2;
104 else if (currsig > 2 && currsig <= 14)
105 retsig = 48 - ((14 - currsig) * 15) / 7;
106 else if (currsig >= 0)
107 retsig = currsig * 9 + 1;
108
109 return retsig;
110}
111
112
113static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw, 55static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
114 struct rtl_stats *pstats, u8 *pdesc, 56 struct rtl_stats *pstats, u8 *pdesc,
115 struct rx_fwinfo *p_drvinfo, 57 struct rx_fwinfo *p_drvinfo,
@@ -119,11 +61,11 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
119{ 61{
120 struct rtl_priv *rtlpriv = rtl_priv(hw); 62 struct rtl_priv *rtlpriv = rtl_priv(hw);
121 struct phy_sts_cck_8192s_t *cck_buf; 63 struct phy_sts_cck_8192s_t *cck_buf;
64 struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
122 s8 rx_pwr_all = 0, rx_pwr[4]; 65 s8 rx_pwr_all = 0, rx_pwr[4];
123 u8 rf_rx_num = 0, evm, pwdb_all; 66 u8 rf_rx_num = 0, evm, pwdb_all;
124 u8 i, max_spatial_stream; 67 u8 i, max_spatial_stream;
125 u32 rssi, total_rssi = 0; 68 u32 rssi, total_rssi = 0;
126 bool in_powersavemode = false;
127 bool is_cck = pstats->is_cck; 69 bool is_cck = pstats->is_cck;
128 70
129 pstats->packet_matchbssid = packet_match_bssid; 71 pstats->packet_matchbssid = packet_match_bssid;
@@ -136,7 +78,7 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
136 u8 report, cck_highpwr; 78 u8 report, cck_highpwr;
137 cck_buf = (struct phy_sts_cck_8192s_t *)p_drvinfo; 79 cck_buf = (struct phy_sts_cck_8192s_t *)p_drvinfo;
138 80
139 if (!in_powersavemode) 81 if (ppsc->rfpwr_state == ERFON)
140 cck_highpwr = (u8) rtl_get_bbreg(hw, 82 cck_highpwr = (u8) rtl_get_bbreg(hw,
141 RFPGA0_XA_HSSIPARAMETER2, 83 RFPGA0_XA_HSSIPARAMETER2,
142 0x200); 84 0x200);
@@ -181,7 +123,7 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
181 } 123 }
182 } 124 }
183 125
184 pwdb_all = _rtl92s_query_rxpwrpercentage(rx_pwr_all); 126 pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
185 127
186 /* CCK gain is smaller than OFDM/MCS gain, */ 128 /* CCK gain is smaller than OFDM/MCS gain, */
187 /* so we add gain diff by experiences, the val is 6 */ 129 /* so we add gain diff by experiences, the val is 6 */
@@ -222,13 +164,13 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
222 } else { 164 } else {
223 rtlpriv->dm.rfpath_rxenable[0] = 165 rtlpriv->dm.rfpath_rxenable[0] =
224 rtlpriv->dm.rfpath_rxenable[1] = true; 166 rtlpriv->dm.rfpath_rxenable[1] = true;
225 for (i = RF90_PATH_A; i < RF90_PATH_MAX; i++) { 167 for (i = RF90_PATH_A; i < RF6052_MAX_PATH; i++) {
226 if (rtlpriv->dm.rfpath_rxenable[i]) 168 if (rtlpriv->dm.rfpath_rxenable[i])
227 rf_rx_num++; 169 rf_rx_num++;
228 170
229 rx_pwr[i] = ((p_drvinfo->gain_trsw[i] & 171 rx_pwr[i] = ((p_drvinfo->gain_trsw[i] &
230 0x3f) * 2) - 110; 172 0x3f) * 2) - 110;
231 rssi = _rtl92s_query_rxpwrpercentage(rx_pwr[i]); 173 rssi = rtl_query_rxpwrpercentage(rx_pwr[i]);
232 total_rssi += rssi; 174 total_rssi += rssi;
233 rtlpriv->stats.rx_snr_db[i] = 175 rtlpriv->stats.rx_snr_db[i] =
234 (long)(p_drvinfo->rxsnr[i] / 2); 176 (long)(p_drvinfo->rxsnr[i] / 2);
@@ -238,7 +180,7 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
238 } 180 }
239 181
240 rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 110; 182 rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 110;
241 pwdb_all = _rtl92s_query_rxpwrpercentage(rx_pwr_all); 183 pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all);
242 pstats->rx_pwdb_all = pwdb_all; 184 pstats->rx_pwdb_all = pwdb_all;
243 pstats->rxpower = rx_pwr_all; 185 pstats->rxpower = rx_pwr_all;
244 pstats->recvsignalpower = rx_pwr_all; 186 pstats->recvsignalpower = rx_pwr_all;
@@ -250,7 +192,7 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
250 max_spatial_stream = 1; 192 max_spatial_stream = 1;
251 193
252 for (i = 0; i < max_spatial_stream; i++) { 194 for (i = 0; i < max_spatial_stream; i++) {
253 evm = _rtl92s_evm_db_to_percentage(p_drvinfo->rxevm[i]); 195 evm = rtl_evm_db_to_percentage(p_drvinfo->rxevm[i]);
254 196
255 if (packet_match_bssid) { 197 if (packet_match_bssid) {
256 if (i == 0) 198 if (i == 0)
@@ -262,212 +204,13 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
262 } 204 }
263 205
264 if (is_cck) 206 if (is_cck)
265 pstats->signalstrength = (u8)(_rtl92se_signal_scale_mapping(hw, 207 pstats->signalstrength = (u8)(rtl_signal_scale_mapping(hw,
266 pwdb_all)); 208 pwdb_all));
267 else if (rf_rx_num != 0) 209 else if (rf_rx_num != 0)
268 pstats->signalstrength = (u8) (_rtl92se_signal_scale_mapping(hw, 210 pstats->signalstrength = (u8) (rtl_signal_scale_mapping(hw,
269 total_rssi /= rf_rx_num)); 211 total_rssi /= rf_rx_num));
270} 212}
271 213
272static void _rtl92se_process_ui_rssi(struct ieee80211_hw *hw,
273 struct rtl_stats *pstats)
274{
275 struct rtl_priv *rtlpriv = rtl_priv(hw);
276 struct rtl_phy *rtlphy = &(rtlpriv->phy);
277 u8 rfpath;
278 u32 last_rssi, tmpval;
279
280 if (pstats->packet_toself || pstats->packet_beacon) {
281 rtlpriv->stats.rssi_calculate_cnt++;
282
283 if (rtlpriv->stats.ui_rssi.total_num++ >=
284 PHY_RSSI_SLID_WIN_MAX) {
285 rtlpriv->stats.ui_rssi.total_num =
286 PHY_RSSI_SLID_WIN_MAX;
287 last_rssi = rtlpriv->stats.ui_rssi.elements[
288 rtlpriv->stats.ui_rssi.index];
289 rtlpriv->stats.ui_rssi.total_val -= last_rssi;
290 }
291
292 rtlpriv->stats.ui_rssi.total_val += pstats->signalstrength;
293 rtlpriv->stats.ui_rssi.elements[rtlpriv->stats.ui_rssi.index++]
294 = pstats->signalstrength;
295
296 if (rtlpriv->stats.ui_rssi.index >= PHY_RSSI_SLID_WIN_MAX)
297 rtlpriv->stats.ui_rssi.index = 0;
298
299 tmpval = rtlpriv->stats.ui_rssi.total_val /
300 rtlpriv->stats.ui_rssi.total_num;
301 rtlpriv->stats.signal_strength = _rtl92se_translate_todbm(hw,
302 (u8) tmpval);
303 pstats->rssi = rtlpriv->stats.signal_strength;
304 }
305
306 if (!pstats->is_cck && pstats->packet_toself) {
307 for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath;
308 rfpath++) {
309 if (rtlpriv->stats.rx_rssi_percentage[rfpath] == 0) {
310 rtlpriv->stats.rx_rssi_percentage[rfpath] =
311 pstats->rx_mimo_signalstrength[rfpath];
312
313 }
314
315 if (pstats->rx_mimo_signalstrength[rfpath] >
316 rtlpriv->stats.rx_rssi_percentage[rfpath]) {
317 rtlpriv->stats.rx_rssi_percentage[rfpath] =
318 ((rtlpriv->stats.rx_rssi_percentage[rfpath]
319 * (RX_SMOOTH_FACTOR - 1)) +
320 (pstats->rx_mimo_signalstrength[rfpath])) /
321 (RX_SMOOTH_FACTOR);
322
323 rtlpriv->stats.rx_rssi_percentage[rfpath] =
324 rtlpriv->stats.rx_rssi_percentage[rfpath]
325 + 1;
326 } else {
327 rtlpriv->stats.rx_rssi_percentage[rfpath] =
328 ((rtlpriv->stats.rx_rssi_percentage[rfpath]
329 * (RX_SMOOTH_FACTOR - 1)) +
330 (pstats->rx_mimo_signalstrength[rfpath])) /
331 (RX_SMOOTH_FACTOR);
332 }
333
334 }
335 }
336}
337
338static void _rtl92se_update_rxsignalstatistics(struct ieee80211_hw *hw,
339 struct rtl_stats *pstats)
340{
341 struct rtl_priv *rtlpriv = rtl_priv(hw);
342 int weighting = 0;
343
344 if (rtlpriv->stats.recv_signal_power == 0)
345 rtlpriv->stats.recv_signal_power = pstats->recvsignalpower;
346
347 if (pstats->recvsignalpower > rtlpriv->stats.recv_signal_power)
348 weighting = 5;
349 else if (pstats->recvsignalpower < rtlpriv->stats.recv_signal_power)
350 weighting = (-5);
351
352 rtlpriv->stats.recv_signal_power = (rtlpriv->stats.recv_signal_power * 5
353 + pstats->recvsignalpower +
354 weighting) / 6;
355}
356
357static void _rtl92se_process_pwdb(struct ieee80211_hw *hw,
358 struct rtl_stats *pstats)
359{
360 struct rtl_priv *rtlpriv = rtl_priv(hw);
361 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
362 long undec_sm_pwdb = 0;
363
364 if (mac->opmode == NL80211_IFTYPE_ADHOC) {
365 return;
366 } else {
367 undec_sm_pwdb =
368 rtlpriv->dm.undec_sm_pwdb;
369 }
370
371 if (pstats->packet_toself || pstats->packet_beacon) {
372 if (undec_sm_pwdb < 0)
373 undec_sm_pwdb = pstats->rx_pwdb_all;
374
375 if (pstats->rx_pwdb_all > (u32) undec_sm_pwdb) {
376 undec_sm_pwdb =
377 (((undec_sm_pwdb) *
378 (RX_SMOOTH_FACTOR - 1)) +
379 (pstats->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
380
381 undec_sm_pwdb = undec_sm_pwdb + 1;
382 } else {
383 undec_sm_pwdb = (((undec_sm_pwdb) *
384 (RX_SMOOTH_FACTOR - 1)) + (pstats->rx_pwdb_all)) /
385 (RX_SMOOTH_FACTOR);
386 }
387
388 rtlpriv->dm.undec_sm_pwdb = undec_sm_pwdb;
389 _rtl92se_update_rxsignalstatistics(hw, pstats);
390 }
391}
392
393static void rtl_92s_process_streams(struct ieee80211_hw *hw,
394 struct rtl_stats *pstats)
395{
396 struct rtl_priv *rtlpriv = rtl_priv(hw);
397 u32 stream;
398
399 for (stream = 0; stream < 2; stream++) {
400 if (pstats->rx_mimo_sig_qual[stream] != -1) {
401 if (rtlpriv->stats.rx_evm_percentage[stream] == 0) {
402 rtlpriv->stats.rx_evm_percentage[stream] =
403 pstats->rx_mimo_sig_qual[stream];
404 }
405
406 rtlpriv->stats.rx_evm_percentage[stream] =
407 ((rtlpriv->stats.rx_evm_percentage[stream] *
408 (RX_SMOOTH_FACTOR - 1)) +
409 (pstats->rx_mimo_sig_qual[stream] *
410 1)) / (RX_SMOOTH_FACTOR);
411 }
412 }
413}
414
415static void _rtl92se_process_ui_link_quality(struct ieee80211_hw *hw,
416 struct rtl_stats *pstats)
417{
418 struct rtl_priv *rtlpriv = rtl_priv(hw);
419 u32 last_evm = 0, tmpval;
420
421 if (pstats->signalquality != 0) {
422 if (pstats->packet_toself || pstats->packet_beacon) {
423
424 if (rtlpriv->stats.ui_link_quality.total_num++ >=
425 PHY_LINKQUALITY_SLID_WIN_MAX) {
426 rtlpriv->stats.ui_link_quality.total_num =
427 PHY_LINKQUALITY_SLID_WIN_MAX;
428 last_evm =
429 rtlpriv->stats.ui_link_quality.elements[
430 rtlpriv->stats.ui_link_quality.index];
431 rtlpriv->stats.ui_link_quality.total_val -=
432 last_evm;
433 }
434
435 rtlpriv->stats.ui_link_quality.total_val +=
436 pstats->signalquality;
437 rtlpriv->stats.ui_link_quality.elements[
438 rtlpriv->stats.ui_link_quality.index++] =
439 pstats->signalquality;
440
441 if (rtlpriv->stats.ui_link_quality.index >=
442 PHY_LINKQUALITY_SLID_WIN_MAX)
443 rtlpriv->stats.ui_link_quality.index = 0;
444
445 tmpval = rtlpriv->stats.ui_link_quality.total_val /
446 rtlpriv->stats.ui_link_quality.total_num;
447 rtlpriv->stats.signal_quality = tmpval;
448
449 rtlpriv->stats.last_sigstrength_inpercent = tmpval;
450
451 rtl_92s_process_streams(hw, pstats);
452
453 }
454 }
455}
456
457static void _rtl92se_process_phyinfo(struct ieee80211_hw *hw,
458 u8 *buffer,
459 struct rtl_stats *pcurrent_stats)
460{
461
462 if (!pcurrent_stats->packet_matchbssid &&
463 !pcurrent_stats->packet_beacon)
464 return;
465
466 _rtl92se_process_ui_rssi(hw, pcurrent_stats);
467 _rtl92se_process_pwdb(hw, pcurrent_stats);
468 _rtl92se_process_ui_link_quality(hw, pcurrent_stats);
469}
470
471static void _rtl92se_translate_rx_signal_stuff(struct ieee80211_hw *hw, 214static void _rtl92se_translate_rx_signal_stuff(struct ieee80211_hw *hw,
472 struct sk_buff *skb, struct rtl_stats *pstats, 215 struct sk_buff *skb, struct rtl_stats *pstats,
473 u8 *pdesc, struct rx_fwinfo *p_drvinfo) 216 u8 *pdesc, struct rx_fwinfo *p_drvinfo)
@@ -505,7 +248,7 @@ static void _rtl92se_translate_rx_signal_stuff(struct ieee80211_hw *hw,
505 248
506 _rtl92se_query_rxphystatus(hw, pstats, pdesc, p_drvinfo, 249 _rtl92se_query_rxphystatus(hw, pstats, pdesc, p_drvinfo,
507 packet_matchbssid, packet_toself, packet_beacon); 250 packet_matchbssid, packet_toself, packet_beacon);
508 _rtl92se_process_phyinfo(hw, tmp_buf, pstats); 251 rtl_process_phyinfo(hw, tmp_buf, pstats);
509} 252}
510 253
511bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats, 254bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
@@ -541,9 +284,6 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
541 rx_status->freq = hw->conf.channel->center_freq; 284 rx_status->freq = hw->conf.channel->center_freq;
542 rx_status->band = hw->conf.channel->band; 285 rx_status->band = hw->conf.channel->band;
543 286
544 hdr = (struct ieee80211_hdr *)(skb->data + stats->rx_drvinfo_size
545 + stats->rx_bufshift);
546
547 if (stats->crc) 287 if (stats->crc)
548 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; 288 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
549 289
@@ -563,6 +303,13 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
563 * for IEEE80211w frame, and mac80211 sw will help 303 * for IEEE80211w frame, and mac80211 sw will help
564 * to decrypt it */ 304 * to decrypt it */
565 if (stats->decrypted) { 305 if (stats->decrypted) {
306 hdr = (struct ieee80211_hdr *)(skb->data +
307 stats->rx_drvinfo_size + stats->rx_bufshift);
308
309 if (!hdr) {
310 /* during testing, hdr was NULL here */
311 return false;
312 }
566 if ((ieee80211_is_robust_mgmt_frame(hdr)) && 313 if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
567 (ieee80211_has_protected(hdr->frame_control))) 314 (ieee80211_has_protected(hdr->frame_control)))
568 rx_status->flag &= ~RX_FLAG_DECRYPTED; 315 rx_status->flag &= ~RX_FLAG_DECRYPTED;
@@ -630,6 +377,11 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
630 377
631 CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE_RTL8192S); 378 CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE_RTL8192S);
632 379
380 if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) {
381 firstseg = true;
382 lastseg = true;
383 }
384
633 if (firstseg) { 385 if (firstseg) {
634 if (rtlpriv->dm.useramask) { 386 if (rtlpriv->dm.useramask) {
635 /* set txdesc macId */ 387 /* set txdesc macId */