diff options
Diffstat (limited to 'drivers/staging/r8188eu/core/rtw_wlan_util.c')
-rw-r--r-- | drivers/staging/r8188eu/core/rtw_wlan_util.c | 135 |
1 files changed, 84 insertions, 51 deletions
diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 665b077190bc..392a65783f32 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -276,14 +276,6 @@ void Restore_DM_Func_Flag(struct adapter *padapter) SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); } -void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable) -{ - if (enable) - SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); - else - SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); -} - void Set_MSR(struct adapter *padapter, u8 type) { u8 val8; @@ -511,6 +503,31 @@ int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) return true; } +static void set_acm_ctrl(struct adapter *adapter, u8 acm_mask) +{ + u8 acmctrl = rtw_read8(adapter, REG_ACMHWCTRL); + + if (acm_mask > 1) + acmctrl = acmctrl | 0x1; + + if (acm_mask & BIT(3)) + acmctrl |= ACMHW_VOQEN; + else + acmctrl &= (~ACMHW_VOQEN); + + if (acm_mask & BIT(2)) + acmctrl |= ACMHW_VIQEN; + else + acmctrl &= (~ACMHW_VIQEN); + + if (acm_mask & BIT(1)) + acmctrl |= ACMHW_BEQEN; + else + acmctrl &= (~ACMHW_BEQEN); + + rtw_write8(adapter, REG_ACMHWCTRL, acmctrl); +} + void WMMOnAssocRsp(struct adapter *padapter) { u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; @@ -522,6 +539,7 @@ void WMMOnAssocRsp(struct adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct registry_priv *pregpriv = &padapter->registrypriv; + struct hal_data_8188e *haldata = &padapter->haldata; if (pmlmeinfo->WMM_enable == 0) { padapter->mlmepriv.acm_mask = 0; @@ -550,7 +568,8 @@ void WMMOnAssocRsp(struct adapter *padapter) switch (ACI) { case 0x0: - SetHwReg8188EU(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); + haldata->AcParam_BE = acParm; + rtw_write32(padapter, REG_EDCA_BE_PARAM, acParm); acm_mask |= (ACM ? BIT(1) : 0); edca[XMIT_BE_QUEUE] = acParm; break; @@ -572,7 +591,7 @@ void WMMOnAssocRsp(struct adapter *padapter) } if (padapter->registrypriv.acm_method == 1) - SetHwReg8188EU(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); + set_acm_ctrl(padapter, acm_mask); else padapter->mlmepriv.acm_mask = acm_mask; @@ -743,6 +762,35 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) memcpy(&pmlmeinfo->HT_info, pIE->data, pIE->Length); } +static void set_min_ampdu_spacing(struct adapter *adapter, u8 spacing) +{ + u8 sec_spacing; + + if (spacing <= 7) { + switch (adapter->securitypriv.dot11PrivacyAlgrthm) { + case _NO_PRIVACY_: + case _AES_: + sec_spacing = 0; + break; + case _WEP40_: + case _WEP104_: + case _TKIP_: + case _TKIP_WTMIC_: + sec_spacing = 6; + break; + default: + sec_spacing = 7; + break; + } + + if (spacing < sec_spacing) + spacing = sec_spacing; + + rtw_write8(adapter, REG_AMPDU_MIN_SPACE, + (rtw_read8(adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | spacing); + } +} + void HTOnAssocRsp(struct adapter *padapter) { unsigned char max_AMPDU_len; @@ -767,7 +815,7 @@ void HTOnAssocRsp(struct adapter *padapter) min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; - SetHwReg8188EU(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + set_min_ampdu_spacing(padapter, min_MPDU_spacing); SetHwReg8188EU(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); } @@ -846,7 +894,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (!is_client_associated_to_ap(Adapter)) return true; - len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); + len = packet_len - sizeof(struct ieee80211_hdr_3addr); if (len > MAX_IE_SZ) return _FAIL; @@ -867,7 +915,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* below is to copy the information element */ bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength); + memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); /* check bw and channel offset */ /* parsing HT_CAP_IE */ @@ -916,7 +964,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) else hidden_ssid = false; - if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) { + if (p && (!hidden_ssid && (*(p + 1)))) { memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); bssid->Ssid.SsidLength = *(p + 1); } else { @@ -1275,14 +1323,10 @@ void update_IOT_info(struct adapter *padapter) case HT_IOT_PEER_RALINK: pmlmeinfo->turboMode_cts2self = 0; pmlmeinfo->turboMode_rtsen = 1; - /* disable high power */ - Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); break; case HT_IOT_PEER_REALTEK: /* rtw_write16(padapter, 0x4cc, 0xffff); */ /* rtw_write16(padapter, 0x546, 0x01c0); */ - /* disable high power */ - Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); break; default: pmlmeinfo->turboMode_cts2self = 0; @@ -1291,26 +1335,36 @@ void update_IOT_info(struct adapter *padapter) } } +static void set_ack_preamble(struct adapter *adapter, bool short_preamble) +{ + struct hal_data_8188e *haldata = &adapter->haldata; + u8 val8; + + /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ + val8 = haldata->nCur40MhzPrimeSC << 5; + if (short_preamble) + val8 |= 0x80; + + rtw_write8(adapter, REG_RRSR + 2, val8); +}; + void update_capinfo(struct adapter *Adapter, u16 updateCap) { struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - bool ShortPreamble; /* Check preamble mode, 2005.01.06, by rcnjko. */ /* Mark to update preamble value forever, 2008.03.18 by lanhsin */ if (updateCap & cShortPreamble) { /* Short Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ - ShortPreamble = true; pmlmeinfo->preamble_mode = PREAMBLE_SHORT; - SetHwReg8188EU(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + set_ack_preamble(Adapter, true); } } else { /* Long Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ - ShortPreamble = false; pmlmeinfo->preamble_mode = PREAMBLE_LONG; - SetHwReg8188EU(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + set_ack_preamble(Adapter, false); } } @@ -1338,7 +1392,6 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) void update_wireless_mode(struct adapter *padapter) { int ratelen, network_type = 0; - u32 SIFS_Timer; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; @@ -1365,10 +1418,12 @@ void update_wireless_mode(struct adapter *padapter) pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; - SIFS_Timer = 0x0a0a0808;/* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ - /* change this value if having IOT issues. */ - - SetHwReg8188EU(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); + /* RESP_SIFS for CCK */ + rtw_write8(padapter, REG_R2T_SIFS, 0x08); + rtw_write8(padapter, REG_R2T_SIFS + 1, 0x08); + /* RESP_SIFS for OFDM */ + rtw_write8(padapter, REG_T2T_SIFS, 0x0a); + rtw_write8(padapter, REG_T2T_SIFS + 1, 0x0a); if (pmlmeext->cur_wireless_mode & WIRELESS_11B) update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); @@ -1411,34 +1466,12 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l return _SUCCESS; } -void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) -{ - struct sta_info *psta; - u16 tid; - u16 param; - struct recv_reorder_ctrl *preorder_ctrl; - struct sta_priv *pstapriv = &padapter->stapriv; - struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - psta = rtw_get_stainfo(pstapriv, addr); - - if (psta) { - param = le16_to_cpu(preq->BA_para_set); - tid = (param >> 2) & 0x0f; - preorder_ctrl = &psta->recvreorder_ctrl[tid]; - preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq) ? true : false; - } -} - void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) { u8 *pIE; __le32 *pbuf; - pIE = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + pIE = pframe + sizeof(struct ieee80211_hdr_3addr); pbuf = (__le32 *)pIE; pmlmeext->TSFValue = le32_to_cpu(*(pbuf + 1)); |