diff options
Diffstat (limited to 'drivers/staging/r8188eu/core')
23 files changed, 314 insertions, 8164 deletions
diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 1c07ad28b242..c78feeb9c862 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -7,8 +7,7 @@ #include "../include/drv_types.h" #include "../include/wifi.h" #include "../include/ieee80211.h" - -#ifdef CONFIG_88EU_AP_MODE +#include "../include/rtl8188e_cmd.h" void init_mlme_ap_info(struct adapter *padapter) { @@ -19,7 +18,7 @@ void init_mlme_ap_info(struct adapter *padapter) spin_lock_init(&pmlmepriv->bcn_update_lock); /* for ACL */ - _rtw_init_queue(&pacl_list->acl_node_q); + rtw_init_queue(&pacl_list->acl_node_q); start_ap_mode(padapter); } @@ -343,7 +342,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) } /* n mode ra_bitmap */ if (psta_ht->ht_option) { - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + GetHwReg8188EU(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); if (rf_type == RF_2T2R) limit = 16;/* 2R */ else @@ -393,7 +392,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) /* bitmap[28:31]= Rate Adaptive id */ /* arg[0:4] = macid */ /* arg[5] = Short GI */ - rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level); + rtl8188e_Add_RateATid(padapter, tx_ra_bitmap, arg, rssi_level); if (shortGIrate) init_rate |= BIT(6); @@ -453,7 +452,7 @@ void update_bmc_sta(struct adapter *padapter) init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & 0x3f; /* ap mode */ - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + rtl8188e_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); { u8 arg = 0; @@ -467,7 +466,7 @@ void update_bmc_sta(struct adapter *padapter) /* bitmap[28:31]= Rate Adaptive id */ /* arg[0:4] = macid */ /* arg[5] = Short GI */ - rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, 0); + rtl8188e_Add_RateATid(padapter, tx_ra_bitmap, arg, 0); } /* set ra_id, init_rate */ psta->raid = raid; @@ -505,7 +504,7 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) DBG_88E("%s\n", __func__); /* ap mode */ - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + rtl8188e_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psta->ieee8021x_blocked = true; @@ -558,550 +557,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) spin_unlock_bh(&psta->lock); } -static void update_hw_ht_param(struct adapter *padapter) -{ - unsigned char max_AMPDU_len; - unsigned char min_MPDU_spacing; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - DBG_88E("%s\n", __func__); - - /* handle A-MPDU parameter field */ - /* - AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k - AMPDU_para [4:2]:Min MPDU Start Spacing - */ - max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; - - min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; - - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); - - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); - - /* */ - /* Config SM Power Save setting */ - /* */ - pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & 0x0C) >> 2; - if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) - DBG_88E("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); -} - -static void start_bss_network(struct adapter *padapter, u8 *pbuf) -{ - u8 *p; - u8 val8, cur_channel, cur_bwmode, cur_ch_offset; - u16 bcn_interval; - u32 acparm; - int ie_len; - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; - struct HT_info_element *pht_info = NULL; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ - - bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; - cur_channel = pnetwork->Configuration.DSConfig; - cur_bwmode = HT_CHANNEL_WIDTH_20; - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - /* check if there is wps ie, */ - /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ - /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ - if (!rtw_get_wps_ie(pnetwork->IEs + _FIXED_IE_LENGTH_, pnetwork->IELength - _FIXED_IE_LENGTH_, NULL, NULL)) - pmlmeext->bstart_bss = true; - - /* todo: update wmm, ht cap */ - if (pmlmepriv->qospriv.qos_option) - pmlmeinfo->WMM_enable = true; - if (pmlmepriv->htpriv.ht_option) { - pmlmeinfo->WMM_enable = true; - pmlmeinfo->HT_enable = true; - - update_hw_ht_param(padapter); - } - - if (pmlmepriv->cur_network.join_res != true) { /* setting only at first time */ - /* WEP Key will be set before this function, do not clear CAM. */ - if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && - (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)) - flush_all_cam_entry(padapter); /* clear CAM */ - } - - /* set MSR to AP_Mode */ - Set_MSR(padapter, _HW_STATE_AP_); - - /* Set BSSID REG */ - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->MacAddress); - - /* Set EDCA param reg */ - acparm = 0x002F3217; /* VO */ - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm)); - acparm = 0x005E4317; /* VI */ - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm)); - acparm = 0x005ea42b; - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm)); - acparm = 0x0000A444; /* BK */ - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); - - /* Set Security */ - val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); - - /* Beacon Control related register */ - rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); - - UpdateBrateTbl(padapter, pnetwork->SupportedRates); - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); - - if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */ - /* turn on all dynamic functions */ - Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); - } - /* set channel, bwmode */ - p = rtw_get_ie((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fixed_ie))); - if (p && ie_len) { - pht_info = (struct HT_info_element *)(p + 2); - - if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { - /* switch to the 40M Hz mode */ - cur_bwmode = HT_CHANNEL_WIDTH_40; - switch (pht_info->infos[0] & 0x3) { - case 1: - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; - break; - case 3: - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; - break; - default: - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - break; - } - } - } - /* TODO: need to judge the phy parameters on concurrent mode for single phy */ - set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); - - DBG_88E("CH =%d, BW =%d, offset =%d\n", cur_channel, cur_bwmode, cur_ch_offset); - - /* */ - pmlmeext->cur_channel = cur_channel; - pmlmeext->cur_bwmode = cur_bwmode; - pmlmeext->cur_ch_offset = cur_ch_offset; - pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type; - - /* update cur_wireless_mode */ - update_wireless_mode(padapter); - - /* udpate capability after cur_wireless_mode updated */ - update_capinfo(padapter, rtw_get_capability((struct wlan_bssid_ex *)pnetwork)); - - /* let pnetwork_mlmeext == pnetwork_mlme. */ - memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); - -#ifdef CONFIG_88EU_P2P - memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.Ssid, pnetwork->Ssid.SsidLength); - pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.SsidLength; -#endif /* CONFIG_88EU_P2P */ - - if (pmlmeext->bstart_bss) { - update_beacon(padapter, _TIM_IE_, NULL, false); - - /* issue beacon frame */ - if (send_beacon(padapter) == _FAIL) - DBG_88E("issue_beacon, fail!\n"); - } - - /* update bc/mc sta_info */ - update_bmc_sta(padapter); -} - -int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) -{ - int ret = _SUCCESS; - u8 *p; - u8 *pHT_caps_ie = NULL; - u8 *pHT_info_ie = NULL; - struct sta_info *psta = NULL; - u16 cap, ht_cap = false; - uint ie_len = 0; - int group_cipher, pairwise_cipher; - u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; - int supportRateNum = 0; - u8 OUI1[] = {0x00, 0x50, 0xf2, 0x01}; - u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; - u8 *ie = pbss_network->IEs; - - /* SSID */ - /* Supported rates */ - /* DS Params */ - /* WLAN_EID_COUNTRY */ - /* ERP Information element */ - /* Extended supported rates */ - /* WPA/WPA2 */ - /* Wi-Fi Wireless Multimedia Extensions */ - /* ht_capab, ht_oper */ - /* WPS IE */ - - DBG_88E("%s, len =%d\n", __func__, len); - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return _FAIL; - - if (len > MAX_IE_SZ) - return _FAIL; - - pbss_network->IELength = len; - - memset(ie, 0, MAX_IE_SZ); - - memcpy(ie, pbuf, pbss_network->IELength); - - if (pbss_network->InfrastructureMode != Ndis802_11APMode) - return _FAIL; - - pbss_network->Rssi = 0; - - memcpy(pbss_network->MacAddress, myid(&padapter->eeprompriv), ETH_ALEN); - - /* beacon interval */ - p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ - pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p); - - /* capability */ - cap = get_unaligned_le16(ie); - - /* SSID */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) { - memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); - memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len); - pbss_network->Ssid.SsidLength = ie_len; - } - - /* channel */ - channel = 0; - pbss_network->Configuration.Length = 0; - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) - channel = *(p + 2); - - pbss_network->Configuration.DSConfig = channel; - - memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); - /* get supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p) { - memcpy(supportRate, p + 2, ie_len); - supportRateNum = ie_len; - } - - /* get ext_supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); - if (p) { - memcpy(supportRate + supportRateNum, p + 2, ie_len); - supportRateNum += ie_len; - } - - network_type = rtw_check_network_type(supportRate, supportRateNum, channel); - - rtw_set_supported_rate(pbss_network->SupportedRates, network_type); - - /* parsing ERP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) - ERP_IE_handler(padapter, (struct ndis_802_11_var_ie *)p); - - /* update privacy/security */ - if (cap & BIT(4)) - pbss_network->Privacy = 1; - else - pbss_network->Privacy = 0; - - psecuritypriv->wpa_psk = 0; - - /* wpa2 */ - group_cipher = 0; - pairwise_cipher = 0; - psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; - psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) { - if (rtw_parse_wpa2_ie(p, ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; - - psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ - psecuritypriv->wpa_psk |= BIT(1); - - psecuritypriv->wpa2_group_cipher = group_cipher; - psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; - } - } - /* wpa */ - ie_len = 0; - group_cipher = 0; - pairwise_cipher = 0; - psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; - psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; - for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { - p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if ((p) && (!memcmp(p + 2, OUI1, 4))) { - if (rtw_parse_wpa_ie(p, ie_len + 2, &group_cipher, - &pairwise_cipher, NULL) == _SUCCESS) { - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; - - psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ - - psecuritypriv->wpa_psk |= BIT(0); - - psecuritypriv->wpa_group_cipher = group_cipher; - psecuritypriv->wpa_pairwise_cipher = pairwise_cipher; - } - break; - } - if (!p || ie_len == 0) - break; - } - - /* wmm */ - ie_len = 0; - pmlmepriv->qospriv.qos_option = 0; - if (pregistrypriv->wmm_enable) { - for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { - p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if ((p) && !memcmp(p + 2, WMM_PARA_IE, 6)) { - pmlmepriv->qospriv.qos_option = 1; - - *(p + 8) |= BIT(7);/* QoS Info, support U-APSD */ - - /* disable all ACM bits since the WMM admission control is not supported */ - *(p + 10) &= ~BIT(4); /* BE */ - *(p + 14) &= ~BIT(4); /* BK */ - *(p + 18) &= ~BIT(4); /* VI */ - *(p + 22) &= ~BIT(4); /* VO */ - break; - } - - if (!p || ie_len == 0) - break; - } - } - /* parsing HT_CAP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) { - u8 rf_type; - struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p + 2); - - pHT_caps_ie = p; - ht_cap = true; - network_type |= WIRELESS_11_24N; - - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - - if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || - (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) - pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2)); - else - pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); - - /* set Max Rx AMPDU size to 64K */ - pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_FACTOR & 0x03); - - if (rf_type == RF_1T1R) { - pht_cap->mcs.rx_mask[0] = 0xff; - pht_cap->mcs.rx_mask[1] = 0x0; - } - memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len); - } - - /* parsing HT_INFO_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) - pHT_info_ie = p; - switch (network_type) { - case WIRELESS_11B: - pbss_network->NetworkTypeInUse = Ndis802_11DS; - break; - case WIRELESS_11G: - case WIRELESS_11BG: - case WIRELESS_11G_24N: - case WIRELESS_11BG_24N: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - default: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - } - - pmlmepriv->cur_network.network_type = network_type; - - pmlmepriv->htpriv.ht_option = false; - - if ((psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_TKIP) || - (psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) { - /* todo: */ - /* ht_cap = false; */ - } - - /* ht_cap */ - if (pregistrypriv->ht_enable && ht_cap) { - pmlmepriv->htpriv.ht_option = true; - pmlmepriv->qospriv.qos_option = 1; - - if (pregistrypriv->ampdu_enable == 1) - pmlmepriv->htpriv.ampdu_enable = true; - HT_caps_handler(padapter, (struct ndis_802_11_var_ie *)pHT_caps_ie); - - HT_info_handler(padapter, (struct ndis_802_11_var_ie *)pHT_info_ie); - } - - pbss_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pbss_network); - - /* issue beacon to start bss network */ - start_bss_network(padapter, (u8 *)pbss_network); - - /* alloc sta_info for ap itself */ - psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); - if (!psta) { - psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); - if (!psta) - return _FAIL; - } - - /* fix bug of flush_cam_entry at STOP AP mode */ - psta->state |= WIFI_AP_STATE; - rtw_indicate_connect(padapter); - pmlmepriv->cur_network.join_res = true;/* for check if already set beacon */ - return ret; -} - -void rtw_set_macaddr_acl(struct adapter *padapter, int mode) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - - DBG_88E("%s, mode =%d\n", __func__, mode); - - pacl_list->mode = mode; -} - -int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) -{ - struct list_head *plist, *phead; - u8 added = false; - int i, ret = 0; - struct rtw_wlan_acl_node *paclnode; - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - struct __queue *pacl_node_q = &pacl_list->acl_node_q; - - DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); - - if ((NUM_ACL - 1) < pacl_list->num) - return -1; - - spin_lock_bh(&pacl_node_q->lock); - - phead = get_list_head(pacl_node_q); - plist = phead->next; - - while (phead != plist) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - plist = plist->next; - - if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { - if (paclnode->valid) { - added = true; - DBG_88E("%s, sta has been added\n", __func__); - break; - } - } - } - - spin_unlock_bh(&pacl_node_q->lock); - - if (added) - return ret; - - spin_lock_bh(&pacl_node_q->lock); - - for (i = 0; i < NUM_ACL; i++) { - paclnode = &pacl_list->aclnode[i]; - - if (!paclnode->valid) { - INIT_LIST_HEAD(&paclnode->list); - - memcpy(paclnode->addr, addr, ETH_ALEN); - - paclnode->valid = true; - - list_add_tail(&paclnode->list, get_list_head(pacl_node_q)); - - pacl_list->num++; - - break; - } - } - - DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); - - spin_unlock_bh(&pacl_node_q->lock); - - return ret; -} - -int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) -{ - struct list_head *plist, *phead; - int ret = 0; - struct rtw_wlan_acl_node *paclnode; - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - struct __queue *pacl_node_q = &pacl_list->acl_node_q; - - DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); - - spin_lock_bh(&pacl_node_q->lock); - - phead = get_list_head(pacl_node_q); - plist = phead->next; - - while (phead != plist) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - plist = plist->next; - - if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { - if (paclnode->valid) { - paclnode->valid = false; - - list_del_init(&paclnode->list); - - pacl_list->num--; - } - } - } - - spin_unlock_bh(&pacl_node_q->lock); - - DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); - return ret; -} - static void update_bcn_fixed_ie(struct adapter *padapter) { DBG_88E("%s\n", __func__); @@ -1289,7 +744,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) /* op_mode -Set to 0 (HT pure) under the followign conditions +Set to 0 (HT pure) under the following conditions - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or - all STAs in the BSS are 20 MHz HT in 20 MHz BSS Set to 1 (HT non-member protection) if there may be non-HT STAs @@ -1633,41 +1088,6 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, return beacon_updated; } -int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) -{ - struct list_head *phead, *plist; - int ret = 0; - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) - return ret; - - DBG_88E(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", - FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset); - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - plist = phead->next; - - /* for each sta in asoc_queue */ - while (phead != plist) { - psta = container_of(plist, struct sta_info, asoc_list); - plist = plist->next; - - issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, ch_offset); - psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - issue_action_spct_ch_switch(padapter, bc_addr, new_ch, ch_offset); - - return ret; -} - int rtw_sta_flush(struct adapter *padapter) { struct list_head *phead, *plist; @@ -1736,15 +1156,6 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta) update_sta_info_apmode(padapter, psta); } -/* called >= TSR LEVEL for USB or SDIO Interface*/ -void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta) -{ - if (psta->state & _FW_LINKED) { - /* add ratid */ - add_RATid(padapter, psta, 0);/* DM_RATR_STA_INIT */ - } -} - void start_ap_mode(struct adapter *padapter) { int i; @@ -1846,5 +1257,3 @@ void stop_ap_mode(struct adapter *padapter) rtw_free_mlme_priv_ie_data(pmlmepriv); } - -#endif /* CONFIG_88EU_AP_MODE */ diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 62a672243696..bcd0f9dd64b1 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -695,8 +695,7 @@ void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) } } -void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, - unsigned char *ipAddr) +void *scdb_findEntry(struct adapter *priv, unsigned char *ipAddr) { unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; struct nat25_network_db_entry *db; diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index ce73ac7cf973..48869a7056fd 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -9,6 +9,8 @@ #include "../include/mlme_osdep.h" #include "../include/rtw_br_ext.h" #include "../include/rtw_mlme_ext.h" +#include "../include/rtl8188e_dm.h" +#include "../include/rtl8188e_sreset.h" /* Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. @@ -19,11 +21,12 @@ static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { int res = _SUCCESS; - sema_init(&pcmdpriv->cmd_queue_sema, 0); + init_completion(&pcmdpriv->enqueue_cmd); /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */ - sema_init(&pcmdpriv->terminate_cmdthread_sema, 0); + init_completion(&pcmdpriv->start_cmd_thread); + init_completion(&pcmdpriv->stop_cmd_thread); - _rtw_init_queue(&pcmdpriv->cmd_queue); + rtw_init_queue(&pcmdpriv->cmd_queue); /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ @@ -167,16 +170,6 @@ static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) { u8 bAllow = false; /* set to true to allow enqueuing cmd when hw_init_completed is false */ - /* To decide allow or not */ - if ((pcmdpriv->padapter->pwrctrlpriv.bHWPwrPindetect) && - (!pcmdpriv->padapter->registrypriv.usbss_enable)) { - if (cmd_obj->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra)) { - struct drvextra_cmd_parm *pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)cmd_obj->parmbuf; - if (pdrvextra_cmd_parm->ec_id == POWER_SAVING_CTRL_WK_CID) - bAllow = true; - } - } - if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan)) bAllow = true; @@ -205,7 +198,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); if (res == _SUCCESS) - up(&pcmdpriv->cmd_queue_sema); + complete(&pcmdpriv->enqueue_cmd); exit: @@ -221,14 +214,6 @@ struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv) return cmd_obj; } -void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv) -{ - - pcmdpriv->cmd_done_cnt++; - /* up(&(pcmdpriv->cmd_done_sema)); */ - -} - void rtw_free_cmd_obj(struct cmd_obj *pcmd) { @@ -259,23 +244,14 @@ int rtw_cmd_thread(void *context) struct adapter *padapter = (struct adapter *)context; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - thread_enter("RTW_CMD_THREAD"); - pcmdbuf = pcmdpriv->cmd_buf; pcmdpriv->cmdthd_running = true; - up(&pcmdpriv->terminate_cmdthread_sema); + complete(&pcmdpriv->start_cmd_thread); while (1) { - if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL) - break; + wait_for_completion(&pcmdpriv->enqueue_cmd); - if (padapter->bDriverStopped || - padapter->bSurpriseRemoved) { - DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", - __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); - break; - } _next: if (padapter->bDriverStopped || padapter->bSurpriseRemoved) { @@ -345,41 +321,9 @@ post_process: rtw_free_cmd_obj(pcmd); } while (1); - up(&pcmdpriv->terminate_cmdthread_sema); - - thread_exit(); -} - -u8 rtw_setstandby_cmd(struct adapter *padapter, uint action) -{ - struct cmd_obj *ph2c; - struct usb_suspend_parm *psetusbsuspend; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 ret = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - ret = _FAIL; - goto exit; - } - - psetusbsuspend = kzalloc(sizeof(struct usb_suspend_parm), GFP_ATOMIC); - if (!psetusbsuspend) { - kfree(ph2c); - ret = _FAIL; - goto exit; - } + complete(&pcmdpriv->stop_cmd_thread); - psetusbsuspend->action = action; - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetusbsuspend, GEN_CMD_CODE(_SetUsbSuspend)); - - ret = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - return ret; + return 0; } /* @@ -491,228 +435,12 @@ exit: return res; } -u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset) -{ - struct cmd_obj *ph2c; - struct setbasicrate_parm *pssetbasicratepara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - pssetbasicratepara = kzalloc(sizeof(struct setbasicrate_parm), GFP_ATOMIC); - - if (!pssetbasicratepara) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara, _SetBasicRate_CMD_); - - memcpy(pssetbasicratepara->basicrates, rateset, NumRates); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -/* -unsigned char rtw_setphy_cmd(unsigned char *adapter) - -1. be called only after rtw_update_registrypriv_dev_network(~) or mp testing program -2. for AdHoc/Ap mode or mp mode? - -*/ -u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch) -{ - struct cmd_obj *ph2c; - struct setphy_parm *psetphypara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - psetphypara = kzalloc(sizeof(struct setphy_parm), GFP_ATOMIC); - - if (!psetphypara) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetphypara, _SetPhy_CMD_); - - psetphypara->modem = modem; - psetphypara->rfchannel = ch; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -u8 rtw_setbbreg_cmd(struct adapter *padapter, u8 offset, u8 val) -{ - struct cmd_obj *ph2c; - struct writeBB_parm *pwritebbparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - pwritebbparm = kzalloc(sizeof(struct writeBB_parm), GFP_ATOMIC); - - if (!pwritebbparm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, pwritebbparm, GEN_CMD_CODE(_SetBBReg)); - - pwritebbparm->offset = offset; - pwritebbparm->value = val; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -u8 rtw_getbbreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) -{ - struct cmd_obj *ph2c; - struct readBB_parm *prdbbparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - prdbbparm = kzalloc(sizeof(struct readBB_parm), GFP_ATOMIC); - - if (!prdbbparm) { - kfree(ph2c); - return _FAIL; - } - - INIT_LIST_HEAD(&ph2c->list); - ph2c->cmdcode = GEN_CMD_CODE(_GetBBReg); - ph2c->parmbuf = (unsigned char *)prdbbparm; - ph2c->cmdsz = sizeof(struct readBB_parm); - ph2c->rsp = pval; - ph2c->rspsz = sizeof(struct readBB_rsp); - - prdbbparm->offset = offset; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -u8 rtw_setrfreg_cmd(struct adapter *padapter, u8 offset, u32 val) -{ - struct cmd_obj *ph2c; - struct writeRF_parm *pwriterfparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - pwriterfparm = kzalloc(sizeof(struct writeRF_parm), GFP_ATOMIC); - - if (!pwriterfparm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg)); - - pwriterfparm->offset = offset; - pwriterfparm->value = val; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -u8 rtw_getrfreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) -{ - struct cmd_obj *ph2c; - struct readRF_parm *prdrfparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - prdrfparm = kzalloc(sizeof(struct readRF_parm), GFP_ATOMIC); - if (!prdrfparm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - INIT_LIST_HEAD(&ph2c->list); - ph2c->cmdcode = GEN_CMD_CODE(_GetRFReg); - ph2c->parmbuf = (unsigned char *)prdrfparm; - ph2c->cmdsz = sizeof(struct readRF_parm); - ph2c->rsp = pval; - ph2c->rspsz = sizeof(struct readRF_rsp); - - prdrfparm->offset = offset; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - return res; -} - void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) { kfree(pcmd->parmbuf); kfree(pcmd); - - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.workparam.bcompleted = true; - -} - -void rtw_readtssi_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - - - kfree(pcmd->parmbuf); - kfree(pcmd); - - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.workparam.bcompleted = true; - } u8 rtw_createbss_cmd(struct adapter *padapter) @@ -743,32 +471,6 @@ exit: return res; } -u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, unsigned int sz) -{ - struct cmd_obj *pcmd; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!pcmd) { - res = _FAIL; - goto exit; - } - - INIT_LIST_HEAD(&pcmd->list); - pcmd->cmdcode = GEN_CMD_CODE(_CreateBss); - pcmd->parmbuf = pbss; - pcmd->cmdsz = sz; - pcmd->rsp = NULL; - pcmd->rspsz = 0; - - res = rtw_enqueue_cmd(pcmdpriv, pcmd); - -exit: - - return res; -} - u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) { u8 res = _SUCCESS; @@ -1073,115 +775,6 @@ exit: return res; } -u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_table) -{ - struct cmd_obj *ph2c; - struct setratable_parm *psetrttblparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!ph2c) { - res = _FAIL; - goto exit; - } - psetrttblparm = kzalloc(sizeof(struct setratable_parm), GFP_KERNEL); - - if (!psetrttblparm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable)); - - memcpy(psetrttblparm, prate_table, sizeof(struct setratable_parm)); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval) -{ - struct cmd_obj *ph2c; - struct getratable_parm *pgetrttblparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!ph2c) { - res = _FAIL; - goto exit; - } - pgetrttblparm = kzalloc(sizeof(struct getratable_parm), GFP_KERNEL); - - if (!pgetrttblparm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - -/* init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable)); */ - - INIT_LIST_HEAD(&ph2c->list); - ph2c->cmdcode = GEN_CMD_CODE(_GetRaTable); - ph2c->parmbuf = (unsigned char *)pgetrttblparm; - ph2c->cmdsz = sizeof(struct getratable_parm); - ph2c->rsp = (u8 *)pval; - ph2c->rspsz = sizeof(struct getratable_rsp); - - pgetrttblparm->rsvd = 0x0; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr) -{ - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct cmd_obj *ph2c; - struct set_assocsta_parm *psetassocsta_para; - struct set_stakey_rsp *psetassocsta_rsp = NULL; - - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - psetassocsta_para = kzalloc(sizeof(struct set_assocsta_parm), GFP_ATOMIC); - if (!psetassocsta_para) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - psetassocsta_rsp = kzalloc(sizeof(struct set_assocsta_rsp), GFP_ATOMIC); - if (!psetassocsta_rsp) { - kfree(ph2c); - kfree(psetassocsta_para); - return _FAIL; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_); - ph2c->rsp = (u8 *)psetassocsta_rsp; - ph2c->rspsz = sizeof(struct set_assocsta_rsp); - - memcpy(psetassocsta_para->addr, mac_addr, ETH_ALEN); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - return res; - } - u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -1250,57 +843,6 @@ exit: return res; } -u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue) -{ - struct cmd_obj *pcmdobj; - struct set_ch_parm *set_ch_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; - - DBG_88E(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", - FUNC_NDEV_ARG(padapter->pnetdev), ch, bw, ch_offset); - - /* check input parameter */ - - /* prepare cmd parameter */ - set_ch_parm = kzalloc(sizeof(*set_ch_parm), GFP_ATOMIC); - if (!set_ch_parm) { - res = _FAIL; - goto exit; - } - set_ch_parm->ch = ch; - set_ch_parm->bw = bw; - set_ch_parm->ch_offset = ch_offset; - - if (enqueue) { - /* need enqueue, prepare cmd_obj and enqueue */ - pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!pcmdobj) { - kfree(set_ch_parm); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(pcmdobj, set_ch_parm, GEN_CMD_CODE(_SetChannel)); - res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); - } else { - /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ - if (H2C_SUCCESS != set_ch_hdl(padapter, (u8 *)set_ch_parm)) - res = _FAIL; - - kfree(set_ch_parm); - } - - /* do something based on res... */ - -exit: - - DBG_88E(FUNC_NDEV_FMT" res:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), res); - - return res; -} - u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) { struct cmd_obj *pcmdobj; @@ -1352,74 +894,6 @@ exit: return res; } -u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed) -{ - struct cmd_obj *pcmdobj; - struct LedBlink_param *ledBlink_param; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; - - pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!pcmdobj) { - res = _FAIL; - goto exit; - } - - ledBlink_param = kzalloc(sizeof(struct LedBlink_param), GFP_ATOMIC); - if (!ledBlink_param) { - kfree(pcmdobj); - res = _FAIL; - goto exit; - } - - ledBlink_param->pLed = pLed; - - init_h2fwcmd_w_parm_no_rsp(pcmdobj, ledBlink_param, GEN_CMD_CODE(_LedBlink)); - res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); - -exit: - - return res; -} - -u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no) -{ - struct cmd_obj *pcmdobj; - struct SetChannelSwitch_param *setChannelSwitch_param; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; - - pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!pcmdobj) { - res = _FAIL; - goto exit; - } - - setChannelSwitch_param = kzalloc(sizeof(struct SetChannelSwitch_param), - GFP_ATOMIC); - if (!setChannelSwitch_param) { - kfree(pcmdobj); - res = _FAIL; - goto exit; - } - - setChannelSwitch_param->new_ch_no = new_ch_no; - - init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelSwitch_param, GEN_CMD_CODE(_SetChannelSwitch)); - res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); - -exit: - - return res; -} - -u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option) -{ - return _SUCCESS; -} - static void traffic_status_watchdog(struct adapter *padapter) { u8 bEnterPS; @@ -1486,17 +960,15 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) padapter = (struct adapter *)pbuf; pmlmepriv = &padapter->mlmepriv; -#ifdef CONFIG_88EU_AP_MODE if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) expire_timeout_chk(padapter); -#endif - rtw_hal_sreset_xmit_status_check(padapter); + rtl8188e_sreset_xmit_status_check(padapter); linked_status_chk(padapter); traffic_status_watchdog(padapter); - rtw_hal_dm_watchdog(padapter); + rtl8188e_HalDmWatchDog(padapter); } static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) @@ -1523,12 +995,12 @@ static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) mstatus = 1;/* connect */ /* Reset LPS Setting */ padapter->pwrctrlpriv.LpsIdleCount = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); break; case LPS_CTRL_DISCONNECT: mstatus = 0;/* disconnect */ LPS_Leave(padapter); - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); break; case LPS_CTRL_SPECIAL_PACKET: /* DBG_88E("LPS_CTRL_SPECIAL_PACKET\n"); */ @@ -1588,7 +1060,7 @@ exit: static void rpt_timer_setting_wk_hdl(struct adapter *padapter, u16 min_time) { - rtw_hal_set_hwreg(padapter, HW_VAR_RPT_TIMER_SETTING, (u8 *)(&min_time)); + SetHwReg8188EU(padapter, HW_VAR_RPT_TIMER_SETTING, (u8 *)(&min_time)); } u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) @@ -1625,7 +1097,7 @@ exit: static void antenna_select_wk_hdl(struct adapter *padapter, u8 antenna) { - rtw_hal_set_hwreg(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna)); + SetHwReg8188EU(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna)); } u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) @@ -1636,7 +1108,7 @@ u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) u8 support_ant_div; u8 res = _SUCCESS; - rtw_hal_get_def_var(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div); + GetHalDefVar8188EUsb(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div); if (!support_ant_div) return res; @@ -1669,12 +1141,6 @@ exit: return res; } -static void power_saving_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) -{ - rtw_ps_processor(padapter); -} - -#ifdef CONFIG_88EU_P2P u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType) { struct cmd_obj *ph2c; @@ -1711,7 +1177,6 @@ exit: return res; } -#endif /* CONFIG_88EU_P2P */ u8 rtw_ps_cmd(struct adapter *padapter) { @@ -1745,8 +1210,6 @@ exit: return res; } -#ifdef CONFIG_88EU_AP_MODE - static void rtw_chk_hi_queue_hdl(struct adapter *padapter) { int cnt = 0; @@ -1763,7 +1226,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) /* while ((rtw_read32(padapter, 0x414)&0x00ffff00)!= 0) */ /* while ((rtw_read32(padapter, 0x414)&0x0000ff00)!= 0) */ - rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + GetHwReg8188EU(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); while (!val) { msleep(100); @@ -1773,7 +1236,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) if (cnt > 10) break; - rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + GetHwReg8188EU(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); } if (cnt <= 10) { @@ -1817,7 +1280,6 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) exit: return res; } -#endif u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) { @@ -1852,29 +1314,12 @@ exit: return res; } -static s32 c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) +static void c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) { - s32 ret = _FAIL; u8 buf[16]; - if (!c2h_evt) { - /* No c2h event in cmd_obj, read c2h event before handling*/ - if (c2h_evt_read(adapter, buf) == _SUCCESS) { - c2h_evt = (struct c2h_evt_hdr *)buf; - - if (filter && !filter(c2h_evt->id)) - goto exit; - - ret = rtw_hal_c2h_handler(adapter, c2h_evt); - } - } else { - if (filter && !filter(c2h_evt->id)) - goto exit; - - ret = rtw_hal_c2h_handler(adapter, c2h_evt); - } -exit: - return ret; + if (!c2h_evt) + c2h_evt_read(adapter, buf); } static void c2h_wk_callback(struct work_struct *work) @@ -1882,7 +1327,6 @@ static void c2h_wk_callback(struct work_struct *work) struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk); struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv); struct c2h_evt_hdr *c2h_evt; - c2h_id_filter ccx_id_filter = rtw_hal_c2h_id_filter_ccx(adapter); evtpriv->c2h_wk_alive = true; @@ -1912,16 +1356,8 @@ static void c2h_wk_callback(struct work_struct *work) continue; } - if (ccx_id_filter(c2h_evt->id)) { - /* Handle CCX report here */ - rtw_hal_c2h_handler(adapter, c2h_evt); - kfree(c2h_evt); - } else { -#ifdef CONFIG_88EU_P2P - /* Enqueue into cmd_thread for others */ - rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt); -#endif - } + /* Enqueue into cmd_thread for others */ + rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt); } evtpriv->c2h_wk_alive = false; @@ -1941,7 +1377,7 @@ u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); break; case POWER_SAVING_CTRL_WK_CID: - power_saving_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); + rtw_ps_processor(padapter); break; case LPS_CTRL_WK_CID: lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size); @@ -1952,7 +1388,6 @@ u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) case ANT_SELECT_WK_CID: antenna_select_wk_hdl(padapter, pdrvextra_cmd->type_size); break; -#ifdef CONFIG_88EU_P2P case P2P_PS_WK_CID: p2p_ps_wk_hdl(padapter, pdrvextra_cmd->type_size); break; @@ -1961,12 +1396,9 @@ u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) /* I used the type_size as the type command */ p2p_protocol_wk_hdl(padapter, pdrvextra_cmd->type_size); break; -#endif -#ifdef CONFIG_88EU_AP_MODE case CHECK_HIQ_WK_CID: rtw_chk_hi_queue_hdl(padapter); break; -#endif /* CONFIG_88EU_AP_MODE */ case C2H_WK_CID: c2h_evt_hdl(padapter, (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf, NULL); break; diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c deleted file mode 100644 index 2ee64cef73f7..000000000000 --- a/drivers/staging/r8188eu/core/rtw_debug.c +++ /dev/null @@ -1,904 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2012 Realtek Corporation. */ - -#define _RTW_DEBUG_C_ - -#include "../include/rtw_debug.h" -#include "../include/drv_types.h" - -int proc_get_drv_version(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - int len = 0; - - len += snprintf(page + len, count - len, "%s\n", DRIVERVERSION); - - *eof = 1; - return len; -} - -int proc_get_write_reg(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - *eof = 1; - return 0; -} - -int proc_set_write_reg(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - char tmp[32]; - u32 addr, val, len; - - if (count < 3) { - DBG_88E("argument size is less than 3\n"); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - int num = sscanf(tmp, "%x %x %x", &addr, &val, &len); - - if (num != 3) { - DBG_88E("invalid write_reg parameter!\n"); - return count; - } - switch (len) { - case 1: - rtw_write8(padapter, addr, (u8)val); - break; - case 2: - rtw_write16(padapter, addr, (u16)val); - break; - case 4: - rtw_write32(padapter, addr, val); - break; - default: - DBG_88E("error write length =%d", len); - break; - } - } - return count; -} - -static u32 proc_get_read_addr = 0xeeeeeeee; -static u32 proc_get_read_len = 0x4; - -int proc_get_read_reg(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - int len = 0; - - if (proc_get_read_addr == 0xeeeeeeee) { - *eof = 1; - return len; - } - - switch (proc_get_read_len) { - case 1: - len += snprintf(page + len, count - len, "rtw_read8(0x%x)=0x%x\n", proc_get_read_addr, rtw_read8(padapter, proc_get_read_addr)); - break; - case 2: - len += snprintf(page + len, count - len, "rtw_read16(0x%x)=0x%x\n", proc_get_read_addr, rtw_read16(padapter, proc_get_read_addr)); - break; - case 4: - len += snprintf(page + len, count - len, "rtw_read32(0x%x)=0x%x\n", proc_get_read_addr, rtw_read32(padapter, proc_get_read_addr)); - break; - default: - len += snprintf(page + len, count - len, "error read length=%d\n", proc_get_read_len); - break; - } - - *eof = 1; - return len; -} - -int proc_set_read_reg(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - char tmp[16]; - u32 addr, len; - - if (count < 2) { - DBG_88E("argument size is less than 2\n"); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - int num = sscanf(tmp, "%x %x", &addr, &len); - - if (num != 2) { - DBG_88E("invalid read_reg parameter!\n"); - return count; - } - - proc_get_read_addr = addr; - - proc_get_read_len = len; - } - - return count; -} - -int proc_get_fwstate(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - int len = 0; - - len += snprintf(page + len, count - len, "fwstate=0x%x\n", get_fwstate(pmlmepriv)); - - *eof = 1; - return len; -} - -int proc_get_sec_info(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct security_priv *psecuritypriv = &padapter->securitypriv; - - int len = 0; - - len += snprintf(page + len, count - len, "auth_alg=0x%x, enc_alg=0x%x, auth_type=0x%x, enc_type=0x%x\n", - psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, - psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); - - *eof = 1; - return len; -} - -int proc_get_mlmext_state(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - int len = 0; - - len += snprintf(page + len, count - len, "pmlmeinfo->state=0x%x\n", pmlmeinfo->state); - - *eof = 1; - return len; -} - -int proc_get_qos_option(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - int len = 0; - - len += snprintf(page + len, count - len, "qos_option=%d\n", pmlmepriv->qospriv.qos_option); - - *eof = 1; - return len; -} - -int proc_get_ht_option(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - int len = 0; - len += snprintf(page + len, count - len, "ht_option=%d\n", pmlmepriv->htpriv.ht_option); - *eof = 1; - return len; -} - -int proc_get_rf_info(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - int len = 0; - - len += snprintf(page + len, count - len, "cur_ch=%d, cur_bw=%d, cur_ch_offet=%d\n", - pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); - *eof = 1; - return len; -} - -int proc_get_ap_info(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct sta_info *psta; - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct sta_priv *pstapriv = &padapter->stapriv; - int len = 0; - - psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); - if (psta) { - int i; - struct recv_reorder_ctrl *preorder_ctrl; - - len += snprintf(page + len, count - len, "SSID=%s\n", cur_network->network.Ssid.Ssid); - len += snprintf(page + len, count - len, "sta's macaddr:%pM\n", psta->hwaddr); - len += snprintf(page + len, count - len, "cur_channel=%d, cur_bwmode=%d, cur_ch_offset=%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); - len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); - len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); - len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); - len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); - len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable); - len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); - - for (i = 0; i < 16; i++) { - preorder_ctrl = &psta->recvreorder_ctrl[i]; - if (preorder_ctrl->enable) - len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", i, preorder_ctrl->indicate_seq); - } - } else { - len += snprintf(page + len, count - len, "can't get sta's macaddr, cur_network's macaddr: %pM\n", cur_network->network.MacAddress); - } - - *eof = 1; - return len; -} - -int proc_get_adapter_state(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - - len += snprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n", - padapter->bSurpriseRemoved, padapter->bDriverStopped); - - *eof = 1; - return len; -} - -int proc_get_trx_info(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct recv_priv *precvpriv = &padapter->recvpriv; - int len = 0; - - len += snprintf(page + len, count - len, "free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d, free_ext_xmitbuf_cnt=%d, free_recvframe_cnt=%d\n", - pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt, precvpriv->free_recvframe_cnt); - len += snprintf(page + len, count - len, "rx_urb_pending_cn=%d\n", precvpriv->rx_pending_cnt); - - *eof = 1; - return len; -} - -int proc_get_mac_reg_dump1(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1; - - len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); - - for (i = 0x0; i < 0x300; i += 4) { - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x", i); - len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - - *eof = 1; - return len; -} - -int proc_get_mac_reg_dump2(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1; - - len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); - memset(page, 0, count); - for (i = 0x300; i < 0x600; i += 4) { - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x", i); - len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - - *eof = 1; - return len; -} - -int proc_get_mac_reg_dump3(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1; - - len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); - - for (i = 0x600; i < 0x800; i += 4) { - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x", i); - len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - - *eof = 1; - return len; -} - -int proc_get_bb_reg_dump1(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1; - - len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); - for (i = 0x800; i < 0xB00; i += 4) { - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x", i); - len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - *eof = 1; - return len; -} - -int proc_get_bb_reg_dump2(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1; - - len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); - for (i = 0xB00; i < 0xE00; i += 4) { - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x", i); - len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - *eof = 1; - return len; -} - -int proc_get_bb_reg_dump3(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1; - - len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); - for (i = 0xE00; i < 0x1000; i += 4) { - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x", i); - len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - *eof = 1; - return len; -} - -int proc_get_rf_reg_dump1(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1, path; - u32 value; - - len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); - path = 1; - len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); - for (i = 0; i < 0xC0; i++) { - value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x ", i); - len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - *eof = 1; - return len; -} - -int proc_get_rf_reg_dump2(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1, path; - u32 value; - - len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); - path = 1; - len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); - for (i = 0xC0; i < 0x100; i++) { - value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x ", i); - len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - *eof = 1; - return len; -} - -int proc_get_rf_reg_dump3(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1, path; - u32 value; - - len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); - path = 2; - len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); - for (i = 0; i < 0xC0; i++) { - value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x ", i); - len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - - *eof = 1; - return len; -} - -int proc_get_rf_reg_dump4(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - int i, j = 1, path; - u32 value; - - len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); - path = 2; - len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); - for (i = 0xC0; i < 0x100; i++) { - value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j % 4 == 1) - len += snprintf(page + len, count - len, "0x%02x ", i); - len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++) % 4 == 0) - len += snprintf(page + len, count - len, "\n"); - } - *eof = 1; - return len; -} - -int proc_get_rx_signal(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - int len = 0; - - len = snprintf(page + len, count, - "rssi:%d\n" - "rxpwdb:%d\n" - "signal_strength:%u\n" - "signal_qual:%u\n" - "noise:%u\n", - padapter->recvpriv.rssi, - padapter->recvpriv.rxpwdb, - padapter->recvpriv.signal_strength, - padapter->recvpriv.signal_qual, - padapter->recvpriv.noise - ); - - *eof = 1; - return len; -} - -int proc_set_rx_signal(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - char tmp[32]; - u32 is_signal_dbg; - s32 signal_strength; - - if (count < 1) - return -EFAULT; - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - int num = sscanf(tmp, "%u %u", &is_signal_dbg, &signal_strength); - is_signal_dbg = is_signal_dbg == 0 ? 0 : 1; - if (is_signal_dbg && num != 2) - return count; - - signal_strength = signal_strength > 100 ? 100 : signal_strength; - signal_strength = signal_strength < 0 ? 0 : signal_strength; - - padapter->recvpriv.is_signal_dbg = is_signal_dbg; - padapter->recvpriv.signal_strength_dbg = signal_strength; - - if (is_signal_dbg) - DBG_88E("set %s %u\n", "DBG_SIGNAL_STRENGTH", signal_strength); - else - DBG_88E("set %s\n", "HW_SIGNAL_STRENGTH"); - } - return count; -} - -int proc_get_ht_enable(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - int len = 0; - - if (pregpriv) - len += snprintf(page + len, count - len, - "%d\n", - pregpriv->ht_enable - ); - *eof = 1; - return len; -} - -int proc_set_ht_enable(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - char tmp[32]; - s32 mode = 0; - - if (count < 1) - return -EFAULT; - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - if (pregpriv) { - pregpriv->ht_enable = mode; - pr_info("ht_enable=%d\n", pregpriv->ht_enable); - } - } - - return count; -} - -int proc_get_cbw40_enable(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - - int len = 0; - - if (pregpriv) - len += snprintf(page + len, count - len, - "%d\n", - pregpriv->cbw40_enable - ); - - *eof = 1; - return len; -} - -int proc_set_cbw40_enable(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - char tmp[32]; - s32 mode = 0; - - if (count < 1) - return -EFAULT; - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - if (pregpriv) { - pregpriv->cbw40_enable = mode; - pr_info("cbw40_enable=%d\n", mode); - } - } - return count; -} - -int proc_get_ampdu_enable(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - - int len = 0; - - if (pregpriv) - len += snprintf(page + len, count - len, - "%d\n", - pregpriv->ampdu_enable - ); - - *eof = 1; - return len; -} - -int proc_set_ampdu_enable(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - char tmp[32]; - s32 mode = 0; - - if (count < 1) - return -EFAULT; - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - if (pregpriv) { - pregpriv->ampdu_enable = mode; - pr_info("ampdu_enable=%d\n", mode); - } - } - return count; -} - -int proc_get_two_path_rssi(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - int len = 0; - - if (padapter) - len += snprintf(page + len, count - len, - "%d %d\n", - padapter->recvpriv.RxRssi[0], - padapter->recvpriv.RxRssi[1] - ); - - *eof = 1; - return len; -} - -int proc_get_rx_stbc(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - - int len = 0; - - if (pregpriv) - len += snprintf(page + len, count - len, - "%d\n", - pregpriv->rx_stbc - ); - - *eof = 1; - return len; -} - -int proc_set_rx_stbc(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - char tmp[32]; - u32 mode = 0; - - if (count < 1) - return -EFAULT; - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - if (pregpriv) { - pregpriv->rx_stbc = mode; - printk("rx_stbc=%d\n", mode); - } - } - return count; -} - -int proc_get_rssi_disp(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - *eof = 1; - return 0; -} - -int proc_set_rssi_disp(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - struct net_device *dev = (struct net_device *)data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - char tmp[32]; - u32 enable = 0; - - if (count < 1) { - DBG_88E("argument size is less than 1\n"); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - int num = sscanf(tmp, "%x", &enable); - - if (num != 1) { - DBG_88E("invalid set_rssi_disp parameter!\n"); - return count; - } - - if (enable) { - DBG_88E("Turn On Rx RSSI Display Function\n"); - padapter->bRxRSSIDisplay = enable; - } else { - DBG_88E("Turn Off Rx RSSI Display Function\n"); - padapter->bRxRSSIDisplay = 0; - } - } - return count; -} - -#ifdef CONFIG_88EU_AP_MODE - -int proc_get_all_sta_info(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct sta_info *psta; - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct sta_priv *pstapriv = &padapter->stapriv; - int i, j; - struct list_head *plist, *phead; - struct recv_reorder_ctrl *preorder_ctrl; - int len = 0; - - len += snprintf(page + len, count - len, "sta_dz_bitmap=0x%x, tim_bitmap=0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); - - spin_lock_bh(&pstapriv->sta_hash_lock); - - for (i = 0; i < NUM_STA; i++) { - phead = &pstapriv->sta_hash[i]; - plist = phead->next; - - while (phead != plist) { - psta = container_of(plist, struct sta_info, hash_list); - - plist = plist->next; - - len += snprintf(page + len, count - len, "sta's macaddr: %pM\n", psta->hwaddr); - len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); - len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); - len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); - len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); - len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable); - len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); - len += snprintf(page + len, count - len, "sleepq_len=%d\n", psta->sleepq_len); - len += snprintf(page + len, count - len, "capability=0x%x\n", psta->capability); - len += snprintf(page + len, count - len, "flags=0x%x\n", psta->flags); - len += snprintf(page + len, count - len, "wpa_psk=0x%x\n", psta->wpa_psk); - len += snprintf(page + len, count - len, "wpa2_group_cipher=0x%x\n", psta->wpa2_group_cipher); - len += snprintf(page + len, count - len, "wpa2_pairwise_cipher=0x%x\n", psta->wpa2_pairwise_cipher); - len += snprintf(page + len, count - len, "qos_info=0x%x\n", psta->qos_info); - len += snprintf(page + len, count - len, "dot118021XPrivacy=0x%x\n", psta->dot118021XPrivacy); - - for (j = 0; j < 16; j++) { - preorder_ctrl = &psta->recvreorder_ctrl[j]; - if (preorder_ctrl->enable) - len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", j, preorder_ctrl->indicate_seq); - } - } - } - spin_unlock_bh(&pstapriv->sta_hash_lock); - - *eof = 1; - return len; -} -#endif - -int proc_get_best_channel(char *page, char **start, - off_t offset, int count, - int *eof, void *data) -{ - struct net_device *dev = data; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - int len = 0; - u32 i, best_channel_24G = 1, index_24G = 0; - - for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { - if (pmlmeext->channel_set[i].ChannelNum == 1) - index_24G = i; - } - - for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { - /* 2.4G */ - if (pmlmeext->channel_set[i].ChannelNum == 6) { - if (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_24G].rx_count) { - index_24G = i; - best_channel_24G = pmlmeext->channel_set[i].ChannelNum; - } - } - - /* debug */ - len += snprintf(page + len, count - len, "The rx cnt of channel %3d = %d\n", - pmlmeext->channel_set[i].ChannelNum, pmlmeext->channel_set[i].rx_count); - } - - len += snprintf(page + len, count - len, "best_channel_24G = %d\n", best_channel_24G); - - *eof = 1; - return len; -} diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index c1c70648f5bc..03c8431b2ed3 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -25,13 +25,10 @@ u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; /*------------------------Define local variable------------------------------*/ -/* */ #define REG_EFUSE_CTRL 0x0030 #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ -/* */ -static bool Efuse_Read1ByteFromFakeContent(struct adapter *pAdapter, - u16 Offset, - u8 *Value) + +static bool Efuse_Read1ByteFromFakeContent(u16 Offset, u8 *Value) { if (Offset >= EFUSE_MAX_HW_SIZE) return false; @@ -58,62 +55,6 @@ Efuse_Write1ByteToFakeContent( return true; } -/*----------------------------------------------------------------------------- - * Function: Efuse_PowerSwitch - * - * Overview: When we want to enable write operation, we should change to - * pwr on state. When we stop write, we should switch to 500k mode - * and disable LDO 2.5V. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/17/2008 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ -void -Efuse_PowerSwitch( - struct adapter *pAdapter, - u8 write, - u8 PwrState) -{ - pAdapter->HalFunc.EfusePowerSwitch(pAdapter, write, PwrState); -} - -/*----------------------------------------------------------------------------- - * Function: efuse_GetCurrentSize - * - * Overview: Get current efuse size!!! - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/16/2008 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ -u16 -Efuse_GetCurrentSize( - struct adapter *pAdapter, - u8 efuseType, - bool pseudo) -{ - u16 ret = 0; - - ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, pseudo); - - return ret; -} - /* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */ u8 Efuse_CalculateWordCnts(u8 word_en) @@ -153,7 +94,7 @@ ReadEFuseByte( u16 retry; if (pseudo) { - Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf); + Efuse_Read1ByteFromFakeContent(_offset, pbuf); return; } @@ -184,93 +125,6 @@ ReadEFuseByte( *pbuf = (u8)(value32 & 0xff); } -/* */ -/* Description: */ -/* 1. Execute E-Fuse read byte operation according as map offset and */ -/* save to E-Fuse table. */ -/* 2. Referred from SD1 Richard. */ -/* */ -/* Assumption: */ -/* 1. Boot from E-Fuse and successfully auto-load. */ -/* 2. PASSIVE_LEVEL (USB interface) */ -/* */ -/* Created by Roger, 2008.10.21. */ -/* */ -/* 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description. */ -/* 2. Add efuse utilization collect. */ -/* 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1 */ -/* write addr must be after sec5. */ -/* */ - -static void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool pseudo) -{ - Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, _size_byte, pbuf, pseudo); -} - -void EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut, bool pseudo - ) -{ - pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, type, pOut, pseudo); -} - -/*----------------------------------------------------------------------------- - * Function: EFUSE_Read1Byte - * - * Overview: Copy from WMAC fot EFUSE read 1 byte. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 09/23/2008 MHC Copy from WMAC. - * - *---------------------------------------------------------------------------*/ -u8 EFUSE_Read1Byte(struct adapter *Adapter, u16 Address) -{ - u8 data; - u8 Bytetemp = {0x00}; - u8 temp = {0x00}; - u32 k = 0; - u16 contentLen = 0; - - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false); - - if (Address < contentLen) { /* E-fuse 512Byte */ - /* Write E-fuse Register address bit0~7 */ - temp = Address & 0xFF; - rtw_write8(Adapter, EFUSE_CTRL + 1, temp); - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 2); - /* Write E-fuse Register address bit8~9 */ - temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); - rtw_write8(Adapter, EFUSE_CTRL + 2, temp); - - /* Write 0x30[31]= 0 */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 3); - temp = Bytetemp & 0x7F; - rtw_write8(Adapter, EFUSE_CTRL + 3, temp); - - /* Wait Write-ready (0x30[31]= 1) */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 3); - while (!(Bytetemp & 0x80)) { - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 3); - k++; - if (k == 1000) { - k = 0; - break; - } - } - data = rtw_read8(Adapter, EFUSE_CTRL); - return data; - } else { - return 0xFF; - } - -} /* EFUSE_Read1Byte */ - /* 11/16/2008 MH Read one byte from real Efuse. */ u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data, bool pseudo) { @@ -278,7 +132,7 @@ u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data, bool pseudo) u8 result; if (pseudo) { - result = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data); + result = Efuse_Read1ByteFromFakeContent(addr, data); return result; } /* -----------------e-fuse reg ctrl --------------------------------- */ @@ -333,33 +187,6 @@ u8 efuse_OneByteWrite(struct adapter *pAdapter, u16 addr, u8 data, bool pseudo) return result; } -int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool pseudo) -{ - int ret = 0; - - ret = pAdapter->HalFunc.Efuse_PgPacketRead(pAdapter, offset, data, pseudo); - - return ret; -} - -int Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool pseudo) -{ - int ret; - - ret = pAdapter->HalFunc.Efuse_PgPacketWrite(pAdapter, offset, word_en, data, pseudo); - - return ret; -} - -static int Efuse_PgPacketWrite_BT(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool pseudo) -{ - int ret; - - ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT(pAdapter, offset, word_en, data, pseudo); - - return ret; -} - /*----------------------------------------------------------------------------- * Function: efuse_WordEnableDataRead * @@ -397,368 +224,6 @@ void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) } } -u8 Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool pseudo) -{ - u8 ret = 0; - - ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite(pAdapter, efuse_addr, word_en, data, pseudo); - - return ret; -} - -static u8 efuse_read8(struct adapter *padapter, u16 address, u8 *value) -{ - return efuse_OneByteRead(padapter, address, value, false); -} - -static u8 efuse_write8(struct adapter *padapter, u16 address, u8 *value) -{ - return efuse_OneByteWrite(padapter, address, *value, false); -} - -/* - * read/wirte raw efuse data - */ -u8 rtw_efuse_access(struct adapter *padapter, u8 write, u16 start_addr, u16 cnts, u8 *data) -{ - int i = 0; - u16 real_content_len = 0, max_available_size = 0; - u8 res = _FAIL; - u8 (*rw8)(struct adapter *, u16, u8*); - - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&real_content_len, false); - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - - if (start_addr > real_content_len) - return _FAIL; - - if (write) { - if ((start_addr + cnts) > max_available_size) - return _FAIL; - rw8 = &efuse_write8; - } else { - rw8 = &efuse_read8; - } - - Efuse_PowerSwitch(padapter, write, true); - - /* e-fuse one byte read / write */ - for (i = 0; i < cnts; i++) { - if (start_addr >= real_content_len) { - res = _FAIL; - break; - } - - res = rw8(padapter, start_addr++, data++); - if (_FAIL == res) - break; - } - - Efuse_PowerSwitch(padapter, write, false); - - return res; -} -/* */ -u16 efuse_GetMaxSize(struct adapter *padapter) -{ - u16 max_size; - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size, false); - return max_size; -} -/* */ -u8 efuse_GetCurrentSize(struct adapter *padapter, u16 *size) -{ - Efuse_PowerSwitch(padapter, false, true); - *size = Efuse_GetCurrentSize(padapter, EFUSE_WIFI, false); - Efuse_PowerSwitch(padapter, false, false); - - return _SUCCESS; -} -/* */ -u8 rtw_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) -{ - u16 mapLen = 0; - - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); - - if ((addr + cnts) > mapLen) - return _FAIL; - - Efuse_PowerSwitch(padapter, false, true); - - efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data, false); - - Efuse_PowerSwitch(padapter, false, false); - - return _SUCCESS; -} - -u8 rtw_BT_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) -{ - u16 mapLen = 0; - - EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); - - if ((addr + cnts) > mapLen) - return _FAIL; - - Efuse_PowerSwitch(padapter, false, true); - - efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data, false); - - Efuse_PowerSwitch(padapter, false, false); - - return _SUCCESS; -} -/* */ -u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) -{ - u8 offset, word_en; - u8 *map; - u8 newdata[PGPKT_DATA_SIZE + 1]; - s32 i, idx; - u8 ret = _SUCCESS; - u16 mapLen = 0; - - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); - - if ((addr + cnts) > mapLen) - return _FAIL; - - map = kzalloc(mapLen, GFP_KERNEL); - if (!map) - return _FAIL; - - ret = rtw_efuse_map_read(padapter, 0, mapLen, map); - if (ret == _FAIL) - goto exit; - - Efuse_PowerSwitch(padapter, true, true); - - offset = (addr >> 3); - word_en = 0xF; - memset(newdata, 0xFF, PGPKT_DATA_SIZE + 1); - i = addr & 0x7; /* index of one package */ - idx = 0; /* data index */ - - if (i & 0x1) { - /* odd start */ - if (data[idx] != map[addr + idx]) { - word_en &= ~BIT(i >> 1); - newdata[i - 1] = map[addr + idx - 1]; - newdata[i] = data[idx]; - } - i++; - idx++; - } - do { - for (; i < PGPKT_DATA_SIZE; i += 2) { - if (cnts == idx) - break; - if ((cnts - idx) == 1) { - if (data[idx] != map[addr + idx]) { - word_en &= ~BIT(i >> 1); - newdata[i] = data[idx]; - newdata[i + 1] = map[addr + idx + 1]; - } - idx++; - break; - } else { - if ((data[idx] != map[addr + idx]) || - (data[idx + 1] != map[addr + idx + 1])) { - word_en &= ~BIT(i >> 1); - newdata[i] = data[idx]; - newdata[i + 1] = data[idx + 1]; - } - idx += 2; - } - if (idx == cnts) - break; - } - - if (word_en != 0xF) { - ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, false); - DBG_88E("offset=%x\n", offset); - DBG_88E("word_en=%x\n", word_en); - - for (i = 0; i < PGPKT_DATA_SIZE; i++) - DBG_88E("data=%x \t", newdata[i]); - if (ret == _FAIL) - break; - } - - if (idx == cnts) - break; - - offset++; - i = 0; - word_en = 0xF; - memset(newdata, 0xFF, PGPKT_DATA_SIZE); - } while (1); - - Efuse_PowerSwitch(padapter, true, false); -exit: - kfree(map); - return ret; -} - -/* */ -u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) -{ - u8 offset, word_en; - u8 *map; - u8 newdata[PGPKT_DATA_SIZE + 1]; - s32 i, idx; - u8 ret = _SUCCESS; - u16 mapLen = 0; - - EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); - - if ((addr + cnts) > mapLen) - return _FAIL; - - map = kzalloc(mapLen, GFP_KERNEL); - if (!map) - return _FAIL; - - ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map); - if (ret == _FAIL) - goto exit; - - Efuse_PowerSwitch(padapter, true, true); - - offset = (addr >> 3); - word_en = 0xF; - memset(newdata, 0xFF, PGPKT_DATA_SIZE + 1); - i = addr & 0x7; /* index of one package */ - idx = 0; /* data index */ - - if (i & 0x1) { - /* odd start */ - if (data[idx] != map[addr + idx]) { - word_en &= ~BIT(i >> 1); - newdata[i - 1] = map[addr + idx - 1]; - newdata[i] = data[idx]; - } - i++; - idx++; - } - do { - for (; i < PGPKT_DATA_SIZE; i += 2) { - if (cnts == idx) - break; - if ((cnts - idx) == 1) { - if (data[idx] != map[addr + idx]) { - word_en &= ~BIT(i >> 1); - newdata[i] = data[idx]; - newdata[i + 1] = map[addr + idx + 1]; - } - idx++; - break; - } else { - if ((data[idx] != map[addr + idx]) || - (data[idx + 1] != map[addr + idx + 1])) { - word_en &= ~BIT(i >> 1); - newdata[i] = data[idx]; - newdata[i + 1] = data[idx + 1]; - } - idx += 2; - } - if (idx == cnts) - break; - } - - if (word_en != 0xF) { - DBG_88E("%s: offset=%#X\n", __func__, offset); - DBG_88E("%s: word_en=%#X\n", __func__, word_en); - DBG_88E("%s: data=", __func__); - for (i = 0; i < PGPKT_DATA_SIZE; i++) - DBG_88E("0x%02X ", newdata[i]); - DBG_88E("\n"); - - ret = Efuse_PgPacketWrite_BT(padapter, offset, word_en, newdata, false); - if (ret == _FAIL) - break; - } - - if (idx == cnts) - break; - - offset++; - i = 0; - word_en = 0xF; - memset(newdata, 0xFF, PGPKT_DATA_SIZE); - } while (1); - - Efuse_PowerSwitch(padapter, true, false); - -exit: - - kfree(map); - - return ret; -} - -/*----------------------------------------------------------------------------- - * Function: efuse_ShadowRead1Byte - * efuse_ShadowRead2Byte - * efuse_ShadowRead4Byte - * - * Overview: Read from efuse init map by one/two/four bytes !!!!! - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/12/2008 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ -static void -efuse_ShadowRead1Byte( - struct adapter *pAdapter, - u16 Offset, - u8 *Value) -{ - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); - - *Value = pEEPROM->efuse_eeprom_data[Offset]; - -} /* EFUSE_ShadowRead1Byte */ - -/* Read Two Bytes */ -static void -efuse_ShadowRead2Byte( - struct adapter *pAdapter, - u16 Offset, - u16 *Value) -{ - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); - - *Value = pEEPROM->efuse_eeprom_data[Offset]; - *Value |= pEEPROM->efuse_eeprom_data[Offset + 1] << 8; - -} /* EFUSE_ShadowRead2Byte */ - -/* Read Four Bytes */ -static void -efuse_ShadowRead4Byte( - struct adapter *pAdapter, - u16 Offset, - u32 *Value) -{ - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); - - *Value = pEEPROM->efuse_eeprom_data[Offset]; - *Value |= pEEPROM->efuse_eeprom_data[Offset + 1] << 8; - *Value |= pEEPROM->efuse_eeprom_data[Offset + 2] << 16; - *Value |= pEEPROM->efuse_eeprom_data[Offset + 3] << 24; - -} /* efuse_ShadowRead4Byte */ - /*----------------------------------------------------------------------------- * Function: Efuse_ReadAllMap * @@ -779,13 +244,13 @@ static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 efuseType, u8 *Efuse, { u16 mapLen = 0; - Efuse_PowerSwitch(pAdapter, false, true); + rtl8188e_EfusePowerSwitch(pAdapter, false, true); - EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + rtl8188e_EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); - efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, pseudo); + rtl8188e_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, pseudo); - Efuse_PowerSwitch(pAdapter, false, false); + rtl8188e_EfusePowerSwitch(pAdapter, false, false); } /*----------------------------------------------------------------------------- @@ -809,40 +274,13 @@ void EFUSE_ShadowMapUpdate( u8 efuseType, bool pseudo) { - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + struct eeprom_priv *pEEPROM = &pAdapter->eeprompriv; u16 mapLen = 0; - EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + rtl8188e_EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); if (pEEPROM->bautoload_fail_flag) memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen); else Efuse_ReadAllMap(pAdapter, efuseType, pEEPROM->efuse_eeprom_data, pseudo); } /* EFUSE_ShadowMapUpdate */ - -/*----------------------------------------------------------------------------- - * Function: EFUSE_ShadowRead - * - * Overview: Read from efuse init map !!!!! - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/12/2008 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ -void EFUSE_ShadowRead(struct adapter *pAdapter, u8 Type, u16 Offset, u32 *Value) -{ - if (Type == 1) - efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value); - else if (Type == 2) - efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value); - else if (Type == 4) - efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value); - -} /* EFUSE_ShadowRead */ diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index b3a74198596a..343c2f9a4ce8 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -140,59 +140,6 @@ u8 *rtw_set_ie return pbuf + len + 2; } -inline u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, - u8 new_ch, u8 ch_switch_cnt) -{ - u8 ie_data[3]; - - ie_data[0] = ch_switch_mode; - ie_data[1] = new_ch; - ie_data[2] = ch_switch_cnt; - return rtw_set_ie(buf, WLAN_EID_CHANNEL_SWITCH, 3, ie_data, buf_len); -} - -inline u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset) -{ - if (ch_offset == SCN) - return HAL_PRIME_CHNL_OFFSET_DONT_CARE; - else if (ch_offset == SCA) - return HAL_PRIME_CHNL_OFFSET_UPPER; - else if (ch_offset == SCB) - return HAL_PRIME_CHNL_OFFSET_LOWER; - - return HAL_PRIME_CHNL_OFFSET_DONT_CARE; -} - -inline u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset) -{ - if (ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) - return SCN; - else if (ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) - return SCB; - else if (ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) - return SCA; - - return SCN; -} - -inline u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset) -{ - return rtw_set_ie(buf, WLAN_EID_SECONDARY_CHANNEL_OFFSET, 1, &secondary_ch_offset, buf_len); -} - -inline u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, - u8 flags, u16 reason, u16 precedence) -{ - u8 ie_data[6]; - - ie_data[0] = ttl; - ie_data[1] = flags; - *(u16 *)(ie_data + 2) = cpu_to_le16(reason); - *(u16 *)(ie_data + 4) = cpu_to_le16(precedence); - - return rtw_set_ie(buf, 0x118, 6, ie_data, buf_len); -} - /*---------------------------------------------------------------------------- index: the information element id index, limit is the limit for search -----------------------------------------------------------------------------*/ @@ -225,96 +172,6 @@ u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit) return NULL; } -/** - * rtw_get_ie_ex - Search specific IE from a series of IEs - * @in_ie: Address of IEs to search - * @in_len: Length limit from in_ie - * @eid: Element ID to match - * @oui: OUI to match - * @oui_len: OUI length - * @ie: If not NULL and the specific IE is found, the IE will be copied to the buf starting from the specific IE - * @ielen: If not NULL and the specific IE is found, will set to the length of the entire IE - * - * Returns: The address of the specific IE found, or NULL - */ -u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen) -{ - uint cnt; - u8 *target_ie = NULL; - - if (ielen) - *ielen = 0; - - if (!in_ie || in_len <= 0) - return target_ie; - - cnt = 0; - - while (cnt < in_len) { - if (eid == in_ie[cnt] && (!oui || !memcmp(&in_ie[cnt + 2], oui, oui_len))) { - target_ie = &in_ie[cnt]; - - if (ie) - memcpy(ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - - if (ielen) - *ielen = in_ie[cnt + 1] + 2; - - break; - } else { - cnt += in_ie[cnt + 1] + 2; /* goto next */ - } - } - return target_ie; -} - -/** - * rtw_ies_remove_ie - Find matching IEs and remove - * @ies: Address of IEs to search - * @ies_len: Pointer of length of ies, will update to new length - * @offset: The offset to start scarch - * @eid: Element ID to match - * @oui: OUI to match - * @oui_len: OUI length - * - * Returns: _SUCCESS: ies is updated, _FAIL: not updated - */ -int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len) -{ - int ret = _FAIL; - u8 *target_ie; - u32 target_ielen; - u8 *start; - uint search_len; - - if (!ies || !ies_len || *ies_len <= offset) - goto exit; - - start = ies + offset; - search_len = *ies_len - offset; - - while (1) { - target_ie = rtw_get_ie_ex(start, search_len, eid, oui, oui_len, NULL, &target_ielen); - if (target_ie && target_ielen) { - u8 buf[MAX_IE_SZ] = {0}; - u8 *remain_ies = target_ie + target_ielen; - uint remain_len = search_len - (remain_ies - start); - - memcpy(buf, remain_ies, remain_len); - memcpy(target_ie, buf, remain_len); - *ies_len = *ies_len - target_ielen; - ret = _SUCCESS; - - start = target_ie; - search_len = remain_len; - } else { - break; - } - } -exit: - return ret; -} - void rtw_set_supported_rate(u8 *SupportedRates, uint mode) { @@ -1021,97 +878,24 @@ u8 key_2char2num(u8 hch, u8 lch) void rtw_macaddr_cfg(u8 *mac_addr) { u8 mac[ETH_ALEN]; + if (!mac_addr) return; - if (rtw_initmac) { /* Users specify the mac address */ - int jj, kk; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]); - memcpy(mac_addr, mac, ETH_ALEN); - } else { /* Use the mac address stored in the Efuse */ - memcpy(mac, mac_addr, ETH_ALEN); + if (rtw_initmac && mac_pton(rtw_initmac, mac)) { + /* Users specify the mac address */ + ether_addr_copy(mac_addr, mac); + } else { + /* Use the mac address stored in the Efuse */ + ether_addr_copy(mac, mac_addr); } - if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) && - (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || - ((mac[0] == 0x0) && (mac[1] == 0x0) && (mac[2] == 0x0) && - (mac[3] == 0x0) && (mac[4] == 0x0) && (mac[5] == 0x0))) { - mac[0] = 0x00; - mac[1] = 0xe0; - mac[2] = 0x4c; - mac[3] = 0x87; - mac[4] = 0x00; - mac[5] = 0x00; - /* use default mac addresss */ - memcpy(mac_addr, mac, ETH_ALEN); - DBG_88E("MAC Address from efuse error, assign default one !!!\n"); + if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) { + eth_random_addr(mac_addr); + DBG_88E("MAC Address from efuse error, assign random one !!!\n"); } - DBG_88E("rtw_macaddr_cfg MAC Address = %pM\n", (mac_addr)); -} - -void dump_ies(u8 *buf, u32 buf_len) -{ - u8 *pos = (u8 *)buf; - u8 id, len; - - while (pos - buf <= buf_len) { - id = *pos; - len = *(pos + 1); - - DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); - #ifdef CONFIG_88EU_P2P - dump_p2p_ie(pos, len); - #endif - dump_wps_ie(pos, len); - - pos += (2 + len); - } -} - -void dump_wps_ie(u8 *ie, u32 ie_len) -{ - u8 *pos = (u8 *)ie; - u16 id; - u16 len; - u8 *wps_ie; - uint wps_ielen; - - wps_ie = rtw_get_wps_ie(ie, ie_len, NULL, &wps_ielen); - if (wps_ie != ie || wps_ielen == 0) - return; - - pos += 6; - while (pos - ie < ie_len) { - id = RTW_GET_BE16(pos); - len = RTW_GET_BE16(pos + 2); - DBG_88E("%s ID:0x%04x, LEN:%u\n", __func__, id, len); - pos += (4 + len); - } -} - -#ifdef CONFIG_88EU_P2P -void dump_p2p_ie(u8 *ie, u32 ie_len) -{ - u8 *pos = (u8 *)ie; - u8 id; - u16 len; - u8 *p2p_ie; - uint p2p_ielen; - - p2p_ie = rtw_get_p2p_ie(ie, ie_len, NULL, &p2p_ielen); - if (p2p_ie != ie || p2p_ielen == 0) - return; - - pos += 6; - while (pos - ie < ie_len) { - id = *pos; - len = get_unaligned_le16(pos + 1); - DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); - pos += (3 + len); - } + DBG_88E("rtw_macaddr_cfg MAC Address = %pM\n", mac_addr); } /** @@ -1294,52 +1078,6 @@ void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, u8 attr_id) } } -#endif /* CONFIG_88EU_P2P */ - -/* Baron adds to avoid FreeBSD warning */ -int ieee80211_is_empty_essid(const char *essid, int essid_len) -{ - /* Single white space is for Linksys APs */ - if (essid_len == 1 && essid[0] == ' ') - return 1; - - /* Otherwise, if the entire essid is 0, we assume it is hidden */ - while (essid_len) { - essid_len--; - if (essid[essid_len] != '\0') - return 0; - } - - return 1; -} - -int ieee80211_get_hdrlen(u16 fc) -{ - int hdrlen = 24; - - switch (WLAN_FC_GET_TYPE(fc)) { - case RTW_IEEE80211_FTYPE_DATA: - if (fc & RTW_IEEE80211_STYPE_QOS_DATA) - hdrlen += 2; - if ((fc & RTW_IEEE80211_FCTL_FROMDS) && (fc & RTW_IEEE80211_FCTL_TODS)) - hdrlen += 6; /* Addr4 */ - break; - case RTW_IEEE80211_FTYPE_CTL: - switch (WLAN_FC_GET_STYPE(fc)) { - case RTW_IEEE80211_STYPE_CTS: - case RTW_IEEE80211_STYPE_ACK: - hdrlen = 10; - break; - default: - hdrlen = 16; - break; - } - break; - } - - return hdrlen; -} - static int rtw_get_cipher_info(struct wlan_network *pnetwork) { u32 wpa_ielen; @@ -1482,58 +1220,3 @@ u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsign } return max_rate; } - -int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action) -{ - const u8 *frame_body = frame + sizeof(struct rtw_ieee80211_hdr_3addr); - u16 fc; - u8 c, a = 0; - - fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl); - - if ((fc & (RTW_IEEE80211_FCTL_FTYPE | RTW_IEEE80211_FCTL_STYPE)) != - (RTW_IEEE80211_FTYPE_MGMT | RTW_IEEE80211_STYPE_ACTION)) - return false; - - c = frame_body[0]; - - switch (c) { - case RTW_WLAN_CATEGORY_P2P: /* vendor-specific */ - break; - default: - a = frame_body[1]; - } - - if (category) - *category = c; - if (action) - *action = a; - - return true; -} - -static const char *_action_public_str[] = { - "ACT_PUB_BSSCOEXIST", - "ACT_PUB_DSE_ENABLE", - "ACT_PUB_DSE_DEENABLE", - "ACT_PUB_DSE_REG_LOCATION", - "ACT_PUB_EXT_CHL_SWITCH", - "ACT_PUB_DSE_MSR_REQ", - "ACT_PUB_DSE_MSR_RPRT", - "ACT_PUB_MP", - "ACT_PUB_DSE_PWR_CONSTRAINT", - "ACT_PUB_VENDOR", - "ACT_PUB_GAS_INITIAL_REQ", - "ACT_PUB_GAS_INITIAL_RSP", - "ACT_PUB_GAS_COMEBACK_REQ", - "ACT_PUB_GAS_COMEBACK_RSP", - "ACT_PUB_TDLS_DISCOVERY_RSP", - "ACT_PUB_LOCATION_TRACK", - "ACT_PUB_RSVD", -}; - -const char *action_public_str(u8 action) -{ - action = (action >= ACT_PUBLIC_MAX) ? ACT_PUBLIC_MAX : action; - return _action_public_str[action]; -} diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c deleted file mode 100644 index cde0205816b1..000000000000 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ /dev/null @@ -1,299 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -/* - -The purpose of rtw_io.c - -a. provides the API - -b. provides the protocol engine - -c. provides the software interface between caller and the hardware interface - -Compiler Flag Option: - -USB: - a. USE_ASYNC_IRP: Both sync/async operations are provided. - -Only sync read/rtw_write_mem operations are provided. - -jackson@realtek.com.tw - -*/ - -#define _RTW_IO_C_ -#include "../include/osdep_service.h" -#include "../include/drv_types.h" -#include "../include/rtw_io.h" -#include "../include/osdep_intf.h" -#include "../include/usb_ops.h" - -#define rtw_le16_to_cpu(val) le16_to_cpu(val) -#define rtw_le32_to_cpu(val) le32_to_cpu(val) -#define rtw_cpu_to_le16(val) cpu_to_le16(val) -#define rtw_cpu_to_le32(val) cpu_to_le32(val) - -u8 _rtw_read8(struct adapter *adapter, u32 addr) -{ - u8 r_val; - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); - - - _read8 = pintfhdl->io_ops._read8; - r_val = _read8(pintfhdl, addr); - - return r_val; -} - -u16 _rtw_read16(struct adapter *adapter, u32 addr) -{ - u16 r_val; - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); - - _read16 = pintfhdl->io_ops._read16; - - r_val = _read16(pintfhdl, addr); - - return r_val; -} - -u32 _rtw_read32(struct adapter *adapter, u32 addr) -{ - u32 r_val; - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); - - _read32 = pintfhdl->io_ops._read32; - - r_val = _read32(pintfhdl, addr); - - return r_val; -} - -int _rtw_write8(struct adapter *adapter, u32 addr, u8 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); - int ret; - - _write8 = pintfhdl->io_ops._write8; - - ret = _write8(pintfhdl, addr, val); - - - return RTW_STATUS_CODE(ret); -} - -int _rtw_write16(struct adapter *adapter, u32 addr, u16 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); - int ret; - - _write16 = pintfhdl->io_ops._write16; - - ret = _write16(pintfhdl, addr, val); - - - return RTW_STATUS_CODE(ret); -} -int _rtw_write32(struct adapter *adapter, u32 addr, u32 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); - int ret; - - _write32 = pintfhdl->io_ops._write32; - - ret = _write32(pintfhdl, addr, val); - - - return RTW_STATUS_CODE(ret); -} - -int _rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = (struct intf_hdl *)(&pio_priv->intf); - int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); - int ret; - - _writeN = pintfhdl->io_ops._writeN; - - ret = _writeN(pintfhdl, addr, length, pdata); - - - return RTW_STATUS_CODE(ret); -} -int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); - int ret; - - _write8_async = pintfhdl->io_ops._write8_async; - - ret = _write8_async(pintfhdl, addr, val); - - - return RTW_STATUS_CODE(ret); -} - -int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); - int ret; - - _write16_async = pintfhdl->io_ops._write16_async; - ret = _write16_async(pintfhdl, addr, val); - - return RTW_STATUS_CODE(ret); -} - -int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); - int ret; - - _write32_async = pintfhdl->io_ops._write32_async; - ret = _write32_async(pintfhdl, addr, val); - - return RTW_STATUS_CODE(ret); -} - -void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) -{ - void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - return; - _read_mem = pintfhdl->io_ops._read_mem; - _read_mem(pintfhdl, addr, cnt, pmem); - -} - -void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) -{ - void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - - - - _write_mem = pintfhdl->io_ops._write_mem; - - _write_mem(pintfhdl, addr, cnt, pmem); - - -} - -void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) -{ - u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - - - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - return; - - _read_port = pintfhdl->io_ops._read_port; - - _read_port(pintfhdl, addr, cnt, pmem); - - -} - -void _rtw_read_port_cancel(struct adapter *adapter) -{ - void (*_read_port_cancel)(struct intf_hdl *pintfhdl); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - - _read_port_cancel = pintfhdl->io_ops._read_port_cancel; - - if (_read_port_cancel) - _read_port_cancel(pintfhdl); -} - -u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) -{ - u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - u32 ret = _SUCCESS; - - - - _write_port = pintfhdl->io_ops._write_port; - - ret = _write_port(pintfhdl, addr, cnt, pmem); - - - - return ret; -} - -u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem, int timeout_ms) -{ - int ret = _SUCCESS; - struct xmit_buf *pxmitbuf = (struct xmit_buf *)pmem; - struct submit_ctx sctx; - - rtw_sctx_init(&sctx, timeout_ms); - pxmitbuf->sctx = &sctx; - - ret = _rtw_write_port(adapter, addr, cnt, pmem); - - if (ret == _SUCCESS) - ret = rtw_sctx_wait(&sctx); - - return ret; -} - -void _rtw_write_port_cancel(struct adapter *adapter) -{ - void (*_write_port_cancel)(struct intf_hdl *pintfhdl); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - - _write_port_cancel = pintfhdl->io_ops._write_port_cancel; - - if (_write_port_cancel) - _write_port_cancel(pintfhdl); -} - -int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct _io_ops *pops)) -{ - struct io_priv *piopriv = &padapter->iopriv; - struct intf_hdl *pintf = &piopriv->intf; - - if (!set_intf_ops) - return _FAIL; - - piopriv->padapter = padapter; - pintf->padapter = padapter; - pintf->pintf_dev = adapter_to_dvobj(padapter); - - set_intf_ops(&pintf->io_ops); - - return _SUCCESS; -} diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index c187de78b4ac..411b06e135be 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -13,29 +13,6 @@ extern void indicate_wx_scan_complete_event(struct adapter *padapter); -u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) -{ - u8 i; - u8 ret = true; - - if (ssid->SsidLength > 32) { - ret = false; - goto exit; - } - - for (i = 0; i < ssid->SsidLength; i++) { - /* wifi, printable ascii code must be supported */ - if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) { - ret = false; - break; - } - } - -exit: - - return ret; -} - u8 rtw_do_join(struct adapter *padapter) { struct list_head *plist, *phead; @@ -74,7 +51,7 @@ u8 rtw_do_join(struct adapter *padapter) ret = _FAIL; } - goto exit; + return ret; } else { int select_ret; @@ -101,10 +78,9 @@ u8 rtw_do_join(struct adapter *padapter) rtw_generate_random_ibss(pibss); - if (rtw_createbss_cmd(padapter) != _SUCCESS) { - ret = false; - goto exit; - } + if (rtw_createbss_cmd(padapter) != _SUCCESS) + return false; + pmlmepriv->to_join = false; } else { /* can't associate ; reset under-linking */ @@ -125,8 +101,6 @@ u8 rtw_do_join(struct adapter *padapter) } } -exit: - return ret; } @@ -312,9 +286,7 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, /* change to other mode from Ndis802_11APMode */ cur_network->join_res = -1; -#ifdef CONFIG_88EU_AP_MODE stop_ap_mode(padapter); -#endif } if ((check_fwstate(pmlmepriv, _FW_LINKED)) || @@ -343,9 +315,6 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, break; case Ndis802_11APMode: set_fwstate(pmlmepriv, WIFI_AP_STATE); -#ifdef CONFIG_88EU_AP_MODE - start_ap_mode(padapter); -#endif break; case Ndis802_11AutoUnknown: case Ndis802_11InfrastructureMax: @@ -472,298 +441,6 @@ exit: return ret; } -u8 rtw_set_802_11_remove_wep(struct adapter *padapter, u32 keyindex) -{ - u8 ret = _SUCCESS; - - if (keyindex >= 0x80000000 || !padapter) { - ret = false; - goto exit; - } else { - int res; - struct security_priv *psecuritypriv = &padapter->securitypriv; - if (keyindex < 4) { - memset(&psecuritypriv->dot11DefKey[keyindex], 0, 16); - res = rtw_set_key(padapter, psecuritypriv, keyindex, 0); - psecuritypriv->dot11DefKeylen[keyindex] = 0; - if (res == _FAIL) - ret = _FAIL; - } else { - ret = _FAIL; - } - } -exit: - - return ret; -} - -u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) -{ - uint encryptionalgo; - u8 *pbssid; - struct sta_info *stainfo; - u8 bgroup = false; - u8 bgrouptkey = false;/* can be removed later */ - u8 ret = _SUCCESS; - - if (((key->KeyIndex & 0x80000000) == 0) && ((key->KeyIndex & 0x40000000) > 0)) { - /* It is invalid to clear bit 31 and set bit 30. If the miniport driver encounters this combination, */ - /* it must fail the request and return NDIS_STATUS_INVALID_DATA. */ - ret = _FAIL; - goto exit; - } - - if (key->KeyIndex & 0x40000000) { - /* Pairwise key */ - - pbssid = get_bssid(&padapter->mlmepriv); - stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); - - if (stainfo && padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) - encryptionalgo = stainfo->dot118021XPrivacy; - else - encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; - - if (key->KeyIndex & 0x000000FF) { - /* The key index is specified in the lower 8 bits by values of zero to 255. */ - /* The key index should be set to zero for a Pairwise key, and the driver should fail with */ - /* NDIS_STATUS_INVALID_DATA if the lower 8 bits is not zero */ - ret = _FAIL; - goto exit; - } - - /* check BSSID */ - if (is_broadcast_ether_addr(key->BSSID)) { - ret = false; - goto exit; - } - - /* Check key length for TKIP. */ - if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { - ret = _FAIL; - goto exit; - } - - /* Check key length for AES. */ - if ((encryptionalgo == _AES_) && (key->KeyLength != 16)) { - /* For our supplicant, EAPPkt9x.vxd, cannot differentiate TKIP and AES case. */ - if (key->KeyLength == 32) { - key->KeyLength = 16; - } else { - ret = _FAIL; - goto exit; - } - } - - /* Check key length for WEP. For NDTEST, 2005.01.27, by rcnjko. */ - if ((encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_) && - (key->KeyLength != 5 && key->KeyLength != 13)) { - ret = _FAIL; - goto exit; - } - - bgroup = false; - } else { - /* Group key - KeyIndex(BIT(30) == 0) */ - /* when add wep key through add key and didn't assigned encryption type before */ - if ((padapter->securitypriv.ndisauthtype <= 3) && - (padapter->securitypriv.dot118021XGrpPrivacy == 0)) { - switch (key->KeyLength) { - case 5: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - break; - case 13: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - break; - default: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - break; - } - - encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; - } else { - encryptionalgo = padapter->securitypriv.dot118021XGrpPrivacy; - } - - if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE) && !is_broadcast_ether_addr(key->BSSID)) { - ret = _FAIL; - goto exit; - } - - /* Check key length for TKIP */ - if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { - ret = _FAIL; - goto exit; - } else if (encryptionalgo == _AES_ && (key->KeyLength != 16 && key->KeyLength != 32)) { - /* Check key length for AES */ - /* For NDTEST, we allow keylen = 32 in this case. 2005.01.27, by rcnjko. */ - ret = _FAIL; - goto exit; - } - - /* Change the key length for EAPPkt9x.vxd. Added by Annie, 2005-11-03. */ - if ((encryptionalgo == _AES_) && (key->KeyLength == 32)) - key->KeyLength = 16; - - if (key->KeyIndex & 0x8000000) {/* error ??? 0x8000_0000 */ - bgrouptkey = true; - } - - if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE)) && - (check_fwstate(&padapter->mlmepriv, _FW_LINKED))) - bgrouptkey = true; - bgroup = true; - } - - /* If WEP encryption algorithm, just call rtw_set_802_11_add_wep(). */ - if ((padapter->securitypriv.dot11AuthAlgrthm != dot11AuthAlgrthm_8021X) && - (encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_)) { - u32 keyindex; - u32 len = FIELD_OFFSET(struct ndis_802_11_key, KeyMaterial) + key->KeyLength; - struct ndis_802_11_wep *wep = &padapter->securitypriv.ndiswep; - - wep->Length = len; - keyindex = key->KeyIndex & 0x7fffffff; - wep->KeyIndex = keyindex; - wep->KeyLength = key->KeyLength; - - memcpy(wep->KeyMaterial, key->KeyMaterial, key->KeyLength); - memcpy(&padapter->securitypriv.dot11DefKey[keyindex].skey[0], key->KeyMaterial, key->KeyLength); - - padapter->securitypriv.dot11DefKeylen[keyindex] = key->KeyLength; - padapter->securitypriv.dot11PrivacyKeyIndex = keyindex; - - ret = rtw_set_802_11_add_wep(padapter, wep); - goto exit; - } - if (key->KeyIndex & 0x20000000) { - /* SetRSC */ - if (bgroup) { - unsigned long long keysrc = key->KeyRSC & 0x00FFFFFFFFFFFFULL; - memcpy(&padapter->securitypriv.dot11Grprxpn, &keysrc, 8); - } else { - unsigned long long keysrc = key->KeyRSC & 0x00FFFFFFFFFFFFULL; - memcpy(&padapter->securitypriv.dot11Grptxpn, &keysrc, 8); - } - } - - /* Indicate this key idx is used for TX */ - /* Save the key in KeyMaterial */ - if (bgroup) { /* Group transmit key */ - int res; - - if (bgrouptkey) - padapter->securitypriv.dot118021XGrpKeyid = (u8)key->KeyIndex; - if ((key->KeyIndex & 0x3) == 0) { - ret = _FAIL; - goto exit; - } - memset(&padapter->securitypriv.dot118021XGrpKey[(u8)((key->KeyIndex) & 0x03)], 0, 16); - memset(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], 0, 16); - memset(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], 0, 16); - - if ((key->KeyIndex & 0x10000000)) { - memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); - memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); - } else { - memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); - memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); - } - - /* set group key by index */ - memcpy(&padapter->securitypriv.dot118021XGrpKey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial, key->KeyLength); - - key->KeyIndex = key->KeyIndex & 0x03; - - padapter->securitypriv.binstallGrpkey = true; - - padapter->securitypriv.bcheck_grpkey = false; - - res = rtw_set_key(padapter, &padapter->securitypriv, key->KeyIndex, 1); - - if (res == _FAIL) - ret = _FAIL; - - goto exit; - - } else { /* Pairwise Key */ - u8 res; - - pbssid = get_bssid(&padapter->mlmepriv); - stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); - - if (stainfo) { - memset(&stainfo->dot118021x_UncstKey, 0, 16);/* clear keybuffer */ - - memcpy(&stainfo->dot118021x_UncstKey, key->KeyMaterial, 16); - - if (encryptionalgo == _TKIP_) { - padapter->securitypriv.busetkipkey = false; - - /* _set_timer(&padapter->securitypriv.tkip_timer, 50); */ - - /* if TKIP, save the Receive/Transmit MIC key in KeyMaterial[128-255] */ - if ((key->KeyIndex & 0x10000000)) { - memcpy(&stainfo->dot11tkiptxmickey, key->KeyMaterial + 16, 8); - memcpy(&stainfo->dot11tkiprxmickey, key->KeyMaterial + 24, 8); - - } else { - memcpy(&stainfo->dot11tkiptxmickey, key->KeyMaterial + 24, 8); - memcpy(&stainfo->dot11tkiprxmickey, key->KeyMaterial + 16, 8); - } - } - - /* Set key to CAM through H2C command */ - if (bgrouptkey) /* never go to here */ - res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, false); - else - res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, true); - if (!res) - ret = _FAIL; - } - } -exit: - - return ret; -} - -u8 rtw_set_802_11_remove_key(struct adapter *padapter, struct ndis_802_11_remove_key *key) -{ - u8 *pbssid; - struct sta_info *stainfo; - u8 bgroup = (key->KeyIndex & 0x4000000) > 0 ? false : true; - u8 keyIndex = (u8)key->KeyIndex & 0x03; - u8 ret = _SUCCESS; - - if ((key->KeyIndex & 0xbffffffc) > 0) { - ret = _FAIL; - goto exit; - } - - if (bgroup) { - /* clear group key by index */ - - memset(&padapter->securitypriv.dot118021XGrpKey[keyIndex], 0, 16); - - /* \todo Send a H2C Command to Firmware for removing this Key in CAM Entry. */ - } else { - pbssid = get_bssid(&padapter->mlmepriv); - stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); - if (stainfo) { - /* clear key by BSSID */ - memset(&stainfo->dot118021x_UncstKey, 0, 16); - - /* \todo Send a H2C Command to Firmware for disable this Key in CAM Entry. */ - } else { - ret = _FAIL; - goto exit; - } - } -exit: - - return ret; -} - /* * rtw_get_cur_max_rate - * @adapter: pointer to struct adapter structure @@ -786,11 +463,6 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) u16 mcs_rate = 0; u32 ht_ielen = 0; - if (adapter->registrypriv.mp_mode == 1) { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) - return 0; - } - if ((!check_fwstate(pmlmepriv, _FW_LINKED)) && (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) return 0; @@ -808,7 +480,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) short_GI_20 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_20) ? 1 : 0; short_GI_40 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_40) ? 1 : 0; - rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + GetHwReg8188EU(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); max_rate = rtw_mcs_rate( rf_type, bw_40MHz & (pregistrypriv->cbw40_enable), @@ -830,62 +502,3 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) return max_rate; } - -/* -* rtw_set_scan_mode - -* @adapter: pointer to struct adapter structure -* @scan_mode: -* -* Return _SUCCESS or _FAIL -*/ -int rtw_set_scan_mode(struct adapter *adapter, enum rt_scan_type scan_mode) -{ - if (scan_mode != SCAN_ACTIVE && scan_mode != SCAN_PASSIVE) - return _FAIL; - - adapter->mlmepriv.scan_mode = scan_mode; - - return _SUCCESS; -} - -/* -* rtw_set_channel_plan - -* @adapter: pointer to struct adapter structure -* @channel_plan: -* -* Return _SUCCESS or _FAIL -*/ -int rtw_set_channel_plan(struct adapter *adapter, u8 channel_plan) -{ - /* handle by cmd_thread to sync with scan operation */ - return rtw_set_chplan_cmd(adapter, channel_plan, 1); -} - -/* -* rtw_set_country - -* @adapter: pointer to struct adapter structure -* @country_code: string of country code -* -* Return _SUCCESS or _FAIL -*/ -int rtw_set_country(struct adapter *adapter, const char *country_code) -{ - int channel_plan = RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G; - - DBG_88E("%s country_code:%s\n", __func__, country_code); - - /* TODO: should have a table to match country code and RT_CHANNEL_DOMAIN */ - /* TODO: should consider 2-character and 3-character country code */ - if (0 == strcmp(country_code, "US")) - channel_plan = RT_CHANNEL_DOMAIN_FCC; - else if (0 == strcmp(country_code, "EU")) - channel_plan = RT_CHANNEL_DOMAIN_ETSI; - else if (0 == strcmp(country_code, "JP")) - channel_plan = RT_CHANNEL_DOMAIN_MKK; - else if (0 == strcmp(country_code, "CN")) - channel_plan = RT_CHANNEL_DOMAIN_CHINA; - else - DBG_88E("%s unknown country_code:%s\n", __func__, country_code); - - return rtw_set_channel_plan(adapter, channel_plan); -} diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c index 5c1b19679cad..7e78b47c1284 100644 --- a/drivers/staging/r8188eu/core/rtw_iol.c +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -13,15 +13,14 @@ struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) xmit_frame = rtw_alloc_xmitframe(pxmitpriv); if (!xmit_frame) { DBG_88E("%s rtw_alloc_xmitframe return null\n", __func__); - goto exit; + return NULL; } xmitbuf = rtw_alloc_xmitbuf(pxmitpriv); if (!xmitbuf) { DBG_88E("%s rtw_alloc_xmitbuf return null\n", __func__); rtw_free_xmitframe(pxmitpriv, xmit_frame); - xmit_frame = NULL; - goto exit; + return NULL; } xmit_frame->frame_tag = MGNT_FRAMETAG; @@ -35,7 +34,7 @@ struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) pattrib->subtype = WIFI_BEACON; pattrib->pktlen = 0; pattrib->last_txcmdsz = 0; -exit: + return xmit_frame; } @@ -72,16 +71,6 @@ bool rtw_IOL_applied(struct adapter *adapter) return false; } -int rtw_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt) -{ - return rtw_hal_iol_cmd(adapter, xmit_frame, max_wating_ms, bndy_cnt); -} - -int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary) -{ - return _SUCCESS; -} - int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask) { struct ioreg_cfg cmd = {8, IOREG_CMD_WB_REG, 0x0, 0x0, 0x0}; @@ -173,20 +162,3 @@ u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame) } return is_cmd_bndy; } - -void rtw_IOL_cmd_buf_dump(struct adapter *Adapter, int buf_len, u8 *pbuf) -{ - int i; - int j = 1; - - pr_info("###### %s ######\n", __func__); - for (i = 0; i < buf_len; i++) { - printk("%02x-", *(pbuf + i)); - - if (j % 32 == 0) - printk("\n"); - j++; - } - printk("\n"); - pr_info("=============ioreg_cmd len=%d===============\n", buf_len); -} diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index b33e34cce12e..0e3453639a8b 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -4,11 +4,6 @@ #include "../include/drv_types.h" #include "../include/rtw_led.h" -/* */ -/* Description: */ -/* Callback function of LED BlinkTimer, */ -/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ -/* */ void BlinkTimerCallback(struct timer_list *t) { struct LED_871x *pLed = from_timer(pLed, t, BlinkTimer); @@ -20,21 +15,12 @@ void BlinkTimerCallback(struct timer_list *t) _set_workitem(&pLed->BlinkWorkItem); } -/* */ -/* Description: */ -/* Callback function of LED BlinkWorkItem. */ -/* We dispatch acture LED blink action according to LedStrategy. */ -/* */ void BlinkWorkItemCallback(struct work_struct *work) { struct LED_871x *pLed = container_of(work, struct LED_871x, BlinkWorkItem); BlinkHandler(pLed); } -/* */ -/* Description: */ -/* Reset status of LED_871x object. */ -/* */ void ResetLedStatus(struct LED_871x *pLed) { pLed->CurrLedState = RTW_LED_OFF; /* Current LED state. */ @@ -52,8 +38,6 @@ void ResetLedStatus(struct LED_871x *pLed) pLed->bLedScanBlinkInProgress = false; } -/*Description: */ -/* Initialize an LED_871x object. */ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin) { pLed->padapter = padapter; @@ -65,10 +49,6 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_8 _init_workitem(&pLed->BlinkWorkItem, BlinkWorkItemCallback, pLed); } -/* */ -/* Description: */ -/* DeInitialize an LED_871x object. */ -/* */ void DeInitLed871x(struct LED_871x *pLed) { _cancel_workitem_sync(&pLed->BlinkWorkItem); @@ -76,84 +56,6 @@ void DeInitLed871x(struct LED_871x *pLed) ResetLedStatus(pLed); } -/* */ -/* Description: */ -/* Implementation of LED blinking behavior. */ -/* It toggle off LED and schedule corresponding timer if necessary. */ -/* */ - -static void SwLedBlink(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - SwLedOn(padapter, pLed); - else - SwLedOff(padapter, pLed); - - /* Determine if we shall change LED state again. */ - pLed->BlinkTimes--; - switch (pLed->CurrLedState) { - case LED_BLINK_NORMAL: - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - case LED_BLINK_StartToBlink: - if (check_fwstate(pmlmepriv, _FW_LINKED) && check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - bStopBlinking = true; - if (check_fwstate(pmlmepriv, _FW_LINKED) && - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) - bStopBlinking = true; - else if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - case LED_BLINK_WPS: - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - default: - bStopBlinking = true; - break; - } - - if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) && !pLed->bLedOn) { - SwLedOn(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED) && pLed->bLedOn) { - SwLedOff(padapter, pLed); - } - pLed->BlinkTimes = 0; - pLed->bLedBlinkInProgress = false; - } else { - /* Assign LED state to toggle. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - /* Schedule a timer to toggle LED state. */ - switch (pLed->CurrLedState) { - case LED_BLINK_NORMAL: - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - break; - case LED_BLINK_SLOWLY: - case LED_BLINK_StartToBlink: - _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); - break; - case LED_BLINK_WPS: - _set_timer(&pLed->BlinkTimer, LED_BLINK_LONG_INTERVAL); - break; - default: - _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); - break; - } - } -} - static void SwLedBlink1(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; @@ -240,7 +142,6 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); } - pLed->BlinkTimes = 0; pLed->bLedBlinkInProgress = false; } else { if (pLed->bLedOn) @@ -283,421 +184,6 @@ static void SwLedBlink1(struct LED_871x *pLed) } } -static void SwLedBlink2(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - SwLedOn(padapter, pLed); - else - SwLedOff(padapter, pLed); - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - default: - break; - } -} - -static void SwLedBlink3(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); - } else { - if (pLed->CurrLedState != LED_BLINK_WPS_STOP) - SwLedOff(padapter, pLed); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - SwLedOn(padapter, pLed); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - SwLedOn(padapter, pLed); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_WPS: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - break; - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - bStopBlinking = false; - } else { - bStopBlinking = true; - } - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - } - pLed->bLedWPSBlinkInProgress = false; - } - break; - default: - break; - } -} - -static void SwLedBlink4(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &padapter->ledpriv; - struct LED_871x *pLed1 = &ledpriv->SwLed1; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - SwLedOn(padapter, pLed); - else - SwLedOff(padapter, pLed); - - if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) { - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed1); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SLOWLY: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); - break; - case LED_BLINK_StartToBlink: - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - } - break; - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = false; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - pLed->bLedNoLinkBlinkInProgress = false; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_WPS: - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - } - break; - case LED_BLINK_WPS_STOP: /* WPS authentication fail */ - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - break; - case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - if (pLed->bLedOn) - pLed->BlinkTimes = 1; - else - bStopBlinking = true; - } - - if (bStopBlinking) { - pLed->BlinkTimes = 10; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_LINK_INTERVAL_ALPHA); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - } - break; - default: - break; - } -} - -static void SwLedBlink5(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - SwLedOn(padapter, pLed); - else - SwLedOff(padapter, pLed); - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - - default: - break; - } -} - -static void SwLedBlink6(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - SwLedOn(padapter, pLed); - else - SwLedOff(padapter, pLed); -} - - /* ALPHA, added by chiyoko, 20090106 */ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) { struct led_priv *ledpriv = &padapter->ledpriv; @@ -902,662 +388,14 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct } } - /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ -static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &ledpriv->SwLed0; - - switch (LedAction) { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { - } else if (!pLed->bLedScanBlinkInProgress) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_LINK: - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - _set_timer(&pLed->BlinkTimer, 0); - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (!pLed->bLedWPSBlinkInProgress) { - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, 0); - } - break; - case LED_CTL_STOP_WPS: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, 0); - } - break; - case LED_CTL_STOP_WPS_FAIL: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, 0); - } - break; - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, 0); - } - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - _set_timer(&pLed->BlinkTimer, 0); - break; - default: - break; - } -} - - /* COREGA, added by chiyoko, 20090316 */ - static void SwLedControlMode3(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &ledpriv->SwLed0; - - switch (LedAction) { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { - } else if (!pLed->bLedScanBlinkInProgress) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_LINK: - if (IS_LED_WPS_BLINKING(pLed)) - return; - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - - _set_timer(&pLed->BlinkTimer, 0); - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (!pLed->bLedWPSBlinkInProgress) { - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_STOP_WPS: - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } else { - pLed->bLedWPSBlinkInProgress = true; - } - - pLed->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, 0); - } - break; - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, 0); - break; - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, 0); - } - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - _set_timer(&pLed->BlinkTimer, 0); - break; - default: - break; - } -} - - /* Edimax-Belkin, added by chiyoko, 20090413 */ -static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &ledpriv->SwLed0; - struct LED_871x *pLed1 = &ledpriv->SwLed1; - - switch (LedAction) { - case LED_CTL_START_TO_LINK: - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&pLed1->BlinkTimer); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&pLed->BlinkTimer, 0); - } - - if (!pLed->bLedStartToLinkBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - - pLed->bLedStartToLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_StartToBlink; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - } - } - break; - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - /* LED1 settings */ - if (LedAction == LED_CTL_LINK) { - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&pLed1->BlinkTimer); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&pLed->BlinkTimer, 0); - } - } - - if (!pLed->bLedNoLinkBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - break; - case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - } else if (!pLed->bLedScanBlinkInProgress) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if (!pLed->bLedBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&pLed1->BlinkTimer); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&pLed->BlinkTimer, 0); - } - - if (!pLed->bLedWPSBlinkInProgress) { - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - } - } - break; - case LED_CTL_STOP_WPS: /* WPS connect success */ - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - break; - case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&pLed1->BlinkTimer); - else - pLed1->bLedWPSBlinkInProgress = true; - pLed1->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed1->bLedOn) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - break; - case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&pLed1->BlinkTimer); - else - pLed1->bLedWPSBlinkInProgress = true; - pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; - pLed1->BlinkTimes = 10; - if (pLed1->bLedOn) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedStartToLinkBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedStartToLinkBlinkInProgress = false; - } - if (pLed1->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&pLed1->BlinkTimer); - pLed1->bLedWPSBlinkInProgress = false; - } - pLed1->BlinkingLedState = LED_UNKNOWN; - SwLedOff(padapter, pLed); - SwLedOff(padapter, pLed1); - break; - default: - break; - } -} - - /* Sercomm-Belkin, added by chiyoko, 20090415 */ -static void -SwLedControlMode5( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &ledpriv->SwLed0; - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_NO_LINK: - case LED_CTL_LINK: /* solid blue */ - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - - _set_timer(&pLed->BlinkTimer, 0); - break; - case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - } else if (!pLed->bLedScanBlinkInProgress) { - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if (!pLed->bLedBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN) - return; - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - SwLedOff(padapter, pLed); - break; - default: - break; - } -} - - /* WNC-Corega, added by chiyoko, 20090902 */ -static void -SwLedControlMode6( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct LED_871x *pLed0 = &ledpriv->SwLed0; - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - _cancel_timer_ex(&pLed0->BlinkTimer); - pLed0->CurrLedState = RTW_LED_ON; - pLed0->BlinkingLedState = RTW_LED_ON; - _set_timer(&pLed0->BlinkTimer, 0); - break; - case LED_CTL_POWER_OFF: - SwLedOff(padapter, pLed0); - break; - default: - break; - } -} - -/* */ -/* Description: */ -/* Handler function of LED Blinking. */ -/* We dispatch acture LED blink action according to LedStrategy. */ -/* */ void BlinkHandler(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &padapter->ledpriv; if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; - switch (ledpriv->LedStrategy) { - case SW_LED_MODE0: - SwLedBlink(pLed); - break; - case SW_LED_MODE1: - SwLedBlink1(pLed); - break; - case SW_LED_MODE2: - SwLedBlink2(pLed); - break; - case SW_LED_MODE3: - SwLedBlink3(pLed); - break; - case SW_LED_MODE4: - SwLedBlink4(pLed); - break; - case SW_LED_MODE5: - SwLedBlink5(pLed); - break; - case SW_LED_MODE6: - SwLedBlink6(pLed); - break; - default: - break; - } + SwLedBlink1(pLed); } void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) @@ -1585,28 +423,5 @@ void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) LedAction == LED_CTL_POWER_ON)) return; - switch (ledpriv->LedStrategy) { - case SW_LED_MODE0: - break; - case SW_LED_MODE1: - SwLedControlMode1(padapter, LedAction); - break; - case SW_LED_MODE2: - SwLedControlMode2(padapter, LedAction); - break; - case SW_LED_MODE3: - SwLedControlMode3(padapter, LedAction); - break; - case SW_LED_MODE4: - SwLedControlMode4(padapter, LedAction); - break; - case SW_LED_MODE5: - SwLedControlMode5(padapter, LedAction); - break; - case SW_LED_MODE6: - SwLedControlMode6(padapter, LedAction); - break; - default: - break; - } + SwLedControlMode1(padapter, LedAction); } diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 1115ff5d865a..8d14aff32f61 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -14,6 +14,7 @@ #include "../include/wlan_bssdef.h" #include "../include/rtw_ioctl_set.h" #include "../include/usb_osintf.h" +#include "../include/rtl8188e_dm.h" extern unsigned char MCS_rate_2R[16]; extern unsigned char MCS_rate_1R[16]; @@ -48,8 +49,8 @@ int _rtw_init_mlme_priv(struct adapter *padapter) pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ spin_lock_init(&pmlmepriv->lock); - _rtw_init_queue(&pmlmepriv->free_bss_pool); - _rtw_init_queue(&pmlmepriv->scanned_queue); + rtw_init_queue(&pmlmepriv->free_bss_pool); + rtw_init_queue(&pmlmepriv->scanned_queue); set_scanned_network_val(pmlmepriv, 0); @@ -88,7 +89,6 @@ static void rtw_mfree_mlme_priv_lock(struct mlme_priv *pmlmepriv) { } -#if defined(CONFIG_88EU_AP_MODE) static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) { kfree(*ppie); @@ -111,11 +111,6 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len); rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); } -#else -void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) -{ -} -#endif void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { @@ -130,42 +125,6 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) } -int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork) -{ - - if (!pnetwork) - goto exit; - - spin_lock_bh(&queue->lock); - - list_add_tail(&pnetwork->list, &queue->queue); - - spin_unlock_bh(&queue->lock); - -exit: - - return _SUCCESS; -} - -struct wlan_network *_rtw_dequeue_network(struct __queue *queue) -{ - struct wlan_network *pnetwork; - - spin_lock_bh(&queue->lock); - - if (list_empty(&queue->queue)) { - pnetwork = NULL; - } else { - pnetwork = container_of((&queue->queue)->next, struct wlan_network, list); - - list_del_init(&pnetwork->list); - } - - spin_unlock_bh(&queue->lock); - - return pnetwork; -} - struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *free_queue) */ { struct wlan_network *pnetwork; @@ -331,11 +290,6 @@ u16 rtw_get_capability(struct wlan_bssid_ex *bss) return le16_to_cpu(val); } -u8 *rtw_get_timestampe_from_ie(u8 *ie) -{ - return ie + 0; -} - u8 *rtw_get_beacon_interval_from_ie(u8 *ie) { return ie + 8; @@ -469,7 +423,7 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, u8 sq_final; long rssi_final; - rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */ + AntDivCompare8188E(padapter, dst, src); /* this will update src.Rssi, need consider again */ /* The rule below is 1/5 for sample value, 4/5 for history value */ if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&padapter->mlmepriv.cur_network.network, src)) { @@ -550,7 +504,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t /* If there are no more slots, expire the oldest */ pnetwork = oldest; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &target->PhyInfo.Optimum_antenna); + GetHalDefVar8188EUsb(adapter, HAL_DEF_CURRENT_ANTENNA, &target->PhyInfo.Optimum_antenna); memcpy(&pnetwork->network, target, get_wlan_bssid_ex_sz(target)); /* variable initialize */ pnetwork->fixed = false; @@ -573,7 +527,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t bssid_ex_sz = get_wlan_bssid_ex_sz(target); target->Length = bssid_ex_sz; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &target->PhyInfo.Optimum_antenna); + GetHalDefVar8188EUsb(adapter, HAL_DEF_CURRENT_ANTENNA, &target->PhyInfo.Optimum_antenna); memcpy(&pnetwork->network, target, bssid_ex_sz); pnetwork->last_scanned = jiffies; @@ -611,9 +565,7 @@ static void rtw_add_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) { -#if defined(CONFIG_88EU_P2P) rtw_wlan_bssid_ex_remove_p2p_attr(pnetwork, P2P_ATTR_GROUP_INFO); -#endif update_current_network(adapter, pnetwork); rtw_update_scanned_network(adapter, pnetwork); @@ -945,29 +897,6 @@ inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) rtw_os_indicate_scan_done(padapter, aborted); } -void rtw_scan_abort(struct adapter *adapter) -{ - u32 start; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - - start = jiffies; - pmlmeext->scan_abort = true; - while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) && - rtw_get_passing_time_ms(start) <= 200) { - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - break; - DBG_88E(FUNC_NDEV_FMT"fw_state=_FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev)); - msleep(20); - } - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { - if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) - DBG_88E(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); - rtw_indicate_scan_done(adapter, true); - } - pmlmeext->scan_abort = false; -} - static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, struct wlan_network *pnetwork) { int i; @@ -984,7 +913,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str psta->aid = pnetwork->join_res; psta->mac_id = 0; /* sta mode */ - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + rtl8188e_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); /* security related */ if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { padapter->securitypriv.binstallGrpkey = false; @@ -1200,24 +1129,20 @@ void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) static u8 search_max_mac_id(struct adapter *padapter) { u8 mac_id; -#if defined(CONFIG_88EU_AP_MODE) u8 aid; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; -#endif struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; -#if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = (pstapriv->max_num_sta); aid > 0; aid--) { if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; - } else -#endif - {/* adhoc id = 31~2 */ + } else { + /* adhoc id = 31~2 */ for (mac_id = (NUM_STA - 1); mac_id >= IBSS_START_MAC_ID; mac_id--) { if (pmlmeinfo->FW_sta_info[mac_id].status == 1) break; @@ -1237,11 +1162,10 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, return; macid = search_max_mac_id(adapter); - rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); + SetHwReg8188EU(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); /* MACID|OPMODE:1 connect */ media_status_rpt = (u16)((psta->mac_id << 8) | mstatus); - rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, - (u8 *)&media_status_rpt); + SetHwReg8188EU(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status_rpt); } void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) @@ -1255,14 +1179,12 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) if (!rtw_access_ctrl(adapter, pstassoc->macaddr)) return; -#if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta) rtw_indicate_sta_assoc_event(adapter, psta); return; } -#endif /* for AD-HOC mode */ psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta) @@ -1276,7 +1198,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) psta->mac_id = (uint)pstassoc->cam_id; DBG_88E("%s\n", __func__); /* for ad-hoc mode */ - rtw_hal_set_odm_var(adapter, HAL_ODM_STA_INFO, psta, true); + rtl8188e_SetHalODMVar(adapter, HAL_ODM_STA_INFO, psta, true); rtw_sta_media_status_rpt(adapter, psta, 1); if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; @@ -1323,7 +1245,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) u16 media_status; media_status = (mac_id << 8) | 0; /* MACID|OPMODE:0 means disconnect */ /* for STA, AP, ADHOC mode, report disconnect stauts to FW */ - rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + SetHwReg8188EU(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) @@ -1486,10 +1408,8 @@ void rtw_dynamic_check_timer_handlder(struct adapter *adapter) rtw_dynamic_chk_wk_cmd(adapter); if (pregistrypriv->wifi_spec == 1) { -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &adapter->wdinfo; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) -#endif { /* auto site survey */ rtw_auto_scan_handler(adapter); @@ -1618,10 +1538,10 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) rtw_free_assoc_resources(adapter, 0); } - rtw_hal_get_def_var(adapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(supp_ant_div)); + GetHalDefVar8188EUsb(adapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &supp_ant_div); if (supp_ant_div) { u8 cur_ant; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(cur_ant)); + GetHalDefVar8188EUsb(adapter, HAL_DEF_CURRENT_ANTENNA, &cur_ant); DBG_88E("#### Opt_Ant_(%s), cur_Ant(%s)\n", (2 == candidate->network.PhyInfo.Optimum_antenna) ? "A" : "B", (2 == cur_ant) ? "A" : "B" @@ -1690,8 +1610,6 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in goto exit; } - memset(psetkeyparm, 0, sizeof(struct setkey_parm)); - if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; else @@ -1722,6 +1640,8 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in psetkeyparm->grpkey = 1; break; default: + kfree(psetkeyparm); + kfree(pcmd); res = _FAIL; goto exit; } @@ -1959,10 +1879,10 @@ void rtw_joinbss_reset(struct adapter *padapter) threshold = 1; else threshold = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); + SetHwReg8188EU(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); } else { threshold = 1; - rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); + SetHwReg8188EU(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); } } @@ -2002,15 +1922,15 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_DSSSCCK40); - rtw_hal_get_def_var(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset); - rtw_hal_get_def_var(padapter, HAL_DEF_MAX_RECVBUF_SZ, &max_recvbuf_sz); + GetHalDefVar8188EUsb(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset); + GetHalDefVar8188EUsb(padapter, HAL_DEF_MAX_RECVBUF_SZ, &max_recvbuf_sz); /* AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k AMPDU_para [4:2]:Min MPDU Start Spacing */ - rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); + GetHalDefVar8188EUsb(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); ht_capie.ampdu_params_info = (max_rx_ampdu_factor & 0x03); if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) @@ -2081,7 +2001,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) int i; u8 rf_type; - padapter->HalFunc.GetHwRegHandler(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + GetHwReg8188EU(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); /* update the MCS rates */ for (i = 0; i < 16; i++) { diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 5a472a4954b0..55c3d4a6faeb 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -10,6 +10,9 @@ #include "../include/wlan_bssdef.h" #include "../include/mlme_osdep.h" #include "../include/recv_osdep.h" +#include "../include/rtl8188e_sreset.h" +#include "../include/rtl8188e_xmit.h" +#include "../include/rtl8188e_dm.h" static struct mlme_handler mlme_sta_tbl[] = { {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, @@ -362,9 +365,7 @@ int init_mlme_ext_priv(struct adapter *padapter) init_mlme_ext_timer(padapter); -#ifdef CONFIG_88EU_AP_MODE init_mlme_ap_info(padapter); -#endif pmlmeext->max_chan_nums = init_channel_set(padapter, pmlmepriv->ChannelPlan, pmlmeext->channel_set); init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); @@ -393,13 +394,12 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) { - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 *pframe = precv_frame->rx_data; if (ptable->func) { /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + !is_broadcast_ether_addr(GetAddr1Ptr(pframe))) return; ptable->func(padapter, precv_frame); } @@ -409,10 +409,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) { int index; struct mlme_handler *ptable; -#ifdef CONFIG_88EU_AP_MODE struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#endif /* CONFIG_88EU_AP_MODE */ - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 *pframe = precv_frame->rx_data; struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); @@ -421,7 +418,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + !is_broadcast_ether_addr(GetAddr1Ptr(pframe))) return; ptable = mlme_sta_tbl; @@ -443,7 +440,6 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num; } -#ifdef CONFIG_88EU_AP_MODE switch (GetFrameSubType(pframe)) { case WIFI_AUTH: if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) @@ -453,17 +449,8 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) fallthrough; case WIFI_ASSOCREQ: case WIFI_REASSOCREQ: - _mgt_dispatcher(padapter, ptable, precv_frame); - break; case WIFI_PROBEREQ: - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - _mgt_dispatcher(padapter, ptable, precv_frame); - else - _mgt_dispatcher(padapter, ptable, precv_frame); - break; case WIFI_BEACON: - _mgt_dispatcher(padapter, ptable, precv_frame); - break; case WIFI_ACTION: _mgt_dispatcher(padapter, ptable, precv_frame); break; @@ -473,12 +460,8 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) rtw_hostapd_mlme_rx(padapter, precv_frame); break; } -#else - _mgt_dispatcher(padapter, ptable, precv_frame); -#endif } -#ifdef CONFIG_88EU_P2P static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da) { bool response = true; @@ -492,7 +475,6 @@ static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da) return _SUCCESS; } -#endif /* CONFIG_88EU_P2P */ /**************************************************************************** @@ -512,7 +494,6 @@ unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame uint len = precv_frame->len; u8 is_valid_p2p_probereq = false; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 wifi_test_chk_rate = 1; @@ -547,7 +528,6 @@ unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame } _continue: -#endif /* CONFIG_88EU_P2P */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) return _SUCCESS; @@ -581,12 +561,9 @@ _issue_probersp: unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 *pframe = precv_frame->rx_data; -#endif -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { if (pwdinfo->tx_prov_disc_info.benable) { if (!memcmp(pwdinfo->tx_prov_disc_info.peerIFAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { @@ -621,8 +598,6 @@ unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame } } } -#endif - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { report_survey_event(padapter, precv_frame); return _SUCCESS; @@ -723,7 +698,6 @@ _END_ONBEACON_: unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_88EU_AP_MODE unsigned int auth_mode, ie_len; u16 seq; unsigned char *sa, *p; @@ -867,9 +841,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) /* Now, we are going to issue_auth... */ pstat->auth_seq = seq + 1; -#ifdef CONFIG_88EU_AP_MODE issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_)); -#endif if (pstat->state & WIFI_FW_AUTH_SUCCESS) pstat->auth_seq = 0; @@ -886,11 +858,7 @@ auth_fail: pstat->auth_seq = 2; memcpy(pstat->hwaddr, sa, 6); -#ifdef CONFIG_88EU_AP_MODE issue_auth(padapter, pstat, (unsigned short)status); -#endif - -#endif return _FAIL; } @@ -971,7 +939,6 @@ authclnt_fail: unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_88EU_AP_MODE u16 capab_info; struct rtw_ieee802_11_elems elems; struct sta_info *pstat; @@ -990,12 +957,10 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->rx_data; uint pkt_len = precv_frame->len; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 p2p_status_code = P2P_STATUS_SUCCESS; u8 *p2pie; u32 p2pielen = 0; -#endif /* CONFIG_88EU_P2P */ if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -1319,7 +1284,6 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame if (status != _STATS_SUCCESSFUL_) goto OnAssocReqFail; -#ifdef CONFIG_88EU_P2P pstat->is_p2p_device = false; if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, pkt_len - WLAN_HDR_A3_LEN - ie_offset, NULL, &p2pielen); @@ -1334,7 +1298,6 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame } } pstat->p2p_status_code = p2p_status_code; -#endif /* CONFIG_88EU_P2P */ /* TODO: identify_proprietary_vendor_ie(); */ /* Realtek proprietary IE */ @@ -1385,7 +1348,6 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame /* now the station is qualified to join our BSS... */ if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { -#ifdef CONFIG_88EU_AP_MODE /* 1 bss_cap_update & sta_info_update */ bss_cap_update_on_sta_join(padapter, pstat); sta_info_update(padapter, pstat); @@ -1402,30 +1364,23 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame /* 3-(1) report sta add event */ report_add_sta_event(padapter, pstat->hwaddr, pstat->aid); -#endif } return _SUCCESS; asoc_class2_error: -#ifdef CONFIG_88EU_AP_MODE issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status); -#endif return _FAIL; OnAssocReqFail: -#ifdef CONFIG_88EU_AP_MODE pstat->aid = 0; if (frame_type == WIFI_ASSOCREQ) issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); else issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); -#endif - -#endif /* CONFIG_88EU_AP_MODE */ return _FAIL; } @@ -1527,26 +1482,21 @@ unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->rx_data; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ /* check A3 */ if (!(!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) return _SUCCESS; -#ifdef CONFIG_88EU_P2P if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); } -#endif /* CONFIG_88EU_P2P */ reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); DBG_88E("%s Reason code(%d)\n", __func__, reason); -#ifdef CONFIG_88EU_AP_MODE if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1570,9 +1520,7 @@ unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) } return _SUCCESS; - } else -#endif - { + } else { int ignore_received_deauth = 0; /* Before sending the auth frame to start the STA/GC mode connection with AP/GO, @@ -1607,26 +1555,21 @@ unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->rx_data; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ /* check A3 */ if (!(!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) return _SUCCESS; -#ifdef CONFIG_88EU_P2P if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); } -#endif /* CONFIG_88EU_P2P */ reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); DBG_88E("%s Reason code(%d)\n", __func__, reason); -#ifdef CONFIG_88EU_AP_MODE if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1650,9 +1593,7 @@ unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame } return _SUCCESS; - } else -#endif - { + } else { DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", reason, GetAddr3Ptr(pframe)); @@ -1794,8 +1735,6 @@ unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_fr return _SUCCESS; } -#ifdef CONFIG_88EU_P2P - static int get_reg_classes_full_count(struct p2p_channels *channel_list) { int cnt = 0; @@ -3472,7 +3411,6 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) unsigned char *mac; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; u16 wpsielen = 0, p2pielen = 0; @@ -3506,8 +3444,8 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) memcpy(pwlanhdr->addr3, pwdinfo->p2p_peer_interface_addr, ETH_ALEN); } else { /* broadcast probe request frame */ - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); + eth_broadcast_addr(pwlanhdr->addr1); + eth_broadcast_addr(pwlanhdr->addr3); } } memcpy(pwlanhdr->addr2, mac, ETH_ALEN); @@ -3751,45 +3689,6 @@ inline void issue_probereq_p2p(struct adapter *adapter, u8 *da) _issue_probereq_p2p(adapter, da, false); } -int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, int wait_ms) -{ - int ret; - int i = 0; - u32 start = jiffies; - - do { - ret = _issue_probereq_p2p(adapter, da, wait_ms > 0); - - i++; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - msleep(wait_ms); - } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); - - if (ret != _FAIL) { - ret = _SUCCESS; - goto exit; - } - - if (try_cnt && wait_ms) { - if (da) - DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(adapter), da, rtw_get_oper_ch(adapter), - ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); - else - DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(adapter), rtw_get_oper_ch(adapter), - ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); - } -exit: - return ret; -} - -#endif /* CONFIG_88EU_P2P */ - static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { struct adapter *adapter = recv_frame->adapter; @@ -3827,7 +3726,6 @@ static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) u8 *pframe = precv_frame->rx_data; u8 *frame_body; u8 dialogToken = 0; -#ifdef CONFIG_88EU_P2P struct adapter *padapter = precv_frame->adapter; uint len = precv_frame->len; u8 *p2p_ie; @@ -3835,7 +3733,6 @@ static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 result = P2P_STATUS_SUCCESS; u8 empty_addr[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -#endif /* CONFIG_88EU_P2P */ frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); @@ -3844,7 +3741,6 @@ static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) return _FAIL; -#ifdef CONFIG_88EU_P2P _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); /* Do nothing if the driver doesn't enable the P2P function. */ if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) @@ -4107,7 +4003,6 @@ static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); break; } -#endif /* CONFIG_88EU_P2P */ return _SUCCESS; } @@ -4184,7 +4079,6 @@ unsigned int OnAction_wmm(struct adapter *padapter, struct recv_frame *precv_fra unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_88EU_P2P u8 *frame_body; u8 category, OUI_Subtype; u8 *pframe = precv_frame->rx_data; @@ -4222,7 +4116,6 @@ unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_fra default: break; } -#endif /* CONFIG_88EU_P2P */ return _SUCCESS; } @@ -4327,7 +4220,7 @@ void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; - rtw_hal_mgnt_xmit(padapter, pmgntframe); + rtl8188eu_mgnt_xmit(padapter, pmgntframe); } s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms) @@ -4342,7 +4235,7 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntfr rtw_sctx_init(&sctx, timeout_ms); pxmitbuf->sctx = &sctx; - ret = rtw_hal_mgnt_xmit(padapter, pmgntframe); + ret = rtl8188eu_mgnt_xmit(padapter, pmgntframe); if (ret == _SUCCESS) ret = rtw_sctx_wait(&sctx); @@ -4359,16 +4252,16 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return -1; - _enter_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + mutex_lock(&pxmitpriv->ack_tx_mutex); pxmitpriv->ack_tx = true; pmgntframe->ack_report = 1; - if (rtw_hal_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) { + if (rtl8188eu_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) { ret = rtw_ack_tx_wait(pxmitpriv, timeout_ms); } pxmitpriv->ack_tx = false; - _exit_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + mutex_unlock(&pxmitpriv->ack_tx_mutex); return ret; } @@ -4419,19 +4312,14 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) { DBG_88E("%s, alloc mgnt frame fail\n", __func__); return; } -#if defined(CONFIG_88EU_AP_MODE) spin_lock_bh(&pmlmepriv->bcn_update_lock); -#endif /* if defined (CONFIG_88EU_AP_MODE) */ /* update attribute */ pattrib = &pmgntframe->attrib; @@ -4446,7 +4334,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + eth_broadcast_addr(pwlanhdr->addr1); memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); @@ -4458,7 +4346,6 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { -#ifdef CONFIG_88EU_P2P /* for P2P : Primary Device Type & Device Name */ u32 wpsielen = 0, insert_len = 0; u8 *wpsie = NULL; @@ -4523,9 +4410,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) memcpy(pframe, premainder_ie, remainder_ielen); pframe += remainder_ielen; pattrib->pktlen += remainder_ielen; - } else -#endif /* CONFIG_88EU_P2P */ - { + } else { int len_diff; memcpy(pframe, cur_network->IEs, cur_network->IELength); len_diff = update_hidden_ssid( @@ -4551,7 +4436,6 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS); } -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { u32 len; len = build_beacon_p2p_ie(pwdinfo, pframe); @@ -4559,7 +4443,6 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pframe += len; pattrib->pktlen += len; } -#endif /* CONFIG_88EU_P2P */ goto _issue_bcn; } @@ -4611,11 +4494,9 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* todo:HT for adhoc */ _issue_bcn: -#if defined(CONFIG_88EU_AP_MODE) pmlmepriv->update_bcn = false; spin_unlock_bh(&pmlmepriv->bcn_update_lock); -#endif /* if defined (CONFIG_88EU_AP_MODE) */ if ((pattrib->pktlen + TXDESC_SIZE) > 512) { DBG_88E("beacon frame too large\n"); @@ -4640,18 +4521,14 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p __le16 *fctrl; unsigned char *mac, *bssid; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; -#if defined(CONFIG_88EU_AP_MODE) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#endif /* if defined (CONFIG_88EU_AP_MODE) */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; unsigned int rate_len; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) { @@ -4688,7 +4565,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p if (cur_network->IELength > MAX_IE_SZ) return; -#if defined(CONFIG_88EU_AP_MODE) if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { pwps_ie = rtw_get_wps_ie(cur_network->IEs + _FIXED_IE_LENGTH_, cur_network->IELength - _FIXED_IE_LENGTH_, NULL, &wps_ielen); @@ -4724,9 +4600,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe += cur_network->IELength; pattrib->pktlen += cur_network->IELength; } - } else -#endif - { + } else { /* timestamp will be inserted by hardware */ pframe += 8; pattrib->pktlen += 8; @@ -4775,7 +4649,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* todo:HT for adhoc */ } -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && is_valid_p2p_probereq) { u32 len; len = build_probe_resp_p2p_ie(pwdinfo, pframe); @@ -4783,7 +4656,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe += len; pattrib->pktlen += len; } -#endif /* CONFIG_88EU_P2P */ pattrib->last_txcmdsz = pattrib->pktlen; @@ -4804,7 +4676,6 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; int bssrate_len = 0; - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -4830,8 +4701,8 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps memcpy(pwlanhdr->addr3, da, ETH_ALEN); } else { /* broadcast probe request frame */ - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); + eth_broadcast_addr(pwlanhdr->addr1); + eth_broadcast_addr(pwlanhdr->addr3); } memcpy(pwlanhdr->addr2, mac, ETH_ALEN); @@ -4931,9 +4802,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short __le16 *fctrl; unsigned int val32; u16 val16; -#ifdef CONFIG_88EU_AP_MODE __le16 le_val16; -#endif int use_shared_key = 0; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -4963,8 +4832,6 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); if (psta) {/* for AP mode */ -#ifdef CONFIG_88EU_AP_MODE - memcpy(pwlanhdr->addr1, psta->hwaddr, ETH_ALEN); memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); @@ -4997,7 +4864,6 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short /* added challenging text... */ if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &pattrib->pktlen); -#endif } else { __le32 le_tmp32; __le16 le_tmp16; @@ -5049,14 +4915,13 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short pattrib->last_txcmdsz = pattrib->pktlen; - rtw_wep_encrypt(padapter, (u8 *)pmgntframe); + rtw_wep_encrypt(padapter, pmgntframe); DBG_88E("%s\n", __func__); dump_mgntframe(padapter, pmgntframe); } void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) { -#ifdef CONFIG_88EU_AP_MODE struct xmit_frame *pmgntframe; struct rtw_ieee80211_hdr *pwlanhdr; struct pkt_attrib *pattrib; @@ -5070,9 +4935,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; u8 *ie = pnetwork->IEs; __le16 lestatus, leval; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ DBG_88E("%s\n", __func__); @@ -5175,7 +5038,6 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len; } -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && (pstat->is_p2p_device)) { u32 len; @@ -5184,10 +5046,8 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i pframe += len; pattrib->pktlen += len; } -#endif /* CONFIG_88EU_P2P */ pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); -#endif } void issue_assocreq(struct adapter *padapter) @@ -5208,11 +5068,9 @@ void issue_assocreq(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int bssrate_len = 0, sta_bssrate_len = 0; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 p2pie[255] = { 0x00 }; u16 p2pielen = 0; -#endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -5327,7 +5185,7 @@ void issue_assocreq(struct adapter *padapter) /* todo: disable SM power save mode */ pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x000c); - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + GetHwReg8188EU(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); switch (rf_type) { case RF_1T1R: if (pregpriv->rx_stbc) @@ -5378,8 +5236,6 @@ void issue_assocreq(struct adapter *padapter) if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen); -#ifdef CONFIG_88EU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) { /* Should add the P2P IE in the association request frame. */ /* P2P OUI */ @@ -5507,8 +5363,6 @@ void issue_assocreq(struct adapter *padapter) pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); } -#endif /* CONFIG_88EU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); @@ -5678,9 +5532,6 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) SetToDs(fctrl); - if (pattrib->mdata) - SetMData(fctrl); - qc = (unsigned short *)(pframe + pattrib->hdrlen - 2); SetPriority(qc, tid); @@ -5770,16 +5621,12 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int ret = _FAIL; __le16 le_tmp; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ -#ifdef CONFIG_88EU_P2P if (!(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) && (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); } -#endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -5869,65 +5716,6 @@ exit: return ret; } -void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct rtw_ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - DBG_88E(FUNC_NDEV_FMT" ra =%pM, ch:%u, offset:%u\n", - FUNC_NDEV_ARG(padapter->pnetdev), ra, new_ch, ch_offset); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_ctl; - *(fctrl) = 0; - - memcpy(pwlanhdr->addr1, ra, ETH_ALEN); /* RA */ - memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); /* TA */ - memcpy(pwlanhdr->addr3, ra, ETH_ALEN); /* DA = RA */ - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - - /* category, action */ - { - u8 category, action; - category = RTW_WLAN_CATEGORY_SPECTRUM_MGMT; - action = RTW_WLAN_ACTION_SPCT_CHL_SWITCH; - - pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); - } - - pframe = rtw_set_ie_ch_switch(pframe, &pattrib->pktlen, 0, new_ch, 0); - pframe = rtw_set_ie_secondary_ch_offset(pframe, &pattrib->pktlen, - hal_ch_offset_to_secondary_ch_offset(ch_offset)); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); -} - void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status) { u8 category = RTW_WLAN_CATEGORY_BACK; @@ -6016,7 +5804,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen); pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen); BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f; - rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); + GetHalDefVar8188EUsb(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); switch (max_rx_ampdu_factor) { case MAX_AMPDU_FACTOR_64K: BA_para_set |= 0x1000; /* 64 buffer size */ @@ -6240,13 +6028,13 @@ unsigned int send_beacon(struct adapter *padapter) u32 start = jiffies; - rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); + SetHwReg8188EU(padapter, HW_VAR_BCN_VALID, NULL); do { issue_beacon(padapter, 100); issue++; do { yield(); - rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); + GetHwReg8188EU(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); poll++; } while ((poll % 10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); } while (!bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); @@ -6278,8 +6066,6 @@ void site_survey(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u32 initialgain = 0; - -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) { @@ -6299,9 +6085,7 @@ void site_survey(struct adapter *padapter) ScanType = pmlmeext->channel_set[ch_set_idx].ScanType; else ScanType = SCAN_ACTIVE; - } else -#endif /* CONFIG_88EU_P2P */ - { + } else { struct rtw_ieee80211_channel *ch; if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) { ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; @@ -6311,25 +6095,18 @@ void site_survey(struct adapter *padapter) } if (survey_channel != 0) { - /* PAUSE 4-AC Queue when site_survey */ - /* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ - /* val8 |= 0x0f; */ - /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ if (pmlmeext->sitesurvey_res.channel_idx == 0) set_channel_bwmode(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); else SelectChannel(padapter, survey_channel); if (ScanType == SCAN_ACTIVE) { /* obey the channel plan setting... */ - #ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) { issue_probereq_p2p(padapter, NULL); issue_probereq_p2p(padapter, NULL); issue_probereq_p2p(padapter, NULL); - } else - #endif /* CONFIG_88EU_P2P */ - { + } else { int i; for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { @@ -6352,8 +6129,6 @@ void site_survey(struct adapter *padapter) set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); } else { /* channel number is 0 or this channel is not valid. */ - -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) { if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) { /* Set the find_phase_state_exchange_cnt to P2P_FINDPHASE_EX_CNT. */ @@ -6369,51 +6144,41 @@ void site_survey(struct adapter *padapter) pmlmeext->sitesurvey_res.state = SCAN_DISABLE; initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + SetHwReg8188EU(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); /* turn on dynamic functions */ Restore_DM_Func_Flag(padapter); /* Switch_DM_Func(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ _set_timer(&pwdinfo->find_phase_timer, (u32)((u32)(pwdinfo->listen_dwell) * 100)); - } else -#endif /* CONFIG_88EU_P2P */ - { + } else { /* 20100721:Interrupt scan operation here. */ /* For SW antenna diversity before link, it needs to switch to another antenna and scan again. */ /* It compares the scan result and select beter one to do connection. */ - if (rtw_hal_antdiv_before_linked(padapter)) { + if (AntDivBeforeLink8188E(padapter)) { pmlmeext->sitesurvey_res.bss_cnt = 0; pmlmeext->sitesurvey_res.channel_idx = -1; pmlmeext->chan_scan_time = SURVEY_TO / 2; set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); return; } -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); -#endif /* CONFIG_88EU_P2P */ pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; /* switch back to the original channel */ -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); else set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); -#endif /* CONFIG_88EU_P2P */ - - /* flush 4-AC Queue after site_survey */ - /* val8 = 0; */ - /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ /* config MSR */ Set_MSR(padapter, (pmlmeinfo->state & 0x3)); initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + SetHwReg8188EU(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); /* turn on dynamic functions */ Restore_DM_Func_Flag(padapter); /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ @@ -6422,7 +6187,7 @@ void site_survey(struct adapter *padapter) issue_nulldata(padapter, NULL, 0, 3, 500); val8 = 0; /* survey done */ - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); report_surveydone_event(padapter); @@ -6487,7 +6252,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st bssid->Rssi = precv_frame->attrib.phy_info.recvpower; /* in dBM.raw data */ bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ - rtw_hal_get_def_var(padapter, HAL_DEF_CURRENT_ANTENNA, &bssid->PhyInfo.Optimum_antenna); + GetHalDefVar8188EUsb(padapter, HAL_DEF_CURRENT_ANTENNA, &bssid->PhyInfo.Optimum_antenna); /* checking SSID */ p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset); @@ -6615,7 +6380,7 @@ void start_create_ibss(struct adapter *padapter) update_capinfo(padapter, caps); if (caps & cap_IBSS) {/* adhoc master */ val8 = 0xcf; - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); /* switch channel */ /* SelectChannel(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */ @@ -6632,9 +6397,9 @@ void start_create_ibss(struct adapter *padapter) report_join_res(padapter, -1); pmlmeinfo->state = WIFI_FW_NULL_STATE; } else { - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); + SetHwReg8188EU(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); join_type = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + SetHwReg8188EU(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); report_join_res(padapter, 1); pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; @@ -6671,7 +6436,7 @@ void start_clnt_join(struct adapter *padapter) val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); /* switch channel */ set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); @@ -6688,7 +6453,7 @@ void start_clnt_join(struct adapter *padapter) Set_MSR(padapter, WIFI_FW_ADHOC_STATE); val8 = 0xcf; - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); /* switch channel */ set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); @@ -7225,8 +6990,8 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) if (join_res < 0) { join_type = 1; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + SetHwReg8188EU(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + SetHwReg8188EU(padapter, HW_VAR_BSSID, null_addr); /* restore to initial setting. */ update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); @@ -7250,10 +7015,10 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) /* update IOT-releated issue */ update_IOT_info(padapter); - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); + SetHwReg8188EU(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); /* BCN interval */ - rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); + SetHwReg8188EU(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); /* udpate capability */ update_capinfo(padapter, pmlmeinfo->capability); @@ -7274,13 +7039,13 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) /* set per sta rate after updating HT cap. */ set_sta_rate(padapter, psta); - rtw_hal_set_hwreg(padapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&psta->mac_id); + SetHwReg8188EU(padapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&psta->mac_id); media_status = (psta->mac_id << 8) | 1; /* MACID|OPMODE: 1 means connect */ - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + SetHwReg8188EU(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } join_type = 2; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + SetHwReg8188EU(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) { /* correcting TSF */ @@ -7318,7 +7083,7 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p } join_type = 2; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + SetHwReg8188EU(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); } pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; @@ -7336,8 +7101,8 @@ void mlmeext_sta_del_event_callback(struct adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (is_client_associated_to_ap(padapter) || is_IBSS_empty(padapter)) { - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + SetHwReg8188EU(padapter, HW_VAR_MLME_DISCONNECT, NULL); + SetHwReg8188EU(padapter, HW_VAR_BSSID, null_addr); /* restore to initial setting. */ update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); @@ -7378,9 +7143,9 @@ void _linked_rx_signal_strehgth_display(struct adapter *padapter) else if ((pmlmeinfo->state & 0x03) == _HW_STATE_AP_) mac_id = 2; - rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &mac_id); + GetHalDefVar8188EUsb(padapter, HW_DEF_RA_INFO_DUMP, &mac_id); - rtw_hal_get_def_var(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); + GetHalDefVar8188EUsb(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); DBG_88E("UndecoratedSmoothedPWDB:%d\n", UndecoratedSmoothedPWDB); } @@ -7412,7 +7177,7 @@ void linked_status_chk(struct adapter *padapter) if (padapter->bRxRSSIDisplay) _linked_rx_signal_strehgth_display(padapter); - rtw_hal_sreset_linked_status_check(padapter); + rtl8188e_sreset_linked_status_check(padapter); if (is_client_associated_to_ap(padapter)) { /* linked infrastructure client mode */ @@ -7424,9 +7189,7 @@ void linked_status_chk(struct adapter *padapter) psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); if (psta) { bool is_p2p_enable = false; - #ifdef CONFIG_88EU_P2P is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE); - #endif if (!chk_ap_is_alive(padapter, psta)) rx_chk = _FAIL; @@ -7524,9 +7287,7 @@ void survey_timer_hdl(struct adapter *padapter) struct sitesurvey_parm *psurveyPara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* issue rtw_sitesurvey_cmd */ if (pmlmeext->sitesurvey_res.state > SCAN_START) { @@ -7534,7 +7295,6 @@ void survey_timer_hdl(struct adapter *padapter) pmlmeext->sitesurvey_res.channel_idx++; if (pmlmeext->scan_abort) { - #ifdef CONFIG_88EU_P2P if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE)) { rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); pmlmeext->sitesurvey_res.channel_idx = 3; @@ -7542,9 +7302,7 @@ void survey_timer_hdl(struct adapter *padapter) , pmlmeext->sitesurvey_res.channel_idx , pwdinfo->find_phase_state_exchange_cnt ); - } else - #endif - { + } else { pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; DBG_88E("%s idx:%d\n", __func__ , pmlmeext->sitesurvey_res.channel_idx @@ -7647,8 +7405,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) type = _HW_STATE_NOLINK_; } - rtw_hal_set_hwreg(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); - /* Set_NETYPE0_MSR(padapter, type); */ + SetHwReg8188EU(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); return H2C_SUCCESS; } @@ -7662,13 +7419,10 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) /* u32 initialgain; */ if (pparm->network.InfrastructureMode == Ndis802_11APMode) { -#ifdef CONFIG_88EU_AP_MODE - if (pmlmeinfo->state == WIFI_FW_AP_STATE) { /* todo: */ return H2C_SUCCESS; } -#endif } /* below is for ad-hoc master */ @@ -7689,10 +7443,6 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) Save_DM_Func_Flag(padapter); Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); - /* config the initial gain under linking, need to write the BB registers */ - /* initialgain = 0x1E; */ - /* rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - /* cancel link timer */ _cancel_timer_ex(&pmlmeext->link_timer); @@ -7739,7 +7489,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) /* set MSR to nolink -> infra. mode */ Set_MSR(padapter, _HW_STATE_STATION_); - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); + SetHwReg8188EU(padapter, HW_VAR_MLME_DISCONNECT, NULL); } rtw_antenna_select_cmd(padapter, pparm->network.PhyInfo.Optimum_antenna, false); @@ -7814,9 +7564,9 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) /* config the initial gain under linking, need to write the BB registers */ - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); + SetHwReg8188EU(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); join_type = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + SetHwReg8188EU(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); /* cancel link timer */ _cancel_timer_ex(&pmlmeext->link_timer); @@ -7837,8 +7587,8 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) if (is_client_associated_to_ap(padapter)) issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms / 100, 100); - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + SetHwReg8188EU(padapter, HW_VAR_MLME_DISCONNECT, NULL); + SetHwReg8188EU(padapter, HW_VAR_BSSID, null_addr); /* restore to initial setting. */ update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); @@ -7846,7 +7596,7 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { /* Stop BCN */ val8 = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); } /* set MSR to no link state -> infra. mode */ @@ -7919,14 +7669,10 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) u8 val8; u32 initialgain; u32 i; - -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { /* for first time sitesurvey_cmd */ - rtw_hal_set_hwreg(padapter, HW_VAR_CHECK_TXBUF, NULL); pmlmeext->sitesurvey_res.state = SCAN_START; pmlmeext->sitesurvey_res.bss_cnt = 0; @@ -7969,22 +7715,18 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); /* config the initial gain under scanning, need to write the BB registers */ -#ifdef CONFIG_88EU_P2P if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) initialgain = 0x1E; else initialgain = 0x28; -#else /* CONFIG_88EU_P2P */ - initialgain = 0x1E; -#endif /* CONFIG_88EU_P2P */ - rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + SetHwReg8188EU(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); /* set MSR to no link state */ Set_MSR(padapter, _HW_STATE_NOLINK_); val8 = 1; /* under site survey */ - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); pmlmeext->sitesurvey_res.state = SCAN_PROCESS; } @@ -8208,9 +7950,8 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) if (send_beacon(padapter) == _FAIL) { DBG_88E("issue_beacon, fail!\n"); return H2C_PARAMETERS_ERROR; - } -#ifdef CONFIG_88EU_AP_MODE - else { /* tx bc/mc frames after update TIM */ + } else { + /* tx bc/mc frames after update TIM */ struct sta_info *psta_bmc; struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; @@ -8246,14 +7987,13 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) pxmitframe->attrib.qsel = 0x11;/* HIQ */ spin_unlock_bh(&psta_bmc->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe)) + if (rtl8188eu_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); spin_lock_bh(&psta_bmc->sleep_q.lock); } spin_unlock_bh(&psta_bmc->sleep_q.lock); } } -#endif return H2C_SUCCESS; } diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c deleted file mode 100644 index dabdd0406f30..000000000000 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ /dev/null @@ -1,935 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#define _RTW_MP_C_ - -#include "../include/drv_types.h" -#include "../include/odm_precomp.h" -#include "../include/rtl8188e_hal.h" - -u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask) -{ - return rtw_hal_read_bbreg(padapter, addr, bitmask); -} - -void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val) -{ - rtw_hal_write_bbreg(padapter, addr, bitmask, val); -} - -u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask) -{ - return rtw_hal_read_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bitmask); -} - -void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val) -{ - rtw_hal_write_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bitmask, val); -} - -u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr) -{ - return _read_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bRFRegOffsetMask); -} - -void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val) -{ - _write_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bRFRegOffsetMask, val); -} - -static void _init_mp_priv_(struct mp_priv *pmp_priv) -{ - struct wlan_bssid_ex *pnetwork; - - memset(pmp_priv, 0, sizeof(struct mp_priv)); - - pmp_priv->mode = MP_OFF; - - pmp_priv->channel = 1; - pmp_priv->bandwidth = HT_CHANNEL_WIDTH_20; - pmp_priv->prime_channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pmp_priv->rateidx = MPT_RATE_1M; - pmp_priv->txpoweridx = 0x2A; - - pmp_priv->antenna_tx = ANTENNA_A; - pmp_priv->antenna_rx = ANTENNA_AB; - - pmp_priv->check_mp_pkt = 0; - - pmp_priv->tx_pktcount = 0; - - pmp_priv->rx_pktcount = 0; - pmp_priv->rx_crcerrpktcount = 0; - - pmp_priv->network_macaddr[0] = 0x00; - pmp_priv->network_macaddr[1] = 0xE0; - pmp_priv->network_macaddr[2] = 0x4C; - pmp_priv->network_macaddr[3] = 0x87; - pmp_priv->network_macaddr[4] = 0x66; - pmp_priv->network_macaddr[5] = 0x55; - - pnetwork = &pmp_priv->mp_network.network; - memcpy(pnetwork->MacAddress, pmp_priv->network_macaddr, ETH_ALEN); - - pnetwork->Ssid.SsidLength = 8; - memcpy(pnetwork->Ssid.Ssid, "mp_871x", pnetwork->Ssid.SsidLength); -} - -static void mp_init_xmit_attrib(struct mp_tx *pmptx, struct adapter *padapter) -{ - struct pkt_attrib *pattrib; - struct tx_desc *desc; - - /* init xmitframe attribute */ - pattrib = &pmptx->attrib; - memset(pattrib, 0, sizeof(struct pkt_attrib)); - desc = &pmptx->desc; - memset(desc, 0, TXDESC_SIZE); - - pattrib->ether_type = 0x8712; - memset(pattrib->dst, 0xFF, ETH_ALEN); - pattrib->ack_policy = 0; - pattrib->hdrlen = WLAN_HDR_A3_LEN; - pattrib->subtype = WIFI_DATA; - pattrib->priority = 0; - pattrib->qsel = pattrib->priority; - pattrib->nr_frags = 1; - pattrib->encrypt = 0; - pattrib->bswenc = false; - pattrib->qos_en = false; -} - -s32 init_mp_priv(struct adapter *padapter) -{ - struct mp_priv *pmppriv = &padapter->mppriv; - - _init_mp_priv_(pmppriv); - pmppriv->papdater = padapter; - - pmppriv->tx.stop = 1; - mp_init_xmit_attrib(&pmppriv->tx, padapter); - - switch (padapter->registrypriv.rf_config) { - case RF_1T1R: - pmppriv->antenna_tx = ANTENNA_A; - pmppriv->antenna_rx = ANTENNA_A; - break; - case RF_1T2R: - default: - pmppriv->antenna_tx = ANTENNA_A; - pmppriv->antenna_rx = ANTENNA_AB; - break; - case RF_2T2R: - case RF_2T2R_GREEN: - pmppriv->antenna_tx = ANTENNA_AB; - pmppriv->antenna_rx = ANTENNA_AB; - break; - case RF_2T4R: - pmppriv->antenna_tx = ANTENNA_AB; - pmppriv->antenna_rx = ANTENNA_ABCD; - break; - } - - return _SUCCESS; -} - -void free_mp_priv(struct mp_priv *pmp_priv) -{ - kfree(pmp_priv->pallocated_mp_xmitframe_buf); - pmp_priv->pallocated_mp_xmitframe_buf = NULL; - pmp_priv->pmp_xmtframe_buf = NULL; -} - -#define PHY_IQCalibrate(a, b) PHY_IQCalibrate_8188E(a, b) -#define PHY_LCCalibrate(a) PHY_LCCalibrate_8188E(a) -#define PHY_SetRFPathSwitch(a, b) PHY_SetRFPathSwitch_8188E(a, b) - -s32 MPT_InitializeAdapter(struct adapter *pAdapter, u8 Channel) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - s32 rtStatus = _SUCCESS; - struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; - struct mlme_priv *pmlmepriv = &pAdapter->mlmepriv; - - /* HW Initialization for 8190 MPT. */ - /* SW Initialization for 8190 MP. */ - pMptCtx->bMptDrvUnload = false; - pMptCtx->bMassProdTest = false; - pMptCtx->bMptIndexEven = true; /* default gain index is -6.0db */ - pMptCtx->h2cReqNum = 0x0; - /* Init mpt event. */ - /* init for BT MP */ - - pMptCtx->bMptWorkItemInProgress = false; - pMptCtx->CurrMptAct = NULL; - /* */ - - /* Don't accept any packets */ - rtw_write32(pAdapter, REG_RCR, 0); - - PHY_IQCalibrate(pAdapter, false); - dm_CheckTXPowerTracking(&pHalData->odmpriv); /* trigger thermal meter */ - PHY_LCCalibrate(pAdapter); - - pMptCtx->backup0xc50 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_XAAGCCore1, bMaskByte0); - pMptCtx->backup0xc58 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_XBAGCCore1, bMaskByte0); - pMptCtx->backup0xc30 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_RxDetector1, bMaskByte0); - pMptCtx->backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); - pMptCtx->backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); - - /* set ant to wifi side in mp mode */ - rtw_write16(pAdapter, 0x870, 0x300); - rtw_write16(pAdapter, 0x860, 0x110); - - if (pAdapter->registrypriv.mp_mode == 1) - pmlmepriv->fw_state = WIFI_MP_STATE; - - return rtStatus; -} - -/*----------------------------------------------------------------------------- - * Function: MPT_DeInitAdapter() - * - * Overview: Extra DeInitialization for Mass Production Test. - * - * Input: struct adapter * pAdapter - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 05/08/2007 MHC Create Version 0. - * 05/18/2007 MHC Add normal driver MPHalt code. - * - *---------------------------------------------------------------------------*/ -void MPT_DeInitAdapter(struct adapter *pAdapter) -{ - struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; - - pMptCtx->bMptDrvUnload = true; -} - -static u8 mpt_ProStartTest(struct adapter *padapter) -{ - struct mpt_context *pMptCtx = &padapter->mppriv.MptCtx; - - pMptCtx->bMassProdTest = true; - pMptCtx->bStartContTx = false; - pMptCtx->bCckContTx = false; - pMptCtx->bOfdmContTx = false; - pMptCtx->bSingleCarrier = false; - pMptCtx->bCarrierSuppression = false; - pMptCtx->bSingleTone = false; - - return _SUCCESS; -} - -/* - * General use - */ -s32 SetPowerTracking(struct adapter *padapter, u8 enable) -{ - Hal_SetPowerTracking(padapter, enable); - return 0; -} - -void GetPowerTracking(struct adapter *padapter, u8 *enable) -{ - Hal_GetPowerTracking(padapter, enable); -} - -static void disable_dm(struct adapter *padapter) -{ - u8 v8; - - /* 3 1. disable firmware dynamic mechanism */ - /* disable Power Training, Rate Adaptive */ - v8 = rtw_read8(padapter, REG_BCN_CTRL); - v8 &= ~EN_BCN_FUNCTION; - rtw_write8(padapter, REG_BCN_CTRL, v8); - - /* 3 2. disable driver dynamic mechanism */ - /* disable Dynamic Initial Gain */ - /* disable High Power */ - /* disable Power Tracking */ - Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); - - /* enable APK, LCK and IQK but disable power tracking */ - Switch_DM_Func(padapter, DYNAMIC_RF_CALIBRATION, true); -} - -/* This function initializes the DUT to the MP test mode */ -s32 mp_start_test(struct adapter *padapter) -{ - struct wlan_bssid_ex bssid; - struct sta_info *psta; - u32 length; - u8 val8; - s32 res = _SUCCESS; - struct mp_priv *pmppriv = &padapter->mppriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *tgt_network = &pmlmepriv->cur_network; - - padapter->registrypriv.mp_mode = 1; - pmppriv->bSetTxPower = 0; /* for manually set tx power */ - - /* 3 disable dynamic mechanism */ - disable_dm(padapter); - - /* 3 0. update mp_priv */ - - if (padapter->registrypriv.rf_config == RF_819X_MAX_TYPE) { - switch (GET_RF_TYPE(padapter)) { - case RF_1T1R: - pmppriv->antenna_tx = ANTENNA_A; - pmppriv->antenna_rx = ANTENNA_A; - break; - case RF_1T2R: - default: - pmppriv->antenna_tx = ANTENNA_A; - pmppriv->antenna_rx = ANTENNA_AB; - break; - case RF_2T2R: - case RF_2T2R_GREEN: - pmppriv->antenna_tx = ANTENNA_AB; - pmppriv->antenna_rx = ANTENNA_AB; - break; - case RF_2T4R: - pmppriv->antenna_tx = ANTENNA_AB; - pmppriv->antenna_rx = ANTENNA_ABCD; - break; - } - } - - mpt_ProStartTest(padapter); - - /* 3 1. initialize a new struct wlan_bssid_ex */ -/* memset(&bssid, 0, sizeof(struct wlan_bssid_ex)); */ - memcpy(bssid.MacAddress, pmppriv->network_macaddr, ETH_ALEN); - bssid.Ssid.SsidLength = strlen("mp_pseudo_adhoc"); - memcpy(bssid.Ssid.Ssid, (u8 *)"mp_pseudo_adhoc", bssid.Ssid.SsidLength); - bssid.InfrastructureMode = Ndis802_11IBSS; - bssid.NetworkTypeInUse = Ndis802_11DS; - bssid.IELength = 0; - - length = get_wlan_bssid_ex_sz(&bssid); - if (length % 4) - bssid.Length = ((length >> 2) + 1) << 2; /* round up to multiple of 4 bytes. */ - else - bssid.Length = length; - - spin_lock_bh(&pmlmepriv->lock); - - if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) - goto end_of_mp_start_test; - - /* init mp_start_test status */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - rtw_disassoc_cmd(padapter, 500, true); - rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter, 1); - } - pmppriv->prev_fw_state = get_fwstate(pmlmepriv); - if (padapter->registrypriv.mp_mode == 1) - pmlmepriv->fw_state = WIFI_MP_STATE; - set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - - /* 3 2. create a new psta for mp driver */ - /* clear psta in the cur_network, if any */ - psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress); - if (psta) - rtw_free_stainfo(padapter, psta); - - psta = rtw_alloc_stainfo(&padapter->stapriv, bssid.MacAddress); - if (!psta) { - pmlmepriv->fw_state = pmppriv->prev_fw_state; - res = _FAIL; - goto end_of_mp_start_test; - } - - /* 3 3. join psudo AdHoc */ - tgt_network->join_res = 1; - tgt_network->aid = 1; - psta->aid = 1; - memcpy(&tgt_network->network, &bssid, length); - - rtw_indicate_connect(padapter); - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - -end_of_mp_start_test: - - spin_unlock_bh(&pmlmepriv->lock); - - if (res == _SUCCESS) { - /* set MSR to WIFI_FW_ADHOC_STATE */ - val8 = rtw_read8(padapter, MSR) & 0xFC; /* 0x0102 */ - val8 |= WIFI_FW_ADHOC_STATE; - rtw_write8(padapter, MSR, val8); /* Link in ad hoc network */ - } - return res; -} -/* */ -/* This function change the DUT from the MP test mode into normal mode */ -void mp_stop_test(struct adapter *padapter) -{ - struct mp_priv *pmppriv = &padapter->mppriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *tgt_network = &pmlmepriv->cur_network; - struct sta_info *psta; - - if (pmppriv->mode == MP_ON) { - pmppriv->bSetTxPower = 0; - spin_lock_bh(&pmlmepriv->lock); - if (!check_fwstate(pmlmepriv, WIFI_MP_STATE)) - goto end_of_mp_stop_test; - - /* 3 1. disconnect psudo AdHoc */ - rtw_indicate_disconnect(padapter); - - /* 3 2. clear psta used in mp test mode. */ - psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress); - if (psta) - rtw_free_stainfo(padapter, psta); - - /* 3 3. return to normal state (default:station mode) */ - pmlmepriv->fw_state = pmppriv->prev_fw_state; /* WIFI_STATION_STATE; */ - - /* flush the cur_network */ - memset(tgt_network, 0, sizeof(struct wlan_network)); - - _clr_fwstate_(pmlmepriv, WIFI_MP_STATE); - -end_of_mp_stop_test: - - spin_unlock_bh(&pmlmepriv->lock); - } -} - -/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ -/* - * SetChannel - * Description - * Use H2C command to change channel, - * not only modify rf register, but also other setting need to be done. - */ -void SetChannel(struct adapter *pAdapter) -{ - Hal_SetChannel(pAdapter); -} - -/* - * Notice - * Switch bandwitdth may change center frequency(channel) - */ -void SetBandwidth(struct adapter *pAdapter) -{ - Hal_SetBandwidth(pAdapter); -} - -void SetAntenna(struct adapter *pAdapter) -{ - Hal_SetAntenna(pAdapter); -} - -void SetAntennaPathPower(struct adapter *pAdapter) -{ - Hal_SetAntennaPathPower(pAdapter); -} - -void SetTxPower(struct adapter *pAdapter) -{ - Hal_SetTxPower(pAdapter); - } - -void SetDataRate(struct adapter *pAdapter) -{ - Hal_SetDataRate(pAdapter); -} - -void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter, bool bMain) -{ - PHY_SetRFPathSwitch(pAdapter, bMain); -} - -s32 SetThermalMeter(struct adapter *pAdapter, u8 target_ther) -{ - return Hal_SetThermalMeter(pAdapter, target_ther); -} - -void GetThermalMeter(struct adapter *pAdapter, u8 *value) -{ - Hal_GetThermalMeter(pAdapter, value); -} - -void SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) -{ - PhySetTxPowerLevel(pAdapter); - Hal_SetSingleCarrierTx(pAdapter, bStart); -} - -void SetSingleToneTx(struct adapter *pAdapter, u8 bStart) -{ - PhySetTxPowerLevel(pAdapter); - Hal_SetSingleToneTx(pAdapter, bStart); -} - -void SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) -{ - PhySetTxPowerLevel(pAdapter); - Hal_SetCarrierSuppressionTx(pAdapter, bStart); -} - -void SetContinuousTx(struct adapter *pAdapter, u8 bStart) -{ - PhySetTxPowerLevel(pAdapter); - Hal_SetContinuousTx(pAdapter, bStart); -} - -void PhySetTxPowerLevel(struct adapter *pAdapter) -{ - struct mp_priv *pmp_priv = &pAdapter->mppriv; - - if (pmp_priv->bSetTxPower == 0) /* for NO manually set power index */ - PHY_SetTxPowerLevel8188E(pAdapter, pmp_priv->channel); -} - -/* */ -static void dump_mpframe(struct adapter *padapter, struct xmit_frame *pmpframe) -{ - rtw_hal_mgnt_xmit(padapter, pmpframe); -} - -static struct xmit_frame *alloc_mp_xmitframe(struct xmit_priv *pxmitpriv) -{ - struct xmit_frame *pmpframe; - struct xmit_buf *pxmitbuf; - - pmpframe = rtw_alloc_xmitframe(pxmitpriv); - if (!pmpframe) - return NULL; - - pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (!pxmitbuf) { - rtw_free_xmitframe(pxmitpriv, pmpframe); - return NULL; - } - - pmpframe->frame_tag = MP_FRAMETAG; - - pmpframe->pxmitbuf = pxmitbuf; - - pmpframe->buf_addr = pxmitbuf->pbuf; - - pxmitbuf->priv_data = pmpframe; - - return pmpframe; -} - -static int mp_xmit_packet_thread(void *context) -{ - struct xmit_frame *pxmitframe; - struct mp_tx *pmptx; - struct mp_priv *pmp_priv; - struct xmit_priv *pxmitpriv; - struct adapter *padapter; - - pmp_priv = (struct mp_priv *)context; - pmptx = &pmp_priv->tx; - padapter = pmp_priv->papdater; - pxmitpriv = &padapter->xmitpriv; - - thread_enter("RTW_MP_THREAD"); - - /* DBG_88E("%s:pkTx Start\n", __func__); */ - while (1) { - pxmitframe = alloc_mp_xmitframe(pxmitpriv); - if (!pxmitframe) { - if (pmptx->stop || - padapter->bSurpriseRemoved || - padapter->bDriverStopped) { - goto exit; - } else { - msleep(1); - continue; - } - } - - memcpy((u8 *)(pxmitframe->buf_addr + TXDESC_OFFSET), pmptx->buf, pmptx->write_size); - memcpy(&pxmitframe->attrib, &pmptx->attrib, sizeof(struct pkt_attrib)); - - dump_mpframe(padapter, pxmitframe); - - pmptx->sended++; - pmp_priv->tx_pktcount++; - - if (pmptx->stop || - padapter->bSurpriseRemoved || - padapter->bDriverStopped) - goto exit; - if ((pmptx->count != 0) && - (pmptx->count == pmptx->sended)) - goto exit; - - flush_signals_thread(); - } - -exit: - kfree(pmptx->pallocated_buf); - pmptx->pallocated_buf = NULL; - pmptx->stop = 1; - - thread_exit(); -} - -void fill_txdesc_for_mp(struct adapter *padapter, struct tx_desc *ptxdesc) -{ - struct mp_priv *pmp_priv = &padapter->mppriv; - memcpy(ptxdesc, &pmp_priv->tx.desc, TXDESC_SIZE); -} - -void SetPacketTx(struct adapter *padapter) -{ - u8 *ptr, *pkt_start, *pkt_end; - u32 pkt_size; - struct tx_desc *desc; - struct rtw_ieee80211_hdr *hdr; - u8 payload; - bool bmcast; - struct pkt_attrib *pattrib; - struct mp_priv *pmp_priv; - - pmp_priv = &padapter->mppriv; - if (pmp_priv->tx.stop) - return; - pmp_priv->tx.sended = 0; - pmp_priv->tx.stop = 0; - pmp_priv->tx_pktcount = 0; - - /* 3 1. update_attrib() */ - pattrib = &pmp_priv->tx.attrib; - memcpy(pattrib->src, padapter->eeprompriv.mac_addr, ETH_ALEN); - memcpy(pattrib->ta, pattrib->src, ETH_ALEN); - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - bmcast = is_multicast_ether_addr(pattrib->ra); - if (bmcast) { - pattrib->mac_id = 1; - pattrib->psta = rtw_get_bcmc_stainfo(padapter); - } else { - pattrib->mac_id = 0; - pattrib->psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); - } - - pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->pktlen; - - /* 3 2. allocate xmit buffer */ - pkt_size = pattrib->last_txcmdsz; - - kfree(pmp_priv->tx.pallocated_buf); - pmp_priv->tx.write_size = pkt_size; - pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ; - pmp_priv->tx.pallocated_buf = kzalloc(pmp_priv->tx.buf_size, GFP_KERNEL); - if (!pmp_priv->tx.pallocated_buf) { - DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size); - return; - } - pmp_priv->tx.buf = (u8 *)N_BYTE_ALIGMENT((size_t)(pmp_priv->tx.pallocated_buf), XMITBUF_ALIGN_SZ); - ptr = pmp_priv->tx.buf; - - desc = &pmp_priv->tx.desc; - memset(desc, 0, TXDESC_SIZE); - pkt_start = ptr; - pkt_end = pkt_start + pkt_size; - - /* 3 3. init TX descriptor */ - /* offset 0 */ - desc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); - desc->txdw0 |= cpu_to_le32(pkt_size & 0x0000FFFF); /* packet size */ - desc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00FF0000); /* 32 bytes for TX Desc */ - if (bmcast) - desc->txdw0 |= cpu_to_le32(BMC); /* broadcast packet */ - - desc->txdw1 |= cpu_to_le32((0x01 << 26) & 0xff000000); - /* offset 4 */ - desc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x3F); /* CAM_ID(MAC_ID) */ - desc->txdw1 |= cpu_to_le32((pattrib->qsel << QSEL_SHT) & 0x00001F00); /* Queue Select, TID */ - - desc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); /* Rate Adaptive ID */ - /* offset 8 */ - /* offset 12 */ - - desc->txdw3 |= cpu_to_le32((pattrib->seqnum << 16) & 0x0fff0000); - - /* offset 16 */ - desc->txdw4 |= cpu_to_le32(HW_SSN); - desc->txdw4 |= cpu_to_le32(USERATE); - desc->txdw4 |= cpu_to_le32(DISDATAFB); - - if (pmp_priv->preamble) { - if (pmp_priv->rateidx <= MPT_RATE_54M) - desc->txdw4 |= cpu_to_le32(DATA_SHORT); /* CCK Short Preamble */ - } - if (pmp_priv->bandwidth == HT_CHANNEL_WIDTH_40) - desc->txdw4 |= cpu_to_le32(DATA_BW); - - /* offset 20 */ - desc->txdw5 |= cpu_to_le32(pmp_priv->rateidx & 0x0000001F); - - if (pmp_priv->preamble) { - if (pmp_priv->rateidx > MPT_RATE_54M) - desc->txdw5 |= cpu_to_le32(SGI); /* MCS Short Guard Interval */ - } - desc->txdw5 |= cpu_to_le32(RTY_LMT_EN); /* retry limit enable */ - desc->txdw5 |= cpu_to_le32(0x00180000); /* DATA/RTS Rate Fallback Limit */ - - /* 3 4. make wlan header, make_wlanhdr() */ - hdr = (struct rtw_ieee80211_hdr *)pkt_start; - SetFrameSubType(&hdr->frame_ctl, pattrib->subtype); - memcpy(hdr->addr1, pattrib->dst, ETH_ALEN); /* DA */ - memcpy(hdr->addr2, pattrib->src, ETH_ALEN); /* SA */ - memcpy(hdr->addr3, get_bssid(&padapter->mlmepriv), ETH_ALEN); /* RA, BSSID */ - - /* 3 5. make payload */ - ptr = pkt_start + pattrib->hdrlen; - - switch (pmp_priv->tx.payload) { - case 0: - payload = 0x00; - break; - case 1: - payload = 0x5a; - break; - case 2: - payload = 0xa5; - break; - case 3: - payload = 0xff; - break; - default: - payload = 0x00; - break; - } - - memset(ptr, payload, pkt_end - ptr); - - /* 3 6. start thread */ - pmp_priv->tx.PktTxThread = kthread_run(mp_xmit_packet_thread, pmp_priv, "RTW_MP_THREAD"); - if (IS_ERR(pmp_priv->tx.PktTxThread)) - DBG_88E("Create PktTx Thread Fail !!!!!\n"); -} - -void SetPacketRx(struct adapter *pAdapter, u8 bStartRx) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - - if (bStartRx) { - /* Accept CRC error and destination address */ - pHalData->ReceiveConfig = AAP | APM | AM | AB | APP_ICV | - AMF | ADF | APP_FCS | HTC_LOC_CTRL | - APP_MIC | APP_PHYSTS; - - pHalData->ReceiveConfig |= (RCR_ACRC32 | RCR_AAP); - - rtw_write32(pAdapter, REG_RCR, pHalData->ReceiveConfig); - - /* Accept all data frames */ - rtw_write16(pAdapter, REG_RXFLTMAP2, 0xFFFF); - } else { - rtw_write32(pAdapter, REG_RCR, 0); - } -} - -void ResetPhyRxPktCount(struct adapter *pAdapter) -{ - u32 i, phyrx_set = 0; - - for (i = 0; i <= 0xF; i++) { - phyrx_set = 0; - phyrx_set |= _RXERR_RPT_SEL(i); /* select */ - phyrx_set |= RXERR_RPT_RST; /* set counter to zero */ - rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set); - } -} - -static u32 GetPhyRxPktCounts(struct adapter *pAdapter, u32 selbit) -{ - /* selection */ - u32 phyrx_set = 0, count = 0; - - phyrx_set = _RXERR_RPT_SEL(selbit & 0xF); - rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set); - - /* Read packet count */ - count = rtw_read32(pAdapter, REG_RXERR_RPT) & RXERR_COUNTER_MASK; - - return count; -} - -u32 GetPhyRxPktReceived(struct adapter *pAdapter) -{ - u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; - - OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_OK); - CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_OK); - HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_OK); - - return OFDM_cnt + CCK_cnt + HT_cnt; -} - -u32 GetPhyRxPktCRC32Error(struct adapter *pAdapter) -{ - u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; - - OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_FAIL); - CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_FAIL); - HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_FAIL); - - return OFDM_cnt + CCK_cnt + HT_cnt; -} - -/* reg 0x808[9:0]: FFT data x */ -/* reg 0x808[22]: 0 --> 1 to get 1 FFT data y */ -/* reg 0x8B4[15:0]: FFT data y report */ -static u32 rtw_GetPSDData(struct adapter *pAdapter, u32 point) -{ - int psd_val; - - psd_val = rtw_read32(pAdapter, 0x808); - psd_val &= 0xFFBFFC00; - psd_val |= point; - - rtw_write32(pAdapter, 0x808, psd_val); - mdelay(1); - psd_val |= 0x00400000; - - rtw_write32(pAdapter, 0x808, psd_val); - mdelay(1); - psd_val = rtw_read32(pAdapter, 0x8B4); - - psd_val &= 0x0000FFFF; - - return psd_val; -} - -/* - *pts start_point_min stop_point_max - * 128 64 64 + 128 = 192 - * 256 128 128 + 256 = 384 - * 512 256 256 + 512 = 768 - * 1024 512 512 + 1024 = 1536 - */ -u32 mp_query_psd(struct adapter *pAdapter, u8 *data) -{ - u32 i, psd_pts = 0, psd_start = 0, psd_stop = 0; - u32 psd_data = 0; - - if (!netif_running(pAdapter->pnetdev)) - return 0; - - if (!check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE)) - return 0; - - if (strlen(data) == 0) { /* default value */ - psd_pts = 128; - psd_start = 64; - psd_stop = 128; - } else { - sscanf(data, "pts =%d, start =%d, stop =%d", &psd_pts, &psd_start, &psd_stop); - } - - memset(data, '\0', sizeof(*data)); - - i = psd_start; - while (i < psd_stop) { - if (i >= psd_pts) { - psd_data = rtw_GetPSDData(pAdapter, i - psd_pts); - } else { - psd_data = rtw_GetPSDData(pAdapter, i); - } - sprintf(data + strlen(data), "%x ", psd_data); - i++; - } - - msleep(100); - return strlen(data) + 1; -} - -void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) -{ - int i, res; - struct adapter *padapter = pxmitpriv->adapter; - struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; - u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; - u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - - if (padapter->registrypriv.mp_mode == 0) { - max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; - num_xmit_extbuf = NR_XMIT_EXTBUFF; - } else { - max_xmit_extbuf_size = 6000; - num_xmit_extbuf = 8; - } - - pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; - for (i = 0; i < num_xmit_extbuf; i++) { - rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); - - pxmitbuf++; - } - - vfree(pxmitpriv->pallocated_xmit_extbuf); - - if (padapter->registrypriv.mp_mode == 0) { - max_xmit_extbuf_size = 6000; - num_xmit_extbuf = 8; - } else { - max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; - num_xmit_extbuf = NR_XMIT_EXTBUFF; - } - - /* Init xmit extension buff */ - _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - - pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - - if (!pxmitpriv->pallocated_xmit_extbuf) { - res = _FAIL; - goto exit; - } - - pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4); - - pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; - - for (i = 0; i < num_xmit_extbuf; i++) { - INIT_LIST_HEAD(&pxmitbuf->list); - - pxmitbuf->priv_data = NULL; - pxmitbuf->padapter = padapter; - pxmitbuf->ext_tag = true; - - res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); - if (res == _FAIL) { - res = _FAIL; - goto exit; - } - - list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); - pxmitbuf++; - } - - pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; - -exit: - ; -} - -void Hal_ProSetCrystalCap(struct adapter *pAdapter, u32 CrystalCapVal) -{ - CrystalCapVal = CrystalCapVal & 0x3F; - - // write 0x24[16:11] = 0x24[22:17] = CrystalCap - PHY_SetBBReg(pAdapter, REG_AFE_XTAL_CTRL, 0x7FF800, - (CrystalCapVal | (CrystalCapVal << 6))); -} diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c deleted file mode 100644 index c85f8e467337..000000000000 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ /dev/null @@ -1,1170 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#define _RTW_MP_IOCTL_C_ - -#include "../include/osdep_service.h" -#include "../include/drv_types.h" -#include "../include/mlme_osdep.h" -#include "../include/rtw_mp_ioctl.h" - -/* rtl8188eu_oid_rtl_seg_81_85 section start **************** */ -int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->information_buf_len < sizeof(u8)) - return NDIS_STATUS_INVALID_LENGTH; - - if (poid_par_priv->type_of_oid == SET_OID) { - Adapter->registrypriv.wireless_mode = *(u8 *)poid_par_priv->information_buf; - } else if (poid_par_priv->type_of_oid == QUERY_OID) { - *(u8 *)poid_par_priv->information_buf = Adapter->registrypriv.wireless_mode; - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else { - status = NDIS_STATUS_NOT_ACCEPTED; - } - - return status; -} -/* rtl8188eu_oid_rtl_seg_81_87_80 section start **************** */ -int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) -{ - struct bb_reg_param *pbbreg; - u16 offset; - u32 value; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; - - pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); - - offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */ - if (offset < BB_REG_BASE_ADDR) - offset |= BB_REG_BASE_ADDR; - - value = pbbreg->value; - - _irqlevel_changed_(&oldirql, LOWER); - write_bbreg(Adapter, offset, 0xFFFFFFFF, value); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) -{ - struct bb_reg_param *pbbreg; - u16 offset; - u32 value; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; - - pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); - - offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */ - if (offset < BB_REG_BASE_ADDR) - offset |= BB_REG_BASE_ADDR; - - _irqlevel_changed_(&oldirql, LOWER); - value = read_bbreg(Adapter, offset, 0xFFFFFFFF); - _irqlevel_changed_(&oldirql, RAISE); - - pbbreg->value = value; - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) -{ - struct rf_reg_param *pbbreg; - u8 path; - u8 offset; - u32 value; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; - - pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); - - if (pbbreg->path >= RF_PATH_MAX) - return NDIS_STATUS_NOT_ACCEPTED; - if (pbbreg->offset > 0xFF) - return NDIS_STATUS_NOT_ACCEPTED; - if (pbbreg->value > 0xFFFFF) - return NDIS_STATUS_NOT_ACCEPTED; - - path = (u8)pbbreg->path; - offset = (u8)pbbreg->offset; - value = pbbreg->value; - - _irqlevel_changed_(&oldirql, LOWER); - write_rfreg(Adapter, path, offset, value); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) -{ - struct rf_reg_param *pbbreg; - u8 path; - u8 offset; - u32 value; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - int status = NDIS_STATUS_SUCCESS; - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) - return NDIS_STATUS_INVALID_LENGTH; - - pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); - - if (pbbreg->path >= RF_PATH_MAX) - return NDIS_STATUS_NOT_ACCEPTED; - if (pbbreg->offset > 0xFF) - return NDIS_STATUS_NOT_ACCEPTED; - - path = (u8)pbbreg->path; - offset = (u8)pbbreg->offset; - - _irqlevel_changed_(&oldirql, LOWER); - value = read_rfreg(Adapter, path, offset); - _irqlevel_changed_(&oldirql, RAISE); - - pbbreg->value = value; - - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - - return status; -} -/* rtl8188eu_oid_rtl_seg_81_87_00 section end**************** */ -/* */ - -/* rtl8188eu_oid_rtl_seg_81_80_00 section start **************** */ -/* */ -int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 ratevalue;/* 4 */ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - ratevalue = *((u32 *)poid_par_priv->information_buf);/* 4 */ - if (ratevalue >= MPT_RATE_LAST) - return NDIS_STATUS_INVALID_DATA; - - Adapter->mppriv.rateidx = ratevalue; - - _irqlevel_changed_(&oldirql, LOWER); - SetDataRate(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 mode; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (Adapter->registrypriv.mp_mode == 0) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - - /* IQCalibrateBcut(Adapter); */ - - mode = *((u32 *)poid_par_priv->information_buf); - Adapter->mppriv.mode = mode;/* 1 for loopback */ - - if (mp_start_test(Adapter) == _FAIL) { - status = NDIS_STATUS_NOT_ACCEPTED; - goto exit; - } - -exit: - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - mp_stop_test(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 Channel; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - if (poid_par_priv->type_of_oid == QUERY_OID) { - *((u32 *)poid_par_priv->information_buf) = Adapter->mppriv.channel; - return NDIS_STATUS_SUCCESS; - } - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - Channel = *((u32 *)poid_par_priv->information_buf); - if (Channel > 14) - return NDIS_STATUS_NOT_ACCEPTED; - Adapter->mppriv.channel = Channel; - - _irqlevel_changed_(&oldirql, LOWER); - SetChannel(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) -{ - u16 bandwidth; - u16 channel_offset; - int status = NDIS_STATUS_SUCCESS; - struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - bandwidth = *((u32 *)poid_par_priv->information_buf);/* 4 */ - channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - if (bandwidth != HT_CHANNEL_WIDTH_40) - bandwidth = HT_CHANNEL_WIDTH_20; - padapter->mppriv.bandwidth = (u8)bandwidth; - padapter->mppriv.prime_channel_offset = (u8)channel_offset; - - _irqlevel_changed_(&oldirql, LOWER); - SetBandwidth(padapter); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 antenna; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - if (poid_par_priv->type_of_oid == SET_OID) { - antenna = *(u32 *)poid_par_priv->information_buf; - - Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16); - Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF); - - _irqlevel_changed_(&oldirql, LOWER); - SetAntenna(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - } else { - antenna = (Adapter->mppriv.antenna_tx << 16) | Adapter->mppriv.antenna_rx; - *(u32 *)poid_par_priv->information_buf = antenna; - } - - return status; -} - -int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 tx_pwr_idx; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - tx_pwr_idx = *((u32 *)poid_par_priv->information_buf); - if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE) - return NDIS_STATUS_NOT_ACCEPTED; - - Adapter->mppriv.txpoweridx = (u8)tx_pwr_idx; - - _irqlevel_changed_(&oldirql, LOWER); - SetTxPower(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} - -/* */ -/* rtl8188eu_oid_rtl_seg_81_80_20 section start **************** */ -/* */ -int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - - if (poid_par_priv->information_buf_len == sizeof(u32)) { - *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.tx_pktcount; - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else { - status = NDIS_STATUS_INVALID_LENGTH; - } - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - if (poid_par_priv->information_buf_len == sizeof(u32)) { - *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_pktcount; - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else { - status = NDIS_STATUS_INVALID_LENGTH; - } - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - if (poid_par_priv->information_buf_len == sizeof(u32)) { - *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_crcerrpktcount; - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else { - status = NDIS_STATUS_INVALID_LENGTH; - } - - return status; -} -/* */ - -int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - - Adapter->mppriv.tx_pktcount = 0; - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - - if (poid_par_priv->information_buf_len == sizeof(u32)) { - Adapter->mppriv.rx_pktcount = 0; - Adapter->mppriv.rx_crcerrpktcount = 0; - } else { - status = NDIS_STATUS_INVALID_LENGTH; - } - - return status; -} -/* */ -int rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - - _irqlevel_changed_(&oldirql, LOWER); - ResetPhyRxPktCount(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - _irqlevel_changed_(&oldirql, LOWER); - *(u32 *)poid_par_priv->information_buf = GetPhyRxPktReceived(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - - return status; -} -/* */ -int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len != sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - _irqlevel_changed_(&oldirql, LOWER); - *(u32 *)poid_par_priv->information_buf = GetPhyRxPktCRC32Error(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - - return status; -} -/* rtl8188eu_oid_rtl_seg_81_80_20 section end **************** */ -int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 bStartTest; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - bStartTest = *((u32 *)poid_par_priv->information_buf); - - _irqlevel_changed_(&oldirql, LOWER); - SetContinuousTx(Adapter, (u8)bStartTest); - if (bStartTest) { - struct mp_priv *pmp_priv = &Adapter->mppriv; - if (pmp_priv->tx.stop == 0) { - pmp_priv->tx.stop = 1; - DBG_88E("%s: pkt tx is running...\n", __func__); - msleep(5); - } - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(Adapter); - } - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} - -int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 bStartTest; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - bStartTest = *((u32 *)poid_par_priv->information_buf); - - _irqlevel_changed_(&oldirql, LOWER); - SetSingleCarrierTx(Adapter, (u8)bStartTest); - if (bStartTest) { - struct mp_priv *pmp_priv = &Adapter->mppriv; - if (pmp_priv->tx.stop == 0) { - pmp_priv->tx.stop = 1; - DBG_88E("%s: pkt tx is running...\n", __func__); - msleep(5); - } - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(Adapter); - } - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} - -int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 bStartTest; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - bStartTest = *((u32 *)poid_par_priv->information_buf); - - _irqlevel_changed_(&oldirql, LOWER); - SetCarrierSuppressionTx(Adapter, (u8)bStartTest); - if (bStartTest) { - struct mp_priv *pmp_priv = &Adapter->mppriv; - if (pmp_priv->tx.stop == 0) { - pmp_priv->tx.stop = 1; - DBG_88E("%s: pkt tx is running...\n", __func__); - msleep(5); - } - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(Adapter); - } - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} - -int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv) -{ - u32 bStartTest; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - bStartTest = *((u32 *)poid_par_priv->information_buf); - - _irqlevel_changed_(&oldirql, LOWER); - SetSingleToneTx(Adapter, (u8)bStartTest); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} - -int rtl8188eu_oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv) -{ - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - int status = NDIS_STATUS_SUCCESS; - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - rtw_hal_set_hwreg(Adapter, HW_VAR_TRIGGER_GPIO_0, NULL); - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* rtl8188eu_oid_rtl_seg_81_80_00 section end **************** */ -/* */ -int rtl8188eu_oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) -{ - struct mp_rw_reg *RegRWStruct; - u32 offset, width; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; - offset = RegRWStruct->offset; - width = RegRWStruct->width; - - if (offset > 0xFFF) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - - switch (width) { - case 1: - RegRWStruct->value = rtw_read8(Adapter, offset); - break; - case 2: - RegRWStruct->value = rtw_read16(Adapter, offset); - break; - default: - width = 4; - RegRWStruct->value = rtw_read32(Adapter, offset); - break; - } - - _irqlevel_changed_(&oldirql, RAISE); - - *poid_par_priv->bytes_rw = width; - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) -{ - struct mp_rw_reg *RegRWStruct; - u32 offset, value; - int status = NDIS_STATUS_SUCCESS; - struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; - offset = RegRWStruct->offset; - value = RegRWStruct->value; - - if (offset > 0xFFF) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - - switch (RegRWStruct->width) { - case 1: - if (value > 0xFF) { - status = NDIS_STATUS_NOT_ACCEPTED; - break; - } - rtw_write8(padapter, offset, (u8)value); - break; - case 2: - if (value > 0xFFFF) { - status = NDIS_STATUS_NOT_ACCEPTED; - break; - } - rtw_write16(padapter, offset, (u16)value); - break; - case 4: - rtw_write32(padapter, offset, value); - break; - default: - status = NDIS_STATUS_NOT_ACCEPTED; - break; - } - - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -/* */ -int rtl8188eu_oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -/* */ -int rtl8188eu_oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_wr_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv) -{ - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - int status = NDIS_STATUS_SUCCESS; - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - - if (rtw_setdatarate_cmd(Adapter, poid_par_priv->information_buf) != _SUCCESS) - status = NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - u8 thermal = 0; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - _irqlevel_changed_(&oldirql, LOWER); - GetThermalMeter(Adapter, &thermal); - _irqlevel_changed_(&oldirql, RAISE); - - *(u32 *)poid_par_priv->information_buf = (u32)thermal; - *poid_par_priv->bytes_rw = sizeof(u32); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->information_buf_len < sizeof(u8)) - return NDIS_STATUS_INVALID_LENGTH; - - _irqlevel_changed_(&oldirql, LOWER); - if (poid_par_priv->type_of_oid == SET_OID) { - u8 enable; - - enable = *(u8 *)poid_par_priv->information_buf; - - SetPowerTracking(Adapter, enable); - } else { - GetPowerTracking(Adapter, (u8 *)poid_par_priv->information_buf); - } - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} -/* */ -int rtl8188eu_oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -/* rtl8188eu_oid_rtl_seg_87_12_00 section start **************** */ -int rtl8188eu_oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -int rtl8188eu_oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -int rtl8188eu_oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -int rtl8188eu_oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -int rtl8188eu_oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) -{ - return NDIS_STATUS_SUCCESS; -} -/* */ -int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) -{ - struct efuse_access_struct *pefuse; - u8 *data; - u16 addr = 0, cnts = 0, max_available_size = 0; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(struct efuse_access_struct)) - return NDIS_STATUS_INVALID_LENGTH; - - pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf; - addr = pefuse->start_addr; - cnts = pefuse->cnts; - data = pefuse->data; - - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - - if ((addr + cnts) > max_available_size) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) - status = NDIS_STATUS_FAILURE; - else - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) -{ - struct efuse_access_struct *pefuse; - u8 *data; - u16 addr = 0, cnts = 0, max_available_size = 0; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf; - addr = pefuse->start_addr; - cnts = pefuse->cnts; - data = pefuse->data; - - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - - if ((addr + cnts) > max_available_size) - return NDIS_STATUS_NOT_ACCEPTED; - - _irqlevel_changed_(&oldirql, LOWER); - if (rtw_efuse_access(Adapter, true, addr, cnts, data) == _FAIL) - status = NDIS_STATUS_FAILURE; - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) -{ - struct pgpkt *ppgpkt; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - *poid_par_priv->bytes_rw = 0; - - if (poid_par_priv->information_buf_len < sizeof(struct pgpkt *)) - return NDIS_STATUS_INVALID_LENGTH; - - ppgpkt = (struct pgpkt *)poid_par_priv->information_buf; - - _irqlevel_changed_(&oldirql, LOWER); - - if (poid_par_priv->type_of_oid == QUERY_OID) { - Efuse_PowerSwitch(Adapter, false, true); - if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false)) - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - else - status = NDIS_STATUS_FAILURE; - Efuse_PowerSwitch(Adapter, false, false); - } else { - Efuse_PowerSwitch(Adapter, true, true); - if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false)) - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - else - status = NDIS_STATUS_FAILURE; - Efuse_PowerSwitch(Adapter, true, false); - } - - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv) -{ - u16 size; - u8 ret; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - _irqlevel_changed_(&oldirql, LOWER); - ret = efuse_GetCurrentSize(Adapter, &size); - _irqlevel_changed_(&oldirql, RAISE); - if (ret == _SUCCESS) { - *(u32 *)poid_par_priv->information_buf = size; - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } else { - status = NDIS_STATUS_FAILURE; - } - - return status; -} -/* */ -int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - - if (poid_par_priv->type_of_oid != QUERY_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(u32)) - return NDIS_STATUS_INVALID_LENGTH; - - *(u32 *)poid_par_priv->information_buf = efuse_GetMaxSize(Adapter); - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) -{ - int status; - - if (poid_par_priv->type_of_oid == QUERY_OID) - status = rtl8188eu_oid_rt_pro_read_efuse_hdl(poid_par_priv); - else - status = rtl8188eu_oid_rt_pro_write_efuse_hdl(poid_par_priv); - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) -{ - u8 *data; - int status = NDIS_STATUS_SUCCESS; - struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - u16 maplen = 0; - - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&maplen, false); - - *poid_par_priv->bytes_rw = 0; - - if (poid_par_priv->information_buf_len < maplen) - return NDIS_STATUS_INVALID_LENGTH; - - data = (u8 *)poid_par_priv->information_buf; - - _irqlevel_changed_(&oldirql, LOWER); - - if (poid_par_priv->type_of_oid == QUERY_OID) { - if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) - *poid_par_priv->bytes_rw = maplen; - else - status = NDIS_STATUS_FAILURE; - } else { - /* SET_OID */ - if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) - *poid_par_priv->bytes_rw = maplen; - else - status = NDIS_STATUS_FAILURE; - } - - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} - -int rtl8188eu_oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - return status; -} - -int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - - if (poid_par_priv->type_of_oid != SET_OID) - return NDIS_STATUS_NOT_ACCEPTED; - - if (poid_par_priv->information_buf_len < sizeof(u8)) - return NDIS_STATUS_INVALID_LENGTH; - - return status; -} - -int rtl8188eu_oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -int rtl8188eu_oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} - -int rtl8188eu_mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) -{ - struct mp_xmit_parm *pparm; - struct adapter *padapter; - struct mp_priv *pmp_priv; - struct pkt_attrib *pattrib; - - pparm = (struct mp_xmit_parm *)poid_par_priv->information_buf; - padapter = (struct adapter *)poid_par_priv->adapter_context; - pmp_priv = &padapter->mppriv; - - if (poid_par_priv->type_of_oid == QUERY_OID) { - pparm->enable = !pmp_priv->tx.stop; - pparm->count = pmp_priv->tx.sended; - } else { - if (pparm->enable == 0) { - pmp_priv->tx.stop = 1; - } else if (pmp_priv->tx.stop == 1) { - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = pparm->count; - pmp_priv->tx.payload = pparm->payload_type; - pattrib = &pmp_priv->tx.attrib; - pattrib->pktlen = pparm->length; - memcpy(pattrib->dst, pparm->da, ETH_ALEN); - SetPacketTx(padapter); - } else { - return NDIS_STATUS_FAILURE; - } - } - - return NDIS_STATUS_SUCCESS; -} - -/* */ -int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) -{ - int status = NDIS_STATUS_SUCCESS; - - if (poid_par_priv->type_of_oid != SET_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - - _irqlevel_changed_(&oldirql, LOWER); - - /* CALL the power_down function */ - _irqlevel_changed_(&oldirql, RAISE); - - return status; -} -/* */ -int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index e2b6cf2386e0..b265b5e46851 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -7,8 +7,6 @@ #include "../include/rtw_p2p.h" #include "../include/wifi.h" -#ifdef CONFIG_88EU_P2P - static int rtw_p2p_is_channel_list_ok(u8 desired_ch, u8 *ch_list, u8 ch_cnt) { int found = 0, i = 0; @@ -735,13 +733,6 @@ u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status return len; } -u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u32 len = 0; - - return len; -} - u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) { u8 *p; @@ -1494,7 +1485,7 @@ static void pre_tx_invitereq_handler(struct adapter *padapter) u8 val8 = 1; set_channel_bwmode(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); issue_probereq_p2p(padapter, NULL); _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); @@ -1506,7 +1497,7 @@ static void pre_tx_provdisc_handler(struct adapter *padapter) u8 val8 = 1; set_channel_bwmode(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); issue_probereq_p2p(padapter, NULL); _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); @@ -1518,7 +1509,7 @@ static void pre_tx_negoreq_handler(struct adapter *padapter) u8 val8 = 1; set_channel_bwmode(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + SetHwReg8188EU(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); issue_probereq_p2p(padapter, NULL); _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); @@ -1643,7 +1634,7 @@ void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) case P2P_PS_DISABLE: pwdinfo->p2p_ps_state = p2p_ps_state; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); pwdinfo->noa_index = 0; pwdinfo->ctwindow = 0; @@ -1653,7 +1644,7 @@ void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) if (padapter->pwrctrlpriv.bFwCurrentInPSMode) { if (pwrpriv->smart_ps == 0) { pwrpriv->smart_ps = 2; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&padapter->pwrctrlpriv.pwr_mode)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&padapter->pwrctrlpriv.pwr_mode)); } } break; @@ -1665,10 +1656,10 @@ void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) if (pwrpriv->smart_ps != 0) { pwrpriv->smart_ps = 0; DBG_88E("%s(): Enter CTW, change SmartPS\n", __func__); - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&padapter->pwrctrlpriv.pwr_mode)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&padapter->pwrctrlpriv.pwr_mode)); } } - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); } break; case P2P_PS_SCAN: @@ -1676,7 +1667,7 @@ void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) case P2P_PS_ALLSTASLEEP: if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { pwdinfo->p2p_ps_state = p2p_ps_state; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); } break; default: @@ -1832,7 +1823,6 @@ void rtw_init_wifidirect_timers(struct adapter *padapter) void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, u8 *iface_addr) { -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; /*init device&interface address */ @@ -1840,7 +1830,6 @@ void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, u8 *iface memcpy(pwdinfo->device_addr, dev_addr, ETH_ALEN); if (iface_addr) memcpy(pwdinfo->interface_addr, iface_addr, ETH_ALEN); -#endif } void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role) @@ -1955,7 +1944,7 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) /* Enable P2P function */ init_wifidirect_info(padapter, role); - rtw_hal_set_odm_var(padapter, HAL_ODM_P2P_STATE, NULL, true); + rtl8188e_SetHalODMVar(padapter, HAL_ODM_P2P_STATE, NULL, true); } else if (role == P2P_ROLE_DISABLE) { if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = _FAIL; @@ -1974,7 +1963,7 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info)); } - rtw_hal_set_odm_var(padapter, HAL_ODM_P2P_STATE, NULL, false); + rtl8188e_SetHalODMVar(padapter, HAL_ODM_P2P_STATE, NULL, false); /* Restore to initial setting. */ update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); @@ -1983,15 +1972,3 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) exit: return ret; } - -#else -u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) -{ - return _FAIL; -} - -void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) -{ -} - -#endif /* CONFIG_88EU_P2P */ diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index c3897b29121c..5d595cf2a47e 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -13,9 +13,6 @@ void ips_enter(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct xmit_priv *pxmit_priv = &padapter->xmitpriv; - if (padapter->registrypriv.mp_mode == 1) - return; - if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF || pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) { DBG_88E_LEVEL(_drv_info_, "There are some pkts to transmit\n"); @@ -24,7 +21,7 @@ void ips_enter(struct adapter *padapter) return; } - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); pwrpriv->bips_processing = true; @@ -45,7 +42,7 @@ void ips_enter(struct adapter *padapter) } pwrpriv->bips_processing = false; - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } int ips_leave(struct adapter *padapter) @@ -56,7 +53,7 @@ int ips_leave(struct adapter *padapter) int result = _SUCCESS; int keyid; - _enter_pwrlock(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { pwrpriv->bips_processing = true; @@ -90,7 +87,7 @@ int ips_leave(struct adapter *padapter) pwrpriv->bpower_saving = false; } - _exit_pwrlock(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); return result; } @@ -99,10 +96,7 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) { struct adapter *buddy = adapter->pbuddy_adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &adapter->wdinfo; -#endif - bool ret = false; if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) @@ -113,29 +107,19 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) check_fwstate(pmlmepriv, WIFI_UNDER_WPS) || check_fwstate(pmlmepriv, WIFI_AP_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE) || -#if defined(CONFIG_88EU_P2P) !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) -#else - 0) -#endif goto exit; /* consider buddy, if exist */ if (buddy) { struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv; - #ifdef CONFIG_88EU_P2P struct wifidirect_info *b_pwdinfo = &buddy->wdinfo; - #endif if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING | WIFI_UNDER_WPS) || check_fwstate(b_pmlmepriv, WIFI_AP_STATE) || check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE) || -#if defined(CONFIG_88EU_P2P) !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE)) -#else - 0) -#endif goto exit; } ret = true; @@ -148,32 +132,12 @@ void rtw_ps_processor(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - enum rt_rf_power_state rfpwrstate; pwrpriv->ps_processing = true; if (pwrpriv->bips_processing) goto exit; - if (padapter->pwrctrlpriv.bHWPwrPindetect) { - rfpwrstate = RfOnOffDetect(padapter); - DBG_88E("@@@@- #2 %s==> rfstate:%s\n", __func__, (rfpwrstate == rf_on) ? "rf_on" : "rf_off"); - - if (rfpwrstate != pwrpriv->rf_pwrstate) { - if (rfpwrstate == rf_off) { - pwrpriv->change_rfpwrstate = rf_off; - pwrpriv->brfoffbyhw = true; - padapter->bCardDisableWOHSM = true; - rtw_hw_suspend(padapter); - } else { - pwrpriv->change_rfpwrstate = rf_on; - rtw_hw_resume(padapter); - } - DBG_88E("current rf_pwrstate(%s)\n", (pwrpriv->rf_pwrstate == rf_off) ? "rf_off" : "rf_on"); - } - pwrpriv->pwr_state_check_cnts++; - } - if (pwrpriv->ips_mode_req == IPS_NONE) goto exit; @@ -199,51 +163,6 @@ static void pwr_state_check_handler(struct timer_list *t) rtw_ps_cmd(padapter); } -/* - * - * Parameters - * padapter - * pslv power state level, only could be PS_STATE_S0 ~ PS_STATE_S4 - * - */ -void rtw_set_rpwm(struct adapter *padapter, u8 pslv) -{ - u8 rpwm; - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - - pslv = PS_STATE(pslv); - - if (pwrpriv->btcoex_rfon) { - if (pslv < PS_STATE_S4) - pslv = PS_STATE_S3; - } - - if (pwrpriv->rpwm == pslv) - return; - - if ((padapter->bSurpriseRemoved) || - (!padapter->hw_init_completed)) { - pwrpriv->cpwm = PS_STATE_S4; - - return; - } - - if (padapter->bDriverStopped) { - if (pslv < PS_STATE_S2) - return; - } - - rpwm = pslv | pwrpriv->tog; - - pwrpriv->rpwm = pslv; - - rtw_hal_set_hwreg(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm)); - - pwrpriv->tog += 0x80; - pwrpriv->cpwm = pslv; - -} - static u8 PS_RDY_CHECK(struct adapter *padapter) { u32 curr_time, delta_time; @@ -274,9 +193,7 @@ static u8 PS_RDY_CHECK(struct adapter *padapter) void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ if (ps_mode > PM_Card_Disable) return; @@ -292,31 +209,24 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ if (ps_mode == PS_MODE_ACTIVE) { -#ifdef CONFIG_88EU_P2P if (pwdinfo->opp_ps == 0) { DBG_88E("rtw_set_ps_mode: Leave 802.11 power save\n"); pwrpriv->pwr_mode = ps_mode; - rtw_set_rpwm(padapter, PS_STATE_S4); - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); pwrpriv->bFwCurrentInPSMode = false; } } else { -#endif /* CONFIG_88EU_P2P */ if (PS_RDY_CHECK(padapter)) { DBG_88E("%s: Enter 802.11 power save\n", __func__); pwrpriv->bFwCurrentInPSMode = true; pwrpriv->pwr_mode = ps_mode; pwrpriv->smart_ps = smart_ps; pwrpriv->bcn_ant_mode = bcn_ant_mode; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + SetHwReg8188EU(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); -#ifdef CONFIG_88EU_P2P /* Set CTWindow after LPS */ if (pwdinfo->opp_ps == 1) p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 0); -#endif /* CONFIG_88EU_P2P */ - - rtw_set_rpwm(padapter, PS_STATE_S2); } } @@ -336,7 +246,7 @@ s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) start_time = jiffies; while (1) { - rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); + GetHwReg8188EU(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); if (bAwake) break; @@ -427,7 +337,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) { struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - _init_pwrlock(&pwrctrlpriv->lock); + mutex_init(&pwrctrlpriv->lock); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts = 0; pwrctrlpriv->ips_leave_cnts = 0; @@ -443,50 +353,18 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->bkeepfwalive = false; pwrctrlpriv->LpsIdleCount = 0; - if (padapter->registrypriv.mp_mode == 1) - pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; - else - pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ + pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; pwrctrlpriv->bFwCurrentInPSMode = false; - pwrctrlpriv->rpwm = 0; - pwrctrlpriv->cpwm = PS_STATE_S4; - pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE; pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps; pwrctrlpriv->bcn_ant_mode = 0; - pwrctrlpriv->tog = 0x80; - - pwrctrlpriv->btcoex_rfon = false; - timer_setup(&pwrctrlpriv->pwr_state_check_timer, pwr_state_check_handler, 0); } -void rtw_free_pwrctrl_priv(struct adapter *adapter) -{ - struct pwrctrl_priv *pwrctrlpriv = &adapter->pwrctrlpriv; - - _free_pwrlock(&pwrctrlpriv->lock); - -} - -u8 rtw_interface_ps_func(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val) -{ - u8 bResult = true; - rtw_hal_intf_ps_func(padapter, efunc_id, val); - - return bResult; -} - -inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ms); -} - /* * rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend * @adapter: pointer to struct adapter structure diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index e082edfbaad8..51a13262a226 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -9,6 +9,7 @@ #include "../include/mlme_osdep.h" #include "../include/usb_ops.h" #include "../include/wifi.h" +#include "../include/rtl8188e_recv.h" static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; @@ -31,7 +32,7 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) spin_lock_init(&psta_recvpriv->lock); - _rtw_init_queue(&psta_recvpriv->defrag_q); + rtw_init_queue(&psta_recvpriv->defrag_q); } @@ -45,9 +46,9 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) spin_lock_init(&precvpriv->lock); - _rtw_init_queue(&precvpriv->free_recv_queue); - _rtw_init_queue(&precvpriv->recv_pending_queue); - _rtw_init_queue(&precvpriv->uc_swdec_pending_queue); + rtw_init_queue(&precvpriv->free_recv_queue); + rtw_init_queue(&precvpriv->recv_pending_queue); + rtw_init_queue(&precvpriv->uc_swdec_pending_queue); precvpriv->adapter = padapter; @@ -82,7 +83,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) sema_init(&precvpriv->allrxreturnevt, 0); - res = rtw_hal_init_recv_priv(padapter); + res = rtl8188eu_init_recv_priv(padapter); timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl, 0); precvpriv->signal_stat_sampling_interval = 1000; /* ms */ @@ -103,7 +104,7 @@ void _rtw_free_recv_priv(struct recv_priv *precvpriv) vfree(precvpriv->pallocated_frame_buf); - rtw_hal_free_recv_priv(padapter); + rtl8188eu_free_recv_priv(padapter); } struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) @@ -147,14 +148,6 @@ struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue) return precvframe; } -void rtw_init_recvframe(struct recv_frame *precvframe, struct recv_priv *precvpriv) -{ - /* Perry: This can be removed */ - INIT_LIST_HEAD(&precvframe->list); - - precvframe->len = 0; -} - int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue) { struct adapter *padapter; @@ -257,56 +250,6 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) return cnt; } -int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue) -{ - spin_lock_bh(&queue->lock); - - list_del_init(&precvbuf->list); - list_add(&precvbuf->list, get_list_head(queue)); - - spin_unlock_bh(&queue->lock); - - return _SUCCESS; -} - -int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) -{ - unsigned long flags; - - spin_lock_irqsave(&queue->lock, flags); - - list_del_init(&precvbuf->list); - - list_add_tail(&precvbuf->list, get_list_head(queue)); - spin_unlock_irqrestore(&queue->lock, flags); - return _SUCCESS; -} - -struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue) -{ - struct recv_buf *precvbuf; - struct list_head *plist, *phead; - unsigned long flags; - - spin_lock_irqsave(&queue->lock, flags); - - if (list_empty(&queue->queue)) { - precvbuf = NULL; - } else { - phead = get_list_head(queue); - - plist = phead->next; - - precvbuf = container_of(plist, struct recv_buf, list); - - list_del_init(&precvbuf->list); - } - - spin_unlock_irqrestore(&queue->lock, flags); - - return precvbuf; -} - static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvframe) { int i, res = _SUCCESS; @@ -418,13 +361,13 @@ static struct recv_frame *decryptor(struct adapter *padapter, struct recv_frame switch (prxattrib->encrypt) { case _WEP40_: case _WEP104_: - rtw_wep_decrypt(padapter, (u8 *)precv_frame); + rtw_wep_decrypt(padapter, precv_frame); break; case _TKIP_: - res = rtw_tkip_decrypt(padapter, (u8 *)precv_frame); + res = rtw_tkip_decrypt(padapter, precv_frame); break; case _AES_: - res = rtw_aes_decrypt(padapter, (u8 *)precv_frame); + res = rtw_aes_decrypt(padapter, precv_frame); break; default: break; @@ -523,7 +466,6 @@ static int recv_decache(struct recv_frame *precv_frame, u8 bretry, struct stainf void process_pwrbit_data(struct adapter *padapter, struct recv_frame *precv_frame); void process_pwrbit_data(struct adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_88EU_AP_MODE unsigned char pwrbit; u8 *ptr = precv_frame->rx_data; struct rx_pkt_attrib *pattrib = &precv_frame->attrib; @@ -543,13 +485,10 @@ void process_pwrbit_data(struct adapter *padapter, struct recv_frame *precv_fram wakeup_sta_to_xmit(padapter, psta); } } - -#endif } static void process_wmmps_data(struct adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_88EU_AP_MODE struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; @@ -598,8 +537,6 @@ static void process_wmmps_data(struct adapter *padapter, struct recv_frame *prec } } } - -#endif } static void count_rx_stats(struct adapter *padapter, struct recv_frame *prframe, struct sta_info *sta) @@ -710,14 +647,8 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, else *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ - if (!*psta) { - if (adapter->registrypriv.mp_mode == 1) { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) - adapter->mppriv.rx_pktloss++; - } - ret = _FAIL; + if (!*psta) goto exit; - } exit: @@ -883,7 +814,6 @@ exit: static int validate_recv_ctrl_frame(struct adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_88EU_AP_MODE struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->rx_data; @@ -966,8 +896,6 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, pxmitframe->attrib.triggered = 1; - rtw_hal_xmitframe_enqueue(padapter, pxmitframe); - if (psta->sleepq_len == 0) { pstapriv->tim_bitmap &= ~BIT(psta->aid); @@ -998,8 +926,6 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, } } -#endif - return _FAIL; } @@ -1189,7 +1115,7 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv pattrib->order = GetOrder(ptr); /* Dump rx packets */ - rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt)); + GetHalDefVar8188EUsb(adapter, HAL_DEF_DBG_DUMP_RXPKT, &bDumpRxPkt); if (bDumpRxPkt == 1) {/* dump all rx packets */ int i; DBG_88E("#############################\n"); @@ -1860,22 +1786,7 @@ static int process_recv_indicatepkts(struct adapter *padapter, struct recv_frame static int recv_func_prehandle(struct adapter *padapter, struct recv_frame *rframe) { int ret = _SUCCESS; - struct rx_pkt_attrib *pattrib = &rframe->attrib; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (padapter->registrypriv.mp_mode == 1) { - if (pattrib->crc_err == 1) - padapter->mppriv.rx_crcerrpktcount++; - else - padapter->mppriv.rx_pktcount++; - - if (!check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE)) { - ret = _FAIL; - rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ - goto exit; - } - } /* check the frame crtl field and decache */ ret = validate_recv_frame(padapter, rframe); @@ -1998,9 +1909,6 @@ s32 rtw_recv_entry(struct recv_frame *precvframe) _recv_entry_drop: - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.rx_pktloss = precvpriv->rx_drop; - return ret; } diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c index 321546c40446..2ec56012516e 100644 --- a/drivers/staging/r8188eu/core/rtw_rf.c +++ b/drivers/staging/r8188eu/core/rtw_rf.c @@ -53,20 +53,3 @@ u32 rtw_ch2freq(u32 channel) return freq; } - -u32 rtw_freq2ch(u32 freq) -{ - u8 i; - u32 ch = 0; - - for (i = 0; i < ch_freq_map_num; i++) { - if (freq == ch_freq_map[i].frequency) { - ch = ch_freq_map[i].channel; - break; - } - } - if (i == ch_freq_map_num) - ch = 1; - - return ch; -} diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 5aa893ab46e9..db35f326bbb1 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -10,80 +10,15 @@ /* WEP related ===== */ -#define CRC32_POLY 0x04c11db7 - -struct arc4context { - u32 x; - u32 y; - u8 state[256]; -}; - -static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) -{ - u32 t, u; - u32 keyindex; - u32 stateindex; - u8 *state; - u32 counter; - - state = parc4ctx->state; - parc4ctx->x = 0; - parc4ctx->y = 0; - for (counter = 0; counter < 256; counter++) - state[counter] = (u8)counter; - keyindex = 0; - stateindex = 0; - for (counter = 0; counter < 256; counter++) { - t = state[counter]; - stateindex = (stateindex + key[keyindex] + t) & 0xff; - u = state[stateindex]; - state[stateindex] = (u8)t; - state[counter] = (u8)u; - if (++keyindex >= key_len) - keyindex = 0; - } - -} - -static u32 arcfour_byte(struct arc4context *parc4ctx) -{ - u32 x; - u32 y; - u32 sx, sy; - u8 *state; - - state = parc4ctx->state; - x = (parc4ctx->x + 1) & 0xff; - sx = state[x]; - y = (sx + parc4ctx->y) & 0xff; - sy = state[y]; - parc4ctx->x = x; - parc4ctx->y = y; - state[y] = (u8)sx; - state[x] = (u8)sy; - - return state[(sx + sy) & 0xff]; -} - -static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) -{ - u32 i; - - for (i = 0; i < len; i++) - dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); - -} - /* Need to consider the fragment situation */ -void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) +void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { /* exclude ICV */ union { __le32 f0; u8 f1[4]; } crc; - struct arc4context mycontext; int curfragnum, length; u32 keylength; @@ -91,17 +26,16 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 *pframe, *payload, *iv; /* wepkey */ u8 wepkey[16]; u8 hw_hdr_offset = 0; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct arc4_ctx *ctx = &psecuritypriv->xmit_arc4_ctx; - if (!((struct xmit_frame *)pxmitframe)->buf_addr) + if (!pxmitframe->buf_addr) return; - hw_hdr_offset = TXDESC_SIZE + - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); - - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + hw_hdr_offset = TXDESC_SIZE + pxmitframe->pkt_offset * PACKET_OFFSET_SZ; + pframe = pxmitframe->buf_addr + hw_hdr_offset; /* start to encrypt each fragment */ if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) { @@ -118,15 +52,15 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - arcfour_init(&mycontext, wepkey, 3 + keylength); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); + arc4_setkey(ctx, wepkey, 3 + keylength); + arc4_crypt(ctx, payload, payload, length); + arc4_crypt(ctx, payload + length, crc.f1, 4); } else { length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - arcfour_init(&mycontext, wepkey, 3 + keylength); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); + arc4_setkey(ctx, wepkey, 3 + keylength); + arc4_crypt(ctx, payload, payload, length); + arc4_crypt(ctx, payload + length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((size_t)(pframe)); @@ -136,18 +70,18 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) } -void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) +void rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe) { /* exclude ICV */ - struct arc4context mycontext; int length; u32 keylength; u8 *pframe, *payload, *iv, wepkey[16]; u8 keyindex; - struct rx_pkt_attrib *prxattrib = &(((struct recv_frame *)precvframe)->attrib); + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; + struct arc4_ctx *ctx = &psecuritypriv->recv_arc4_ctx; - pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; + pframe = precvframe->rx_data; /* start to decrypt recvframe */ if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { @@ -156,13 +90,13 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) keylength = psecuritypriv->dot11DefKeylen[keyindex]; memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength); - length = ((struct recv_frame *)precvframe)->len - prxattrib->hdrlen - prxattrib->iv_len; + length = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len; payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; /* decrypt payload include icv */ - arcfour_init(&mycontext, wepkey, 3 + keylength); - arcfour_encrypt(&mycontext, payload, payload, length); + arc4_setkey(ctx, wepkey, 3 + keylength); + arc4_crypt(ctx, payload, payload, length); } } @@ -502,7 +436,7 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) } /* The hlen isn't include the IV */ -u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) +u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { /* exclude ICV */ u16 pnl; u32 pnh; @@ -513,23 +447,23 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 f1[4]; } crc; u8 hw_hdr_offset = 0; - struct arc4context mycontext; int curfragnum, length; u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; struct sta_info *stainfo; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct arc4_ctx *ctx = &psecuritypriv->xmit_arc4_ctx; u32 res = _SUCCESS; - if (!((struct xmit_frame *)pxmitframe)->buf_addr) + if (!pxmitframe->buf_addr) return _FAIL; - hw_hdr_offset = TXDESC_SIZE + - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + hw_hdr_offset = TXDESC_SIZE + pxmitframe->pkt_offset * PACKET_OFFSET_SZ; + pframe = pxmitframe->buf_addr + hw_hdr_offset; + /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _TKIP_) { if (pattrib->psta) @@ -558,16 +492,16 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); + arc4_setkey(ctx, rc4key, 16); + arc4_crypt(ctx, payload, payload, length); + arc4_crypt(ctx, payload + length, crc.f1, 4); } else { length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); + arc4_setkey(ctx, rc4key, 16); + arc4_crypt(ctx, payload, payload, length); + arc4_crypt(ctx, payload + length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((size_t)(pframe)); @@ -582,7 +516,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) } /* The hlen isn't include the IV */ -u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) +u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe) { /* exclude ICV */ u16 pnl; u32 pnh; @@ -592,17 +526,17 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) __le32 f0; u8 f1[4]; } crc; - struct arc4context mycontext; int length; u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; + struct arc4_ctx *ctx = &psecuritypriv->recv_arc4_ctx; u32 res = _SUCCESS; - pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; + pframe = precvframe->rx_data; /* 4 start to decrypt recvframe */ if (prxattrib->encrypt == _TKIP_) { @@ -621,7 +555,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) iv = pframe + prxattrib->hdrlen; payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; - length = ((struct recv_frame *)precvframe)->len - prxattrib->hdrlen - prxattrib->iv_len; + length = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len; GET_TKIP_PN(iv, dot11txpn); @@ -633,8 +567,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) /* 4 decrypt payload include icv */ - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); + arc4_setkey(ctx, rc4key, 16); + arc4_crypt(ctx, payload, payload, length); crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); @@ -1154,7 +1088,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) return _SUCCESS; } -u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) +u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { /* exclude ICV */ /*static*/ @@ -1165,20 +1099,18 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 *pframe, *prwskey; /* *payload,*iv */ u8 hw_hdr_offset = 0; struct sta_info *stainfo; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; /* uint offset = 0; */ u32 res = _SUCCESS; - if (!((struct xmit_frame *)pxmitframe)->buf_addr) + if (!pxmitframe->buf_addr) return _FAIL; - hw_hdr_offset = TXDESC_SIZE + - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); - - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + hw_hdr_offset = TXDESC_SIZE + pxmitframe->pkt_offset * PACKET_OFFSET_SZ; + pframe = pxmitframe->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _AES_) { @@ -1406,17 +1338,18 @@ static int aes_decipher(u8 *key, uint hdrlen, return res; } -u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) +u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe) { /* exclude ICV */ /* Intermediate Buffers */ int length; u8 *pframe, *prwskey; /* *payload,*iv */ struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; - pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; + pframe = precvframe->rx_data; + /* 4 start to encrypt each fragment */ if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); @@ -1438,7 +1371,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; } - length = ((struct recv_frame *)precvframe)->len - prxattrib->hdrlen - prxattrib->iv_len; + length = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len; res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); } else { res = _FAIL; @@ -1622,35 +1555,3 @@ const u8 rcons[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ }; - -/** - * Expand the cipher key into the encryption key schedule. - * - * @return the number of rounds for the given cipher key size. - */ -#define ROUND(i, d, s) \ -do { \ - d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \ - d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \ - d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \ - d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \ -} while (0); - -/** - * omac1_aes_128 - One-Key CBC MAC (OMAC1) hash with AES-128 (aka AES-CMAC) - * @key: 128-bit key for the hash operation - * @data: Data buffer for which a MAC is determined - * @data_len: Length of data buffer in bytes - * @mac: Buffer for MAC (128 bits, i.e., 16 bytes) - * Returns: 0 on success, -1 on failure - * - * This is a mode for using block cipher (AES in this case) for authentication. - * OMAC1 was standardized with the name CMAC by NIST in a Special Publication - * (SP) 800-38B. - */ -void rtw_use_tkipkey_handler(void *FunctionContext) -{ - struct adapter *padapter = (struct adapter *)FunctionContext; - - padapter->securitypriv.busetkipkey = true; -} diff --git a/drivers/staging/r8188eu/core/rtw_sreset.c b/drivers/staging/r8188eu/core/rtw_sreset.c deleted file mode 100644 index c831033d20a9..000000000000 --- a/drivers/staging/r8188eu/core/rtw_sreset.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2012 Realtek Corporation. */ - -#include "../include/rtw_sreset.h" - -void sreset_init_value(struct adapter *padapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct sreset_priv *psrtpriv = &pHalData->srestpriv; - - _rtw_mutex_init(&psrtpriv->silentreset_mutex); - psrtpriv->silent_reset_inprogress = false; - psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; - psrtpriv->last_tx_time = 0; - psrtpriv->last_tx_complete_time = 0; -} -void sreset_reset_value(struct adapter *padapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct sreset_priv *psrtpriv = &pHalData->srestpriv; - - psrtpriv->silent_reset_inprogress = false; - psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; - psrtpriv->last_tx_time = 0; - psrtpriv->last_tx_complete_time = 0; -} - -u8 sreset_get_wifi_status(struct adapter *padapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct sreset_priv *psrtpriv = &pHalData->srestpriv; - - u8 status = WIFI_STATUS_SUCCESS; - u32 val32 = 0; - - if (psrtpriv->silent_reset_inprogress) - return status; - val32 = rtw_read32(padapter, REG_TXDMA_STATUS); - if (val32 == 0xeaeaeaea) { - psrtpriv->wifi_error_status = WIFI_IF_NOT_EXIST; - } else if (val32 != 0) { - DBG_88E("txdmastatu(%x)\n", val32); - psrtpriv->wifi_error_status = WIFI_MAC_TXDMA_ERROR; - } - - if (WIFI_STATUS_SUCCESS != psrtpriv->wifi_error_status) { - DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->wifi_error_status); - status = (psrtpriv->wifi_error_status & (~(USB_READ_PORT_FAIL | USB_WRITE_PORT_FAIL))); - } - DBG_88E("==> %s wifi_status(0x%x)\n", __func__, status); - - /* status restore */ - psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; - - return status; -} - -void sreset_set_wifi_error_status(struct adapter *padapter, u32 status) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - pHalData->srestpriv.wifi_error_status = status; -} diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index f6dffed53a60..a3d4d5d8a785 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -18,14 +18,12 @@ static void _rtw_init_stainfo(struct sta_info *psta) spin_lock_init(&psta->lock); INIT_LIST_HEAD(&psta->list); INIT_LIST_HEAD(&psta->hash_list); - _rtw_init_queue(&psta->sleep_q); + rtw_init_queue(&psta->sleep_q); psta->sleepq_len = 0; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); _rtw_init_sta_recv_priv(&psta->sta_recvpriv); -#ifdef CONFIG_88EU_AP_MODE - INIT_LIST_HEAD(&psta->asoc_list); INIT_LIST_HEAD(&psta->auth_list); @@ -38,21 +36,16 @@ static void _rtw_init_stainfo(struct sta_info *psta) psta->bpairwise_key_installed = false; -#ifdef CONFIG_88EU_AP_MODE psta->nonerp_set = 0; psta->no_short_slot_time_set = 0; psta->no_short_preamble_set = 0; psta->no_ht_gf_set = 0; psta->no_ht_set = 0; psta->ht_20mhz_set = 0; -#endif psta->under_exist_checking = 0; psta->keep_alive_trycnt = 0; - -#endif /* CONFIG_88EU_AP_MODE */ - } u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) @@ -68,13 +61,13 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((size_t)(pstapriv->pallocated_stainfo_buf) & 3); - _rtw_init_queue(&pstapriv->free_sta_queue); + rtw_init_queue(&pstapriv->free_sta_queue); spin_lock_init(&pstapriv->sta_hash_lock); pstapriv->asoc_sta_count = 0; - _rtw_init_queue(&pstapriv->sleep_q); - _rtw_init_queue(&pstapriv->wakeup_q); + rtw_init_queue(&pstapriv->sleep_q); + rtw_init_queue(&pstapriv->wakeup_q); psta = (struct sta_info *)(pstapriv->pstainfo_buf); @@ -88,8 +81,6 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) psta++; } -#ifdef CONFIG_88EU_AP_MODE - pstapriv->sta_dz_bitmap = 0; pstapriv->tim_bitmap = 0; @@ -104,7 +95,6 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) pstapriv->assoc_to = 3; pstapriv->expire_to = 3; /* 3*2 = 6 sec */ pstapriv->max_num_sta = NUM_STA; -#endif return _SUCCESS; } @@ -155,9 +145,8 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) spin_unlock_bh(&pstapriv->sta_hash_lock); /*===============================*/ - if (pstapriv->pallocated_stainfo_buf) - vfree(pstapriv->pallocated_stainfo_buf); - } + vfree(pstapriv->pallocated_stainfo_buf); + } return _SUCCESS; } @@ -222,7 +211,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) preorder_ctrl->wend_b = 0xffff; preorder_ctrl->wsize_b = 64;/* 64; */ - _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); + rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); rtw_init_recv_timer(preorder_ctrl); } @@ -321,9 +310,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) } if (!(psta->state & WIFI_AP_STATE)) - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, false); - -#ifdef CONFIG_88EU_AP_MODE + rtl8188e_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, false); spin_lock_bh(&pstapriv->auth_list_lock); if (!list_empty(&psta->auth_list)) { @@ -354,8 +341,6 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) psta->under_exist_checking = 0; -#endif /* CONFIG_88EU_AP_MODE */ - spin_lock_bh(&pfree_sta_queue->lock); list_add_tail(&psta->list, get_list_head(pfree_sta_queue)); spin_unlock_bh(&pfree_sta_queue->lock); @@ -471,7 +456,6 @@ struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) { u8 res = true; -#ifdef CONFIG_88EU_AP_MODE struct list_head *plist, *phead; struct rtw_wlan_acl_node *paclnode; u8 match = false; @@ -502,7 +486,5 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) else res = true; -#endif - return res; } diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index a3a5e1c64c4a..6d4e21a16783 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -266,27 +266,27 @@ void Save_DM_Func_Flag(struct adapter *padapter) { u8 saveflag = true; - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); + SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); } void Restore_DM_Func_Flag(struct adapter *padapter) { u8 saveflag = false; - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); + SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); } void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable) { if (enable) - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); + SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); else - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); + SetHwReg8188EU(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); } static void Set_NETYPE0_MSR(struct adapter *padapter, u8 type) { - rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); + SetHwReg8188EU(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); } void Set_MSR(struct adapter *padapter, u8 type) @@ -304,21 +304,11 @@ inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch) adapter->mlmeextpriv.oper_channel = ch; } -inline u8 rtw_get_oper_bw(struct adapter *adapter) -{ - return adapter->mlmeextpriv.oper_bwmode; -} - inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw) { adapter->mlmeextpriv.oper_bwmode = bw; } -inline u8 rtw_get_oper_choffset(struct adapter *adapter) -{ - return adapter->mlmeextpriv.oper_ch_offset; -} - inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset) { adapter->mlmeextpriv.oper_ch_offset = offset; @@ -328,7 +318,7 @@ void SelectChannel(struct adapter *padapter, unsigned char channel) { /* saved channel info */ rtw_set_oper_ch(padapter, channel); - rtw_hal_set_chan(padapter, channel); + PHY_SwChnl8188E(padapter, channel); } void SetBWMode(struct adapter *padapter, unsigned short bwmode, @@ -338,7 +328,7 @@ void SetBWMode(struct adapter *padapter, unsigned short bwmode, rtw_set_oper_bw(padapter, bwmode); rtw_set_oper_choffset(padapter, channel_offset); - rtw_hal_set_bwmode(padapter, (enum ht_channel_width)bwmode, channel_offset); + PHY_SetBWMode8188E(padapter, (enum ht_channel_width)bwmode, channel_offset); } void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode) @@ -369,20 +359,10 @@ void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigne rtw_set_oper_bw(padapter, bwmode); rtw_set_oper_choffset(padapter, channel_offset); - rtw_hal_set_chan(padapter, center_ch); /* set center channel */ + PHY_SwChnl8188E(padapter, center_ch); /* set center channel */ SetBWMode(padapter, bwmode, channel_offset); } -int get_bsstype(unsigned short capability) -{ - if (capability & BIT(0)) - return WIFI_FW_AP_STATE; - else if (capability & BIT(1)) - return WIFI_FW_ADHOC_STATE; - else - return 0; -} - __inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) { return pnetwork->MacAddress; @@ -447,14 +427,9 @@ unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval) return bcn_interval << 2; } -void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex) -{ - rtw_hal_set_hwreg(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex)); -} - void invalidate_cam_all(struct adapter *padapter) { - rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + SetHwReg8188EU(padapter, HW_VAR_CAM_INVALID_ALL, NULL); } void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) @@ -482,7 +457,7 @@ void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) cam_val[0] = val; cam_val[1] = addr + (unsigned int)j; - rtw_hal_set_hwreg(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val); + SetHwReg8188EU(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val); } } @@ -517,7 +492,7 @@ void flush_all_cam_entry(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + SetHwReg8188EU(padapter, HW_VAR_CAM_INVALID_ALL, NULL); memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); } @@ -578,21 +553,21 @@ void WMMOnAssocRsp(struct adapter *padapter) switch (ACI) { case 0x0: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); + SetHwReg8188EU(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); acm_mask |= (ACM ? BIT(1) : 0); edca[XMIT_BE_QUEUE] = acParm; break; case 0x1: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); + SetHwReg8188EU(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); edca[XMIT_BK_QUEUE] = acParm; break; case 0x2: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); + SetHwReg8188EU(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); acm_mask |= (ACM ? BIT(2) : 0); edca[XMIT_VI_QUEUE] = acParm; break; case 0x3: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); + SetHwReg8188EU(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); acm_mask |= (ACM ? BIT(3) : 0); edca[XMIT_VO_QUEUE] = acParm; break; @@ -602,14 +577,14 @@ void WMMOnAssocRsp(struct adapter *padapter) } if (padapter->registrypriv.acm_method == 1) - rtw_hal_set_hwreg(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); + SetHwReg8188EU(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); else padapter->mlmepriv.acm_mask = acm_mask; inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; if (pregpriv->wifi_spec == 1) { - u32 j, tmp, change_inx = false; + u32 j, change_inx = false; /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ for (i = 0; i < 4; i++) { @@ -624,13 +599,8 @@ void WMMOnAssocRsp(struct adapter *padapter) } if (change_inx) { - tmp = edca[i]; - edca[i] = edca[j]; - edca[j] = tmp; - - tmp = inx[i]; - inx[i] = inx[j]; - inx[j] = tmp; + swap(edca[i], edca[j]); + swap(inx[i], inx[j]); change_inx = false; } @@ -760,7 +730,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) } } - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + GetHwReg8188EU(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); /* update the MCS rates */ for (i = 0; i < 16; i++) { @@ -817,9 +787,9 @@ void HTOnAssocRsp(struct adapter *padapter) min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + SetHwReg8188EU(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + SetHwReg8188EU(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); } void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) @@ -1123,72 +1093,6 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) } } -unsigned int should_forbid_n_rate(struct adapter *padapter) -{ - u32 i; - struct ndis_802_11_var_ie *pIE; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; - - if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ie); i < cur_network->IELength;) { - pIE = (struct ndis_802_11_var_ie *)(cur_network->IEs + i); - - switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: - if (!memcmp(pIE->data, RTW_WPA_OUI, 4) && - ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) || - (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4)))) - return false; - break; - case _RSN_IE_2_: - if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || - (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) - return false; - break; - default: - break; - } - - i += (pIE->Length + 2); - } - - return true; - } else { - return false; - } -} - -unsigned int is_ap_in_wep(struct adapter *padapter) -{ - u32 i; - struct ndis_802_11_var_ie *pIE; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - - if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i); - - switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: - if (!memcmp(pIE->data, RTW_WPA_OUI, 4)) - return false; - break; - case _RSN_IE_2_: - return false; - default: - break; - } - i += (pIE->Length + 2); - } - return true; - } else { - return false; - } -} - int wifirate2_ratetbl_inx(unsigned char rate) { int inx = 0; @@ -1324,7 +1228,6 @@ void set_sta_rate(struct adapter *padapter, struct sta_info *psta) void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode) { unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX]; -#ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; /* Added by Albert 2011/03/22 */ @@ -1332,7 +1235,6 @@ void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode) /* So, the Tx packet shouldn't use the CCK rate */ if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) return; -#endif /* CONFIG_88EU_P2P */ memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B)) @@ -1347,7 +1249,7 @@ void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode) else update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB); - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, supported_rates); + SetHwReg8188EU(padapter, HW_VAR_BASIC_RATE, supported_rates); } unsigned char check_assoc_AP(u8 *pframe, uint len) @@ -1369,7 +1271,6 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) DBG_88E("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || - (!memcmp(pIE->data, BROADCOM_OUI2, 3)) || (!memcmp(pIE->data, BROADCOM_OUI2, 3))) { DBG_88E("link to Broadcom AP\n"); return HT_IOT_PEER_BROADCOM; @@ -1465,13 +1366,13 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ ShortPreamble = true; pmlmeinfo->preamble_mode = PREAMBLE_SHORT; - rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + SetHwReg8188EU(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); } } else { /* Long Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ ShortPreamble = false; pmlmeinfo->preamble_mode = PREAMBLE_LONG; - rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + SetHwReg8188EU(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); } } @@ -1493,7 +1394,7 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) } } - rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); + SetHwReg8188EU(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); } void update_wireless_mode(struct adapter *padapter) @@ -1529,7 +1430,7 @@ void update_wireless_mode(struct adapter *padapter) SIFS_Timer = 0x0a0a0808;/* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ /* change this value if having IOT issues. */ - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); + SetHwReg8188EU(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); if (pmlmeext->cur_wireless_mode & WIRELESS_11B) update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); @@ -1611,12 +1512,12 @@ void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext) { - rtw_hal_set_hwreg(padapter, HW_VAR_CORRECT_TSF, NULL); + SetHwReg8188EU(padapter, HW_VAR_CORRECT_TSF, NULL); } void beacon_timing_control(struct adapter *padapter) { - rtw_hal_bcn_related_reg_setting(padapter); + SetBeaconRelatedRegisters8188EUsb(padapter); } static struct adapter *pbuddy_padapter; diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 46fe62c7c32c..0c033a077bf9 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -9,6 +9,7 @@ #include "../include/osdep_intf.h" #include "../include/usb_ops.h" #include "../include/usb_osintf.h" +#include "../include/rtl8188e_xmit.h" static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; @@ -17,7 +18,7 @@ static void _init_txservq(struct tx_servq *ptxservq) { INIT_LIST_HEAD(&ptxservq->tx_pending); - _rtw_init_queue(&ptxservq->sta_pending); + rtw_init_queue(&ptxservq->sta_pending); ptxservq->qcnt = 0; } @@ -48,22 +49,21 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ spin_lock_init(&pxmitpriv->lock); - sema_init(&pxmitpriv->xmit_sema, 0); sema_init(&pxmitpriv->terminate_xmitthread_sema, 0); /* - Please insert all the queue initializaiton using _rtw_init_queue below + Please insert all the queue initializaiton using rtw_init_queue below */ pxmitpriv->adapter = padapter; - _rtw_init_queue(&pxmitpriv->be_pending); - _rtw_init_queue(&pxmitpriv->bk_pending); - _rtw_init_queue(&pxmitpriv->vi_pending); - _rtw_init_queue(&pxmitpriv->vo_pending); - _rtw_init_queue(&pxmitpriv->bm_pending); + rtw_init_queue(&pxmitpriv->be_pending); + rtw_init_queue(&pxmitpriv->bk_pending); + rtw_init_queue(&pxmitpriv->vi_pending); + rtw_init_queue(&pxmitpriv->vo_pending); + rtw_init_queue(&pxmitpriv->bm_pending); - _rtw_init_queue(&pxmitpriv->free_xmit_queue); + rtw_init_queue(&pxmitpriv->free_xmit_queue); /* Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, @@ -105,8 +105,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->frag_len = MAX_FRAG_THRESHOLD; /* init xmit_buf */ - _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); - _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); + rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); + rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); @@ -147,7 +147,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; /* Init xmit extension buff */ - _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); + rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); @@ -196,10 +196,10 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->voq_cnt = 0; pxmitpriv->ack_tx = false; - _rtw_mutex_init(&pxmitpriv->ack_tx_mutex); + mutex_init(&pxmitpriv->ack_tx_mutex); rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0); - rtw_hal_init_xmit_priv(padapter); + rtl8188eu_init_xmit_priv(padapter); exit: @@ -243,7 +243,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) rtw_free_hwxmits(padapter); - _rtw_mutex_free(&pxmitpriv->ack_tx_mutex); + mutex_destroy(&pxmitpriv->ack_tx_mutex); } static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe) @@ -576,8 +576,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p else pattrib->bswenc = false; - rtw_set_tx_chksum_offload(pkt, pattrib); - update_attrib_phy_info(pattrib, psta); exit: @@ -683,13 +681,13 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: - rtw_wep_encrypt(padapter, (u8 *)pxmitframe); + rtw_wep_encrypt(padapter, pxmitframe); break; case _TKIP_: - rtw_tkip_encrypt(padapter, (u8 *)pxmitframe); + rtw_tkip_encrypt(padapter, pxmitframe); break; case _AES_: - rtw_aes_encrypt(padapter, (u8 *)pxmitframe); + rtw_aes_encrypt(padapter, pxmitframe); break; default: break; @@ -863,24 +861,6 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pat } /* - * Calculate wlan 802.11 packet MAX size from pkt_attrib - * This function doesn't consider fragment case - */ -u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib) -{ - u32 len = 0; - - len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */ - len += SNAP_SIZE + sizeof(u16); /* LLC */ - len += pattrib->pktlen; - if (pattrib->encrypt == _TKIP_) - len += 8; /* MIC */ - len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */ - - return len; -} - -/* This sub-routine will perform all the following: @@ -1572,31 +1552,31 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) rcu_read_unlock(); spin_lock_bh(&padapter->br_ext_lock); if (!(skb->data[0] & 1) && br_port && - memcmp(skb->data + MACADDRLEN, padapter->br_mac, MACADDRLEN) && - *((__be16 *)(skb->data + MACADDRLEN * 2)) != __constant_htons(ETH_P_8021Q) && - *((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_IP) && - !memcmp(padapter->scdb_mac, skb->data + MACADDRLEN, MACADDRLEN) && padapter->scdb_entry) { - memcpy(skb->data + MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) && + *((__be16 *)(skb->data + ETH_ALEN * 2)) != __constant_htons(ETH_P_8021Q) && + *((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP) && + !memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN) && padapter->scdb_entry) { + memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN); padapter->scdb_entry->ageing_timer = jiffies; spin_unlock_bh(&padapter->br_ext_lock); } else { - if (*((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_8021Q)) { + if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_8021Q)) { is_vlan_tag = 1; - vlan_hdr = *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)); + vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)); for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + MACADDRLEN * 2 - 2 - i * 2)); + *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + ETH_ALEN * 2 - 2 - i * 2)); skb_pull(skb, 4); } - if (!memcmp(skb->data + MACADDRLEN, padapter->br_mac, MACADDRLEN) && - (*((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_IP))) + if (!memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) && + (*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP))) memcpy(padapter->br_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4); - if (*((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_IP)) { - if (memcmp(padapter->scdb_mac, skb->data + MACADDRLEN, MACADDRLEN)) { + if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP)) { + if (memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN)) { padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter, - skb->data + MACADDRLEN, skb->data + WLAN_ETHHDR_LEN + 12); + skb->data + WLAN_ETHHDR_LEN + 12); if (padapter->scdb_entry) { - memcpy(padapter->scdb_mac, skb->data + MACADDRLEN, MACADDRLEN); + memcpy(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN); memcpy(padapter->scdb_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4); padapter->scdb_entry->ageing_timer = jiffies; do_nat25 = 0; @@ -1606,7 +1586,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) padapter->scdb_entry->ageing_timer = jiffies; do_nat25 = 0; } else { - memset(padapter->scdb_mac, 0, MACADDRLEN); + memset(padapter->scdb_mac, 0, ETH_ALEN); memset(padapter->scdb_ip, 0, 4); } } @@ -1620,8 +1600,8 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) skb_push(skb, 4); for (i = 0; i < 6; i++) *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); - *((__be16 *)(skb->data + MACADDRLEN * 2)) = __constant_htons(ETH_P_8021Q); - *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)) = vlan_hdr; + *((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr; } newskb = skb_copy(skb, GFP_ATOMIC); @@ -1633,9 +1613,9 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) *pskb = skb = newskb; if (is_vlan_tag) { - vlan_hdr = *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)); + vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)); for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + MACADDRLEN * 2 - 2 - i * 2)); + *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + ETH_ALEN * 2 - 2 - i * 2)); skb_pull(skb, 4); } } @@ -1659,7 +1639,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) } } - memcpy(skb->data + MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN); dhcp_flag_bcast(padapter, skb); @@ -1667,13 +1647,13 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) skb_push(skb, 4); for (i = 0; i < 6; i++) *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); - *((__be16 *)(skb->data + MACADDRLEN * 2)) = __constant_htons(ETH_P_8021Q); - *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)) = vlan_hdr; + *((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr; } } /* check if SA is equal to our MAC */ - if (memcmp(skb->data + MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) { + if (memcmp(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN)) { DEBUG_ERR("TX DROP: untransformed frame SA:%02X%02X%02X%02X%02X%02X!\n", skb->data[6], skb->data[7], skb->data[8], skb->data[9], skb->data[10], skb->data[11]); return -1; @@ -1773,23 +1753,19 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) do_queue_select(padapter, &pxmitframe->attrib); -#ifdef CONFIG_88EU_AP_MODE spin_lock_bh(&pxmitpriv->lock); if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) { spin_unlock_bh(&pxmitpriv->lock); return 1; } spin_unlock_bh(&pxmitpriv->lock); -#endif - if (!rtw_hal_xmit(padapter, pxmitframe)) + if (!rtl8188eu_hal_xmit(padapter, pxmitframe)) return 1; return 0; } -#if defined(CONFIG_88EU_AP_MODE) - int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe) { int ret = false; @@ -2018,7 +1994,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; spin_unlock_bh(&psta->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe)) + if (rtl8188eu_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); spin_lock_bh(&psta->sleep_q.lock); } @@ -2068,7 +2044,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; spin_unlock_bh(&psta_bmc->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe)) + if (rtl8188eu_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); spin_lock_bh(&psta_bmc->sleep_q.lock); } @@ -2142,7 +2118,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst pxmitframe->attrib.triggered = 1; - if (rtw_hal_xmit(padapter, pxmitframe)) + if (rtl8188eu_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { @@ -2156,8 +2132,6 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst spin_unlock_bh(&psta->sleep_q.lock); } -#endif - void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms) { sctx->timeout_ms = timeout_ms; @@ -2213,11 +2187,6 @@ void rtw_sctx_done_err(struct submit_ctx **sctx, int status) } } -void rtw_sctx_done(struct submit_ctx **sctx) -{ - rtw_sctx_done_err(sctx, RTW_SCTX_DONE_SUCCESS); -} - int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms) { struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; |