From adfd7de95d8ee2968a576cf7eb201806d4114223 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 15 Nov 2014 18:18:30 -0600 Subject: [PATCH] rtl8188eu: Put the current kernel files into a new branch named kernel_code Signed-off-by: Larry Finger --- Makefile | 30 +- core/rtw_ap.c | 258 +- core/rtw_br_ext.c | 1198 ------ core/rtw_cmd.c | 1171 +----- core/rtw_debug.c | 59 +- core/rtw_efuse.c | 1625 ++++---- core/rtw_ieee80211.c | 334 +- core/rtw_io.c | 329 -- core/rtw_ioctl_set.c | 567 +-- core/rtw_iol.c | 178 - core/rtw_led.c | 1275 +------ core/rtw_mlme.c | 702 ++-- core/rtw_mlme_ext.c | 3610 ++---------------- core/rtw_mp.c | 997 ----- core/rtw_mp_ioctl.c | 1508 -------- core/rtw_p2p.c | 2064 ---------- core/rtw_pwrctrl.c | 238 +- core/rtw_recv.c | 710 ++-- core/rtw_security.c | 172 +- core/rtw_sreset.c | 19 +- core/rtw_sta_mgt.c | 267 +- core/rtw_wlan_util.c | 124 +- core/rtw_xmit.c | 527 +-- hal/Hal8188ERateAdaptive.c | 17 +- hal/HalHWImg8188E_MAC.c | 231 -- hal/HalHWImg8188E_RF.c | 269 -- hal/HalPhyRf.c | 49 - hal/HalPhyRf_8188e.c | 1505 -------- hal/{HalHWImg8188E_BB.c => bb_cfg.c} | 472 ++- hal/fw.c | 236 ++ hal/hal_com.c | 60 - hal/hal_intf.c | 113 - hal/mac_cfg.c | 134 + hal/odm.c | 1097 +----- hal/odm_HWConfig.c | 390 +- hal/odm_RTL8188E.c | 441 +-- hal/odm_RegConfig8188E.c | 130 - hal/odm_debug.c | 32 - hal/odm_interface.c | 203 - hal/phy.c | 1570 ++++++++ hal/{Hal8188EPwrSeq.c => pwrseq.c} | 48 +- hal/{HalPwrSeqCmd.c => pwrseqcmd.c} | 77 +- hal/rf.c | 318 ++ hal/rf_cfg.c | 320 ++ hal/rtl8188e_cmd.c | 129 +- hal/rtl8188e_dm.c | 57 +- hal/rtl8188e_hal_init.c | 1758 +-------- hal/rtl8188e_mp.c | 860 ----- hal/rtl8188e_phycfg.c | 1144 ------ hal/rtl8188e_rf6052.c | 572 --- hal/rtl8188e_rxdesc.c | 43 +- hal/rtl8188e_sreset.c | 80 - hal/rtl8188e_xmit.c | 3 +- hal/rtl8188eu_led.c | 50 +- hal/rtl8188eu_recv.c | 52 +- hal/rtl8188eu_xmit.c | 54 +- hal/usb_halinit.c | 721 ++-- hal/usb_ops_linux.c | 728 ---- include/Hal8188EPhyCfg.h | 38 - include/drv_types.h | 93 +- include/fw.h | 59 + include/hal_com.h | 4 - include/hal_intf.h | 98 - include/ieee80211.h | 13 - include/ieee80211_ext.h | 20 +- include/odm.h | 109 +- include/odm_HWConfig.h | 9 +- include/odm_RTL8188E.h | 18 +- include/odm_debug.h | 42 +- include/odm_precomp.h | 19 +- include/odm_types.h | 25 - include/osdep_intf.h | 38 +- include/osdep_service.h | 380 +- include/phy.h | 30 + include/pwrseq.h | 341 ++ include/pwrseqcmd.h | 90 + include/recv_osdep.h | 15 +- include/rf.h | 11 + include/rtl8188e_cmd.h | 5 - include/rtl8188e_dm.h | 1 - include/rtl8188e_hal.h | 71 +- include/rtl8188e_recv.h | 14 +- include/rtl8188e_spec.h | 70 +- include/rtl8188e_xmit.h | 1 - include/rtw_cmd.h | 652 +--- include/rtw_debug.h | 30 +- include/rtw_eeprom.h | 4 +- include/rtw_efuse.h | 52 +- include/rtw_ioctl.h | 2 - include/rtw_ioctl_set.h | 12 +- include/rtw_iol.h | 56 - include/rtw_led.h | 125 +- include/rtw_mlme.h | 118 +- include/rtw_mlme_ext.h | 168 +- include/rtw_pwrctrl.h | 18 +- include/rtw_recv.h | 178 +- include/rtw_security.h | 3 +- include/rtw_sreset.h | 5 - include/rtw_xmit.h | 5 - include/sta_info.h | 15 - include/usb_ops_linux.h | 42 +- include/wifi.h | 38 +- include/wlan_bssdef.h | 4 - include/xmit_osdep.h | 6 - os_dep/ioctl_linux.c | 5266 +------------------------- os_dep/mlme_linux.c | 73 +- os_dep/os_intfs.c | 182 +- os_dep/osdep_service.c | 462 +-- os_dep/recv_linux.c | 116 +- os_dep/rtw_android.c | 55 +- os_dep/usb_intf.c | 447 +-- os_dep/usb_ops_linux.c | 662 +++- os_dep/xmit_linux.c | 46 +- 113 files changed, 8126 insertions(+), 34255 deletions(-) delete mode 100644 core/rtw_br_ext.c delete mode 100644 core/rtw_io.c delete mode 100644 core/rtw_mp.c delete mode 100644 core/rtw_mp_ioctl.c delete mode 100644 core/rtw_p2p.c delete mode 100644 hal/HalHWImg8188E_MAC.c delete mode 100644 hal/HalHWImg8188E_RF.c delete mode 100644 hal/HalPhyRf.c delete mode 100644 hal/HalPhyRf_8188e.c rename hal/{HalHWImg8188E_BB.c => bb_cfg.c} (54%) create mode 100644 hal/fw.c create mode 100644 hal/mac_cfg.c delete mode 100644 hal/odm_RegConfig8188E.c delete mode 100644 hal/odm_debug.c delete mode 100644 hal/odm_interface.c create mode 100644 hal/phy.c rename hal/{Hal8188EPwrSeq.c => pwrseq.c} (68%) rename hal/{HalPwrSeqCmd.c => pwrseqcmd.c} (55%) create mode 100644 hal/rf.c create mode 100644 hal/rf_cfg.c delete mode 100644 hal/rtl8188e_mp.c delete mode 100644 hal/rtl8188e_phycfg.c delete mode 100644 hal/rtl8188e_rf6052.c delete mode 100644 hal/rtl8188e_sreset.c delete mode 100644 hal/usb_ops_linux.c create mode 100644 include/fw.h create mode 100644 include/phy.h create mode 100644 include/pwrseq.h create mode 100644 include/pwrseqcmd.h create mode 100644 include/rf.h diff --git a/Makefile b/Makefile index 016dd3c..a38c8af 100644 --- a/Makefile +++ b/Makefile @@ -27,36 +27,29 @@ export TopDIR ?= $(shell pwd) OUTSRC_FILES := \ - hal/HalHWImg8188E_MAC.o \ - hal/HalHWImg8188E_BB.o \ - hal/HalHWImg8188E_RF.o \ - hal/HalPhyRf.o \ - hal/HalPhyRf_8188e.o \ - hal/HalPwrSeqCmd.o \ - hal/Hal8188EPwrSeq.o \ + hal/fw.o \ + hal/mac_cfg.o \ + hal/bb_cfg.o \ + hal/rf_cfg.o \ + hal/pwrseqcmd.o \ + hal/pwrseq.o \ hal/Hal8188ERateAdaptive.o\ hal/hal_intf.o \ hal/hal_com.o \ hal/odm.o \ - hal/odm_debug.o \ - hal/odm_interface.o \ hal/odm_HWConfig.o \ - hal/odm_RegConfig8188E.o\ hal/odm_RTL8188E.o \ hal/rtl8188e_cmd.o \ hal/rtl8188e_dm.o \ hal/rtl8188e_hal_init.o \ - hal/rtl8188e_mp.o \ - hal/rtl8188e_phycfg.o \ - hal/rtl8188e_rf6052.o \ + hal/phy.o \ + hal/rf.o \ hal/rtl8188e_rxdesc.o \ - hal/rtl8188e_sreset.o \ hal/rtl8188e_xmit.o \ hal/rtl8188eu_led.o \ hal/rtl8188eu_recv.o \ hal/rtl8188eu_xmit.o \ - hal/usb_halinit.o \ - hal/usb_ops_linux.o + hal/usb_halinit.o RTL871X = rtl8188e @@ -105,21 +98,16 @@ ifneq ($(KERNELRELEASE),) rtk_core := \ core/rtw_ap.o \ - core/rtw_br_ext.o \ core/rtw_cmd.o \ core/rtw_debug.o \ core/rtw_efuse.o \ core/rtw_ieee80211.o \ - core/rtw_io.o \ core/rtw_ioctl_set.o \ core/rtw_iol.o \ core/rtw_led.o \ core/rtw_mlme.o \ core/rtw_mlme_ext.o \ - core/rtw_mp.o \ - core/rtw_mp_ioctl.o \ core/rtw_pwrctrl.o \ - core/rtw_p2p.o \ core/rtw_recv.o \ core/rtw_rf.o \ core/rtw_security.o \ diff --git a/core/rtw_ap.c b/core/rtw_ap.c index 2f548eb..d61842e 100644 --- a/core/rtw_ap.c +++ b/core/rtw_ap.c @@ -33,7 +33,7 @@ void init_mlme_ap_info(struct adapter *padapter) struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - _rtw_spinlock_init(&pmlmepriv->bcn_update_lock); + spin_lock_init(&pmlmepriv->bcn_update_lock); /* for ACL */ _rtw_init_queue(&pacl_list->acl_node_q); @@ -43,7 +43,6 @@ void init_mlme_ap_info(struct adapter *padapter) void free_mlme_ap_info(struct adapter *padapter) { - unsigned long irqL; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -62,11 +61,9 @@ void free_mlme_ap_info(struct adapter *padapter) /* free bc/mc sta_info */ psta = rtw_get_bcmc_stainfo(padapter); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(padapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); - - _rtw_spinlock_free(&pmlmepriv->bcn_update_lock); + spin_unlock_bh(&(pstapriv->sta_hash_lock)); } static void update_BCNTIM(struct adapter *padapter) @@ -97,7 +94,7 @@ static void update_BCNTIM(struct adapter *padapter) } else { tim_ielen = 0; - /* calucate head_len */ + /* calculate head_len */ offset = _FIXED_IE_LENGTH_; offset += pnetwork_mlmeext->Ssid.SsidLength + 2; @@ -132,7 +129,7 @@ static void update_BCNTIM(struct adapter *padapter) *dst_ie++ = tim_ielen; *dst_ie++ = 0;/* DTIM count */ - *dst_ie++ = 1;/* DTIM peroid */ + *dst_ie++ = 1;/* DTIM period */ if (pstapriv->tim_bitmap&BIT(0))/* for bc/mc frames */ *dst_ie++ = BIT(0);/* bitmap ctrl */ @@ -277,7 +274,6 @@ static u8 chk_sta_is_alive(struct sta_info *psta) void expire_timeout_chk(struct adapter *padapter) { - unsigned long irqL; struct list_head *phead, *plist; u8 updated = 0; struct sta_info *psta = NULL; @@ -286,49 +282,49 @@ void expire_timeout_chk(struct adapter *padapter) char chk_alive_list[NUM_STA]; int i; - _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + spin_lock_bh(&pstapriv->auth_list_lock); phead = &pstapriv->auth_list; - plist = get_next(phead); + plist = phead->next; /* check auth_queue */ - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, auth_list); - plist = get_next(plist); + while (phead != plist) { + psta = container_of(plist, struct sta_info, auth_list); + plist = plist->next; if (psta->expire_to > 0) { psta->expire_to--; if (psta->expire_to == 0) { - rtw_list_delete(&psta->auth_list); + list_del_init(&psta->auth_list); pstapriv->auth_list_cnt--; DBG_88E("auth expire %6ph\n", psta->hwaddr); - _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + spin_unlock_bh(&pstapriv->auth_list_lock); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(padapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + spin_unlock_bh(&(pstapriv->sta_hash_lock)); - _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + spin_lock_bh(&pstapriv->auth_list_lock); } } } - _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + spin_unlock_bh(&pstapriv->auth_list_lock); psta = NULL; - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* check asoc_queue */ - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); - plist = get_next(plist); + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + plist = plist->next; if (chk_sta_is_alive(psta) || !psta->expire_to) { psta->expire_to = pstapriv->expire_to; @@ -369,7 +365,7 @@ void expire_timeout_chk(struct adapter *padapter) continue; } - rtw_list_delete(&psta->asoc_list); + list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; DBG_88E("asoc expire %pM, state = 0x%x\n", (psta->hwaddr), psta->state); @@ -387,7 +383,7 @@ void expire_timeout_chk(struct adapter *padapter) } } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); if (chk_alive_num) { u8 backup_oper_channel = 0; @@ -424,11 +420,11 @@ void expire_timeout_chk(struct adapter *padapter) psta->keep_alive_trycnt = 0; DBG_88E("asoc expire %pM, state = 0x%x\n", (psta->hwaddr), psta->state); - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - rtw_list_delete(&psta->asoc_list); + spin_lock_bh(&pstapriv->asoc_list_lock); + list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); } if (backup_oper_channel > 0) /* back to the original operation channel */ @@ -535,7 +531,6 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) static void update_bmc_sta(struct adapter *padapter) { - unsigned long irqL; u32 init_rate = 0; unsigned char network_type, raid; int i, supportRateNum = 0; @@ -553,7 +548,7 @@ static void update_bmc_sta(struct adapter *padapter) psta->ieee8021x_blocked = 0; - _rtw_memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); /* prepare for add_RATid */ supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates); @@ -604,9 +599,9 @@ static void update_bmc_sta(struct adapter *padapter) rtw_stassoc_hw_rpt(padapter, psta); - _enter_critical_bh(&psta->lock, &irqL); + spin_lock_bh(&psta->lock); psta->state = _FW_LINKED; - _exit_critical_bh(&psta->lock, &irqL); + spin_unlock_bh(&psta->lock); } else { DBG_88E("add_RATid_bmc_sta error!\n"); @@ -622,7 +617,6 @@ static void update_bmc_sta(struct adapter *padapter) void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) { - unsigned long irqL; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); @@ -677,11 +671,11 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) /* todo: init other variables */ - _rtw_memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); - _enter_critical_bh(&psta->lock, &irqL); + spin_lock_bh(&psta->lock); psta->state |= _FW_LINKED; - _exit_critical_bh(&psta->lock, &irqL); + spin_unlock_bh(&psta->lock); } static void update_hw_ht_param(struct adapter *padapter) @@ -729,9 +723,6 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) 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; @@ -827,17 +818,12 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) /* update cur_wireless_mode */ update_wireless_mode(padapter); - /* udpate capability after cur_wireless_mode updated */ + /* update 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); @@ -892,7 +878,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->IELength = len; - _rtw_memset(ie, 0, MAX_IE_SZ); + memset(ie, 0, MAX_IE_SZ); memcpy(ie, pbuf, pbss_network->IELength); @@ -902,19 +888,19 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->Rssi = 0; - memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN); + ether_addr_copy(pbss_network->MacAddress, myid(&(padapter->eeprompriv))); /* beacon interval */ p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ - pbss_network->Configuration.BeaconPeriod = RTW_GET_LE16(p); + pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p); /* capability */ - cap = RTW_GET_LE16(ie); + 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) { - _rtw_memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + 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; } @@ -928,7 +914,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->Configuration.DSConfig = channel; - _rtw_memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); + 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 != NULL) { @@ -986,7 +972,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) 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) && (_rtw_memcmp(p+2, OUI1, 4))) { + 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; @@ -1011,7 +997,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) 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) && _rtw_memcmp(p+2, WMM_PARA_IE, 6)) { + if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { pmlmepriv->qospriv.qos_option = 1; *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ @@ -1134,7 +1120,6 @@ void rtw_set_macaddr_acl(struct adapter *padapter, int mode) int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) { - unsigned long irqL; struct list_head *plist, *phead; u8 added = false; int i, ret = 0; @@ -1148,16 +1133,16 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) if ((NUM_ACL-1) < pacl_list->num) return -1; - _enter_critical_bh(&(pacl_node_q->lock), &irqL); + spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); + plist = phead->next; - while (!rtw_end_of_queue_search(phead, plist)) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; - if (_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid) { added = true; DBG_88E("%s, sta has been added\n", __func__); @@ -1166,24 +1151,24 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) } } - _exit_critical_bh(&(pacl_node_q->lock), &irqL); + spin_unlock_bh(&(pacl_node_q->lock)); if (added) return ret; - _enter_critical_bh(&(pacl_node_q->lock), &irqL); + spin_lock_bh(&(pacl_node_q->lock)); for (i = 0; i < NUM_ACL; i++) { paclnode = &pacl_list->aclnode[i]; if (!paclnode->valid) { - _rtw_init_listhead(&paclnode->list); + INIT_LIST_HEAD(&paclnode->list); - memcpy(paclnode->addr, addr, ETH_ALEN); + ether_addr_copy(paclnode->addr, addr); paclnode->valid = true; - rtw_list_insert_tail(&paclnode->list, get_list_head(pacl_node_q)); + list_add_tail(&paclnode->list, get_list_head(pacl_node_q)); pacl_list->num++; @@ -1193,16 +1178,14 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); - _exit_critical_bh(&(pacl_node_q->lock), &irqL); + spin_unlock_bh(&(pacl_node_q->lock)); return ret; } int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) { - unsigned long irqL; 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; @@ -1210,30 +1193,30 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); - _enter_critical_bh(&(pacl_node_q->lock), &irqL); + spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); + plist = phead->next; - while (!rtw_end_of_queue_search(phead, plist)) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; - if (_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid) { paclnode->valid = false; - rtw_list_delete(&paclnode->list); + list_del_init(&paclnode->list); pacl_list->num--; } } } - _exit_critical_bh(&(pacl_node_q->lock), &irqL); + spin_unlock_bh(&(pacl_node_q->lock)); DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); - return ret; + return 0; } static void update_bcn_fixed_ie(struct adapter *padapter) @@ -1314,6 +1297,10 @@ static void update_bcn_wps_ie(struct adapter *padapter) DBG_88E("%s\n", __func__); + pwps_ie_src = pmlmepriv->wps_beacon_ie; + if (pwps_ie_src == NULL) + return; + pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); if (pwps_ie == NULL || wps_ielen == 0) @@ -1331,10 +1318,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } - pwps_ie_src = pmlmepriv->wps_beacon_ie; - if (pwps_ie_src == NULL) - return; - wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); @@ -1347,8 +1330,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) pnetwork->IELength = wps_offset + (wps_ielen+2) + remainder_ielen; } - if (pbackup_remainder_ie) - kfree(pbackup_remainder_ie); + kfree(pbackup_remainder_ie); } static void update_bcn_p2p_ie(struct adapter *padapter) @@ -1359,13 +1341,13 @@ static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) { DBG_88E("%s\n", __func__); - if (_rtw_memcmp(RTW_WPA_OUI, oui, 4)) + if (!memcmp(RTW_WPA_OUI, oui, 4)) update_bcn_wpa_ie(padapter); - else if (_rtw_memcmp(WMM_OUI, oui, 4)) + else if (!memcmp(WMM_OUI, oui, 4)) update_bcn_wmm_ie(padapter); - else if (_rtw_memcmp(WPS_OUI, oui, 4)) + else if (!memcmp(WPS_OUI, oui, 4)) update_bcn_wps_ie(padapter); - else if (_rtw_memcmp(P2P_OUI, oui, 4)) + else if (!memcmp(P2P_OUI, oui, 4)) update_bcn_p2p_ie(padapter); else DBG_88E("unknown OUI type!\n"); @@ -1373,7 +1355,6 @@ static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) { - unsigned long irqL; struct mlme_priv *pmlmepriv; struct mlme_ext_priv *pmlmeext; @@ -1386,7 +1367,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) if (!pmlmeext->bstart_bss) return; - _enter_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); + spin_lock_bh(&pmlmepriv->bcn_update_lock); switch (ie_id) { case 0xFF: @@ -1416,7 +1397,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) pmlmepriv->update_bcn = true; - _exit_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); + spin_unlock_bh(&pmlmepriv->bcn_update_lock); if (tx) set_tx_beacon_cmd(padapter); @@ -1424,7 +1405,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 @@ -1503,27 +1484,26 @@ static int rtw_ht_operation_update(struct adapter *padapter) void associated_clients_update(struct adapter *padapter, u8 updated) { - /* update associcated stations cap. */ + /* update associated stations cap. */ if (updated) { - unsigned long irqL; struct list_head *phead, *plist; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* check asoc_queue */ - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; VCS_update(padapter, psta); } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); } } @@ -1657,7 +1637,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } - /* update associcated stations cap. */ + /* update associated stations cap. */ associated_clients_update(padapter, beacon_updated); DBG_88E("%s, updated =%d\n", __func__, beacon_updated); @@ -1721,7 +1701,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } - /* update associcated stations cap. */ + /* update associated stations cap. */ DBG_88E("%s, updated =%d\n", __func__, beacon_updated); @@ -1731,7 +1711,6 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, bool active, u16 reason) { - unsigned long irqL; u8 beacon_updated = false; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1753,9 +1732,9 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, rtw_clearstakey_cmd(padapter, (u8 *)psta, (u8)(psta->mac_id + 3), true); - _enter_critical_bh(&psta->lock, &irqL); + spin_lock_bh(&psta->lock); psta->state &= ~_FW_LINKED; - _exit_critical_bh(&psta->lock, &irqL); + spin_unlock_bh(&psta->lock); rtw_indicate_sta_disassoc_event(padapter, psta); @@ -1763,18 +1742,16 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, beacon_updated = bss_cap_update_on_sta_leave(padapter, psta); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(padapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + spin_unlock_bh(&(pstapriv->sta_hash_lock)); return beacon_updated; } int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) { - unsigned long irqL; 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; @@ -1782,35 +1759,33 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - return ret; + return 0; DBG_88E(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset); - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* for each sta in asoc_queue */ - while (!rtw_end_of_queue_search(phead, plist)) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); - plist = get_next(plist); + 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); } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); issue_action_spct_ch_switch(padapter, bc_addr, new_ch, ch_offset); - return ret; + return 0; } int rtw_sta_flush(struct adapter *padapter) { - unsigned long irqL; 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; @@ -1820,31 +1795,31 @@ int rtw_sta_flush(struct adapter *padapter) DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - return ret; + return 0; - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* free sta asoc_queue */ - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; - rtw_list_delete(&psta->asoc_list); + list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); associated_clients_update(padapter, true); - return ret; + return 0; } /* called > TSR LEVEL for USB or SDIO Interface*/ @@ -1924,18 +1899,17 @@ void start_ap_mode(struct adapter *padapter) pmlmepriv->p2p_probe_resp_ie = NULL; /* for ACL */ - _rtw_init_listhead(&(pacl_list->acl_node_q.queue)); + INIT_LIST_HEAD(&(pacl_list->acl_node_q.queue)); pacl_list->num = 0; pacl_list->mode = 0; for (i = 0; i < NUM_ACL; i++) { - _rtw_init_listhead(&pacl_list->aclnode[i].list); + INIT_LIST_HEAD(&pacl_list->aclnode[i].list); pacl_list->aclnode[i].valid = false; } } void stop_ap_mode(struct adapter *padapter) { - unsigned long irqL; struct list_head *phead, *plist; struct rtw_wlan_acl_node *paclnode; struct sta_info *psta = NULL; @@ -1949,27 +1923,27 @@ void stop_ap_mode(struct adapter *padapter) pmlmeext->bstart_bss = false; /* reset and init security priv , this can refine with rtw_reset_securitypriv */ - _rtw_memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv)); + memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv)); padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; /* for ACL */ - _enter_critical_bh(&(pacl_node_q->lock), &irqL); + spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); - while ((rtw_end_of_queue_search(phead, plist)) == false) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + plist = phead->next; + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; if (paclnode->valid) { paclnode->valid = false; - rtw_list_delete(&paclnode->list); + list_del_init(&paclnode->list); pacl_list->num--; } } - _exit_critical_bh(&(pacl_node_q->lock), &irqL); + spin_unlock_bh(&(pacl_node_q->lock)); DBG_88E("%s, free acl_node_queue, num =%d\n", __func__, pacl_list->num); @@ -1979,9 +1953,9 @@ void stop_ap_mode(struct adapter *padapter) rtw_free_all_stainfo(padapter); psta = rtw_get_bcmc_stainfo(padapter); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(padapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + spin_unlock_bh(&(pstapriv->sta_hash_lock)); rtw_init_bcmc_stainfo(padapter); diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c deleted file mode 100644 index 11b1808..0000000 --- a/core/rtw_br_ext.c +++ /dev/null @@ -1,1198 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _RTW_BR_EXT_C_ - -#include -#include -#include -#include -#include -#include - -#include -#include "rtw_br_ext.h" -#include -#include - -#ifndef csum_ipv6_magic -#include -#endif - -#include -#include -#include -#include - -#define NAT25_IPV4 01 -#define NAT25_IPV6 02 -#define NAT25_IPX 03 -#define NAT25_APPLE 04 -#define NAT25_PPPOE 05 - -#define RTL_RELAY_TAG_LEN (ETH_ALEN) -#define TAG_HDR_LEN 4 - -#define MAGIC_CODE 0x8186 -#define MAGIC_CODE_LEN 2 -#define WAIT_TIME_PPPOE 5 /* waiting time for pppoe server in sec */ - -/*----------------------------------------------------------------- - How database records network address: - 0 1 2 3 4 5 6 7 8 9 10 - |----|----|----|----|----|----|----|----|----|----|----| - IPv4 |type| | IP addr | - IPX |type| Net addr | Node addr | - IPX |type| Net addr |Sckt addr| - Apple |type| Network |node| - PPPoE |type| SID | AC MAC | ------------------------------------------------------------------*/ - - -/* Find a tag in pppoe frame and return the pointer */ -static inline unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type) -{ - unsigned char *cur_ptr, *start_ptr; - unsigned short tagLen, tagType; - - start_ptr = cur_ptr = (unsigned char *)ph->tag; - while ((cur_ptr - start_ptr) < ntohs(ph->length)) { - /* prevent un-alignment access */ - tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]); - tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]); - if (tagType == type) - return cur_ptr; - cur_ptr = cur_ptr + TAG_HDR_LEN + tagLen; - } - return NULL; -} - - -static inline int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) -{ - struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); - int data_len; - - data_len = tag->tag_len + TAG_HDR_LEN; - if (skb_tailroom(skb) < data_len) { - _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n"); - return -1; - } - - skb_put(skb, data_len); - /* have a room for new tag */ - memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length)); - ph->length = htons(ntohs(ph->length) + data_len); - memcpy((unsigned char *)ph->tag, tag, data_len); - return data_len; -} - -static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len) -{ - int tail_len; - unsigned long end, tail; - - if ((src+len) > skb_tail_pointer(skb) || skb->len < len) - return -1; - - tail = (unsigned long)skb_tail_pointer(skb); - end = (unsigned long)src+len; - if (tail < end) - return -1; - - tail_len = (int)(tail-end); - if (tail_len > 0) - memmove(src, src+len, tail_len); - - skb_trim(skb, skb->len-len); - return 0; -} - -static inline unsigned long __nat25_timeout(struct adapter *priv) -{ - unsigned long timeout; - - timeout = jiffies - NAT25_AGEING_TIME*HZ; - - return timeout; -} - - -static inline int __nat25_has_expired(struct adapter *priv, - struct nat25_network_db_entry *fdb) -{ - if (time_before_eq(fdb->ageing_timer, __nat25_timeout(priv))) - return 1; - - return 0; -} - - -static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, - unsigned int *ipAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPV4; - memcpy(networkAddr+7, (unsigned char *)ipAddr, 4); -} - - -static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); - memcpy(networkAddr+5, ipxNodeAddr, 6); -} - - -static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); - memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2); -} - - -static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, - unsigned short *network, unsigned char *node) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_APPLE; - memcpy(networkAddr+1, (unsigned char *)network, 2); - networkAddr[3] = *node; -} - -static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, - unsigned char *ac_mac, unsigned short *sid) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_PPPOE; - memcpy(networkAddr+1, (unsigned char *)sid, 2); - memcpy(networkAddr+3, (unsigned char *)ac_mac, 6); -} - -static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr, - unsigned int *ipAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPV6; - memcpy(networkAddr+1, (unsigned char *)ipAddr, 16); -} - -static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b) -{ - while (len > 0) { - if (*data == tag && *(data+1) == len8b && len >= len8b*8) - return data+2; - - len -= (*(data+1))*8; - data += (*(data+1))*8; - } - return NULL; -} - -static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac) -{ - struct icmp6hdr *icmphdr = (struct icmp6hdr *)data; - unsigned char *mac; - - if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) { - if (len >= 8) { - mac = scan_tlv(&data[8], len-8, 1, 1); - if (mac) { - _DEBUG_INFO("Router Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], - replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); - memcpy(mac, replace_mac, 6); - return 1; - } - } - } else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) { - if (len >= 16) { - mac = scan_tlv(&data[16], len-16, 1, 1); - if (mac) { - _DEBUG_INFO("Router Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], - replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); - memcpy(mac, replace_mac, 6); - return 1; - } - } - } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) { - if (len >= 24) { - mac = scan_tlv(&data[24], len-24, 1, 1); - if (mac) { - _DEBUG_INFO("Neighbor Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], - replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); - memcpy(mac, replace_mac, 6); - return 1; - } - } - } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) { - if (len >= 24) { - mac = scan_tlv(&data[24], len-24, 2, 1); - if (mac) { - _DEBUG_INFO("Neighbor Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], - replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); - memcpy(mac, replace_mac, 6); - return 1; - } - } - } else if (icmphdr->icmp6_type == NDISC_REDIRECT) { - if (len >= 40) { - mac = scan_tlv(&data[40], len-40, 2, 1); - if (mac) { - _DEBUG_INFO("Redirect, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], - replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); - memcpy(mac, replace_mac, 6); - return 1; - } - } - } - return 0; -} - -static inline int __nat25_network_hash(unsigned char *networkAddr) -{ - if (networkAddr[0] == NAT25_IPV4) { - unsigned long x; - - x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; - - return x & (NAT25_HASH_SIZE - 1); - } else if (networkAddr[0] == NAT25_IPX) { - unsigned long x; - - x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ - networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; - - return x & (NAT25_HASH_SIZE - 1); - } else if (networkAddr[0] == NAT25_APPLE) { - unsigned long x; - - x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3]; - - return x & (NAT25_HASH_SIZE - 1); - } else if (networkAddr[0] == NAT25_PPPOE) { - unsigned long x; - - x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ networkAddr[6] ^ networkAddr[7] ^ networkAddr[8]; - - return x & (NAT25_HASH_SIZE - 1); - } else if (networkAddr[0] == NAT25_IPV6) { - unsigned long x; - - x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ - networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10] ^ - networkAddr[11] ^ networkAddr[12] ^ networkAddr[13] ^ networkAddr[14] ^ networkAddr[15] ^ - networkAddr[16]; - - return x & (NAT25_HASH_SIZE - 1); - } else { - unsigned long x = 0; - int i; - - for (i = 0; i < MAX_NETWORK_ADDR_LEN; i++) - x ^= networkAddr[i]; - - return x & (NAT25_HASH_SIZE - 1); - } -} - -static inline void __network_hash_link(struct adapter *priv, - struct nat25_network_db_entry *ent, int hash) -{ - /* Caller must _enter_critical_bh already! */ - ent->next_hash = priv->nethash[hash]; - if (ent->next_hash != NULL) - ent->next_hash->pprev_hash = &ent->next_hash; - priv->nethash[hash] = ent; - ent->pprev_hash = &priv->nethash[hash]; -} - -static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) -{ - /* Caller must _enter_critical_bh already! */ - *(ent->pprev_hash) = ent->next_hash; - if (ent->next_hash != NULL) - ent->next_hash->pprev_hash = ent->pprev_hash; - ent->next_hash = NULL; - ent->pprev_hash = NULL; -} - -static int __nat25_db_network_lookup_and_replace(struct adapter *priv, - struct sk_buff *skb, unsigned char *networkAddr) -{ - struct nat25_network_db_entry *db; - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); - - db = priv->nethash[__nat25_network_hash(networkAddr)]; - while (db != NULL) { - if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { - if (!__nat25_has_expired(priv, db)) { - /* replace the destination mac address */ - memcpy(skb->data, db->macAddr, ETH_ALEN); - atomic_inc(&db->use_count); - - DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" - "%02x%02x%02x%02x%02x%02x\n", - db->macAddr[0], - db->macAddr[1], - db->macAddr[2], - db->macAddr[3], - db->macAddr[4], - db->macAddr[5], - db->networkAddr[0], - db->networkAddr[1], - db->networkAddr[2], - db->networkAddr[3], - db->networkAddr[4], - db->networkAddr[5], - db->networkAddr[6], - db->networkAddr[7], - db->networkAddr[8], - db->networkAddr[9], - db->networkAddr[10], - db->networkAddr[11], - db->networkAddr[12], - db->networkAddr[13], - db->networkAddr[14], - db->networkAddr[15], - db->networkAddr[16]); - } - _exit_critical_bh(&priv->br_ext_lock, &irqL); - return 1; - } - db = db->next_hash; - } - _exit_critical_bh(&priv->br_ext_lock, &irqL); - return 0; -} - -static void __nat25_db_network_insert(struct adapter *priv, - unsigned char *macAddr, unsigned char *networkAddr) -{ - struct nat25_network_db_entry *db; - int hash; - unsigned long irqL; - - _enter_critical_bh(&priv->br_ext_lock, &irqL); - hash = __nat25_network_hash(networkAddr); - db = priv->nethash[hash]; - while (db != NULL) { - if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { - memcpy(db->macAddr, macAddr, ETH_ALEN); - db->ageing_timer = jiffies; - _exit_critical_bh(&priv->br_ext_lock, &irqL); - return; - } - db = db->next_hash; - } - db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); - if (db == NULL) { - _exit_critical_bh(&priv->br_ext_lock, &irqL); - return; - } - memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN); - memcpy(db->macAddr, macAddr, ETH_ALEN); - atomic_set(&db->use_count, 1); - db->ageing_timer = jiffies; - - __network_hash_link(priv, db, hash); - - _exit_critical_bh(&priv->br_ext_lock, &irqL); -} - -static void __nat25_db_print(struct adapter *priv) -{ -} - -/* - * NAT2.5 interface - */ - -void nat25_db_cleanup(struct adapter *priv) -{ - int i; - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); - - for (i = 0; i < NAT25_HASH_SIZE; i++) { - struct nat25_network_db_entry *f; - f = priv->nethash[i]; - while (f != NULL) { - struct nat25_network_db_entry *g; - - g = f->next_hash; - if (priv->scdb_entry == f) { - memset(priv->scdb_mac, 0, ETH_ALEN); - memset(priv->scdb_ip, 0, 4); - priv->scdb_entry = NULL; - } - __network_hash_unlink(f); - kfree(f); - f = g; - } - } - _exit_critical_bh(&priv->br_ext_lock, &irqL); -} - -void nat25_db_expire(struct adapter *priv) -{ - int i; - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); - - for (i = 0; i < NAT25_HASH_SIZE; i++) { - struct nat25_network_db_entry *f; - f = priv->nethash[i]; - - while (f != NULL) { - struct nat25_network_db_entry *g; - g = f->next_hash; - - if (__nat25_has_expired(priv, f)) { - if (atomic_dec_and_test(&f->use_count)) { - if (priv->scdb_entry == f) { - memset(priv->scdb_mac, 0, ETH_ALEN); - memset(priv->scdb_ip, 0, 4); - priv->scdb_entry = NULL; - } - __network_hash_unlink(f); - kfree(f); - } - } - f = g; - } - } - _exit_critical_bh(&priv->br_ext_lock, &irqL); -} - -int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) -{ - unsigned short protocol; - unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; - unsigned int tmp; - - if (skb == NULL) - return -1; - - if ((method <= NAT25_MIN) || (method >= NAT25_MAX)) - return -1; - - protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN))); - - /*---------------------------------------------------*/ - /* Handle IP frame */ - /*---------------------------------------------------*/ - if (protocol == ETH_P_IP) { - struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN); - - if (((unsigned char *)(iph) + (iph->ihl<<2)) >= (skb->data + ETH_HLEN + skb->len)) { - DEBUG_WARN("NAT25: malformed IP packet !\n"); - return -1; - } - - switch (method) { - case NAT25_CHECK: - return -1; - case NAT25_INSERT: - /* some multicast with source IP is all zero, maybe other case is illegal */ - /* in class A, B, C, host address is all zero or all one is illegal */ - if (iph->saddr == 0) - return 0; - tmp = be32_to_cpu(iph->saddr); - DEBUG_INFO("NAT25: Insert IP, SA =%08x, DA =%08x\n", tmp, iph->daddr); - __nat25_generate_ipv4_network_addr(networkAddr, &tmp); - /* record source IP address and , source mac address into db */ - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup IP, SA =%08x, DA =%08x\n", iph->saddr, iph->daddr); - tmp = be32_to_cpu(iph->daddr); - __nat25_generate_ipv4_network_addr(networkAddr, &tmp); - - if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) { - if (*((unsigned char *)&iph->daddr + 3) == 0xff) { - /* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */ - DEBUG_INFO("NAT25: Set DA as boardcast\n"); - memset(skb->data, 0xff, ETH_ALEN); - } else { - /* forward unknow IP packet to upper TCP/IP */ - DEBUG_INFO("NAT25: Replace DA with BR's MAC\n"); - if ((*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0) { - printk("Re-init netdev_br_init() due to br_mac == 0!\n"); - netdev_br_init(priv->pnetdev); - } - memcpy(skb->data, priv->br_mac, ETH_ALEN); - } - } - return 0; - default: - return -1; - } - } else if (protocol == ETH_P_ARP) { - /*---------------------------------------------------*/ - /* Handle ARP frame */ - /*---------------------------------------------------*/ - struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN); - unsigned char *arp_ptr = (unsigned char *)(arp + 1); - unsigned int *sender, *target; - - if (arp->ar_pro != __constant_htons(ETH_P_IP)) { - DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", be16_to_cpu(arp->ar_pro)); - return -1; - } - - switch (method) { - case NAT25_CHECK: - return 0; /* skb_copy for all ARP frame */ - case NAT25_INSERT: - DEBUG_INFO("NAT25: Insert ARP, MAC =%02x%02x%02x%02x%02x%02x\n", arp_ptr[0], - arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]); - - /* change to ARP sender mac address to wlan STA address */ - memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN); - arp_ptr += arp->ar_hln; - sender = (unsigned int *)arp_ptr; - __nat25_generate_ipv4_network_addr(networkAddr, sender); - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup ARP\n"); - - arp_ptr += arp->ar_hln; - sender = (unsigned int *)arp_ptr; - arp_ptr += (arp->ar_hln + arp->ar_pln); - target = (unsigned int *)arp_ptr; - __nat25_generate_ipv4_network_addr(networkAddr, target); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - /* change to ARP target mac address to Lookup result */ - arp_ptr = (unsigned char *)(arp + 1); - arp_ptr += (arp->ar_hln + arp->ar_pln); - memcpy(arp_ptr, skb->data, ETH_ALEN); - return 0; - default: - return -1; - } - } else if ((protocol == ETH_P_IPX) || - (protocol <= ETH_FRAME_LEN)) { - /*---------------------------------------------------*/ - /* Handle IPX and Apple Talk frame */ - /*---------------------------------------------------*/ - unsigned char ipx_header[2] = {0xFF, 0xFF}; - struct ipxhdr *ipx = NULL; - struct elapaarp *ea = NULL; - struct ddpehdr *ddp = NULL; - unsigned char *framePtr = skb->data + ETH_HLEN; - - if (protocol == ETH_P_IPX) { - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet II)\n"); - ipx = (struct ipxhdr *)framePtr; - } else if (protocol <= ETH_FRAME_LEN) { - if (!memcmp(ipx_header, framePtr, 2)) { - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.3)\n"); - ipx = (struct ipxhdr *)framePtr; - } else { - unsigned char ipx_8022_type = 0xE0; - unsigned char snap_8022_type = 0xAA; - - if (*framePtr == snap_8022_type) { - unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */ - unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */ - unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */ - - framePtr += 3; /* eliminate the 802.2 header */ - - if (!memcmp(ipx_snap_id, framePtr, 5)) { - framePtr += 5; /* eliminate the SNAP header */ - - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet SNAP)\n"); - ipx = (struct ipxhdr *)framePtr; - } else if (!memcmp(aarp_snap_id, framePtr, 5)) { - framePtr += 5; /* eliminate the SNAP header */ - - ea = (struct elapaarp *)framePtr; - } else if (!memcmp(ddp_snap_id, framePtr, 5)) { - framePtr += 5; /* eliminate the SNAP header */ - - ddp = (struct ddpehdr *)framePtr; - } else { - DEBUG_WARN("NAT25: Protocol = Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], - framePtr[1], framePtr[2], framePtr[3], framePtr[4]); - return -1; - } - } else if (*framePtr == ipx_8022_type) { - framePtr += 3; /* eliminate the 802.2 header */ - - if (!memcmp(ipx_header, framePtr, 2)) { - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.2)\n"); - ipx = (struct ipxhdr *)framePtr; - } else { - return -1; - } - } else { - return -1; - } - } - } else { - return -1; - } - - /* IPX */ - if (ipx != NULL) { - switch (method) { - case NAT25_CHECK: - if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) - DEBUG_INFO("NAT25: Check IPX skb_copy\n"); - return 0; - case NAT25_INSERT: - DEBUG_INFO("NAT25: Insert IPX, Dest =%08x,%02x%02x%02x%02x%02x%02x,%04x Source =%08x,%02x%02x%02x%02x%02x%02x,%04x\n", - ipx->ipx_dest.net, - ipx->ipx_dest.node[0], - ipx->ipx_dest.node[1], - ipx->ipx_dest.node[2], - ipx->ipx_dest.node[3], - ipx->ipx_dest.node[4], - ipx->ipx_dest.node[5], - ipx->ipx_dest.sock, - ipx->ipx_source.net, - ipx->ipx_source.node[0], - ipx->ipx_source.node[1], - ipx->ipx_source.node[2], - ipx->ipx_source.node[3], - ipx->ipx_source.node[4], - ipx->ipx_source.node[5], - ipx->ipx_source.sock); - - if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { - DEBUG_INFO("NAT25: Use IPX Net, and Socket as network addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); - - /* change IPX source node addr to wlan STA address */ - memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); - } else { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); - } - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - if (!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) { - DEBUG_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - - /* replace IPX destination node addr with Lookup destination MAC addr */ - memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); - } else { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - } - return 0; - default: - return -1; - } - } else if (ea != NULL) { - /* Sanity check fields. */ - if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) { - DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); - return -1; - } - - switch (method) { - case NAT25_CHECK: - return 0; - case NAT25_INSERT: - /* change to AARP source mac address to wlan STA address */ - memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN); - - DEBUG_INFO("NAT25: Insert AARP, Source =%d,%d Destination =%d,%d\n", - ea->pa_src_net, - ea->pa_src_node, - ea->pa_dst_net, - ea->pa_dst_node); - - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node); - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup AARP, Source =%d,%d Destination =%d,%d\n", - ea->pa_src_net, - ea->pa_src_node, - ea->pa_dst_net, - ea->pa_dst_node); - - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - - /* change to AARP destination mac address to Lookup result */ - memcpy(ea->hw_dst, skb->data, ETH_ALEN); - return 0; - default: - return -1; - } - } else if (ddp != NULL) { - switch (method) { - case NAT25_CHECK: - return -1; - case NAT25_INSERT: - DEBUG_INFO("NAT25: Insert DDP, Source =%d,%d Destination =%d,%d\n", - ddp->deh_snet, - ddp->deh_snode, - ddp->deh_dnet, - ddp->deh_dnode); - - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode); - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup DDP, Source =%d,%d Destination =%d,%d\n", - ddp->deh_snet, - ddp->deh_snode, - ddp->deh_dnet, - ddp->deh_dnode); - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - return 0; - default: - return -1; - } - } - - return -1; - } else if ((protocol == ETH_P_PPP_DISC) || - (protocol == ETH_P_PPP_SES)) { - /*---------------------------------------------------*/ - /* Handle PPPoE frame */ - /*---------------------------------------------------*/ - struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); - unsigned short *pMagic; - - switch (method) { - case NAT25_CHECK: - if (ph->sid == 0) - return 0; - return 1; - case NAT25_INSERT: - if (ph->sid == 0) { /* Discovery phase according to tag */ - if (ph->code == PADI_CODE || ph->code == PADR_CODE) { - if (priv->ethBrExtInfo.addPPPoETag) { - struct pppoe_tag *tag, *pOldTag; - unsigned char tag_buf[40]; - int old_tag_len = 0; - - tag = (struct pppoe_tag *)tag_buf; - pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); - if (pOldTag) { /* if SID existed, copy old value and delete it */ - old_tag_len = ntohs(pOldTag->tag_len); - if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) { - DEBUG_ERR("SID tag length too long!\n"); - return -1; - } - - memcpy(tag->tag_data+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN, - pOldTag->tag_data, old_tag_len); - - if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN+old_tag_len) < 0) { - DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n"); - return -1; - } - ph->length = htons(ntohs(ph->length)-TAG_HDR_LEN-old_tag_len); - } - - tag->tag_type = PTT_RELAY_SID; - tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len); - - /* insert the magic_code+client mac in relay tag */ - pMagic = (unsigned short *)tag->tag_data; - *pMagic = htons(MAGIC_CODE); - memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN); - - /* Add relay tag */ - if (__nat25_add_pppoe_tag(skb, tag) < 0) - return -1; - - DEBUG_INFO("NAT25: Insert PPPoE, forward %s packet\n", - (ph->code == PADI_CODE ? "PADI" : "PADR")); - } else { /* not add relay tag */ - if (priv->pppoe_connection_in_progress && - memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) { - DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n"); - return -2; - } - - if (priv->pppoe_connection_in_progress == 0) - memcpy(priv->pppoe_addr, skb->data+ETH_ALEN, ETH_ALEN); - - priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE; - } - } else { - return -1; - } - } else { /* session phase */ - DEBUG_INFO("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name); - - __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid)); - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - - if (!priv->ethBrExtInfo.addPPPoETag && - priv->pppoe_connection_in_progress && - !memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) - priv->pppoe_connection_in_progress = 0; - } - return 0; - case NAT25_LOOKUP: - if (ph->code == PADO_CODE || ph->code == PADS_CODE) { - if (priv->ethBrExtInfo.addPPPoETag) { - struct pppoe_tag *tag; - unsigned char *ptr; - unsigned short tagType, tagLen; - int offset = 0; - - ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); - if (ptr == NULL) { - DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n"); - return -1; - } - - tag = (struct pppoe_tag *)ptr; - tagType = (unsigned short)((ptr[0] << 8) + ptr[1]); - tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]); - - if ((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) { - DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen); - return -1; - } - - pMagic = (unsigned short *)tag->tag_data; - if (ntohs(*pMagic) != MAGIC_CODE) { - DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n", - (ph->code == PADO_CODE ? "PADO" : "PADS")); - return -1; - } - - memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN); - - if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN) - offset = TAG_HDR_LEN; - - if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) { - DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n"); - return -1; - } - ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset)); - if (offset > 0) - tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN); - - DEBUG_INFO("NAT25: Lookup PPPoE, forward %s Packet from %s\n", - (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name); - } else { /* not add relay tag */ - if (!priv->pppoe_connection_in_progress) { - DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n"); - return -1; - } - memcpy(skb->data, priv->pppoe_addr, ETH_ALEN); - priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE; - } - } else { - if (ph->sid != 0) { - DEBUG_INFO("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name); - __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid)); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - __nat25_db_print(priv); - } else { - return -1; - } - } - return 0; - default: - return -1; - } - } else if (protocol == 0x888e) { - /*---------------------------------------------------*/ - /* Handle EAP frame */ - /*---------------------------------------------------*/ - switch (method) { - case NAT25_CHECK: - return -1; - case NAT25_INSERT: - return 0; - case NAT25_LOOKUP: - return 0; - default: - return -1; - } - } else if ((protocol == 0xe2ae) || (protocol == 0xe2af)) { - /*---------------------------------------------------*/ - /* Handle C-Media proprietary frame */ - /*---------------------------------------------------*/ - switch (method) { - case NAT25_CHECK: - return -1; - case NAT25_INSERT: - return 0; - case NAT25_LOOKUP: - return 0; - default: - return -1; - } - } else if (protocol == ETH_P_IPV6) { - /*------------------------------------------------*/ - /* Handle IPV6 frame */ - /*------------------------------------------------*/ - struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN); - - if (sizeof(*iph) >= (skb->len - ETH_HLEN)) { - DEBUG_WARN("NAT25: malformed IPv6 packet !\n"); - return -1; - } - - switch (method) { - case NAT25_CHECK: - if (skb->data[0] & 1) - return 0; - return -1; - case NAT25_INSERT: - DEBUG_INFO("NAT25: Insert IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x," - " DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n", - iph->saddr.s6_addr16[0], iph->saddr.s6_addr16[1], iph->saddr.s6_addr16[2], iph->saddr.s6_addr16[3], - iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], - iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], - iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); - - if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) { - __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr); - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - __nat25_db_print(priv); - - if (iph->nexthdr == IPPROTO_ICMPV6 && - skb->len > (ETH_HLEN + sizeof(*iph) + 4)) { - if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph), - skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) { - struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph)); - hdr->icmp6_cksum = 0; - hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr, - iph->payload_len, - IPPROTO_ICMPV6, - csum_partial((__u8 *)hdr, iph->payload_len, 0)); - } - } - } - return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x, DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n", - iph->saddr.s6_addr16[0], iph->saddr.s6_addr16[1], iph->saddr.s6_addr16[2], iph->saddr.s6_addr16[3], - iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], - iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], - iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); - __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - return 0; - default: - return -1; - } - } - return -1; -} - -int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb) -{ - if (!(skb->data[0] & 1)) { - int is_vlan_tag = 0, i, retval = 0; - unsigned short vlan_hdr = 0; - unsigned short protocol; - - protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN))); - if (protocol == ETH_P_8021Q) { - is_vlan_tag = 1; - vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2)); - for (i = 0; i < 6; i++) - *((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 (!priv->ethBrExtInfo.nat25_disable) { - unsigned long irqL; - _enter_critical_bh(&priv->br_ext_lock, &irqL); - /* - * This function look up the destination network address from - * the NAT2.5 database. Return value = -1 means that the - * corresponding network protocol is NOT support. - */ - if (!priv->ethBrExtInfo.nat25sc_disable && - (be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && - !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) { - memcpy(skb->data, priv->scdb_mac, ETH_ALEN); - - _exit_critical_bh(&priv->br_ext_lock, &irqL); - } else { - _exit_critical_bh(&priv->br_ext_lock, &irqL); - - retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); - } - } else { - if (((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && - !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) || - ((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_ARP) && - !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) { - /* for traffic to upper TCP/IP */ - retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); - } - } - - if (is_vlan_tag) { - 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+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q); - *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr; - } - - if (retval == -1) { - /* DEBUG_ERR("NAT25: Lookup fail!\n"); */ - return -1; - } - } - - return 0; -} - -#define SERVER_PORT 67 -#define CLIENT_PORT 68 -#define DHCP_MAGIC 0x63825363 -#define BROADCAST_FLAG 0x8000 - -struct dhcpMessage { - u_int8_t op; - u_int8_t htype; - u_int8_t hlen; - u_int8_t hops; - u_int32_t xid; - u_int16_t secs; - u_int16_t flags; - u_int32_t ciaddr; - u_int32_t yiaddr; - u_int32_t siaddr; - u_int32_t giaddr; - u_int8_t chaddr[16]; - u_int8_t sname[64]; - u_int8_t file[128]; - u_int32_t cookie; - u_int8_t options[308]; /* 312 - cookie */ -}; - -void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) -{ - if (skb == NULL) - return; - - if (!priv->ethBrExtInfo.dhcp_bcst_disable) { - __be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN)); - - if (protocol == __constant_htons(ETH_P_IP)) { /* IP */ - struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN); - - if (iph->protocol == IPPROTO_UDP) { /* UDP */ - struct udphdr *udph = (struct udphdr *)((size_t)iph + (iph->ihl << 2)); - - if ((udph->source == __constant_htons(CLIENT_PORT)) && - (udph->dest == __constant_htons(SERVER_PORT))) { /* DHCP request */ - struct dhcpMessage *dhcph = - (struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr)); - u32 cookie = be32_to_cpu((__be32)dhcph->cookie); - - if (cookie == DHCP_MAGIC) { /* match magic word */ - if (!(dhcph->flags & htons(BROADCAST_FLAG))) { - /* if not broadcast */ - register int sum = 0; - - DEBUG_INFO("DHCP: change flag of DHCP request to broadcast.\n"); - /* or BROADCAST flag */ - dhcph->flags |= htons(BROADCAST_FLAG); - /* recalculate checksum */ - sum = ~(udph->check) & 0xffff; - sum += be16_to_cpu(dhcph->flags); - while (sum >> 16) - sum = (sum & 0xffff) + (sum >> 16); - udph->check = ~sum; - } - } - } - } - } - } -} - - -void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, - unsigned char *ipAddr) -{ - unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; - struct nat25_network_db_entry *db; - int hash; - /* unsigned long irqL; */ - /* _enter_critical_bh(&priv->br_ext_lock, &irqL); */ - - __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr); - hash = __nat25_network_hash(networkAddr); - db = priv->nethash[hash]; - while (db != NULL) { - if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { - /* _exit_critical_bh(&priv->br_ext_lock, &irqL); */ - return (void *)db; - } - - db = db->next_hash; - } - - /* _exit_critical_bh(&priv->br_ext_lock, &irqL); */ - return NULL; -} diff --git a/core/rtw_cmd.c b/core/rtw_cmd.c index f45f4ed..4b43462 100644 --- a/core/rtw_cmd.c +++ b/core/rtw_cmd.c @@ -22,9 +22,7 @@ #include #include #include -#include #include -#include #include /* @@ -32,106 +30,13 @@ Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. No irqsave is necessary. */ -int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) +int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { - int res = _SUCCESS; - -_func_enter_; - - _rtw_init_sema(&(pcmdpriv->cmd_queue_sema), 0); - /* _rtw_init_sema(&(pcmdpriv->cmd_done_sema), 0); */ - _rtw_init_sema(&(pcmdpriv->terminate_cmdthread_sema), 0); - + sema_init(&(pcmdpriv->cmd_queue_sema), 0); + sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0); _rtw_init_queue(&(pcmdpriv->cmd_queue)); - - /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - - pcmdpriv->cmd_seq = 1; - - pcmdpriv->cmd_allocated_buf = rtw_zmalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ); - - if (pcmdpriv->cmd_allocated_buf == NULL) { - res = _FAIL; - goto exit; - } - - pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); - - pcmdpriv->rsp_allocated_buf = rtw_zmalloc(MAX_RSPSZ + 4); - - if (pcmdpriv->rsp_allocated_buf == NULL) { - res = _FAIL; - goto exit; - } - - pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3); - - pcmdpriv->cmd_issued_cnt = 0; - pcmdpriv->cmd_done_cnt = 0; - pcmdpriv->rsp_cnt = 0; -exit: -_func_exit_; - return res; -} - -static void c2h_wk_callback(struct work_struct *work); - -int _rtw_init_evt_priv(struct evt_priv *pevtpriv) -{ - int res = _SUCCESS; - -_func_enter_; - - /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - ATOMIC_SET(&pevtpriv->event_seq, 0); - pevtpriv->evt_done_cnt = 0; - - _init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL); - pevtpriv->c2h_wk_alive = false; - pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1); - -_func_exit_; - - return res; -} - -void rtw_free_evt_priv(struct evt_priv *pevtpriv) -{ -_func_enter_; - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+rtw_free_evt_priv\n")); - - _cancel_workitem_sync(&pevtpriv->c2h_wk); - while (pevtpriv->c2h_wk_alive) - rtw_msleep_os(10); - - while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { - void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); - if (c2h != NULL && c2h != (void *)pevtpriv) - kfree(c2h); - } - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-rtw_free_evt_priv\n")); - -_func_exit_; -} - -void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) -{ -_func_enter_; - - if (pcmdpriv) { - _rtw_spinlock_free(&(pcmdpriv->cmd_queue.lock)); - _rtw_free_sema(&(pcmdpriv->cmd_queue_sema)); - _rtw_free_sema(&(pcmdpriv->terminate_cmdthread_sema)); - - if (pcmdpriv->cmd_allocated_buf) - kfree(pcmdpriv->cmd_allocated_buf); - - if (pcmdpriv->rsp_allocated_buf) - kfree(pcmdpriv->rsp_allocated_buf); - } -_func_exit_; + return _SUCCESS; } /* @@ -144,80 +49,46 @@ ISR/Call-Back functions can't call this sub-function. */ -int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) +static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) { unsigned long irqL; -_func_enter_; if (obj == NULL) goto exit; - /* _enter_critical_bh(&queue->lock, &irqL); */ - _enter_critical(&queue->lock, &irqL); + spin_lock_irqsave(&queue->lock, irqL); - rtw_list_insert_tail(&obj->list, &queue->queue); + list_add_tail(&obj->list, &queue->queue); - /* _exit_critical_bh(&queue->lock, &irqL); */ - _exit_critical(&queue->lock, &irqL); + spin_unlock_irqrestore(&queue->lock, irqL); exit: -_func_exit_; return _SUCCESS; } -struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) +struct cmd_obj *rtw_dequeue_cmd(struct __queue *queue) { unsigned long irqL; struct cmd_obj *obj; -_func_enter_; - /* _enter_critical_bh(&(queue->lock), &irqL); */ - _enter_critical(&queue->lock, &irqL); - if (rtw_is_list_empty(&(queue->queue))) { + spin_lock_irqsave(&queue->lock, irqL); + if (list_empty(&(queue->queue))) { obj = NULL; } else { - obj = LIST_CONTAINOR(get_next(&(queue->queue)), struct cmd_obj, list); - rtw_list_delete(&obj->list); + obj = container_of((&queue->queue)->next, struct cmd_obj, list); + list_del_init(&obj->list); } - /* _exit_critical_bh(&(queue->lock), &irqL); */ - _exit_critical(&queue->lock, &irqL); + spin_unlock_irqrestore(&queue->lock, irqL); -_func_exit_; return obj; } -u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) -{ - u32 res; -_func_enter_; - res = _rtw_init_cmd_priv (pcmdpriv); -_func_exit_; - return res; -} - -u32 rtw_init_evt_priv (struct evt_priv *pevtpriv) -{ - int res; -_func_enter_; - res = _rtw_init_evt_priv(pevtpriv); -_func_exit_; - return res; -} - -void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) -{ -_func_enter_; - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n")); - _rtw_free_cmd_priv(pcmdpriv); -_func_exit_; -} - 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 */ @@ -227,6 +98,7 @@ static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) (!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; } @@ -246,7 +118,6 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) int res = _FAIL; struct adapter *padapter = pcmdpriv->padapter; -_func_enter_; if (cmd_obj == NULL) goto exit; @@ -262,38 +133,16 @@ _func_enter_; res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); if (res == _SUCCESS) - _rtw_up_sema(&pcmdpriv->cmd_queue_sema); + up(&pcmdpriv->cmd_queue_sema); exit: -_func_exit_; return res; } -struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv) -{ - struct cmd_obj *cmd_obj; - -_func_enter_; - - cmd_obj = _rtw_dequeue_cmd(&pcmdpriv->cmd_queue); - -_func_exit_; - return cmd_obj; -} - -void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv) -{ -_func_enter_; - pcmdpriv->cmd_done_cnt++; - /* _rtw_up_sema(&(pcmdpriv->cmd_done_sema)); */ -_func_exit_; -} - void rtw_free_cmd_obj(struct cmd_obj *pcmd) { -_func_enter_; if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) { /* free parmbuf in cmd_obj */ @@ -310,27 +159,21 @@ _func_enter_; /* free cmd_obj */ kfree(pcmd); -_func_exit_; } int rtw_cmd_thread(void *context) { u8 ret; struct cmd_obj *pcmd; - u8 *pcmdbuf; u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf); void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd); - struct adapter *padapter = (struct adapter *)context; + struct adapter *padapter = context; struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); -_func_enter_; - - thread_enter("RTW_CMD_THREAD"); - - pcmdbuf = pcmdpriv->cmd_buf; + allow_signal(SIGTERM); pcmdpriv->cmdthd_running = true; - _rtw_up_sema(&pcmdpriv->terminate_cmdthread_sema); + up(&pcmdpriv->terminate_cmdthread_sema); RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n")); @@ -352,7 +195,7 @@ _next: break; } - pcmd = rtw_dequeue_cmd(pcmdpriv); + pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue); if (!pcmd) continue; @@ -361,21 +204,13 @@ _next: goto post_process; } - pcmdpriv->cmd_issued_cnt++; - - pcmd->cmdsz = _RND4((pcmd->cmdsz));/* _RND4 */ - - memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); - if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) { cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; if (cmd_hdl) { - ret = cmd_hdl(pcmd->padapter, pcmdbuf); + ret = cmd_hdl(pcmd->padapter, pcmd->parmbuf); pcmd->res = ret; } - - pcmdpriv->cmd_seq++; } else { pcmd->res = H2C_PARAMETERS_ERROR; } @@ -399,7 +234,8 @@ post_process: rtw_free_cmd_obj(pcmd); } - flush_signals_thread(); + if (signal_pending(current)) + flush_signals(current); goto _next; } @@ -407,7 +243,7 @@ post_process: /* free all cmd_obj resources */ do { - pcmd = rtw_dequeue_cmd(pcmdpriv); + pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue); if (pcmd == NULL) break; @@ -416,47 +252,10 @@ post_process: rtw_free_cmd_obj(pcmd); } while (1); - _rtw_up_sema(&pcmdpriv->terminate_cmdthread_sema); + up(&pcmdpriv->terminate_cmdthread_sema); -_func_exit_; - 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; - -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - ret = _FAIL; - goto exit; - } - - psetusbsuspend = (struct usb_suspend_parm *)rtw_zmalloc(sizeof(struct usb_suspend_parm)); - if (psetusbsuspend == NULL) { - kfree(ph2c); - ret = _FAIL; - goto exit; - } - - psetusbsuspend->action = action; - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetusbsuspend, GEN_CMD_CODE(_SetUsbSuspend)); - - ret = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - -_func_exit_; - - return ret; + complete_and_exit(NULL, 0); } /* @@ -473,20 +272,14 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); - } - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1); - } - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); if (psurveyPara == NULL) { kfree(ph2c); return _FAIL; @@ -504,13 +297,11 @@ _func_enter_; /* prepare ssid list */ if (ssid) { int i; + for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) { if (ssid[i].SsidLength) { memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid)); psurveyPara->ssid_num++; - if (0) - DBG_88E(FUNC_ADPT_FMT" ssid:(%s, %d)\n", FUNC_ADPT_ARG(padapter), - psurveyPara->ssid[i].Ssid, psurveyPara->ssid[i].SsidLength); } } } @@ -518,13 +309,11 @@ _func_enter_; /* prepare channel list */ if (ch) { int i; + for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) { memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); psurveyPara->ch_num++; - if (0) - DBG_88E(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), - psurveyPara->ch[i].hw_value); } } } @@ -534,7 +323,7 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); if (res == _SUCCESS) { - pmlmepriv->scan_start_time = rtw_get_current_time(); + pmlmepriv->scan_start_time = jiffies; _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); @@ -545,281 +334,15 @@ _func_enter_; _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } -_func_exit_; return res; } -u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) -{ - struct cmd_obj *ph2c; - struct setdatarate_parm *pbsetdataratepara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - pbsetdataratepara = (struct setdatarate_parm *)rtw_zmalloc(sizeof(struct setdatarate_parm)); - if (pbsetdataratepara == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate)); - pbsetdataratepara->mac_id = 5; - memcpy(pbsetdataratepara->datarates, rateset, NumRates); - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - -_func_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; - -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - pssetbasicratepara = (struct setbasicrate_parm *)rtw_zmalloc(sizeof(struct setbasicrate_parm)); - - if (pssetbasicratepara == NULL) { - 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: - -_func_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; - -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - psetphypara = (struct setphy_parm *)rtw_zmalloc(sizeof(struct setphy_parm)); - - if (psetphypara == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetphypara, _SetPhy_CMD_); - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("CH =%d, modem =%d", ch, modem)); - - psetphypara->modem = modem; - psetphypara->rfchannel = ch; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: -_func_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; - -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - pwritebbparm = (struct writeBB_parm *)rtw_zmalloc(sizeof(struct writeBB_parm)); - - if (pwritebbparm == NULL) { - 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: -_func_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; - -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - prdbbparm = (struct readBB_parm *)rtw_zmalloc(sizeof(struct readBB_parm)); - - if (prdbbparm == NULL) { - kfree(ph2c); - return _FAIL; - } - - _rtw_init_listhead(&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: -_func_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; -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - pwriterfparm = (struct writeRF_parm *)rtw_zmalloc(sizeof(struct writeRF_parm)); - - if (pwriterfparm == NULL) { - 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: -_func_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; - -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - prdrfparm = (struct readRF_parm *)rtw_zmalloc(sizeof(struct readRF_parm)); - if (prdrfparm == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - _rtw_init_listhead(&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: - -_func_exit_; - - return res; -} - -void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - _func_enter_; - - kfree(pcmd->parmbuf); - kfree(pcmd); - - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.workparam.bcompleted = true; -_func_exit_; -} - void rtw_readtssi_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) { - _func_enter_; kfree(pcmd->parmbuf); kfree(pcmd); - - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.workparam.bcompleted = true; -_func_exit_; } u8 rtw_createbss_cmd(struct adapter *padapter) @@ -830,7 +353,6 @@ u8 rtw_createbss_cmd(struct adapter *padapter) struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; u8 res = _SUCCESS; -_func_enter_; rtw_led_control(padapter, LED_CTL_START_TO_LINK); @@ -839,13 +361,13 @@ _func_enter_; else RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (pcmd == NULL) { res = _FAIL; goto exit; } - _rtw_init_listhead(&pcmd->list); + INIT_LIST_HEAD(&pcmd->list); pcmd->cmdcode = _CreateBss_CMD_; pcmd->parmbuf = (unsigned char *)pdev_network; pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); @@ -855,37 +377,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, pcmd); exit: -_func_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; - -_func_enter_; - - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { - res = _FAIL; - goto exit; - } - - _rtw_init_listhead(&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: - -_func_exit_; return res; } @@ -906,17 +397,15 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -_func_enter_; rtw_led_control(padapter, LED_CTL_START_TO_LINK); - if (pmlmepriv->assoc_ssid.SsidLength == 0) { + if (pmlmepriv->assoc_ssid.SsidLength == 0) RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n")); - } else { + else RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); - } - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd == NULL) { res = _FAIL; RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); @@ -944,8 +433,7 @@ _func_enter_; psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; if (psecnetwork == NULL) { - if (pcmd != NULL) - kfree(pcmd); + kfree(pcmd); res = _FAIL; @@ -954,21 +442,20 @@ _func_enter_; goto exit; } - _rtw_memset(psecnetwork, 0, t_len); + memset(psecnetwork, 0, t_len); memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network)); psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; - if ((psecnetwork->IELength-12) < (256-1)) { + if ((psecnetwork->IELength-12) < (256-1)) memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); - } else { + else memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1)); - } psecnetwork->IELength = 0; /* Added by Albert 2009/02/18 */ - /* If the the driver wants to use the bssid to create the connection. */ + /* If the driver wants to use the bssid to create the connection. */ /* If not, we have to copy the connecting AP's MAC address to it so that */ /* the driver just has the bssid information for PMKIDList searching. */ @@ -995,9 +482,12 @@ _func_enter_; phtpriv->ht_option = false; if (pregistrypriv->ht_enable) { - /* Added by Albert 2010/06/23 */ - /* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */ - /* Especially for Realtek 8192u SoftAP. */ + /* + * Added by Albert 2010/06/23 + * For the WEP mode, we will use the bg mode to do + * the connection to avoid some IOT issue. + * Especially for Realtek 8192u SoftAP. + */ if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) && (padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) && (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { @@ -1018,7 +508,7 @@ _func_enter_; pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);/* get cmdsz before endian conversion */ - _rtw_init_listhead(&pcmd->list); + INIT_LIST_HEAD(&pcmd->list); pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */ pcmd->parmbuf = (unsigned char *)psecnetwork; pcmd->rsp = NULL; @@ -1028,7 +518,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1040,12 +529,11 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu struct cmd_priv *cmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); /* prepare cmd parameter */ - param = (struct disconnect_parm *)rtw_zmalloc(sizeof(*param)); + param = kzalloc(sizeof(*param), GFP_KERNEL); if (param == NULL) { res = _FAIL; goto exit; @@ -1054,7 +542,7 @@ _func_enter_; if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ - cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(*cmdobj)); + cmdobj = kzalloc(sizeof(*cmdobj), GFP_KERNEL); if (cmdobj == NULL) { res = _FAIL; kfree(param); @@ -1071,7 +559,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1084,14 +571,13 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra n struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { res = false; goto exit; } - psetop = (struct setopmode_parm *)rtw_zmalloc(sizeof(struct setopmode_parm)); + psetop = kzalloc(sizeof(struct setopmode_parm), GFP_KERNEL); if (psetop == NULL) { kfree(ph2c); @@ -1106,7 +592,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1123,22 +608,21 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) struct sta_info *sta = (struct sta_info *)psta; u8 res = _SUCCESS; -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { res = _FAIL; goto exit; } - psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); if (psetstakey_para == NULL) { kfree(ph2c); res = _FAIL; goto exit; } - psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_KERNEL); if (psetstakey_rsp == NULL) { kfree(ph2c); kfree(psetstakey_para); @@ -1150,10 +634,10 @@ _func_enter_; ph2c->rsp = (u8 *)psetstakey_rsp; ph2c->rspsz = sizeof(struct set_stakey_rsp); - memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + ether_addr_copy(psetstakey_para->addr, sta->hwaddr); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm; + psetstakey_para->algorithm = (unsigned char)psecuritypriv->dot11PrivacyAlgrthm; else GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); @@ -1169,7 +653,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1183,25 +666,24 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) struct sta_info *sta = (struct sta_info *)psta; u8 res = _SUCCESS; -_func_enter_; if (!enqueue) { clear_cam_entry(padapter, entry); } else { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) { res = _FAIL; goto exit; } - psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_ATOMIC); if (psetstakey_para == NULL) { kfree(ph2c); res = _FAIL; goto exit; } - psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_ATOMIC); if (psetstakey_rsp == NULL) { kfree(ph2c); kfree(psetstakey_para); @@ -1213,7 +695,7 @@ _func_enter_; ph2c->rsp = (u8 *)psetstakey_rsp; ph2c->rspsz = sizeof(struct set_stakey_rsp); - memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + ether_addr_copy(psetstakey_para->addr, sta->hwaddr); psetstakey_para->algorithm = _NO_PRIVACY_; @@ -1223,126 +705,10 @@ _func_enter_; } exit: -_func_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; -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - psetrttblparm = (struct setratable_parm *)rtw_zmalloc(sizeof(struct setratable_parm)); - - if (psetrttblparm == NULL) { - 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: -_func_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; -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - pgetrttblparm = (struct getratable_parm *)rtw_zmalloc(sizeof(struct getratable_parm)); - - if (pgetrttblparm == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - -/* init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable)); */ - - _rtw_init_listhead(&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: -_func_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; - -_func_enter_; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - psetassocsta_para = (struct set_assocsta_parm *)rtw_zmalloc(sizeof(struct set_assocsta_parm)); - if (psetassocsta_para == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - psetassocsta_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_assocsta_rsp)); - if (psetassocsta_rsp == NULL) { - 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: - -_func_exit_; - - return res; - } - u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -1350,15 +716,14 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) struct addBaReq_parm *paddbareq_parm; u8 res = _SUCCESS; -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { res = _FAIL; goto exit; } - paddbareq_parm = (struct addBaReq_parm *)rtw_zmalloc(sizeof(struct addBaReq_parm)); + paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL); if (paddbareq_parm == NULL) { kfree(ph2c); res = _FAIL; @@ -1377,7 +742,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1389,15 +753,14 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); if (pdrvextra_cmd_parm == NULL) { kfree(ph2c); res = _FAIL; @@ -1414,62 +777,6 @@ _func_enter_; /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_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; - -_func_enter_; - - 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 = (struct set_ch_parm *)rtw_zmalloc(sizeof(*set_ch_parm)); - if (set_ch_parm == NULL) { - 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 = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmdobj == NULL) { - 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); - -_func_exit_; - return res; } @@ -1481,7 +788,6 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) u8 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_chplan_cmd\n")); @@ -1492,7 +798,7 @@ _func_enter_; } /* prepare cmd parameter */ - setChannelPlan_param = (struct SetChannelPlan_param *)rtw_zmalloc(sizeof(struct SetChannelPlan_param)); + setChannelPlan_param = kzalloc(sizeof(struct SetChannelPlan_param), GFP_KERNEL); if (setChannelPlan_param == NULL) { res = _FAIL; goto exit; @@ -1501,7 +807,7 @@ _func_enter_; if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ - pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (pcmdobj == NULL) { kfree(setChannelPlan_param); res = _FAIL; @@ -1524,90 +830,10 @@ _func_enter_; exit: -_func_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; - -_func_enter_; - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n")); - - pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmdobj == NULL) { - res = _FAIL; - goto exit; - } - - ledBlink_param = (struct LedBlink_param *)rtw_zmalloc(sizeof(struct LedBlink_param)); - if (ledBlink_param == NULL) { - 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: - -_func_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; - -_func_enter_; - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_csa_cmd\n")); - - pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmdobj == NULL) { - res = _FAIL; - goto exit; - } - - setChannelSwitch_param = (struct SetChannelSwitch_param *)rtw_zmalloc(sizeof(struct SetChannelSwitch_param)); - if (setChannelSwitch_param == NULL) { - 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: - -_func_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; @@ -1679,8 +905,6 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) expire_timeout_chk(padapter); #endif - rtw_hal_sreset_xmit_status_check(padapter); - linked_status_chk(padapter); traffic_status_watchdog(padapter); @@ -1693,7 +917,6 @@ static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); u8 mstatus; -_func_enter_; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) @@ -1722,7 +945,7 @@ _func_enter_; break; case LPS_CTRL_SPECIAL_PACKET: /* DBG_88E("LPS_CTRL_SPECIAL_PACKET\n"); */ - pwrpriv->DelayLPSLastTimeStamp = rtw_get_current_time(); + pwrpriv->DelayLPSLastTimeStamp = jiffies; LPS_Leave(padapter); break; case LPS_CTRL_LEAVE: @@ -1732,7 +955,6 @@ _func_enter_; break; } -_func_exit_; } u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) @@ -1743,19 +965,14 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) /* struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; */ u8 res = _SUCCESS; -_func_enter_; - - /* if (!pwrctrlpriv->bLeisurePs) */ - /* return res; */ - if (enqueue) { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); if (pdrvextra_cmd_parm == NULL) { kfree(ph2c); res = _FAIL; @@ -1775,7 +992,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1793,14 +1009,13 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) u8 res = _SUCCESS; -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); if (pdrvextra_cmd_parm == NULL) { kfree(ph2c); res = _FAIL; @@ -1814,7 +1029,6 @@ _func_enter_; res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: -_func_exit_; return res; } @@ -1832,19 +1046,18 @@ u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) u8 support_ant_div; u8 res = _SUCCESS; -_func_enter_; rtw_hal_get_def_var(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div); if (!support_ant_div) return res; if (enqueue) { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); if (pdrvextra_cmd_parm == NULL) { kfree(ph2c); res = _FAIL; @@ -1862,59 +1075,10 @@ _func_enter_; } exit: -_func_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; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - -_func_enter_; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return res; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); - if (pdrvextra_cmd_parm == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID; - pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */ - pdrvextra_cmd_parm->pbuf = NULL; /* Must be NULL here */ - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - -_func_exit_; - - return res; -} -#endif /* CONFIG_88EU_P2P */ - u8 rtw_ps_cmd(struct adapter *padapter) { struct cmd_obj *ppscmd; @@ -1922,15 +1086,14 @@ u8 rtw_ps_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; -_func_enter_; - ppscmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ppscmd == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); if (pdrvextra_cmd_parm == NULL) { kfree(ppscmd); res = _FAIL; @@ -1945,7 +1108,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1971,7 +1133,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); while (!val) { - rtw_msleep_os(100); + msleep(100); cnt++; @@ -1999,13 +1161,13 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); if (pdrvextra_cmd_parm == NULL) { kfree(ph2c); res = _FAIL; @@ -2024,107 +1186,6 @@ exit: } #endif -u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); - if (pdrvextra_cmd_parm == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = C2H_WK_CID; - pdrvextra_cmd_parm->type_size = c2h_evt ? 16 : 0; - pdrvextra_cmd_parm->pbuf = c2h_evt; - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - return res; -} - -static s32 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) == false) - goto exit; - - ret = rtw_hal_c2h_handler(adapter, c2h_evt); - } - } else { - if (filter && filter(c2h_evt->id) == false) - goto exit; - - ret = rtw_hal_c2h_handler(adapter, c2h_evt); - } -exit: - return ret; -} - -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; - - while (!rtw_cbuf_empty(evtpriv->c2h_queue)) { - if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) { - /* This C2H event is read, clear it */ - c2h_evt_clear(adapter); - } else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) { - /* This C2H event is not read, read & clear now */ - if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) - continue; - } - - /* Special pointer to trigger c2h_evt_clear only */ - if ((void *)c2h_evt == (void *)evtpriv) - continue; - - if (!c2h_evt_exist(c2h_evt)) { - kfree(c2h_evt); - continue; - } - - if (ccx_id_filter(c2h_evt->id) == true) { - /* 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 - } - } - - evtpriv->c2h_wk_alive = false; -} - u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) { struct drvextra_cmd_parm *pdrvextra_cmd; @@ -2139,7 +1200,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); @@ -2150,24 +1211,11 @@ 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; - case P2P_PROTO_WK_CID: - /* Commented by Albert 2011/07/01 */ - /* 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; default: break; } @@ -2182,13 +1230,12 @@ void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; if (pcmd->res == H2C_DROPPED) { /* TODO: cancel timer and do timeout handler directly... */ /* need to make timeout handlerOS independent */ _set_timer(&pmlmepriv->scan_to_timer, 1); - } else if (pcmd->res != H2C_SUCCESS) { + } else if (pcmd->res != H2C_SUCCESS) { _set_timer(&pmlmepriv->scan_to_timer, 1); RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n.")); } @@ -2196,39 +1243,29 @@ _func_enter_; /* free cmd */ rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) { - unsigned long irqL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; if (pcmd->res != H2C_SUCCESS) { - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); set_fwstate(pmlmepriv, _FW_LINKED); - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ***Error: disconnect_cmd_callback Fail ***\n.")); - - goto exit; - } else /* clear bridge database */ - nat25_db_cleanup(padapter); + return; + } /* free cmd */ rtw_free_cmd_obj(pcmd); - -exit: - -_func_exit_; } void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; if (pcmd->res == H2C_DROPPED) { /* TODO: cancel timer and do timeout handler directly... */ @@ -2241,29 +1278,25 @@ _func_enter_; rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) { - unsigned long irqL; - u8 timer_cancelled; struct sta_info *psta = NULL; struct wlan_network *pwlan = NULL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; struct wlan_network *tgt_network = &(pmlmepriv->cur_network); -_func_enter_; - if ((pcmd->res != H2C_SUCCESS)) { + if (pcmd->res != H2C_SUCCESS) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback Fail ************\n\n.")); _set_timer(&pmlmepriv->assoc_timer, 1); } - _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); + del_timer_sync(&pmlmepriv->assoc_timer); - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); @@ -2271,26 +1304,24 @@ _func_enter_; psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); if (psta == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n")); - goto createbss_cmd_fail ; + goto createbss_cmd_fail; } } rtw_indicate_connect(padapter); } else { - unsigned long irqL; - pwlan = _rtw_alloc_network(pmlmepriv); - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); if (pwlan == NULL) { pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); if (pwlan == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n Error: can't get pwlan in rtw_joinbss_event_callback\n")); - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto createbss_cmd_fail; } - pwlan->last_scanned = rtw_get_current_time(); + pwlan->last_scanned = jiffies; } else { - rtw_list_insert_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); + list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); } pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork); @@ -2300,17 +1331,16 @@ _func_enter_; _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* we will set _FW_LINKED when there is one more sat to join us (rtw_stassoc_event_callback) */ } createbss_cmd_fail: - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) @@ -2319,7 +1349,6 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pc struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); -_func_enter_; if (psta == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n")); @@ -2327,19 +1356,16 @@ _func_enter_; } exit: rtw_free_cmd_obj(pcmd); -_func_exit_; } void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) { - unsigned long irqL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct set_assocsta_parm *passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf); struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); -_func_enter_; if (psta == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n")); @@ -2349,16 +1375,15 @@ _func_enter_; psta->aid = passocsta_rsp->cam_id; psta->mac_id = passocsta_rsp->cam_id; - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)) _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); set_fwstate(pmlmepriv, _FW_LINKED); - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); exit: rtw_free_cmd_obj(pcmd); -_func_exit_; } diff --git a/core/rtw_debug.c b/core/rtw_debug.c index 0fe5f5d..bc3fe10 100644 --- a/core/rtw_debug.c +++ b/core/rtw_debug.c @@ -20,7 +20,7 @@ #define _RTW_DEBUG_C_ #include -#include +#include int proc_get_drv_version(char *page, char **start, off_t offset, int count, @@ -45,7 +45,7 @@ int proc_get_write_reg(char *page, char **start, 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 net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); char tmp[32]; u32 addr, val, len; @@ -64,13 +64,13 @@ int proc_set_write_reg(struct file *file, const char __user *buffer, } switch (len) { case 1: - rtw_write8(padapter, addr, (u8)val); + usb_write8(padapter, addr, (u8)val); break; case 2: - rtw_write16(padapter, addr, (u16)val); + usb_write16(padapter, addr, (u16)val); break; case 4: - rtw_write32(padapter, addr, val); + usb_write32(padapter, addr, val); break; default: DBG_88E("error write length =%d", len); @@ -99,13 +99,13 @@ int proc_get_read_reg(char *page, char **start, 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)); + len += snprintf(page + len, count - len, "usb_read8(0x%x)=0x%x\n", proc_get_read_addr, usb_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)); + len += snprintf(page + len, count - len, "usb_read16(0x%x)=0x%x\n", proc_get_read_addr, usb_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)); + len += snprintf(page + len, count - len, "usb_read32(0x%x)=0x%x\n", proc_get_read_addr, usb_read32(padapter, proc_get_read_addr)); break; default: len += snprintf(page + len, count - len, "error read length=%d\n", proc_get_read_len); @@ -233,7 +233,7 @@ int proc_get_rf_info(char *page, char **start, 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", + len += snprintf(page + len, count - len, "cur_ch=%d, cur_bw=%d, cur_ch_offset=%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); *eof = 1; return len; @@ -327,7 +327,7 @@ int proc_get_mac_reg_dump1(char *page, char **start, 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)); + len += snprintf(page + len, count - len, " 0x%08x ", usb_read32(padapter, i)); if ((j++)%4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -350,7 +350,7 @@ int proc_get_mac_reg_dump2(char *page, char **start, 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)); + len += snprintf(page + len, count - len, " 0x%08x ", usb_read32(padapter, i)); if ((j++)%4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -373,7 +373,7 @@ int proc_get_mac_reg_dump3(char *page, char **start, 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)); + len += snprintf(page + len, count - len, " 0x%08x ", usb_read32(padapter, i)); if ((j++)%4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -395,7 +395,7 @@ int proc_get_bb_reg_dump1(char *page, char **start, 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)); + len += snprintf(page + len, count - len, " 0x%08x ", usb_read32(padapter, i)); if ((j++)%4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -416,7 +416,7 @@ int proc_get_bb_reg_dump2(char *page, char **start, 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)); + len += snprintf(page + len, count - len, " 0x%08x ", usb_read32(padapter, i)); if ((j++)%4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -437,7 +437,7 @@ int proc_get_bb_reg_dump3(char *page, char **start, 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)); + len += snprintf(page + len, count - len, " 0x%08x ", usb_read32(padapter, i)); if ((j++)%4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -577,7 +577,7 @@ int proc_get_rx_signal(char *page, char **start, 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 net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); char tmp[32]; u32 is_signal_dbg; @@ -627,7 +627,7 @@ int proc_get_ht_enable(char *page, char **start, 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 net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -669,7 +669,7 @@ int proc_get_cbw40_enable(char *page, char **start, 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 net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -710,7 +710,7 @@ int proc_get_ampdu_enable(char *page, char **start, 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 net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -771,7 +771,7 @@ int proc_get_rx_stbc(char *page, char **start, 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 net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct registry_priv *pregpriv = &padapter->registrypriv; char tmp[32]; @@ -783,7 +783,7 @@ int proc_set_rx_stbc(struct file *file, const char __user *buffer, if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { if (pregpriv) { pregpriv->rx_stbc = mode; - printk("rx_stbc=%d\n", mode); + netdev_info(dev, "rx_stbc=%d\n", mode); } } return count; @@ -800,7 +800,7 @@ int proc_get_rssi_disp(char *page, char **start, 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 net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); char tmp[32]; u32 enable = 0; @@ -820,7 +820,7 @@ int proc_set_rssi_disp(struct file *file, const char __user *buffer, if (enable) { DBG_88E("Turn On Rx RSSI Display Function\n"); - padapter->bRxRSSIDisplay = enable ; + padapter->bRxRSSIDisplay = enable; } else { DBG_88E("Turn Off Rx RSSI Display Function\n"); padapter->bRxRSSIDisplay = 0; @@ -835,7 +835,6 @@ int proc_get_all_sta_info(char *page, char **start, off_t offset, int count, int *eof, void *data) { - unsigned long irqL; struct sta_info *psta; struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); @@ -848,16 +847,16 @@ int proc_get_all_sta_info(char *page, char **start, len += snprintf(page + len, count - len, "sta_dz_bitmap=0x%x, tim_bitmap=0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); - _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); + spin_lock_bh(&pstapriv->sta_hash_lock); for (i = 0; i < NUM_STA; i++) { phead = &(pstapriv->sta_hash[i]); - plist = get_next(phead); + plist = phead->next; - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + while (phead != plist) { + psta = container_of(plist, struct sta_info, hash_list); - plist = get_next(plist); + 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); @@ -882,7 +881,7 @@ int proc_get_all_sta_info(char *page, char **start, } } } - _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); + spin_unlock_bh(&pstapriv->sta_hash_lock); *eof = 1; return len; diff --git a/core/rtw_efuse.c b/core/rtw_efuse.c index 806f56f..8816d11 100644 --- a/core/rtw_efuse.c +++ b/core/rtw_efuse.c @@ -22,127 +22,880 @@ #include #include #include +#include +#include +#include - - -/*------------------------Define local variable------------------------------*/ -u8 fakeEfuseBank; -u32 fakeEfuseUsedBytes; -u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE] = {0}; -u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN] = {0}; -u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN] = {0}; - -u32 BTEfuseUsedBytes; -u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; -u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; -u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; - -u32 fakeBTEfuseUsedBytes; -u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; -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. */ -/* */ -bool -Efuse_Read1ByteFromFakeContent( - struct adapter *pAdapter, - u16 Offset, - u8 *Value); -bool -Efuse_Read1ByteFromFakeContent( - struct adapter *pAdapter, - u16 Offset, - u8 *Value) -{ - if (Offset >= EFUSE_MAX_HW_SIZE) - return false; - if (fakeEfuseBank == 0) - *Value = fakeEfuseContent[Offset]; - else - *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset]; - return true; -} +enum{ + VOLTAGE_V25 = 0x03, + LDOE25_SHIFT = 28 , + }; -static bool -Efuse_Write1ByteToFakeContent( - struct adapter *pAdapter, - u16 Offset, - u8 Value) -{ - if (Offset >= EFUSE_MAX_HW_SIZE) - return false; - if (fakeEfuseBank == 0) { - fakeEfuseContent[Offset] = Value; - } else { - fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value; - } - 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( + */ + +void Efuse_PowerSwitch( struct adapter *pAdapter, - u8 write, + u8 bWrite, u8 PwrState) { - pAdapter->HalFunc.EfusePowerSwitch(pAdapter, write, PwrState); + u8 tempval; + u16 tmpV16; + + if (PwrState) { + usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); + + /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ + tmpV16 = usb_read16(pAdapter, REG_SYS_ISO_CTRL); + if (!(tmpV16 & PWC_EV12V)) { + tmpV16 |= PWC_EV12V; + usb_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); + } + /* Reset: 0x0000h[28], default valid */ + tmpV16 = usb_read16(pAdapter, REG_SYS_FUNC_EN); + if (!(tmpV16 & FEN_ELDR)) { + tmpV16 |= FEN_ELDR; + usb_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16); + } + + /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ + tmpV16 = usb_read16(pAdapter, REG_SYS_CLKR); + if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { + tmpV16 |= (LOADER_CLK_EN | ANA8M); + usb_write16(pAdapter, REG_SYS_CLKR, tmpV16); + } + + if (bWrite) { + /* Enable LDO 2.5V before read/write action */ + tempval = usb_read8(pAdapter, EFUSE_TEST+3); + tempval &= 0x0F; + tempval |= (VOLTAGE_V25 << 4); + usb_write8(pAdapter, EFUSE_TEST+3, (tempval | 0x80)); + } + } else { + usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); + + if (bWrite) { + /* Disable LDO 2.5V after read/write action */ + tempval = usb_read8(pAdapter, EFUSE_TEST+3); + usb_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); + } + } } -/*----------------------------------------------------------------------------- - * 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) +static void +efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) { - u16 ret = 0; + u8 *efuseTbl = NULL; + u8 rtemp8; + u16 eFuse_Addr = 0; + u8 offset, wren; + u16 i, j; + u16 **eFuseWord = NULL; + u16 efuse_utilized = 0; + u8 u1temp = 0; - ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, pseudo); + efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL); + if (efuseTbl == NULL) { + DBG_88E("%s: alloc efuseTbl fail!\n", __func__); + return; + } - return ret; + eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + if (eFuseWord == NULL) { + DBG_88E("%s: alloc eFuseWord fail!\n", __func__); + goto eFuseWord_failed; + } + + /* 0. Refresh efuse init map as all oxFF. */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) + eFuseWord[i][j] = 0xFFFF; + + /* */ + /* 1. Read the first byte to check if efuse is empty!!! */ + /* */ + /* */ + rtemp8 = *(phymap+eFuse_Addr); + if (rtemp8 != 0xFF) { + efuse_utilized++; + eFuse_Addr++; + } else { + DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8); + goto exit; + } + + /* */ + /* 2. Read real efuse content. Filter PG header and every section data. */ + /* */ + while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + /* Check PG header for section num. */ + if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */ + u1temp = ((rtemp8 & 0xE0) >> 5); + rtemp8 = *(phymap+eFuse_Addr); + if ((rtemp8 & 0x0F) == 0x0F) { + eFuse_Addr++; + rtemp8 = *(phymap+eFuse_Addr); + + if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) + eFuse_Addr++; + continue; + } else { + offset = ((rtemp8 & 0xF0) >> 1) | u1temp; + wren = (rtemp8 & 0x0F); + eFuse_Addr++; + } + } else { + offset = ((rtemp8 >> 4) & 0x0f); + wren = (rtemp8 & 0x0f); + } + + if (offset < EFUSE_MAX_SECTION_88E) { + /* Get word enable value from PG header */ + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { + /* Check word enable condition in the section */ + if (!(wren & 0x01)) { + rtemp8 = *(phymap+eFuse_Addr); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] = (rtemp8 & 0xff); + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + rtemp8 = *(phymap+eFuse_Addr); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00); + + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + } + wren >>= 1; + } + } + /* Read next PG header */ + rtemp8 = *(phymap+eFuse_Addr); + + if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + efuse_utilized++; + eFuse_Addr++; + } + } + + /* */ + /* 3. Collect 16 sections and 4 word unit into Efuse map. */ + /* */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); + } + } + + /* */ + /* 4. Copy from Efuse map to output pointer memory!!! */ + /* */ + for (i = 0; i < _size_byte; i++) + pbuf[i] = efuseTbl[_offset+i]; + + /* */ + /* 5. Calculate Efuse utilization. */ + /* */ + +exit: + kfree(eFuseWord); + +eFuseWord_failed: + kfree(efuseTbl); } -/* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */ -u8 -Efuse_CalculateWordCnts(u8 word_en) +static void efuse_read_phymap_from_txpktbuf( + struct adapter *adapter, + int bcnhead, /* beacon head, where FW store len(2-byte) and efuse physical map. */ + u8 *content, /* buffer to store efuse physical map */ + u16 *size /* for efuse content: the max byte to read. will update to byte read */ + ) +{ + u16 dbg_addr = 0; + u32 start = 0, passing_time = 0; + u8 reg_0x143 = 0; + u32 lo32 = 0, hi32 = 0; + u16 len = 0, count = 0; + int i = 0; + u16 limit = *size; + + u8 *pos = content; + + if (bcnhead < 0) /* if not valid */ + bcnhead = usb_read8(adapter, REG_TDECTRL+1); + + DBG_88E("%s bcnhead:%d\n", __func__, bcnhead); + + usb_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + + dbg_addr = bcnhead*128/8; /* 8-bytes addressing */ + + while (1) { + usb_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr+i); + + usb_write8(adapter, REG_TXPKTBUF_DBG, 0); + start = jiffies; + while (!(reg_0x143 = usb_read8(adapter, REG_TXPKTBUF_DBG)) && + (passing_time = rtw_get_passing_time_ms(start)) < 1000) { + DBG_88E("%s polling reg_0x143:0x%02x, reg_0x106:0x%02x\n", __func__, reg_0x143, usb_read8(adapter, 0x106)); + usleep_range(1000, 2000); + } + + lo32 = usb_read32(adapter, REG_PKTBUF_DBG_DATA_L); + hi32 = usb_read32(adapter, REG_PKTBUF_DBG_DATA_H); + + if (i == 0) { + u8 lenc[2]; + u16 lenbak, aaabak; + u16 aaa; + lenc[0] = usb_read8(adapter, REG_PKTBUF_DBG_DATA_L); + lenc[1] = usb_read8(adapter, REG_PKTBUF_DBG_DATA_L+1); + + aaabak = le16_to_cpup((__le16 *)lenc); + lenbak = le16_to_cpu(*((__le16 *)lenc)); + aaa = le16_to_cpup((__le16 *)&lo32); + len = le16_to_cpu(*((__le16 *)&lo32)); + + limit = (len-2 < limit) ? len-2 : limit; + + DBG_88E("%s len:%u, lenbak:%u, aaa:%u, aaabak:%u\n", __func__, len, lenbak, aaa, aaabak); + + memcpy(pos, ((u8 *)&lo32)+2, (limit >= count+2) ? 2 : limit-count); + count += (limit >= count+2) ? 2 : limit-count; + pos = content+count; + + } else { + memcpy(pos, ((u8 *)&lo32), (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; + } + + if (limit > count && len-2 > count) { + memcpy(pos, (u8 *)&hi32, (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; + } + + if (limit <= count || len-2 <= count) + break; + i++; + } + usb_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, DISABLE_TRXPKT_BUF_ACCESS); + DBG_88E("%s read count:%u\n", __func__, count); + *size = count; +} + +static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset, u16 size_byte, u8 *logical_map) +{ + s32 status = _FAIL; + u8 physical_map[512]; + u16 size = 512; + + usb_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + memset(physical_map, 0xFF, 512); + usb_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + status = iol_execute(padapter, CMD_READ_EFUSE_MAP); + if (status == _SUCCESS) + efuse_read_phymap_from_txpktbuf(padapter, txpktbuf_bndy, physical_map, &size); + efuse_phymap_to_logical(physical_map, offset, size_byte, logical_map); + return status; +} + +void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf) +{ + + if (rtw_IOL_applied(Adapter)) { + rtw_hal_power_on(Adapter); + iol_mode_enable(Adapter, 1); + iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf); + iol_mode_enable(Adapter, 0); + } +} + +/* Do not support BT */ +void EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) +{ + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + { + u8 *pMax_section; + pMax_section = pOut; + *pMax_section = EFUSE_MAX_SECTION_88E; + } + break; + case TYPE_EFUSE_REAL_CONTENT_LEN: + { + u16 *pu2Tmp; + pu2Tmp = pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_EFUSE_CONTENT_LEN_BANK: + { + u16 *pu2Tmp; + pu2Tmp = pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + { + u16 *pu2Tmp; + pu2Tmp = pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + { + u16 *pu2Tmp; + pu2Tmp = pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_EFUSE_MAP_LEN: + { + u16 *pu2Tmp; + pu2Tmp = pOut; + *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; + } + break; + case TYPE_EFUSE_PROTECT_BYTES_BANK: + { + u8 *pu1Tmp; + pu1Tmp = pOut; + *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + default: + { + u8 *pu1Tmp; + pu1Tmp = pOut; + *pu1Tmp = 0; + } + break; + } +} + +u8 Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data) +{ + u16 tmpaddr = 0; + u16 start_addr = efuse_addr; + u8 badworden = 0x0F; + u8 tmpdata[8]; + + memset((void *)tmpdata, 0xff, PGPKT_DATA_SIZE); + + if (!(word_en&BIT0)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[0]); + efuse_OneByteWrite(pAdapter, start_addr++, data[1]); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0]); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[1]); + if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) + badworden &= (~BIT0); + } + if (!(word_en&BIT1)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[2]); + efuse_OneByteWrite(pAdapter, start_addr++, data[3]); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[2]); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3]); + if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) + badworden &= (~BIT1); + } + if (!(word_en&BIT2)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[4]); + efuse_OneByteWrite(pAdapter, start_addr++, data[5]); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4]); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[5]); + if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) + badworden &= (~BIT2); + } + if (!(word_en&BIT3)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[6]); + efuse_OneByteWrite(pAdapter, start_addr++, data[7]); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6]); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[7]); + if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) + badworden &= (~BIT3); + } + return badworden; +} + +static u16 Efuse_GetCurrentSize(struct adapter *pAdapter) +{ + int bContinual = true; + u16 efuse_addr = 0; + u8 hoffset = 0, hworden = 0; + u8 efuse_data, word_cnts = 0; + + rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); + + while (bContinual && + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data) && + AVAILABLE_EFUSE_ADDR(efuse_addr)) { + if (efuse_data != 0xFF) { + if ((efuse_data&0x1F) == 0x0F) { /* extended header */ + hoffset = efuse_data; + efuse_addr++; + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data); + if ((efuse_data & 0x0F) == 0x0F) { + efuse_addr++; + continue; + } else { + hoffset = ((hoffset & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; + } + } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + word_cnts = Efuse_CalculateWordCnts(hworden); + /* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + } else { + bContinual = false; + } + } + + rtw_hal_set_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); + + return efuse_addr; +} + +int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data) +{ + u8 ReadState = PG_STATE_HEADER; + int bContinual = true; + int bDataEmpty = true; + u8 efuse_data, word_cnts = 0; + u16 efuse_addr = 0; + u8 hoffset = 0, hworden = 0; + u8 tmpidx = 0; + u8 tmpdata[8]; + u8 max_section = 0; + u8 tmp_header = 0; + + EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, (void *)&max_section); + + if (data == NULL) + return false; + if (offset > max_section) + return false; + + memset((void *)data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); + memset((void *)tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); + + /* Efuse has been pre-programmed dummy 5Bytes at the end of Efuse by CP. */ + /* Skip dummy parts to prevent unexpected data read from Efuse. */ + /* By pass right now. 2009.02.19. */ + while (bContinual && AVAILABLE_EFUSE_ADDR(efuse_addr)) { + /* Header Read ------------- */ + if (ReadState & PG_STATE_HEADER) { + if (efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { + tmp_header = efuse_data; + efuse_addr++; + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data); + if (!ALL_WORDS_DISABLED(efuse_data)) { + hoffset = ((tmp_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; + } else { + DBG_88E("Error, All words disabled\n"); + efuse_addr++; + continue; + } + } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + word_cnts = Efuse_CalculateWordCnts(hworden); + bDataEmpty = true; + + if (hoffset == offset) { + for (tmpidx = 0; tmpidx < word_cnts*2; tmpidx++) { + if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx, &efuse_data)) { + tmpdata[tmpidx] = efuse_data; + if (efuse_data != 0xff) + bDataEmpty = false; + } + } + if (bDataEmpty == false) { + ReadState = PG_STATE_DATA; + } else {/* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + } else {/* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + } else { + bContinual = false; + } + } else if (ReadState & PG_STATE_DATA) { + /* Data section Read ------------- */ + efuse_WordEnableDataRead(hworden, tmpdata, data); + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + + } + + if ((data[0] == 0xff) && (data[1] == 0xff) && (data[2] == 0xff) && (data[3] == 0xff) && + (data[4] == 0xff) && (data[5] == 0xff) && (data[6] == 0xff) && (data[7] == 0xff)) + return false; + else + return true; +} + +static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, u8 efuseType, struct pgpkt *pFixPkt, u16 *pAddr) +{ + u8 originaldata[8], badworden = 0; + u16 efuse_addr = *pAddr; + u32 PgWriteSuccess = 0; + + memset((void *)originaldata, 0xff, 8); + + if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata)) { + /* check if data exist */ + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pFixPkt->word_en, originaldata); + + if (badworden != 0xf) { /* write fail */ + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata); + + if (!PgWriteSuccess) + return false; + else + efuse_addr = Efuse_GetCurrentSize(pAdapter); + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + } + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + } + *pAddr = efuse_addr; + return true; +} + +static bool hal_EfusePgPacketWrite2ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt) +{ + bool bRet = false; + u16 efuse_addr = *pAddr, efuse_max_available_len = 0; + u8 pg_header = 0, tmp_header = 0, pg_header_temp = 0; + u8 repeatcnt = 0; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len); + + while (efuse_addr < efuse_max_available_len) { + pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); + } + + /* to write ext_header */ + if (tmp_header == pg_header) { + efuse_addr++; + pg_header_temp = pg_header; + pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); + } + + if ((tmp_header & 0x0F) == 0x0F) { /* word_en PG fail */ + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { + return false; + } + efuse_addr++; + continue; + } else if (pg_header != tmp_header) { /* offset PG fail */ + struct pgpkt fixPkt; + fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); + fixPkt.word_en = tmp_header & 0x0F; + fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr)) + return false; + } else { + bRet = true; + break; + } + } else if ((tmp_header & 0x1F) == 0x0F) { /* wrong extended header */ + efuse_addr += 2; + continue; + } + } + + *pAddr = efuse_addr; + return bRet; +} + +static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt) +{ + bool bRet = false; + u8 pg_header = 0, tmp_header = 0; + u16 efuse_addr = *pAddr; + u8 repeatcnt = 0; + + pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); + } + + if (pg_header == tmp_header) { + bRet = true; + } else { + struct pgpkt fixPkt; + fixPkt.offset = (tmp_header>>4) & 0x0F; + fixPkt.word_en = tmp_header & 0x0F; + fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr)) + return false; + } + + *pAddr = efuse_addr; + return bRet; +} + +static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt) +{ + u16 efuse_addr = *pAddr; + u8 badworden = 0; + u32 PgWriteSuccess = 0; + + badworden = 0x0f; + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data); + if (badworden == 0x0F) { + /* write ok */ + return true; + } + /* reorganize other pg packet */ + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data); + if (!PgWriteSuccess) + return false; + else + return true; +} + +static bool +hal_EfusePgPacketWriteHeader( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt) +{ + bool bRet = false; + + if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) + bRet = hal_EfusePgPacketWrite2ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt); + else + bRet = hal_EfusePgPacketWrite1ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt); + + return bRet; +} + +static bool wordEnMatched(struct pgpkt *pTargetPkt, struct pgpkt *pCurPkt, + u8 *pWden) +{ + u8 match_word_en = 0x0F; /* default all words are disabled */ + + /* check if the same words are enabled both target and current PG packet */ + if (((pTargetPkt->word_en & BIT0) == 0) && + ((pCurPkt->word_en & BIT0) == 0)) + match_word_en &= ~BIT0; /* enable word 0 */ + if (((pTargetPkt->word_en & BIT1) == 0) && + ((pCurPkt->word_en & BIT1) == 0)) + match_word_en &= ~BIT1; /* enable word 1 */ + if (((pTargetPkt->word_en & BIT2) == 0) && + ((pCurPkt->word_en & BIT2) == 0)) + match_word_en &= ~BIT2; /* enable word 2 */ + if (((pTargetPkt->word_en & BIT3) == 0) && + ((pCurPkt->word_en & BIT3) == 0)) + match_word_en &= ~BIT3; /* enable word 3 */ + + *pWden = match_word_en; + + if (match_word_en != 0xf) + return true; + else + return false; +} + +static bool hal_EfuseCheckIfDatafollowed(struct adapter *pAdapter, u8 word_cnts, u16 startAddr) +{ + bool bRet = false; + u8 i, efuse_data; + + for (i = 0; i < (word_cnts*2); i++) { + if (efuse_OneByteRead(pAdapter, (startAddr+i), &efuse_data) && (efuse_data != 0xFF)) + bRet = true; + } + return bRet; +} + +static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt) +{ + bool bRet = false; + u8 i, efuse_data = 0, cur_header = 0; + u8 matched_wden = 0, badworden = 0; + u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; + struct pgpkt curPkt; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len); + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&efuse_max); + + rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); + startAddr %= EFUSE_REAL_CONTENT_LEN; + + while (1) { + if (startAddr >= efuse_max_available_len) { + bRet = false; + break; + } + + if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { + cur_header = efuse_data; + startAddr++; + efuse_OneByteRead(pAdapter, startAddr, &efuse_data); + if (ALL_WORDS_DISABLED(efuse_data)) { + bRet = false; + break; + } else { + curPkt.offset = ((cur_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + curPkt.word_en = efuse_data & 0x0F; + } + } else { + cur_header = efuse_data; + curPkt.offset = (cur_header>>4) & 0x0F; + curPkt.word_en = cur_header & 0x0F; + } + + curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); + /* if same header is found but no data followed */ + /* write some part of data followed by the header. */ + if ((curPkt.offset == pTargetPkt->offset) && + (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1)) && + wordEnMatched(pTargetPkt, &curPkt, &matched_wden)) { + /* Here to write partial data */ + badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr+1, matched_wden, pTargetPkt->data); + if (badworden != 0x0F) { + u32 PgWriteSuccess = 0; + /* if write fail on some words, write these bad words again */ + + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data); + + if (!PgWriteSuccess) { + bRet = false; /* write fail, return */ + break; + } + } + /* partial write ok, update the target packet for later use */ + for (i = 0; i < 4; i++) { + if ((matched_wden & (0x1<word_en |= (0x1<word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); + } + /* read from next header */ + startAddr = startAddr + (curPkt.word_cnts*2) + 1; + } else { + /* not used header, 0xff */ + *pAddr = startAddr; + bRet = true; + break; + } + } + return bRet; +} + +static bool +hal_EfusePgCheckAvailableAddr( + struct adapter *pAdapter, + u8 efuseType + ) +{ + u16 efuse_max_available_len = 0; + + /* Change to check TYPE_EFUSE_MAP_LEN , because 8188E raw 256, logic map over 256. */ + EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&efuse_max_available_len); + + if (Efuse_GetCurrentSize(pAdapter) >= efuse_max_available_len) + return false; + return true; +} + +static void hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, struct pgpkt *pTargetPkt) +{ + memset((void *)pTargetPkt->data, 0xFF, sizeof(u8)*8); + pTargetPkt->offset = offset; + pTargetPkt->word_en = word_en; + efuse_WordEnableDataRead(word_en, pData, pTargetPkt->data); + pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); +} + +bool Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *pData) +{ + struct pgpkt targetPkt; + u16 startAddr = 0; + u8 efuseType = EFUSE_WIFI; + + if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType)) + return false; + + hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); + + if (!hal_EfusePartialWriteCheck(pAdapter, efuseType, &startAddr, &targetPkt)) + return false; + + if (!hal_EfusePgPacketWriteHeader(pAdapter, efuseType, &startAddr, &targetPkt)) + return false; + + if (!hal_EfusePgPacketWriteData(pAdapter, efuseType, &startAddr, &targetPkt)) + return false; + + return true; +} + +u8 Efuse_CalculateWordCnts(u8 word_en) { u8 word_cnts = 0; if (!(word_en & BIT(0))) @@ -156,169 +909,21 @@ Efuse_CalculateWordCnts(u8 word_en) return word_cnts; } -/* */ -/* Description: */ -/* Execute E-Fuse read byte operation. */ -/* 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. */ -/* */ -void -ReadEFuseByte( - struct adapter *Adapter, - u16 _offset, - u8 *pbuf, - bool pseudo) -{ - u32 value32; - u8 readbyte; - u16 retry; - - if (pseudo) { - Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf); - return; - } - - /* Write Address */ - rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); - readbyte = rtw_read8(Adapter, EFUSE_CTRL+2); - rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); - - /* Write bit 32 0 */ - readbyte = rtw_read8(Adapter, EFUSE_CTRL+3); - rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f)); - - /* Check bit 32 read-ready */ - retry = 0; - value32 = rtw_read32(Adapter, EFUSE_CTRL); - while (!(((value32 >> 24) & 0xff) & 0x80) && (retry < 10000)) { - value32 = rtw_read32(Adapter, EFUSE_CTRL); - retry++; - } - - /* 20100205 Joseph: Add delay suggested by SD1 Victor. */ - /* This fix the problem that Efuse read error in high temperature condition. */ - /* Designer says that there shall be some delay after ready bit is set, or the */ - /* result will always stay on last data we read. */ - rtw_udelay_os(50); - value32 = rtw_read32(Adapter, EFUSE_CTRL); - - *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) +u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data) { u8 tmpidx = 0; u8 result; - if (pseudo) { - result = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data); - return result; - } - /* -----------------e-fuse reg ctrl --------------------------------- */ - /* address */ - rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr & 0xff)); - rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) & 0x03)) | - (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC)); + usb_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr & 0xff)); + usb_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) & 0x03)) | + (usb_read8(pAdapter, EFUSE_CTRL+2) & 0xFC)); - rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ + usb_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ - while (!(0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + while (!(0x80 & usb_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) { - *data = rtw_read8(pAdapter, EFUSE_CTRL); + *data = usb_read8(pAdapter, EFUSE_CTRL); result = true; } else { *data = 0xff; @@ -327,28 +932,20 @@ u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data, bool pseudo) return result; } -/* 11/16/2008 MH Write one byte to reald Efuse. */ -u8 efuse_OneByteWrite(struct adapter *pAdapter, u16 addr, u8 data, bool pseudo) +u8 efuse_OneByteWrite(struct adapter *pAdapter, u16 addr, u8 data) { u8 tmpidx = 0; u8 result; - if (pseudo) { - result = Efuse_Write1ByteToFakeContent(pAdapter, addr, data); - return result; - } - - /* -----------------e-fuse reg ctrl --------------------------------- */ - /* address */ - rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); - rtw_write8(pAdapter, EFUSE_CTRL+2, - (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC) | + usb_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); + usb_write8(pAdapter, EFUSE_CTRL+2, + (usb_read8(pAdapter, EFUSE_CTRL+2) & 0xFC) | (u8)((addr>>8) & 0x03)); - rtw_write8(pAdapter, EFUSE_CTRL, data);/* data */ + usb_write8(pAdapter, EFUSE_CTRL, data);/* data */ - rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ + usb_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ - while ((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + while ((0x80 & usb_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) @@ -359,51 +956,9 @@ 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 - * - * Overview: Read allowed word in current efuse section data. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/16/2008 MHC Create Version 0. - * 11/21/2008 MHC Fix Write bug when we only enable late word. - * - *---------------------------------------------------------------------------*/ +/* + * Overview: Read allowed word in current efuse section data. + */ void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) { if (!(word_en&BIT(0))) { @@ -424,452 +979,36 @@ 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 = rtw_zmalloc(mapLen); - if (map == NULL) - 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; - _rtw_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; - _rtw_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 = rtw_zmalloc(mapLen); - if (map == NULL) - 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; - _rtw_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; - _rtw_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 - * * Overview: Read All Efuse content - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/11/2008 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ -static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 efuseType, u8 *Efuse, bool pseudo) + */ +static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 efuseType, u8 *Efuse) { u16 mapLen = 0; Efuse_PowerSwitch(pAdapter, false, true); - EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen); - efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, pseudo); + efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse); Efuse_PowerSwitch(pAdapter, false, false); } -/*----------------------------------------------------------------------------- - * Function: EFUSE_ShadowMapUpdate - * +/* * Overview: Transfer current EFUSE content to shadow init and modify map. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/13/2008 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ + */ void EFUSE_ShadowMapUpdate( struct adapter *pAdapter, - u8 efuseType, - bool pseudo) + u8 efuseType) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); u16 mapLen = 0; - EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen); if (pEEPROM->bautoload_fail_flag) - _rtw_memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen); + 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 */ + Efuse_ReadAllMap(pAdapter, efuseType, pEEPROM->efuse_eeprom_data); +} diff --git a/core/rtw_ieee80211.c b/core/rtw_ieee80211.c index 6fc7742..f2c3ca7 100644 --- a/core/rtw_ieee80211.c +++ b/core/rtw_ieee80211.c @@ -20,11 +20,11 @@ #define _IEEE80211_C #include +#include #include #include #include #include -#include u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; u16 RTW_WPA_VERSION = 1; @@ -147,7 +147,6 @@ u8 *rtw_set_ie uint *frlen /* frame length */ ) { -_func_enter_; *pbuf = (u8)index; *(pbuf + 1) = (u8)len; @@ -157,11 +156,10 @@ _func_enter_; *frlen = *frlen + (len + 2); -_func_exit_; return pbuf + len + 2; } -inline u8 *rtw_set_ie_ch_switch (u8 *buf, u32 *buf_len, u8 ch_switch_mode, +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]; @@ -208,8 +206,8 @@ inline u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, ie_data[0] = ttl; ie_data[1] = flags; - RTW_PUT_LE16((u8 *)&ie_data[2], reason); - RTW_PUT_LE16((u8 *)&ie_data[4], precedence); + *(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); } @@ -221,11 +219,8 @@ u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit) { int tmp, i; u8 *p; -_func_enter_; - if (limit < 1) { - _func_exit_; + if (limit < 1) return NULL; - } p = pbuf; i = 0; @@ -242,7 +237,6 @@ _func_enter_; if (i >= limit) break; } -_func_exit_; return NULL; } @@ -273,7 +267,7 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u cnt = 0; while (cnt < in_len) { - if (eid == in_ie[cnt] && (!oui || _rtw_memcmp(&in_ie[cnt+2], oui, oui_len))) { + if (eid == in_ie[cnt] && (!oui || !memcmp(&in_ie[cnt+2], oui, oui_len))) { target_ie = &in_ie[cnt]; if (ie) @@ -339,9 +333,8 @@ exit: void rtw_set_supported_rate(u8 *SupportedRates, uint mode) { -_func_enter_; - _rtw_memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); switch (mode) { case WIRELESS_11B: @@ -361,13 +354,11 @@ _func_enter_; memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); break; } -_func_exit_; } uint rtw_get_rateset_len(u8 *rateset) { uint i = 0; -_func_enter_; while (1) { if ((rateset[i]) == 0) break; @@ -375,7 +366,6 @@ _func_enter_; break; i++; } -_func_exit_; return i; } @@ -386,7 +376,6 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *ie = pdev_network->IEs; -_func_enter_; /* timestamp will be inserted by hardware */ sz += 8; @@ -444,7 +433,6 @@ _func_enter_; if (rateLen > 8) ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); -_func_exit_; return sz; } @@ -463,7 +451,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) if (pbuf) { /* check if oui matches... */ - if (_rtw_memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type)) == false) + if (!memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type)) == false) goto check_next_ie; /* check version... */ @@ -497,15 +485,15 @@ unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) int rtw_get_wpa_cipher_suite(u8 *s) { - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN)) return WPA_CIPHER_NONE; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN)) return WPA_CIPHER_WEP40; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN)) return WPA_CIPHER_TKIP; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN)) return WPA_CIPHER_CCMP; - if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN) == true) + if (!memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN)) return WPA_CIPHER_WEP104; return 0; @@ -513,15 +501,15 @@ int rtw_get_wpa_cipher_suite(u8 *s) int rtw_get_wpa2_cipher_suite(u8 *s) { - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN)) return WPA_CIPHER_NONE; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN)) return WPA_CIPHER_WEP40; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN)) return WPA_CIPHER_TKIP; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN)) return WPA_CIPHER_CCMP; - if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == true) + if (!memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN)) return WPA_CIPHER_WEP104; return 0; @@ -542,7 +530,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || - (_rtw_memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != true)) + (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) return _FAIL; pos = wpa_ie; @@ -563,7 +551,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis /* pairwise_cipher */ if (left >= 2) { - count = RTW_GET_LE16(pos); + count = get_unaligned_le16(pos); pos += 2; left -= 2; @@ -587,7 +575,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis if (is_8021x) { if (left >= 6) { pos += 2; - if (_rtw_memcmp(pos, SUITE_1X, 4) == 1) { + if (!memcmp(pos, SUITE_1X, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); *is_8021x = 1; } @@ -631,7 +619,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi /* pairwise_cipher */ if (left >= 2) { - count = RTW_GET_LE16(pos); + count = get_unaligned_le16(pos); pos += 2; left -= 2; @@ -657,7 +645,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi if (is_8021x) { if (left >= 6) { pos += 2; - if (_rtw_memcmp(pos, SUITE_1X, 4) == 1) { + if (!memcmp(pos, SUITE_1X, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__)); *is_8021x = 1; } @@ -672,7 +660,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint cnt; -_func_enter_; /* Search required WPA or WPA2 IE and copy to sec_ie[] */ @@ -683,7 +670,7 @@ _func_enter_; while (cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { + if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2)); @@ -726,7 +713,6 @@ _func_enter_; } } -_func_exit_; return *rsn_len + *wpa_len; } @@ -741,7 +727,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; - if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&ie_ptr[2], wps_oui, 4))) { + if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { *wps_ielen = ie_ptr[1]+2; match = true; } @@ -774,7 +760,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; - if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], wps_oui, 4))) { + if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], wps_oui, 4))) { wpsie_ptr = &in_ie[cnt]; if (wps_ie) @@ -813,7 +799,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at *len_attr = 0; if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || - (_rtw_memcmp(wps_ie + 2, wps_oui , 4) != true)) + (memcmp(wps_ie + 2, wps_oui , 4))) return attr_ptr; /* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */ @@ -821,8 +807,8 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at while (attr_ptr - wps_ie < wps_ielen) { /* 4 = 2(Attribute ID) + 2(Length) */ - u16 attr_id = RTW_GET_BE16(attr_ptr); - u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2); + u16 attr_id = get_unaligned_be16(attr_ptr); + u16 attr_data_len = get_unaligned_be16(attr_ptr + 2); u16 attr_len = attr_data_len + 4; if (attr_id == target_attr_id) { @@ -884,7 +870,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, if (elen < 4) { if (show_errors) { DBG_88E("short vendor specific information element ignored (len=%lu)\n", - (unsigned long) elen); + (unsigned long)elen); } return -1; } @@ -904,7 +890,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ if (elen < 5) { DBG_88E("short WME information element ignored (len=%lu)\n", - (unsigned long) elen); + (unsigned long)elen); return -1; } switch (pos[4]) { @@ -919,7 +905,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("unknown WME information element ignored (subtype=%d len=%lu)\n", - pos[4], (unsigned long) elen); + pos[4], (unsigned long)elen); return -1; } break; @@ -930,7 +916,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("Unknown Microsoft information element ignored (type=%d len=%lu)\n", - pos[3], (unsigned long) elen); + pos[3], (unsigned long)elen); return -1; } break; @@ -943,13 +929,13 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("Unknown Broadcom information element ignored (type=%d len=%lu)\n", - pos[3], (unsigned long) elen); + pos[3], (unsigned long)elen); return -1; } break; default: DBG_88E("unknown vendor specific information element ignored (vendor OUI %02x:%02x:%02x len=%lu)\n", - pos[0], pos[1], pos[2], (unsigned long) elen); + pos[0], pos[1], pos[2], (unsigned long)elen); return -1; } return 0; @@ -971,7 +957,7 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, u8 *pos = start; int unknown = 0; - _rtw_memset(elems, 0, sizeof(*elems)); + memset(elems, 0, sizeof(*elems)); while (left >= 2) { u8 id, elen; @@ -983,7 +969,7 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, if (elen > left) { if (show_errors) { DBG_88E("IEEE 802.11 element parse failed (id=%d elen=%d left=%lu)\n", - id, elen, (unsigned long) left); + id, elen, (unsigned long)left); } return ParseFailed; } @@ -1081,41 +1067,18 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, return unknown ? ParseUnknown : ParseOK; } -u8 key_char2num(u8 ch) -{ - if ((ch >= '0') && (ch <= '9')) - return ch - '0'; - else if ((ch >= 'a') && (ch <= 'f')) - return ch - 'a' + 10; - else if ((ch >= 'A') && (ch <= 'F')) - return ch - 'A' + 10; - else - return 0xff; -} - -u8 str_2char2num(u8 hch, u8 lch) -{ - return (key_char2num(hch) * 10) + key_char2num(lch); -} - -u8 key_2char2num(u8 hch, u8 lch) -{ - return (key_char2num(hch) << 4) | key_char2num(lch); -} - void rtw_macaddr_cfg(u8 *mac_addr) { u8 mac[ETH_ALEN]; + if (mac_addr == NULL) 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]); + if (rtw_initmac && mac_pton(rtw_initmac, mac)) { + /* Users specify the mac address */ memcpy(mac_addr, mac, ETH_ALEN); - } else { /* Use the mac address stored in the Efuse */ + } else { + /* Use the mac address stored in the Efuse */ memcpy(mac, mac_addr, ETH_ALEN); } @@ -1129,7 +1092,7 @@ void rtw_macaddr_cfg(u8 *mac_addr) mac[3] = 0x87; mac[4] = 0x00; mac[5] = 0x00; - /* use default mac addresss */ + /* use default mac address */ memcpy(mac_addr, mac, ETH_ALEN); DBG_88E("MAC Address from efuse error, assign default one !!!\n"); } @@ -1147,9 +1110,6 @@ void dump_ies(u8 *buf, u32 buf_len) 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); @@ -1170,217 +1130,13 @@ void dump_wps_ie(u8 *ie, u32 ie_len) pos += 6; while (pos-ie < ie_len) { - id = RTW_GET_BE16(pos); - len = RTW_GET_BE16(pos + 2); + id = get_unaligned_be16(pos); + len = get_unaligned_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 = RTW_GET_LE16(pos+1); - DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); - pos += (3+len); - } -} - -/** - * rtw_get_p2p_ie - Search P2P IE from a series of IEs - * @in_ie: Address of IEs to search - * @in_len: Length limit from in_ie - * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the buf starting from p2p_ie - * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of the entire P2P IE - * - * Returns: The address of the P2P IE found, or NULL - */ -u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) -{ - uint cnt = 0; - u8 *p2p_ie_ptr; - u8 eid, p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09}; - - if (p2p_ielen != NULL) - *p2p_ielen = 0; - - while (cnt < in_len) { - eid = in_ie[cnt]; - if ((in_len < 0) || (cnt > MAX_IE_SZ)) { - dump_stack(); - return NULL; - } - if ((eid == _VENDOR_SPECIFIC_IE_) && (_rtw_memcmp(&in_ie[cnt+2], p2p_oui, 4) == true)) { - p2p_ie_ptr = in_ie + cnt; - - if (p2p_ie != NULL) - memcpy(p2p_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - if (p2p_ielen != NULL) - *p2p_ielen = in_ie[cnt + 1] + 2; - return p2p_ie_ptr; - } else { - cnt += in_ie[cnt + 1] + 2; /* goto next */ - } - } - return NULL; -} - -/** - * rtw_get_p2p_attr - Search a specific P2P attribute from a given P2P IE - * @p2p_ie: Address of P2P IE to search - * @p2p_ielen: Length limit from p2p_ie - * @target_attr_id: The attribute ID of P2P attribute to search - * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will be copied to the buf starting from buf_attr - * @len_attr: If not NULL and the P2P attribute is found, will set to the length of the entire P2P attribute - * - * Returns: the address of the specific WPS attribute found, or NULL - */ -u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_attr, u32 *len_attr) -{ - u8 *attr_ptr = NULL; - u8 *target_attr_ptr = NULL; - u8 p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09}; - - if (len_attr) - *len_attr = 0; - - if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || - (_rtw_memcmp(p2p_ie + 2, p2p_oui , 4) != true)) - return attr_ptr; - - /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ - attr_ptr = p2p_ie + 6; /* goto first attr */ - - while (attr_ptr - p2p_ie < p2p_ielen) { - /* 3 = 1(Attribute ID) + 2(Length) */ - u8 attr_id = *attr_ptr; - u16 attr_data_len = RTW_GET_LE16(attr_ptr + 1); - u16 attr_len = attr_data_len + 3; - - if (attr_id == target_attr_id) { - target_attr_ptr = attr_ptr; - - if (buf_attr) - memcpy(buf_attr, attr_ptr, attr_len); - if (len_attr) - *len_attr = attr_len; - break; - } else { - attr_ptr += attr_len; /* goto next */ - } - } - return target_attr_ptr; -} - -/** - * rtw_get_p2p_attr_content - Search a specific P2P attribute content from a given P2P IE - * @p2p_ie: Address of P2P IE to search - * @p2p_ielen: Length limit from p2p_ie - * @target_attr_id: The attribute ID of P2P attribute to search - * @buf_content: If not NULL and the P2P attribute is found, P2P attribute content will be copied to the buf starting from buf_content - * @len_content: If not NULL and the P2P attribute is found, will set to the length of the P2P attribute content - * - * Returns: the address of the specific P2P attribute content found, or NULL - */ -u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_content, uint *len_content) -{ - u8 *attr_ptr; - u32 attr_len; - - if (len_content) - *len_content = 0; - - attr_ptr = rtw_get_p2p_attr(p2p_ie, p2p_ielen, target_attr_id, NULL, &attr_len); - - if (attr_ptr && attr_len) { - if (buf_content) - memcpy(buf_content, attr_ptr+3, attr_len-3); - - if (len_content) - *len_content = attr_len-3; - - return attr_ptr+3; - } - - return NULL; -} - -u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr) -{ - u32 a_len; - - *pbuf = attr_id; - - /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */ - RTW_PUT_LE16(pbuf + 1, attr_len); - - if (pdata_attr) - memcpy(pbuf + 3, pdata_attr, attr_len); - - a_len = attr_len + 3; - - return a_len; -} - -static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id) -{ - u8 *target_attr; - u32 target_attr_len; - uint ielen = ielen_ori; - - while (1) { - target_attr = rtw_get_p2p_attr(ie, ielen, attr_id, NULL, &target_attr_len); - if (target_attr && target_attr_len) { - u8 *next_attr = target_attr+target_attr_len; - uint remain_len = ielen-(next_attr-ie); - - _rtw_memset(target_attr, 0, target_attr_len); - memcpy(target_attr, next_attr, remain_len); - _rtw_memset(target_attr+remain_len, 0, target_attr_len); - *(ie+1) -= target_attr_len; - ielen -= target_attr_len; - } else { - break; - } - } - return ielen; -} - -void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, u8 attr_id) -{ - u8 *p2p_ie; - uint p2p_ielen, p2p_ielen_ori; - - p2p_ie = rtw_get_p2p_ie(bss_ex->IEs+_FIXED_IE_LENGTH_, bss_ex->IELength-_FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori); - if (p2p_ie) { - p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id); - if (p2p_ielen != p2p_ielen_ori) { - u8 *next_ie_ori = p2p_ie+p2p_ielen_ori; - u8 *next_ie = p2p_ie+p2p_ielen; - uint remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs); - - memcpy(next_ie, next_ie_ori, remain_len); - _rtw_memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen); - bss_ex->IELength -= p2p_ielen_ori-p2p_ielen; - } - } -} - -#endif /* CONFIG_88EU_P2P */ - /* Baron adds to avoid FreeBSD warning */ int ieee80211_is_empty_essid(const char *essid, int essid_len) { diff --git a/core/rtw_io.c b/core/rtw_io.c deleted file mode 100644 index 10c9c65..0000000 --- a/core/rtw_io.c +++ /dev/null @@ -1,329 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -/* - -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 -#include -#include -#include - -#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); - - _func_enter_; - _read8 = pintfhdl->io_ops._read8; - r_val = _read8(pintfhdl, addr); - _func_exit_; - 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); -_func_enter_; - _read16 = pintfhdl->io_ops._read16; - - r_val = _read16(pintfhdl, addr); -_func_exit_; - 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); -_func_enter_; - _read32 = pintfhdl->io_ops._read32; - - r_val = _read32(pintfhdl, addr); -_func_exit_; - 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; - _func_enter_; - _write8 = pintfhdl->io_ops._write8; - - ret = _write8(pintfhdl, addr, val); - _func_exit_; - - 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; - _func_enter_; - _write16 = pintfhdl->io_ops._write16; - - ret = _write16(pintfhdl, addr, val); - _func_exit_; - - 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; - _func_enter_; - _write32 = pintfhdl->io_ops._write32; - - ret = _write32(pintfhdl, addr, val); - _func_exit_; - - 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; - _func_enter_; - _writeN = pintfhdl->io_ops._writeN; - - ret = _writeN(pintfhdl, addr, length, pdata); - _func_exit_; - - 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; - _func_enter_; - _write8_async = pintfhdl->io_ops._write8_async; - - ret = _write8_async(pintfhdl, addr, val); - _func_exit_; - - 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; - -_func_enter_; - _write16_async = pintfhdl->io_ops._write16_async; - ret = _write16_async(pintfhdl, addr, val); -_func_exit_; - - 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; - -_func_enter_; - _write32_async = pintfhdl->io_ops._write32_async; - ret = _write32_async(pintfhdl, addr, val); -_func_exit_; - - 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); - - _func_enter_; - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { - RT_TRACE(_module_rtl871x_io_c_, _drv_info_, - ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - adapter->bDriverStopped, adapter->bSurpriseRemoved)); - return; - } - _read_mem = pintfhdl->io_ops._read_mem; - _read_mem(pintfhdl, addr, cnt, pmem); - _func_exit_; -} - -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); - - _func_enter_; - - _write_mem = pintfhdl->io_ops._write_mem; - - _write_mem(pintfhdl, addr, cnt, pmem); - - _func_exit_; -} - -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); - - _func_enter_; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { - RT_TRACE(_module_rtl871x_io_c_, _drv_info_, - ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - adapter->bDriverStopped, adapter->bSurpriseRemoved)); - return; - } - - _read_port = pintfhdl->io_ops._read_port; - - _read_port(pintfhdl, addr, cnt, pmem); - - _func_exit_; -} - -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; - - _func_enter_; - - _write_port = pintfhdl->io_ops._write_port; - - ret = _write_port(pintfhdl, addr, cnt, pmem); - - _func_exit_; - - 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 == NULL) - 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/core/rtw_ioctl_set.c b/core/rtw_ioctl_set.c index 193f641..2faf6b2 100644 --- a/core/rtw_ioctl_set.c +++ b/core/rtw_ioctl_set.c @@ -25,9 +25,6 @@ #include #include -#include -#include - extern void indicate_wx_scan_complete_event(struct adapter *padapter); #define IS_MAC_ADDRESS_BROADCAST(addr) \ @@ -37,49 +34,18 @@ extern void indicate_wx_scan_complete_event(struct adapter *padapter); (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ ) -u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) -{ - u8 i; - u8 ret = true; - -_func_enter_; - - if (ssid->SsidLength > 32) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n")); - 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))) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid has nonprintabl ascii\n")); - ret = false; - break; - } - } - -exit: - -_func_exit_; - - return ret; -} - u8 rtw_do_join(struct adapter *padapter) { - unsigned long irqL; struct list_head *plist, *phead; u8 *pibss = NULL; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct __queue *queue = &(pmlmepriv->scanned_queue); u8 ret = _SUCCESS; -_func_enter_; - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist)); @@ -91,8 +57,8 @@ _func_enter_; pmlmepriv->to_join = true; - if (_rtw_queue_empty(queue)) { - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + if (list_empty(&queue->queue)) { + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); /* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */ @@ -116,7 +82,7 @@ _func_enter_; } else { int select_ret; - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); if (select_ret == _SUCCESS) { pmlmepriv->to_join = false; @@ -132,7 +98,6 @@ _func_enter_; pibss = padapter->registrypriv.dev_network.MacAddress; - _rtw_memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(padapter); @@ -171,19 +136,16 @@ _func_enter_; exit: -_func_exit_; return ret; } u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) { - unsigned long irqL; u8 status = _SUCCESS; u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; DBG_88E_LEVEL(_drv_info_, "set bssid:%pM\n", bssid); @@ -195,7 +157,7 @@ _func_enter_; goto exit; } - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); DBG_88E("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); @@ -207,7 +169,7 @@ _func_enter_; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); - if (_rtw_memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { + if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { @@ -233,7 +195,7 @@ handle_tkip_countermeasure: /* should we add something here...? */ if (padapter->securitypriv.btkip_countermeasure) { - cur_time = rtw_get_current_time(); + cur_time = jiffies; if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { padapter->securitypriv.btkip_countermeasure = false; @@ -253,27 +215,24 @@ handle_tkip_countermeasure: status = rtw_do_join(padapter); release_mlme_lock: - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid: status=%d\n", status)); -_func_exit_; return status; } u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) { - unsigned long irqL; u8 status = _SUCCESS; u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork = &pmlmepriv->cur_network; -_func_enter_; DBG_88E_LEVEL(_drv_info_, "set ssid [%s] fw_state=0x%08x\n", ssid->Ssid, get_fwstate(pmlmepriv)); @@ -285,21 +244,20 @@ _func_enter_; goto exit; } - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); DBG_88E("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) goto handle_tkip_countermeasure; - } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) goto release_mlme_lock; - } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && - (_rtw_memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { + (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set SSID is the same ssid, fw_state = 0x%08x\n", @@ -346,7 +304,7 @@ _func_enter_; handle_tkip_countermeasure: if (padapter->securitypriv.btkip_countermeasure) { - cur_time = rtw_get_current_time(); + cur_time = jiffies; if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { padapter->securitypriv.btkip_countermeasure = false; @@ -360,38 +318,34 @@ handle_tkip_countermeasure: memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); pmlmepriv->assoc_by_bssid = false; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) pmlmepriv->to_join = true; - } else { + else status = rtw_do_join(padapter); - } release_mlme_lock: - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); exit: RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("-rtw_set_802_11_ssid: status =%d\n", status)); -_func_exit_; return status; } u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, enum ndis_802_11_network_infra networktype) { - unsigned long irqL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode); -_func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", *pold_state, networktype, get_fwstate(pmlmepriv))); if (*pold_state != networktype) { - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!")); /* DBG_88E("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */ @@ -415,7 +369,7 @@ _func_enter_; if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not */ + rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have checked whether issue dis-assoc_cmd or not */ } *pold_state = networktype; @@ -439,10 +393,9 @@ _func_enter_; case Ndis802_11InfrastructureMax: break; } - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); } -_func_exit_; return true; } @@ -450,12 +403,10 @@ _func_exit_; u8 rtw_set_802_11_disassociate(struct adapter *padapter) { - unsigned long irqL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, _FW_LINKED)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, @@ -467,20 +418,17 @@ _func_enter_; rtw_pwr_wakeup(padapter); } - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); -_func_exit_; return true; } u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num) { - unsigned long irqL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 res = true; -_func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); @@ -500,11 +448,12 @@ _func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid_list_scan fail since fw_state = %x\n", get_fwstate(pmlmepriv))); res = true; - if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true) { + if (check_fwstate(pmlmepriv, + (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true) RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###_FW_UNDER_SURVEY|_FW_UNDER_LINKING\n\n")); - } else { + else RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###pmlmepriv->sitesurveyctrl.traffic_busy == true\n\n")); - } + } else { if (rtw_is_scan_deny(padapter)) { DBG_88E(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter)); @@ -512,15 +461,14 @@ _func_enter_; return _SUCCESS; } - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num, NULL, 0); - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); } exit: -_func_exit_; return res; } @@ -531,7 +479,6 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11 int res; u8 ret; -_func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); @@ -551,7 +498,6 @@ _func_enter_; else ret = false; -_func_exit_; return ret; } @@ -562,7 +508,6 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) struct security_priv *psecuritypriv = &(padapter->securitypriv); u8 ret = _SUCCESS; -_func_enter_; keyid = wep->KeyIndex & 0x3fffffff; @@ -587,7 +532,7 @@ _func_enter_; break; } RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep:befor memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", + ("rtw_set_802_11_add_wep:before memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", wep->KeyLength, wep->KeyIndex, keyid)); memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength); @@ -617,428 +562,6 @@ _func_enter_; if (res == _FAIL) ret = false; exit: -_func_exit_; - return ret; -} - -u8 rtw_set_802_11_remove_wep(struct adapter *padapter, u32 keyindex) -{ - u8 ret = _SUCCESS; - -_func_enter_; - if (keyindex >= 0x80000000 || padapter == NULL) { - ret = false; - goto exit; - } else { - int res; - struct security_priv *psecuritypriv = &(padapter->securitypriv); - if (keyindex < 4) { - _rtw_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: - -_func_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; - -_func_enter_; - - 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. */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_key: ((key->KeyIndex & 0x80000000)==0)[=%d]", - (int)(key->KeyIndex & 0x80000000) == 0)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_key:((key->KeyIndex & 0x40000000)>0)[=%d]", - (int)(key->KeyIndex & 0x40000000) > 0)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_key: key->KeyIndex=%d\n", - (int)key->KeyIndex)); - ret = _FAIL; - goto exit; - } - - if (key->KeyIndex & 0x40000000) { - /* Pairwise key */ - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Pairwise key +++++\n")); - - pbssid = get_bssid(&padapter->mlmepriv); - stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); - - if ((stainfo != NULL) && (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("OID_802_11_ADD_KEY:(stainfo!=NULL)&&(Adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X)\n")); - encryptionalgo = stainfo->dot118021XPrivacy; - } else { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: stainfo == NULL)||(Adapter->securitypriv.dot11AuthAlgrthm!= dot11AuthAlgrthm_8021X)\n")); - encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; - } - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (encryptionalgo==%d)!\n", - encryptionalgo)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11PrivacyAlgrthm==%d)!\n", - padapter->securitypriv.dot11PrivacyAlgrthm)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11AuthAlgrthm==%d)!\n", - padapter->securitypriv.dot11AuthAlgrthm)); - - if ((stainfo != NULL)) - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (stainfo->dot118021XPrivacy==%d)!\n", - stainfo->dot118021XPrivacy)); - - 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 */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, (" key->KeyIndex & 0x000000FF.\n")); - ret = _FAIL; - goto exit; - } - - /* check BSSID */ - if (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == true) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MacAddr_isBcst(key->BSSID)\n")); - ret = false; - goto exit; - } - - /* Check key length for TKIP. */ - if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("TKIP KeyLength:0x%x != 32\n", key->KeyLength)); - 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)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("WEP KeyLength:0x%x != 5 or 13\n", key->KeyLength)); - ret = _FAIL; - goto exit; - } - - bgroup = false; - - /* Check the pairwise key. Added by Annie, 2005-07-06. */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Pairwise Key set]\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - - } else { - /* Group key - KeyIndex(BIT30 == 0) */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Group key +++++\n")); - - - /* when add wep key through add key and didn't assigned encryption type before */ - if ((padapter->securitypriv.ndisauthtype <= 3) && - (padapter->securitypriv.dot118021XGrpPrivacy == 0)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("keylen =%d(Adapter->securitypriv.dot11PrivacyAlgrthm=%x )padapter->securitypriv.dot118021XGrpPrivacy(%x)\n", - key->KeyLength, padapter->securitypriv.dot11PrivacyAlgrthm, - padapter->securitypriv.dot118021XGrpPrivacy)); - switch (key->KeyLength) { - case 5: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", - padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); - break; - case 13: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", - padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); - break; - default: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", - padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); - break; - } - - encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - (" Adapter->securitypriv.dot11PrivacyAlgrthm=%x\n", - padapter->securitypriv.dot11PrivacyAlgrthm)); - - } else { - encryptionalgo = padapter->securitypriv.dot118021XGrpPrivacy; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("(Adapter->securitypriv.dot11PrivacyAlgrthm=%x)encryptionalgo(%x)=padapter->securitypriv.dot118021XGrpPrivacy(%x)keylen=%d\n", - padapter->securitypriv.dot11PrivacyAlgrthm, encryptionalgo, - padapter->securitypriv.dot118021XGrpPrivacy, key->KeyLength)); - } - - if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE) == true) && (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == false)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - (" IBSS but BSSID is not Broadcast Address.\n")); - ret = _FAIL; - goto exit; - } - - /* Check key length for TKIP */ - if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - (" TKIP GTK KeyLength:%u != 32\n", key->KeyLength)); - 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. */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("<=== SetInfo, OID_802_11_ADD_KEY: AES GTK KeyLength:%u != 16 or 32\n", - key->KeyLength)); - 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; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("AES key length changed: %u\n", key->KeyLength)); - } - - 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; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Group Key set]\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")) ; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)) ; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - } - - /* 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; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ WEP key +++++\n")); - - wep->Length = len; - keyindex = key->KeyIndex&0x7fffffff; - wep->KeyIndex = keyindex ; - wep->KeyLength = key->KeyLength; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY:Before memcpy\n")); - - 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 */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ SetRSC+++++\n")); - 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; - } - _rtw_memset(&padapter->securitypriv.dot118021XGrpKey[(u8)((key->KeyIndex) & 0x03)], 0, 16); - _rtw_memset(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], 0, 16); - _rtw_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); - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); - } 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); - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); - } - - /* 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; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("reset group key")); - - 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 != NULL) { - _rtw_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); */ - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n========== _set_timer\n")); - - /* 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); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(group)\n")); - } else { - res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, true); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(unicast)\n")); - } - if (!res) - ret = _FAIL; - } - } -exit: - -_func_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; - -_func_enter_; - - if ((key->KeyIndex & 0xbffffffc) > 0) { - ret = _FAIL; - goto exit; - } - - if (bgroup) { - /* clear group key by index */ - - _rtw_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 */ - _rtw_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: - -_func_exit_; return ret; } @@ -1109,36 +632,6 @@ 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 @@ -1165,5 +658,5 @@ int rtw_set_country(struct adapter *adapter, const char *country_code) else DBG_88E("%s unknown country_code:%s\n", __func__, country_code); - return rtw_set_channel_plan(adapter, channel_plan); + return rtw_set_chplan_cmd(adapter, channel_plan, 1); } diff --git a/core/rtw_iol.c b/core/rtw_iol.c index e6fdd32..cdcf0ea 100644 --- a/core/rtw_iol.c +++ b/core/rtw_iol.c @@ -20,65 +20,6 @@ #include -struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) -{ - struct xmit_frame *xmit_frame; - struct xmit_buf *xmitbuf; - struct pkt_attrib *pattrib; - struct xmit_priv *pxmitpriv = &(adapter->xmitpriv); - - xmit_frame = rtw_alloc_xmitframe(pxmitpriv); - if (xmit_frame == NULL) { - DBG_88E("%s rtw_alloc_xmitframe return null\n", __func__); - goto exit; - } - - xmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (xmitbuf == NULL) { - DBG_88E("%s rtw_alloc_xmitbuf return null\n", __func__); - rtw_free_xmitframe(pxmitpriv, xmit_frame); - xmit_frame = NULL; - goto exit; - } - - xmit_frame->frame_tag = MGNT_FRAMETAG; - xmit_frame->pxmitbuf = xmitbuf; - xmit_frame->buf_addr = xmitbuf->pbuf; - xmitbuf->priv_data = xmit_frame; - - pattrib = &xmit_frame->attrib; - update_mgntframe_attrib(adapter, pattrib); - pattrib->qsel = 0x10;/* Beacon */ - pattrib->subtype = WIFI_BEACON; - pattrib->pktlen = 0; - pattrib->last_txcmdsz = 0; -exit: - return xmit_frame; -} - -int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len) -{ - struct pkt_attrib *pattrib = &xmit_frame->attrib; - u16 buf_offset; - u32 ori_len; - - buf_offset = TXDESC_OFFSET; - ori_len = buf_offset+pattrib->pktlen; - - /* check if the io_buf can accommodate new cmds */ - if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) { - DBG_88E("%s %u is large than MAX_XMITBUF_SZ:%u, can't accommodate new cmds\n", - __func__ , ori_len + cmd_len + 8, MAX_XMITBUF_SZ); - return _FAIL; - } - - memcpy(xmit_frame->buf_addr + buf_offset + pattrib->pktlen, IOL_cmds, cmd_len); - pattrib->pktlen += cmd_len; - pattrib->last_txcmdsz += cmd_len; - - return _SUCCESS; -} - bool rtw_IOL_applied(struct adapter *adapter) { if (1 == adapter->registrypriv.fw_iol) @@ -88,122 +29,3 @@ bool rtw_IOL_applied(struct adapter *adapter) return true; 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}; - - cmd.address = cpu_to_le16(addr); - cmd.data = cpu_to_le32(value); - - if (mask != 0xFF) { - cmd.length = 12; - cmd.mask = cpu_to_le32(mask); - } - return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); -} - -int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask) -{ - struct ioreg_cfg cmd = {8, IOREG_CMD_WW_REG, 0x0, 0x0, 0x0}; - - cmd.address = cpu_to_le16(addr); - cmd.data = cpu_to_le32(value); - - if (mask != 0xFFFF) { - cmd.length = 12; - cmd.mask = cpu_to_le32(mask); - } - return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); -} - -int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask) -{ - struct ioreg_cfg cmd = {8, IOREG_CMD_WD_REG, 0x0, 0x0, 0x0}; - - cmd.address = cpu_to_le16(addr); - cmd.data = cpu_to_le32(value); - - if (mask != 0xFFFFFFFF) { - cmd.length = 12; - cmd.mask = cpu_to_le32(mask); - } - return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); -} - -int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask) -{ - struct ioreg_cfg cmd = {8, IOREG_CMD_W_RF, 0x0, 0x0, 0x0}; - - cmd.address = cpu_to_le16((rf_path<<8) | ((addr) & 0xFF)); - cmd.data = cpu_to_le32(value); - - if (mask != 0x000FFFFF) { - cmd.length = 12; - cmd.mask = cpu_to_le32(mask); - } - return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); -} - -int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us) -{ - struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0}; - cmd.address = cpu_to_le16(us); - - return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); -} - -int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms) -{ - struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0}; - - cmd.address = cpu_to_le16(ms); - return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); -} - -int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame) -{ - struct ioreg_cfg cmd = {4, IOREG_CMD_END, cpu_to_le16(0xFFFF), cpu_to_le32(0xFF), 0x0}; - - return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); -} - -u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame) -{ - u8 is_cmd_bndy = false; - if (((pxmit_frame->attrib.pktlen+32)%256) + 8 >= 256) { - rtw_IOL_append_END_cmd(pxmit_frame); - pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen+32)/256)+1)*256); - - pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen; - is_cmd_bndy = true; - } - 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/core/rtw_led.c b/core/rtw_led.c index afac537..2aa6251 100644 --- a/core/rtw_led.c +++ b/core/rtw_led.c @@ -28,19 +28,18 @@ /* */ void BlinkTimerCallback(void *data) { - struct LED_871x *pLed = (struct LED_871x *)data; + struct LED_871x *pLed = data; struct adapter *padapter = pLed->padapter; if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; - _set_workitem(&(pLed->BlinkWorkItem)); + schedule_work(&(pLed->BlinkWorkItem)); } /* */ /* Description: */ /* Callback function of LED BlinkWorkItem. */ -/* We dispatch acture LED blink action according to LedStrategy. */ /* */ void BlinkWorkItemCallback(struct work_struct *work) { @@ -71,16 +70,15 @@ void ResetLedStatus(struct LED_871x *pLed) /*Description: */ /* Initialize an LED_871x object. */ -void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin) +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed) { pLed->padapter = padapter; - pLed->LedPin = LedPin; ResetLedStatus(pLed); _init_timer(&(pLed->BlinkTimer), padapter->pnetdev, BlinkTimerCallback, pLed); - _init_workitem(&(pLed->BlinkWorkItem), BlinkWorkItemCallback, pLed); + INIT_WORK(&(pLed->BlinkWorkItem), BlinkWorkItemCallback); } @@ -90,8 +88,8 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_8 /* */ void DeInitLed871x(struct LED_871x *pLed) { - _cancel_workitem_sync(&(pLed->BlinkWorkItem)); - _cancel_timer_ex(&(pLed->BlinkTimer)); + cancel_work_sync(&(pLed->BlinkWorkItem)); + del_timer_sync(&(pLed->BlinkTimer)); ResetLedStatus(pLed); } @@ -101,87 +99,6 @@ void DeInitLed871x(struct LED_871x *pLed) /* 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - /* 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 (padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */ - if (0) { - SwLedOff(padapter, pLed); - } else 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: - if (pLed->BlinkingLedState == RTW_LED_ON) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); - else - _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; @@ -319,449 +236,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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - } - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); - } - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - if (pLed->CurrLedState != LED_BLINK_WPS_STOP) - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - 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; - } - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); -} - -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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - 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; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); -} - -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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n")); -} - /* ALPHA, added by chiyoko, 20090106 */ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) { @@ -777,11 +251,11 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } @@ -799,11 +273,11 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } pLed->bLedLinkBlinkInProgress = true; @@ -822,15 +296,15 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -849,11 +323,11 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } pLed->bLedBlinkInProgress = true; @@ -870,19 +344,19 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct case LED_CTL_START_WPS_BOTTON: if (!pLed->bLedWPSBlinkInProgress) { if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -896,23 +370,23 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct break; case LED_CTL_STOP_WPS: if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); else pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_WPS_STOP; @@ -926,7 +400,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct break; case LED_CTL_STOP_WPS_FAIL: if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -941,23 +415,23 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedWPSBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + del_timer_sync(&(pLed->BlinkTimer)); pLed->bLedScanBlinkInProgress = false; } SwLedOff(padapter, pLed); @@ -969,676 +443,18 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } - /* 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - 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); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - 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; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); -} - - /* 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; - } - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("CurrLedState %d\n", pLed->CurrLedState)); -} - - /* 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; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); -} - - - - /* 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; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); -} - - /* 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; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); -} - /* */ /* 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) @@ -1661,32 +477,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; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("LedStrategy:%d, LedAction %d\n", - ledpriv->LedStrategy, LedAction)); + SwLedControlMode1(padapter, LedAction); } diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index 27369e4..d4632da 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -20,7 +20,6 @@ #define _RTW_MLME_C_ -#include #include #include #include @@ -31,12 +30,12 @@ #include #include #include -#include +#include extern unsigned char MCS_rate_2R[16]; extern unsigned char MCS_rate_1R[16]; -int _rtw_init_mlme_priv (struct adapter *padapter) +int rtw_init_mlme_priv(struct adapter *padapter) { int i; u8 *pbuf; @@ -44,9 +43,7 @@ int _rtw_init_mlme_priv (struct adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int res = _SUCCESS; -_func_enter_; - - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ pmlmepriv->nic_hdl = (u8 *)padapter; @@ -55,15 +52,15 @@ _func_enter_; pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ - _rtw_spinlock_init(&(pmlmepriv->lock)); + spin_lock_init(&(pmlmepriv->lock)); _rtw_init_queue(&(pmlmepriv->free_bss_pool)); _rtw_init_queue(&(pmlmepriv->scanned_queue)); set_scanned_network_val(pmlmepriv, 0); - _rtw_memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); + memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); - pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); + pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); if (pbuf == NULL) { res = _FAIL; @@ -74,9 +71,9 @@ _func_enter_; pnetwork = (struct wlan_network *)pbuf; for (i = 0; i < MAX_BSS_CNT; i++) { - _rtw_init_listhead(&(pnetwork->list)); + INIT_LIST_HEAD(&(pnetwork->list)); - rtw_list_insert_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue)); + list_add_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue)); pnetwork++; } @@ -88,20 +85,10 @@ _func_enter_; rtw_init_mlme_timer(padapter); exit: - -_func_exit_; - return res; } -static void rtw_mfree_mlme_priv_lock (struct mlme_priv *pmlmepriv) -{ - _rtw_spinlock_free(&pmlmepriv->lock); - _rtw_spinlock_free(&(pmlmepriv->free_bss_pool.lock)); - _rtw_spinlock_free(&(pmlmepriv->scanned_queue.lock)); -} - -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) { kfree(*ppie); @@ -130,155 +117,87 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) } #endif -void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) +void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { -_func_enter_; - rtw_free_mlme_priv_ie_data(pmlmepriv); if (pmlmepriv) { - rtw_mfree_mlme_priv_lock (pmlmepriv); - - if (pmlmepriv->free_bss_buf) { - rtw_vmfree(pmlmepriv->free_bss_buf, MAX_BSS_CNT * sizeof(struct wlan_network)); - } + if (pmlmepriv->free_bss_buf) + vfree(pmlmepriv->free_bss_buf); } -_func_exit_; -} - -int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork) -{ - unsigned long irql; - -_func_enter_; - - if (pnetwork == NULL) - goto exit; - - _enter_critical_bh(&queue->lock, &irql); - - rtw_list_insert_tail(&pnetwork->list, &queue->queue); - - _exit_critical_bh(&queue->lock, &irql); - -exit: - -_func_exit_; - - return _SUCCESS; -} - -struct wlan_network *_rtw_dequeue_network(struct __queue *queue) -{ - unsigned long irql; - - struct wlan_network *pnetwork; - -_func_enter_; - - _enter_critical_bh(&queue->lock, &irql); - - if (_rtw_queue_empty(queue)) { - pnetwork = NULL; - } else { - pnetwork = LIST_CONTAINOR(get_next(&queue->queue), struct wlan_network, list); - - rtw_list_delete(&(pnetwork->list)); - } - - _exit_critical_bh(&queue->lock, &irql); - -_func_exit_; - - return pnetwork; } struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *free_queue) */ { - unsigned long irql; struct wlan_network *pnetwork; struct __queue *free_queue = &pmlmepriv->free_bss_pool; struct list_head *plist = NULL; -_func_enter_; + spin_lock_bh(&free_queue->lock); - _enter_critical_bh(&free_queue->lock, &irql); - - if (_rtw_queue_empty(free_queue) == true) { + if (list_empty(&free_queue->queue)) { pnetwork = NULL; goto exit; } - plist = get_next(&(free_queue->queue)); + plist = free_queue->queue.next; - pnetwork = LIST_CONTAINOR(plist , struct wlan_network, list); + pnetwork = container_of(plist , struct wlan_network, list); - rtw_list_delete(&pnetwork->list); + list_del_init(&pnetwork->list); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("_rtw_alloc_network: ptr=%p\n", plist)); pnetwork->network_type = 0; pnetwork->fixed = false; - pnetwork->last_scanned = rtw_get_current_time(); + pnetwork->last_scanned = jiffies; pnetwork->aid = 0; pnetwork->join_res = 0; pmlmepriv->num_of_scanned++; exit: - _exit_critical_bh(&free_queue->lock, &irql); - -_func_exit_; + spin_unlock_bh(&free_queue->lock); return pnetwork; } -void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall) +static void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall) { u32 curr_time, delta_time; u32 lifetime = SCANQUEUE_LIFETIME; - unsigned long irql; struct __queue *free_queue = &(pmlmepriv->free_bss_pool); -_func_enter_; - if (pnetwork == NULL) - goto exit; + return; if (pnetwork->fixed) - goto exit; - curr_time = rtw_get_current_time(); + return; + curr_time = jiffies; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { delta_time = (curr_time - pnetwork->last_scanned)/HZ; if (delta_time < lifetime)/* unit:sec */ - goto exit; + return; } - _enter_critical_bh(&free_queue->lock, &irql); - rtw_list_delete(&(pnetwork->list)); - rtw_list_insert_tail(&(pnetwork->list), &(free_queue->queue)); + spin_lock_bh(&free_queue->lock); + list_del_init(&(pnetwork->list)); + list_add_tail(&(pnetwork->list), &(free_queue->queue)); pmlmepriv->num_of_scanned--; - _exit_critical_bh(&free_queue->lock, &irql); - -exit: -_func_exit_; + spin_unlock_bh(&free_queue->lock); } void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { struct __queue *free_queue = &(pmlmepriv->free_bss_pool); -_func_enter_; if (pnetwork == NULL) - goto exit; + return; if (pnetwork->fixed) - goto exit; - rtw_list_delete(&(pnetwork->list)); - rtw_list_insert_tail(&(pnetwork->list), get_list_head(free_queue)); + return; + list_del_init(&(pnetwork->list)); + list_add_tail(&(pnetwork->list), get_list_head(free_queue)); pmlmepriv->num_of_scanned--; -exit: - -_func_exit_; } /* @@ -286,65 +205,57 @@ _func_exit_; Shall be calle under atomic context... to avoid possible racing condition... */ -struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) +struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr) { struct list_head *phead, *plist; struct wlan_network *pnetwork = NULL; u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; -_func_enter_; - if (_rtw_memcmp(zero_addr, addr, ETH_ALEN)) { + if (!memcmp(zero_addr, addr, ETH_ALEN)) { pnetwork = NULL; goto exit; } phead = get_list_head(scanned_queue); - plist = get_next(phead); + plist = phead->next; while (plist != phead) { - pnetwork = LIST_CONTAINOR(plist, struct wlan_network , list); - if (_rtw_memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == true) + pnetwork = container_of(plist, struct wlan_network , list); + if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) break; - plist = get_next(plist); + plist = plist->next; } if (plist == phead) pnetwork = NULL; exit: -_func_exit_; return pnetwork; } -void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) +void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) { - unsigned long irql; struct list_head *phead, *plist; struct wlan_network *pnetwork; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *scanned_queue = &pmlmepriv->scanned_queue; -_func_enter_; - - - _enter_critical_bh(&scanned_queue->lock, &irql); + spin_lock_bh(&scanned_queue->lock); phead = get_list_head(scanned_queue); - plist = get_next(phead); + plist = phead->next; - while (rtw_end_of_queue_search(phead, plist) == false) { - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); - plist = get_next(plist); + plist = plist->next; _rtw_free_network(pmlmepriv, pnetwork, isfreeall); } - _exit_critical_bh(&scanned_queue->lock, &irql); -_func_exit_; + spin_unlock_bh(&scanned_queue->lock); } int rtw_if_up(struct adapter *padapter) { int res; -_func_enter_; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { @@ -355,23 +266,19 @@ _func_enter_; } else { res = true; } - -_func_exit_; return res; } void rtw_generate_random_ibss(u8 *pibss) { - u32 curtime = rtw_get_current_time(); + u32 curtime = jiffies; -_func_enter_; pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ -_func_exit_; return; } @@ -384,76 +291,26 @@ u8 *rtw_get_capability_from_ie(u8 *ie) u16 rtw_get_capability(struct wlan_bssid_ex *bss) { __le16 val; -_func_enter_; memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->IEs), 2); -_func_exit_; 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; } -int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ -{ - int res; -_func_enter_; - res = _rtw_init_mlme_priv(padapter);/* (pmlmepriv); */ -_func_exit_; - return res; -} - -void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) -{ -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n")); - _rtw_free_mlme_priv (pmlmepriv); -_func_exit_; -} - static struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) { - struct wlan_network *pnetwork; -_func_enter_; - pnetwork = _rtw_alloc_network(pmlmepriv); -_func_exit_; - return pnetwork; + return _rtw_alloc_network(pmlmepriv); } static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { -_func_enter_; _rtw_free_network_nolock(pmlmepriv, pnetwork); -_func_exit_; -} - - -void rtw_free_network_queue(struct adapter *dev, u8 isfreeall) -{ -_func_enter_; - _rtw_free_network_queue(dev, isfreeall); -_func_exit_; -} - -/* - return the wlan_network with the matching addr - - Shall be calle under atomic context... to avoid possible racing condition... -*/ -struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr) -{ - struct wlan_network *pnetwork = _rtw_find_network(scanned_queue, addr); - - return pnetwork; } int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) @@ -475,7 +332,7 @@ int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) static int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { return (a->Ssid.SsidLength == b->Ssid.SsidLength) && - _rtw_memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); + !memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); } int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) @@ -483,7 +340,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) u16 s_cap, d_cap; __le16 le_scap, le_dcap; -_func_enter_; memcpy((u8 *)&le_scap, rtw_get_capability_from_ie(src->IEs), 2); memcpy((u8 *)&le_dcap, rtw_get_capability_from_ie(dst->IEs), 2); @@ -491,11 +347,9 @@ _func_enter_; s_cap = le16_to_cpu(le_scap); d_cap = le16_to_cpu(le_dcap); -_func_exit_; - return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && - ((_rtw_memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == true) && - ((_rtw_memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) && + ((!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == true) && + ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && ((s_cap & WLAN_CAPABILITY_BSS) == @@ -508,25 +362,23 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) struct wlan_network *pwlan = NULL; struct wlan_network *oldest = NULL; -_func_enter_; phead = get_list_head(scanned_queue); - plist = get_next(phead); + plist = phead->next; while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) + if (phead == plist) break; - pwlan = LIST_CONTAINOR(plist, struct wlan_network, list); + pwlan = container_of(plist, struct wlan_network, list); if (!pwlan->fixed) { if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) oldest = pwlan; } - plist = get_next(plist); + plist = plist->next; } -_func_exit_; return oldest; } @@ -539,7 +391,6 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, u8 sq_final; long rssi_final; -_func_enter_; rtw_hal_antdiv_rssi_compared(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 */ @@ -549,20 +400,20 @@ _func_enter_; sq_final = padapter->recvpriv.signal_qual; /* the rssi value here is undecorated, and will be used for antenna diversity */ if (sq_smp != 101) /* from the right channel */ - rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5; + rssi_final = (src->Rssi+dst->Rssi*4)/5; else rssi_final = rssi_ori; } else { -// if (sq_smp != 101) { /* from the right channel */ - ss_final = (u32)dst->PhyInfo.SignalStrength; //((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = (u32)dst->PhyInfo.SignalQuality; //((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5; -// } else { -// /* bss info not receiving from the right channel, use the original RX signal infos */ -// ss_final = dst->PhyInfo.SignalStrength; -// sq_final = dst->PhyInfo.SignalQuality; -// rssi_final = dst->Rssi; -// } + if (sq_smp != 101) { /* from the right channel */ + ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; + sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; + rssi_final = (src->Rssi+dst->Rssi*4)/5; + } else { + /* bss info not receiving from the right channel, use the original RX signal infos */ + ss_final = dst->PhyInfo.SignalStrength; + sq_final = dst->PhyInfo.SignalQuality; + rssi_final = dst->Rssi; + } } if (update_ie) memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); @@ -570,22 +421,18 @@ _func_enter_; dst->PhyInfo.SignalQuality = sq_final; dst->Rssi = rssi_final; -_func_exit_; } static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) { struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); -_func_enter_; - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork))) { update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fixed_ie), pmlmepriv->cur_network.network.IELength); } -_func_exit_; } /* @@ -593,7 +440,6 @@ Caller must hold pmlmepriv->lock first. */ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target) { - unsigned long irql; struct list_head *plist, *phead; u32 bssid_ex_sz; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); @@ -601,29 +447,24 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t struct wlan_network *pnetwork = NULL; struct wlan_network *oldest = NULL; -_func_enter_; - - _enter_critical_bh(&queue->lock, &irql); + spin_lock_bh(&queue->lock); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); if (is_same_network(&(pnetwork->network), target)) break; if ((oldest == ((struct wlan_network *)0)) || time_after(oldest->last_scanned, pnetwork->last_scanned)) oldest = pnetwork; - plist = get_next(plist); + plist = plist->next; } /* If we didn't find a match, then get a new network slot to initialize * with this beacon's information */ - if (rtw_end_of_queue_search(phead, plist) == true) { - if (_rtw_queue_empty(&(pmlmepriv->free_bss_pool)) == true) { + if (phead == plist) { + if (list_empty(&(pmlmepriv->free_bss_pool.queue))) { /* If there are no more slots, expire the oldest */ pnetwork = oldest; @@ -631,7 +472,7 @@ _func_enter_; memcpy(&(pnetwork->network), target, get_wlan_bssid_ex_sz(target)); /* variable initialize */ pnetwork->fixed = false; - pnetwork->last_scanned = rtw_get_current_time(); + pnetwork->last_scanned = jiffies; pnetwork->network_type = 0; pnetwork->aid = 0; @@ -655,12 +496,12 @@ _func_enter_; rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); memcpy(&(pnetwork->network), target, bssid_ex_sz); - pnetwork->last_scanned = rtw_get_current_time(); + pnetwork->last_scanned = jiffies; /* bss info not receiving from the right channel */ if (pnetwork->network.PhyInfo.SignalQuality == 101) pnetwork->network.PhyInfo.SignalQuality = 0; - rtw_list_insert_tail(&(pnetwork->list), &(queue->queue)); + list_add_tail(&(pnetwork->list), &(queue->queue)); } } else { /* we have an entry and we are going to update it. But this entry may @@ -669,7 +510,7 @@ _func_enter_; */ bool update_ie = true; - pnetwork->last_scanned = rtw_get_current_time(); + pnetwork->last_scanned = jiffies; /* target.Reserved[0]== 1, means that scanned network is a bcn frame. */ if ((pnetwork->network.IELength > target->IELength) && (target->Reserved[0] == 1)) @@ -679,29 +520,25 @@ _func_enter_; } exit: - _exit_critical_bh(&queue->lock, &irql); + spin_unlock_bh(&queue->lock); -_func_exit_; } static void rtw_add_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) { -_func_enter_; -#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); -_func_exit_; } -/* select the desired network based on the capability of the (i)bss. */ -/* check items: (1) security */ -/* (2) network_type */ -/* (3) WMM */ -/* (4) HT */ -/* (5) others */ +/* + * select the desired network based on the capability of the (i)bss. + * check items: (1) security + * (2) network_type + * (3) WMM + * (4) HT + * (5) others + */ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwork) { struct security_priv *psecuritypriv = &adapter->securitypriv; @@ -746,22 +583,17 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * /* TODO: Perry: For Power Management */ void rtw_atimdone_event_callback(struct adapter *adapter , u8 *pbuf) { -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); -_func_exit_; return; } void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) { - unsigned long irql; u32 len; struct wlan_bssid_ex *pnetwork; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); -_func_enter_; - pnetwork = (struct wlan_bssid_ex *)pbuf; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid=%s\n", pnetwork->Ssid.Ssid)); @@ -771,23 +603,22 @@ _func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n****rtw_survey_event_callback: return a wrong bss ***\n")); return; } - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { - if (_rtw_memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { + if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; - unsigned long irql; memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); if (ibss_wlan) { memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto exit; } - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); } } @@ -800,23 +631,16 @@ _func_enter_; exit: - _exit_critical_bh(&pmlmepriv->lock, &irql); - -_func_exit_; - + spin_unlock_bh(&pmlmepriv->lock); return; } - - void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { - unsigned long irql; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); struct mlme_ext_priv *pmlmeext; -_func_enter_; - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); if (pmlmepriv->wps_probe_req_ie) { pmlmepriv->wps_probe_req_ie_len = 0; @@ -827,10 +651,7 @@ _func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv))); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { - u8 timer_cancelled; - - _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled); - + del_timer_sync(&pmlmepriv->scan_to_timer); _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status=%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); @@ -853,7 +674,6 @@ _func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); - _rtw_memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(adapter); @@ -895,17 +715,11 @@ _func_enter_; indicate_wx_scan_complete_event(adapter); - _exit_critical_bh(&pmlmepriv->lock, &irql); - - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0); + spin_unlock_bh(&pmlmepriv->lock); rtw_os_xmit_schedule(adapter); pmlmeext = &adapter->mlmeextpriv; - if (pmlmeext->sitesurvey_res.bss_cnt == 0) - rtw_hal_sreset_reset(adapter); -_func_exit_; } void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf) @@ -918,32 +732,27 @@ void rtw_fwdbg_event_callback(struct adapter *adapter , u8 *pbuf) static void free_scanqueue(struct mlme_priv *pmlmepriv) { - unsigned long irql, irql0; struct __queue *free_queue = &pmlmepriv->free_bss_pool; struct __queue *scan_queue = &pmlmepriv->scanned_queue; struct list_head *plist, *phead, *ptemp; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n")); - _enter_critical_bh(&scan_queue->lock, &irql0); - _enter_critical_bh(&free_queue->lock, &irql); + spin_lock_bh(&scan_queue->lock); + spin_lock_bh(&free_queue->lock); phead = get_list_head(scan_queue); - plist = get_next(phead); + plist = phead->next; while (plist != phead) { - ptemp = get_next(plist); - rtw_list_delete(plist); - rtw_list_insert_tail(plist, &free_queue->queue); + ptemp = plist->next; + list_del_init(plist); + list_add_tail(plist, &free_queue->queue); plist = ptemp; pmlmepriv->num_of_scanned--; } - _exit_critical_bh(&free_queue->lock, &irql); - _exit_critical_bh(&scan_queue->lock, &irql0); - -_func_exit_; + spin_unlock_bh(&free_queue->lock); + spin_unlock_bh(&scan_queue->lock); } /* @@ -951,14 +760,11 @@ _func_exit_; */ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) { - unsigned long irql; struct wlan_network *pwlan = NULL; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n")); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress=%pM ssid=%s\n", @@ -969,9 +775,9 @@ _func_enter_; psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(adapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql); + spin_unlock_bh(&pstapriv->sta_hash_lock); } if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) { @@ -980,15 +786,15 @@ _func_enter_; rtw_free_all_stainfo(adapter); psta = rtw_get_bcmc_stainfo(adapter); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(adapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql); + spin_unlock_bh(&pstapriv->sta_hash_lock); rtw_init_bcmc_stainfo(adapter); } if (lock_scanned_queue) - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) @@ -1000,9 +806,8 @@ _func_enter_; rtw_free_network_nolock(pmlmepriv, pwlan); if (lock_scanned_queue) - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); pmlmepriv->key_mask = 0; -_func_exit_; } /* @@ -1012,8 +817,6 @@ void rtw_indicate_connect(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect\n")); pmlmepriv->to_join = false; @@ -1031,7 +834,6 @@ _func_enter_; rtw_set_scan_deny(padapter, 3000); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); -_func_exit_; } /* @@ -1041,7 +843,6 @@ void rtw_indicate_disconnect(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect\n")); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS); @@ -1058,11 +859,8 @@ _func_enter_; rtw_led_control(padapter, LED_CTL_NO_LINK); rtw_clear_scan_deny(padapter); } - p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 1); - -_func_exit_; } inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) @@ -1076,14 +874,14 @@ void rtw_scan_abort(struct adapter *adapter) struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv); - start = rtw_get_current_time(); + 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)); - rtw_msleep_os(20); + msleep(20); } if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) @@ -1117,15 +915,18 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str padapter->securitypriv.bgrpkey_handshake = false; psta->ieee8021x_blocked = true; psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; - _rtw_memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype)); - _rtw_memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype)); - _rtw_memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype)); - _rtw_memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48)); - _rtw_memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48)); + memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype)); + memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype)); + memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype)); + memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48)); + memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48)); } - /* Commented by Albert 2012/07/21 */ - /* When doing the WPS, the wps_ie_len won't equal to 0 */ - /* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */ + /* + * Commented by Albert 2012/07/21 + * When doing the WPS, the wps_ie_len won't equal to 0 + * And the Wi-Fi driver shouldn't allow the data + * packet to be tramsmitted. + */ if (padapter->securitypriv.wps_ie_len != 0) { psta->ieee8021x_blocked = true; padapter->securitypriv.wps_ie_len = 0; @@ -1220,8 +1021,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) { - unsigned long irql, irql2; - u8 timer_cancelled; struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL; struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); @@ -1230,8 +1029,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; unsigned int the_same_macaddr = false; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("joinbss event call back received with res=%d\n", pnetwork->join_res)); rtw_get_encrypt_decrypt_from_registrypriv(adapter); @@ -1242,20 +1039,20 @@ _func_enter_; else RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - the_same_macaddr = _rtw_memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); + the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); - goto ignore_nolock; + return; } - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nrtw_joinbss_event_callback!! _enter_critical\n")); if (pnetwork->join_res > 0) { - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { /* s1. find ptarget_wlan */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { @@ -1268,9 +1065,9 @@ _func_enter_; pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); if (pcur_sta) { - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(adapter, pcur_sta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + spin_unlock_bh(&pstapriv->sta_hash_lock); } ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); @@ -1292,7 +1089,7 @@ _func_enter_; rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork); } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't find ptarget_wlan when joinbss_event callback\n")); - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } @@ -1302,7 +1099,7 @@ _func_enter_; ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); if (ptarget_sta == NULL) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } } @@ -1316,17 +1113,17 @@ _func_enter_; } /* s5. Cancle assoc_timer */ - _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); + del_timer_sync(&pmlmepriv->assoc_timer); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancle assoc_timer\n")); } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_joinbss_event_callback err: fw_state:%x", get_fwstate(pmlmepriv))); - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); } else if (pnetwork->join_res == -4) { rtw_reset_securitypriv(adapter); @@ -1342,28 +1139,22 @@ _func_enter_; } ignore_joinbss_callback: - _exit_critical_bh(&pmlmepriv->lock, &irql); -ignore_nolock: -_func_exit_; + spin_unlock_bh(&pmlmepriv->lock); } void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) { struct wlan_network *pnetwork = (struct wlan_network *)pbuf; -_func_enter_; - mlmeext_joinbss_event_callback(adapter, pnetwork->join_res); rtw_os_xmit_schedule(adapter); - -_func_exit_; } static u8 search_max_mac_id(struct adapter *padapter) { u8 mac_id; -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) u8 aid; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; @@ -1371,7 +1162,7 @@ static u8 search_max_mac_id(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -#if defined (CONFIG_88EU_AP_MODE) +#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] != NULL) @@ -1406,26 +1197,23 @@ void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta) void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) { - unsigned long irql; struct sta_info *psta; struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; struct wlan_network *cur_network = &(pmlmepriv->cur_network); struct wlan_network *ptarget_wlan = NULL; -_func_enter_; - if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) return; -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta) { ap_sta_info_defer_update(adapter, psta); rtw_stassoc_hw_rpt(adapter, psta); } - goto exit; + return; } #endif /* for AD-HOC mode */ @@ -1433,12 +1221,12 @@ _func_enter_; if (psta != NULL) { /* the sta have been in sta_info_queue => do nothing */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); - goto exit; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ + return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ } psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta == NULL) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); - goto exit; + return; } /* to do: init sta_info variable */ psta->qos_option = 0; @@ -1450,28 +1238,25 @@ _func_enter_; if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; psta->ieee8021x_blocked = false; - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) { if (adapter->stapriv.asoc_sta_count == 2) { - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); if (ptarget_wlan) ptarget_wlan->fixed = true; - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ rtw_indicate_connect(adapter); } } - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); mlmeext_sta_add_event_callback(adapter, psta); -exit: -_func_exit_; } void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) { - unsigned long irql, irql2; int mac_id = -1; struct sta_info *psta; struct wlan_network *pwlan = NULL; @@ -1482,8 +1267,6 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &(pmlmepriv->cur_network); -_func_enter_; - psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); if (psta) mac_id = psta->mac_id; @@ -1504,7 +1287,7 @@ _func_enter_; mlmeext_sta_del_event_callback(adapter); - _enter_critical_bh(&pmlmepriv->lock, &irql2); + spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { if (pmlmepriv->to_roaming > 0) @@ -1519,38 +1302,37 @@ _func_enter_; rtw_free_assoc_resources(adapter, 1); rtw_indicate_disconnect(adapter); - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); /* remove the network entry in scanned_queue */ pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); } - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); _rtw_roaming(adapter, tgt_network); } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql); + spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(adapter, psta); - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql); + spin_unlock_bh(&pstapriv->sta_hash_lock); if (adapter->stapriv.asoc_sta_count == 1) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); /* free old ibss network */ pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); } - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* re-create ibss */ pdev_network = &(adapter->registrypriv.dev_network); pibss = adapter->registrypriv.dev_network.MacAddress; memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); - _rtw_memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(adapter); @@ -1566,36 +1348,31 @@ _func_enter_; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error=>stadel_event_callback: rtw_createbss_cmd status FAIL***\n ")); } } - _exit_critical_bh(&pmlmepriv->lock, &irql2); -_func_exit_; + spin_unlock_bh(&pmlmepriv->lock); } void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) { -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n")); -_func_exit_; } /* * _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss * @adapter: pointer to struct adapter structure */ -void _rtw_join_timeout_handler (struct adapter *adapter) +void _rtw_join_timeout_handler (void *function_context) { - unsigned long irql; + struct adapter *adapter = function_context; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; int do_join_r; -_func_enter_; - DBG_88E("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); if (adapter->bDriverStopped || adapter->bSurpriseRemoved) return; - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); if (pmlmepriv->to_roaming > 0) { /* join timeout caused by roaming */ while (1) { @@ -1618,23 +1395,22 @@ _func_enter_; rtw_indicate_disconnect(adapter); free_scanqueue(pmlmepriv);/* */ } - _exit_critical_bh(&pmlmepriv->lock, &irql); -_func_exit_; + spin_unlock_bh(&pmlmepriv->lock); } /* * rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey * @adapter: pointer to struct adapter structure */ -void rtw_scan_timeout_handler (struct adapter *adapter) +void rtw_scan_timeout_handler (void *function_context) { - unsigned long irql; + struct adapter *adapter = function_context; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); rtw_indicate_scan_done(adapter, true); } @@ -1653,54 +1429,27 @@ static void rtw_auto_scan_handler(struct adapter *padapter) } } -void rtw_dynamic_check_timer_handlder(struct adapter *adapter) +void rtw_dynamic_check_timer_handlder(void *function_context) { - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct adapter *adapter = (struct adapter *)function_context; struct registry_priv *pregistrypriv = &adapter->registrypriv; if (!adapter) return; if (!adapter->hw_init_completed) - return; + goto exit; if ((adapter->bDriverStopped) || (adapter->bSurpriseRemoved)) - return; + goto exit; if (adapter->net_closed) - return; + goto exit; 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); - } + /* auto site survey */ + rtw_auto_scan_handler(adapter); } - - rcu_read_lock(); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) - if (rcu_dereference(adapter->pnetdev->rx_handler_data) && -#else - if (rcu_dereference(adapter->pnetdev->br_port) && -#endif - (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true)) { - /* expire NAT2.5 entry */ - nat25_db_expire(adapter); - - if (adapter->pppoe_connection_in_progress > 0) { - adapter->pppoe_connection_in_progress--; - } - - /* due to rtw_dynamic_check_timer_handlder() is called every 2 seconds */ - if (adapter->pppoe_connection_in_progress > 0) { - adapter->pppoe_connection_in_progress--; - } - } - - rcu_read_unlock(); +exit: + _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); } #define RTW_SCAN_RESULT_EXPIRE 2000 @@ -1719,14 +1468,14 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv /* check bssid, if needed */ if (pmlmepriv->assoc_by_bssid) { - if (!_rtw_memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN)) + if (memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN)) goto exit; } /* check ssid, if needed */ - if (pmlmepriv->assoc_ssid.Ssid && pmlmepriv->assoc_ssid.SsidLength) { + if (pmlmepriv->assoc_ssid.SsidLength) { if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength || - _rtw_memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength) == false) + !memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength) == false) goto exit; } @@ -1766,7 +1515,6 @@ pmlmepriv->lock int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) { - unsigned long irql; int ret; struct list_head *phead; struct adapter *adapter; @@ -1775,20 +1523,18 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) struct wlan_network *candidate = NULL; u8 supp_ant_div = false; -_func_enter_; - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); adapter = (struct adapter *)pmlmepriv->nic_hdl; - pmlmepriv->pscanned = get_next(phead); - while (!rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) { - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + pmlmepriv->pscanned = phead->next; + while (phead != pmlmepriv->pscanned) { + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); if (pnetwork == NULL) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork==NULL)\n", __func__)); ret = _FAIL; goto exit; } - pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + pmlmepriv->pscanned = pmlmepriv->pscanned->next; rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); } if (candidate == NULL) { @@ -1824,10 +1570,7 @@ _func_enter_; ret = rtw_joinbss_cmd(adapter, candidate); exit: - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); - -_func_exit_; - + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); return ret; } @@ -1838,34 +1581,31 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); int res = _SUCCESS; -_func_enter_; - - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (pcmd == NULL) { res = _FAIL; /* try again */ goto exit; } - psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); + psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL); if (psetauthparm == NULL) { kfree(pcmd); res = _FAIL; goto exit; } - _rtw_memset(psetauthparm, 0, sizeof(struct setauth_parm)); + memset(psetauthparm, 0, sizeof(struct setauth_parm)); psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; pcmd->cmdcode = _SetAuth_CMD_; pcmd->parmbuf = (unsigned char *)psetauthparm; pcmd->cmdsz = (sizeof(struct setauth_parm)); pcmd->rsp = NULL; pcmd->rspsz = 0; - _rtw_init_listhead(&pcmd->list); + INIT_LIST_HEAD(&pcmd->list); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("after enqueue set_auth_cmd, auth_mode=%x\n", psecuritypriv->dot11AuthAlgrthm)); res = rtw_enqueue_cmd(pcmdpriv, pcmd); exit: -_func_exit_; return res; } @@ -1878,20 +1618,17 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); int res = _SUCCESS; -_func_enter_; - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { - res = _FAIL; /* try again */ - goto exit; - } - psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (pcmd == NULL) + return _FAIL; /* try again */ + + psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); if (psetkeyparm == NULL) { - kfree(pcmd); res = _FAIL; - goto exit; + goto err_free_cmd; } - _rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + memset(psetkeyparm, 0, sizeof(struct setkey_parm)); if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; @@ -1937,17 +1674,21 @@ _func_enter_; ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm=%x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; - goto exit; + goto err_free_parm; } pcmd->cmdcode = _SetKey_CMD_; pcmd->parmbuf = (u8 *)psetkeyparm; pcmd->cmdsz = (sizeof(struct setkey_parm)); pcmd->rsp = NULL; pcmd->rspsz = 0; - _rtw_init_listhead(&pcmd->list); + INIT_LIST_HEAD(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); -exit: -_func_exit_; + return res; + +err_free_parm: + kfree(psetkeyparm); +err_free_cmd: + kfree(pcmd); return res; } @@ -1979,17 +1720,15 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ return ielength; } -/* */ -/* Ported from 8185: IsInPreAuthKeyList(). (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.) */ -/* Added by Annie, 2006-05-07. */ -/* */ -/* Search by BSSID, */ -/* Return Value: */ -/* -1 :if there is no pre-auth key in the table */ -/* >= 0 :if there is pre-auth key, and return the entry id */ -/* */ -/* */ - +/* + * Ported from 8185: IsInPreAuthKeyList(). + * (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.) + * Added by Annie, 2006-05-07. + * Search by BSSID, + * Return Value: + * -1 :if there is no pre-auth key in the table + * >= 0 :if there is pre-auth key, and return the entry id + */ static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) { struct security_priv *psecuritypriv = &Adapter->securitypriv; @@ -1997,7 +1736,7 @@ static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) do { if ((psecuritypriv->PMKIDList[i].bUsed) && - (_rtw_memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN) == true)) { + (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) { break; } else { i++; @@ -2006,11 +1745,9 @@ static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) } while (i < NUM_PMKID_CACHE); - if (i == NUM_PMKID_CACHE) { + if (i == NUM_PMKID_CACHE) i = -1;/* Could not find. */ - } else { - /* There is one Pre-Authentication Key for the specific BSSID. */ - } + return i; } @@ -2051,8 +1788,6 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ uint ndisauthmode = psecuritypriv->ndisauthtype; uint ndissecuritytype = psecuritypriv->ndisencryptstatus; -_func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_restruct_sec_ie: ndisauthmode=%d ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype)); @@ -2085,9 +1820,6 @@ _func_enter_; if (authmode == _WPA2_IE_ID_) ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); } - -_func_exit_; - return ielength; } @@ -2098,8 +1830,6 @@ void rtw_init_registrypriv_dev_network(struct adapter *adapter) struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *myhwaddr = myid(peepriv); -_func_enter_; - memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN); memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); @@ -2110,8 +1840,6 @@ _func_enter_; pdev_network->Configuration.FHConfig.HopPattern = 0; pdev_network->Configuration.FHConfig.HopSet = 0; pdev_network->Configuration.FHConfig.DwellTime = 0; - -_func_exit_; } void rtw_update_registrypriv_dev_network(struct adapter *adapter) @@ -2122,8 +1850,6 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) struct security_priv *psecuritypriv = &adapter->securitypriv; struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; -_func_enter_; - pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); /* adhoc no 802.1x */ pdev_network->Rssi = 0; @@ -2173,13 +1899,10 @@ _func_enter_; /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ /* pdev_network->IELength = cpu_to_le32(sz); */ -_func_exit_; } void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) { -_func_enter_; -_func_exit_; } /* the function is at passive_level */ @@ -2239,7 +1962,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ out_len = *pout_len; - _rtw_memset(&ht_capie, 0, sizeof(struct rtw_ieee80211_ht_cap)); + memset(&ht_capie, 0, sizeof(struct rtw_ieee80211_ht_cap)); ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH | IEEE80211_HT_CAP_SGI_20 | @@ -2392,19 +2115,18 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr if (0 == issued) { DBG_88E("rtw_issue_addbareq_cmd, p=%d\n", priority); psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority); - rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra); + rtw_addbareq_cmd(padapter, (u8)priority, pattrib->ra); } } } void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) { - unsigned long irql; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); _rtw_roaming(padapter, tgt_network); - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); } void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) { diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 7ab5ff0..e4b7ee4 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -171,7 +171,7 @@ static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { {0x03}, /* 0x41, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G */ }; -static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03}; /* use the conbination for max channel numbers */ +static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03}; /* use the combination for max channel numbers */ /* * Search the @param channel_num in given @param channel_set @@ -221,13 +221,13 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) _12M_RATE_, _24M_RATE_, 0xff, }; - ATOMIC_SET(&pmlmeext->event_seq, 0); + atomic_set(&pmlmeext->event_seq, 0); pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ pmlmeext->cur_channel = padapter->registrypriv.channel; pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pmlmeext->oper_channel = pmlmeext->cur_channel ; + pmlmeext->oper_channel = pmlmeext->cur_channel; pmlmeext->oper_bwmode = pmlmeext->cur_bwmode; pmlmeext->oper_ch_offset = pmlmeext->cur_ch_offset; pmlmeext->retry = 0; @@ -256,7 +256,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) pmlmeinfo->enc_algo = _NO_PRIVACY_; pmlmeinfo->authModeToggle = 0; - _rtw_memset(pmlmeinfo->chg_txt, 0, 128); + memset(pmlmeinfo->chg_txt, 0, 128); pmlmeinfo->slotTime = SHORT_SLOT_TIME; pmlmeinfo->preamble_mode = PREAMBLE_AUTO; @@ -328,7 +328,7 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c u8 b2_4GBand = false; u8 Index2G = 0; - _rtw_memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); + memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { DBG_88E("ChannelPlan ID %x error !!!!!\n", ChannelPlan); @@ -371,7 +371,6 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c int init_mlme_ext_priv(struct adapter *padapter) { - int res = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -397,7 +396,7 @@ int init_mlme_ext_priv(struct adapter *padapter) pmlmeext->active_keep_alive_check = true; - return res; + return _SUCCESS; } void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) @@ -408,27 +407,26 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) return; if (padapter->bDriverStopped) { - _cancel_timer_ex(&pmlmeext->survey_timer); - _cancel_timer_ex(&pmlmeext->link_timer); - /* _cancel_timer_ex(&pmlmeext->ADDBA_timer); */ + del_timer_sync(&pmlmeext->survey_timer); + del_timer_sync(&pmlmeext->link_timer); } } -static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, union recv_frame *precv_frame) +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->u.hdr.rx_data; + 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 (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - !_rtw_memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) return; ptable->func(padapter, precv_frame); } } -void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) +void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) { int index; struct mlme_handler *ptable; @@ -436,7 +434,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) 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->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, @@ -449,8 +447,8 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) } /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - !_rtw_memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) return; ptable = mlme_sta_tbl; @@ -465,13 +463,15 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) if (psta != NULL) { if (GetRetry(pframe)) { - if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) { + if (precv_frame->attrib.seq_num == + psta->RxMgmtFrameSeqNum) { /* drop the duplicate management frame */ - DBG_88E("Drop duplicate management frame with seq_num=%d.\n", precv_frame->u.hdr.attrib.seq_num); + DBG_88E("Drop duplicate management frame with seq_num=%d.\n", + precv_frame->attrib.seq_num); return; } } - psta->RxMgmtFrameSeqNum = precv_frame->u.hdr.attrib.seq_num; + psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num; } #ifdef CONFIG_88EU_AP_MODE @@ -500,8 +500,6 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) break; default: _mgt_dispatcher(padapter, ptable, precv_frame); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - rtw_hostapd_mlme_rx(padapter, precv_frame); break; } #else @@ -509,30 +507,13 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) #endif } -#ifdef CONFIG_88EU_P2P -static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da) -{ - bool response = true; - - /* do nothing if the device name is empty */ - if (!padapter->wdinfo.device_name_len) - response = false; - - if (response) - issue_probersp_p2p(padapter, da); - - return _SUCCESS; -} -#endif /* CONFIG_88EU_P2P */ - - /**************************************************************************** Following are the callback functions for each subtype of the management frames *****************************************************************************/ -unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame) { unsigned int ielen; unsigned char *p; @@ -540,47 +521,10 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur = &(pmlmeinfo->network); - u8 *pframe = precv_frame->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + 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; - - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE) && - !rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN)) { - /* mcs_rate = 0 -> CCK 1M rate */ - /* mcs_rate = 1 -> CCK 2M rate */ - /* mcs_rate = 2 -> CCK 5.5M rate */ - /* mcs_rate = 3 -> CCK 11M rate */ - /* In the P2P mode, the driver should not support the CCK rate */ - - /* Commented by Kurt 2012/10/16 */ - /* IOT issue: Google Nexus7 use 1M rate to send p2p_probe_req after GO nego completed and Nexus7 is client */ - if (wifi_test_chk_rate == 1) { - is_valid_p2p_probereq = process_probe_req_p2p_ie(pwdinfo, pframe, len); - if (is_valid_p2p_probereq) { - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { - /* FIXME */ - report_survey_event(padapter, precv_frame); - p2p_listen_state_process(padapter, get_sa(pframe)); - - return _SUCCESS; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - goto _continue; - } - } - } - -_continue: -#endif /* CONFIG_88EU_P2P */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) return _SUCCESS; @@ -596,7 +540,7 @@ _continue: if (is_valid_p2p_probereq) goto _issue_probersp; - if ((ielen != 0 && !_rtw_memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || + if ((ielen != 0 && memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) return _SUCCESS; @@ -609,51 +553,9 @@ _issue_probersp: return _SUCCESS; } -unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) +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->u.hdr.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 (_rtw_memcmp(pwdinfo->tx_prov_disc_info.peerIFAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - pwdinfo->tx_prov_disc_info.benable = false; - issue_p2p_provision_request(padapter, - pwdinfo->tx_prov_disc_info.ssid.Ssid, - pwdinfo->tx_prov_disc_info.ssid.SsidLength, - pwdinfo->tx_prov_disc_info.peerDevAddr); - } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - pwdinfo->tx_prov_disc_info.benable = false; - issue_p2p_provision_request(padapter, NULL, 0, - pwdinfo->tx_prov_disc_info.peerDevAddr); - } - } - } - return _SUCCESS; - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { - if (pwdinfo->nego_req_info.benable) { - DBG_88E("[%s] P2P State is GONEGO ING!\n", __func__); - if (_rtw_memcmp(pwdinfo->nego_req_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { - pwdinfo->nego_req_info.benable = false; - issue_p2p_GO_request(padapter, pwdinfo->nego_req_info.peerDevAddr); - } - } - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { - if (pwdinfo->invitereq_info.benable) { - DBG_88E("[%s] P2P_STATE_TX_INVITE_REQ!\n", __func__); - if (_rtw_memcmp(pwdinfo->invitereq_info.peer_macaddr, GetAddr2Ptr(pframe), ETH_ALEN)) { - pwdinfo->invitereq_info.benable = false; - issue_p2p_invitation_request(padapter, pwdinfo->invitereq_info.peer_macaddr); - } - } - } -#endif - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { report_survey_event(padapter, precv_frame); @@ -663,7 +565,7 @@ unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) { int cam_idx; struct sta_info *psta; @@ -671,8 +573,8 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; struct wlan_bssid_ex *pbss; int ret = _SUCCESS; @@ -681,7 +583,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } - if (_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { + if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { /* we should update current network before auth, or some IE is wrong */ pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); @@ -718,7 +620,6 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) /* todo: the timer is used instead of the number of the beacon received */ if ((sta_rx_pkts(psta) & 0xf) == 0) update_beacon_info(padapter, pframe, len, psta); - process_p2p_ps_ie(padapter, (pframe + WLAN_HDR_A3_LEN), (len - WLAN_HDR_A3_LEN)); } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); @@ -753,10 +654,9 @@ _END_ONBEACON_: return _SUCCESS; } -unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE - unsigned long irqL; unsigned int auth_mode, ie_len; u16 seq; unsigned char *sa, *p; @@ -768,8 +668,8 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -817,24 +717,24 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) pstat->state = WIFI_FW_AUTH_NULL; pstat->auth_seq = 0; } else { - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - if (!rtw_is_list_empty(&pstat->asoc_list)) { - rtw_list_delete(&pstat->asoc_list); + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&pstat->asoc_list)) { + list_del_init(&pstat->asoc_list); pstapriv->asoc_list_cnt--; } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); if (seq == 1) { /* TODO: STA re_auth and auth timeout */ } } - _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); - if (rtw_is_list_empty(&pstat->auth_list)) { - rtw_list_insert_tail(&pstat->auth_list, &pstapriv->auth_list); + spin_lock_bh(&pstapriv->auth_list_lock); + if (list_empty(&pstat->auth_list)) { + list_add_tail(&pstat->auth_list, &pstapriv->auth_list); pstapriv->auth_list_cnt++; } - _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + spin_unlock_bh(&pstapriv->auth_list_lock); if (pstat->auth_seq == 0) pstat->expire_to = pstapriv->auth_to; @@ -879,7 +779,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) goto auth_fail; } - if (_rtw_memcmp((void *)(p + 2), pstat->chg_txt, 128)) { + if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) { pstat->state &= (~WIFI_FW_AUTH_STATE); pstat->state |= WIFI_FW_AUTH_SUCCESS; /* challenging txt is correct... */ @@ -915,7 +815,7 @@ auth_fail: rtw_free_stainfo(padapter , pstat); pstat = &stat; - _rtw_memset((char *)pstat, '\0', sizeof(stat)); + memset((char *)pstat, '\0', sizeof(stat)); pstat->auth_seq = 2; memcpy(pstat->hwaddr, sa, 6); @@ -927,20 +827,20 @@ auth_fail: return _FAIL; } -unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame) { unsigned int seq, len, status, offset; unsigned char *p; unsigned int go2asoc = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->u.hdr.rx_data; - uint pkt_len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) @@ -1002,10 +902,9 @@ authclnt_fail: return _FAIL; } -unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE - unsigned long irqL; u16 capab_info; struct rtw_ieee802_11_elems elems; struct sta_info *pstat; @@ -1022,14 +921,8 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur = &(pmlmeinfo->network); struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->u.hdr.rx_data; - uint pkt_len = precv_frame->u.hdr.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 */ + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -1051,12 +944,12 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) } pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (pstat == (struct sta_info *)NULL) { + if (pstat == NULL) { status = _RSON_CLS2_; goto asoc_class2_error; } - capab_info = RTW_GET_LE16(pframe + WLAN_HDR_A3_LEN); + capab_info = get_unaligned_le16(pframe + WLAN_HDR_A3_LEN); left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset); pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset); @@ -1099,7 +992,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) status = _STATS_FAILURE_; } else { /* check if ssid match */ - if (!_rtw_memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) status = _STATS_FAILURE_; if (ie_len != cur->Ssid.SsidLength) @@ -1148,7 +1041,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->wpa2_group_cipher = 0; pstat->wpa_pairwise_cipher = 0; pstat->wpa2_pairwise_cipher = 0; - _rtw_memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); + memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) { int group_cipher = 0, pairwise_cipher = 0; @@ -1272,7 +1165,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) for (;;) { p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p != NULL) { - if (_rtw_memcmp(p+2, WMM_IE, 6)) { + if (!memcmp(p+2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; pstat->qos_option = 1; @@ -1316,7 +1209,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) } /* save HT capabilities in the sta object */ - _rtw_memset(&pstat->htpriv.ht_cap, 0, sizeof(struct rtw_ieee80211_ht_cap)); + memset(&pstat->htpriv.ht_cap, 0, sizeof(struct rtw_ieee80211_ht_cap)); if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct rtw_ieee80211_ht_cap)) { pstat->flags |= WLAN_STA_HT; @@ -1359,23 +1252,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union 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); - if (p2pie) { - pstat->is_p2p_device = true; - p2p_status_code = (u8)process_assoc_req_p2p_ie(pwdinfo, pframe, pkt_len, pstat); - if (p2p_status_code > 0) { - pstat->p2p_status_code = p2p_status_code; - status = _STATS_CAP_FAIL_; - goto OnAssocReqFail; - } - } - } - pstat->p2p_status_code = p2p_status_code; -#endif /* CONFIG_88EU_P2P */ - /* TODO: identify_proprietary_vendor_ie(); */ /* Realtek proprietary IE */ /* identify if this is Broadcom sta */ @@ -1408,20 +1284,20 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->state &= (~WIFI_FW_ASSOC_STATE); pstat->state |= WIFI_FW_ASSOC_SUCCESS; - _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); - if (!rtw_is_list_empty(&pstat->auth_list)) { - rtw_list_delete(&pstat->auth_list); + spin_lock_bh(&pstapriv->auth_list_lock); + if (!list_empty(&pstat->auth_list)) { + list_del_init(&pstat->auth_list); pstapriv->auth_list_cnt--; } - _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + spin_unlock_bh(&pstapriv->auth_list_lock); - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - if (rtw_is_list_empty(&pstat->asoc_list)) { + spin_lock_bh(&pstapriv->asoc_list_lock); + if (list_empty(&pstat->asoc_list)) { pstat->expire_to = pstapriv->expire_to; - rtw_list_insert_tail(&pstat->asoc_list, &pstapriv->asoc_list); + list_add_tail(&pstat->asoc_list, &pstapriv->asoc_list); pstapriv->asoc_list_cnt++; } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); /* now the station is qualified to join our BSS... */ if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { @@ -1472,7 +1348,7 @@ OnAssocReqFail: return _FAIL; } -unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame) { uint i; int res; @@ -1482,13 +1358,13 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); /* struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); */ - u8 *pframe = precv_frame->u.hdr.rx_data; - uint pkt_len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) @@ -1497,7 +1373,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) return _SUCCESS; - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); /* status */ status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); @@ -1526,7 +1402,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if (_rtw_memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ + if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ WMM_param_handler(padapter, pIE); break; case _HT_CAPABILITY_IE_: /* HT caps */ @@ -1562,35 +1438,25 @@ report_assoc_result: return _SUCCESS; } -unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->u.hdr.rx_data; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); -#endif /* CONFIG_88EU_P2P */ + u8 *pframe = precv_frame->rx_data; /* check A3 */ - if (!(_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + 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)) { - unsigned long irqL; struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1601,13 +1467,13 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) if (psta) { u8 updated = 0; - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - if (!rtw_is_list_empty(&psta->asoc_list)) { - rtw_list_delete(&psta->asoc_list); + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; updated = ap_free_sta(padapter, psta, false, reason); } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); associated_clients_update(padapter, updated); } @@ -1626,42 +1492,28 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame) { u16 reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->u.hdr.rx_data; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); -#endif /* CONFIG_88EU_P2P */ + u8 *pframe = precv_frame->rx_data; /* check A3 */ - if (!(_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + 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)) { - unsigned long irqL; struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; - /* _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */ - /* rtw_free_stainfo(padapter, psta); */ - /* _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */ - DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", reason, GetAddr2Ptr(pframe)); @@ -1669,13 +1521,13 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) if (psta) { u8 updated = 0; - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - if (!rtw_is_list_empty(&psta->asoc_list)) { - rtw_list_delete(&psta->asoc_list); + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; updated = ap_free_sta(padapter, psta, false, reason); } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); associated_clients_update(padapter, updated); } @@ -1693,18 +1545,17 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAtim(struct adapter *padapter, struct recv_frame *precv_frame) { DBG_88E("%s\n", __func__); return _SUCCESS; } -unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int on_action_spct(struct adapter *padapter, struct recv_frame *precv_frame) { - unsigned int ret = _FAIL; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = (u8 *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); u8 category; u8 action; @@ -1734,20 +1585,20 @@ unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_fr } exit: - return ret; + return _FAIL; } -unsigned int OnAction_qos(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_qos(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_dls(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_dls(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_frame) { u8 *addr; struct sta_info *psta = NULL; @@ -1757,10 +1608,11 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra unsigned short tid, status, reason_code = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), + ETH_ALEN))/* for if1, sta/ap mode */ return _SUCCESS; DBG_88E("%s\n", __func__); @@ -1794,7 +1646,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ break; case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ - status = RTW_GET_LE16(&frame_body[3]); + status = get_unaligned_le16(&frame_body[3]); tid = ((frame_body[5] >> 2) & 0x7); if (status == 0) { /* successful */ DBG_88E("agg_enable for TID=%d\n", tid); @@ -1808,7 +1660,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra if ((frame_body[3] & BIT(3)) == 0) { psta->htpriv.agg_enable_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); psta->htpriv.candidate_tid_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); - reason_code = RTW_GET_LE16(&frame_body[4]); + reason_code = get_unaligned_le16(&frame_body[4]); } else if ((frame_body[3] & BIT(3)) == BIT(3)) { tid = (frame_body[3] >> 4) & 0x0F; preorder_ctrl = &psta->recvreorder_ctrl[tid]; @@ -1825,2049 +1677,13 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra return _SUCCESS; } -#ifdef CONFIG_88EU_P2P - -static int get_reg_classes_full_count(struct p2p_channels *channel_list) +static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { - int cnt = 0; - int i; - - for (i = 0; i < channel_list->reg_classes; i++) { - cnt += channel_list->reg_class[i].channels; - } - - return cnt; -} - -void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) -{ - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_REQ; - u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; - u8 wpsielen = 0, p2pielen = 0; - u16 len_channellist_attr = 0; - 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); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - DBG_88E("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); - - 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); - - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pwdinfo->negotiation_dialog_token = 1; /* Initialize the dialog value */ - pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &(pattrib->pktlen)); - - - - /* WPS Section */ - wpsielen = 0; - /* WPS OUI */ - *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Device Password ID */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - - if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); - else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN) - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); - - wpsielen += 2; - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); - - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110306 */ - /* According to the P2P Specification, the group negoitation request frame should contain 9 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Group Owner Intent */ - /* 3. Configuration Timeout */ - /* 4. Listen Channel */ - /* 5. Extended Listen Timing */ - /* 6. Intended P2P Interface Address */ - /* 7. Channel List */ - /* 8. P2P Device Info */ - /* 9. Operating Channel */ - - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; - else - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - - /* Group Owner Intent */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - /* Todo the tie breaker bit. */ - p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ - - - /* Listen Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->listen_channel; /* listening channel number */ - - - /* Extended Listen Timing ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - - /* Intended P2P Interface Address */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 - + (1 + 1) * (u16)(pmlmeext->channel_list.reg_classes) - + get_reg_classes_full_count(&pmlmeext->channel_list); - - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - - { - int i, j; - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); - - return; -} - -static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame_body, uint len, u8 result) -{ - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_RESP; - u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; - u8 p2pielen = 0; - uint wpsielen = 0; - u16 wps_devicepassword_id = 0x0000; - __be16 be_tmp; - uint wps_devicepassword_id_len = 0; - u16 len_channellist_attr = 0; - - 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); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - DBG_88E("[%s] In, result=%d\n", __func__, result); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); - - 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); - - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pwdinfo->negotiation_dialog_token = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ - pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); - - /* Commented by Albert 20110328 */ - /* Try to get the device password ID from the WPS IE of group negotiation request frame */ - /* WiFi Direct test plan 5.1.15 */ - rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, &wpsielen); - rtw_get_wps_attr_content(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(be_tmp); - - _rtw_memset(wpsie, 0x00, 255); - wpsielen = 0; - - /* WPS Section */ - wpsielen = 0; - /* WPS OUI */ - *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Device Password ID */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); - else - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); - wpsielen += 2; - - /* Commented by Kurt 20120113 */ - /* If some device wants to do p2p handshake without sending prov_disc_req */ - /* We have to get peer_req_cm from here. */ - if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); - else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); - else - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); - } - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); - - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20100908 */ - /* According to the P2P Specification, the group negoitation response frame should contain 9 P2P attributes */ - /* 1. Status */ - /* 2. P2P Capability */ - /* 3. Group Owner Intent */ - /* 4. Configuration Timeout */ - /* 5. Operating Channel */ - /* 6. Intended P2P Interface Address */ - /* 7. Channel List */ - /* 8. Device Info */ - /* 9. Group ID (Only GO) */ - - - /* ToDo: */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = result; - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - /* Commented by Albert 2011/03/08 */ - /* According to the P2P specification */ - /* if the sending device will be client, the P2P Capability should be reserved of group negotiation response frame */ - p2pie[p2pielen++] = 0; - } else { - /* Be group owner or meet the error case */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - } - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; - } else { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - } - - /* Group Owner Intent */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - if (pwdinfo->peer_intent & 0x01) { - /* Peer's tie breaker bit is 1, our tie breaker bit should be 0 */ - p2pie[p2pielen++] = (pwdinfo->intent << 1); - } else { - /* Peer's tie breaker bit is 0, our tie breaker bit should be 1 */ - p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); - } - - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - - /* Intended P2P Interface Address */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 - + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes - + get_reg_classes_full_count(&pmlmeext->channel_list); - - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - - { - int i, j; - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Group ID Attribute */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); - p2pielen += 2; - - /* Value: */ - /* p2P Device Address */ - memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - p2pielen += pwdinfo->nego_ssidlen; - } - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); - return; -} - -static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) -{ - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_CONF; - u8 p2pie[255] = { 0x00 }; - u8 p2pielen = 0; - - 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); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - DBG_88E("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); - - 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); - - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); - - - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110306 */ - /* According to the P2P Specification, the group negoitation request frame should contain 5 P2P attributes */ - /* 1. Status */ - /* 2. P2P Capability */ - /* 3. Operating Channel */ - /* 4. Channel List */ - /* 5. Group ID (if this WiFi is GO) */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = result; - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; - else - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - p2pie[p2pielen++] = pwdinfo->peer_operating_ch; - } else { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; /* Use the listen channel as the operating channel */ - } - - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(pwdinfo->channel_list_attr_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len); - p2pielen += pwdinfo->channel_list_attr_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Group ID Attribute */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); - p2pielen += 2; - - /* Value: */ - /* p2P Device Address */ - memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - p2pielen += pwdinfo->nego_ssidlen; - } - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); - pattrib->last_txcmdsz = pattrib->pktlen; - dump_mgntframe(padapter, pmgntframe); - return; -} - -void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) -{ - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_INVIT_REQ; - u8 p2pie[255] = { 0x00 }; - u8 p2pielen = 0; - u8 dialogToken = 3; - u16 len_channellist_attr = 0; - 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); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); - - 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); - - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101011 */ - /* According to the P2P Specification, the P2P Invitation request frame should contain 7 P2P attributes */ - /* 1. Configuration Timeout */ - /* 2. Invitation Flags */ - /* 3. Operating Channel (Only GO) */ - /* 4. P2P Group BSSID (Should be included if I am the GO) */ - /* 5. Channel List */ - /* 6. P2P Group ID */ - /* 7. P2P Device Info */ - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ - - /* Invitation Flags */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INVITATION_FLAGS; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = P2P_INVITATION_FLAGS_PERSISTENT; - - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch; /* operating channel number */ - - if (_rtw_memcmp(myid(&padapter->eeprompriv), pwdinfo->invitereq_info.go_bssid, ETH_ALEN)) { - /* P2P Group BSSID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); - p2pielen += ETH_ALEN; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 - + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes - + get_reg_classes_full_count(&pmlmeext->channel_list); - - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - { - int i, j; - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - - - /* P2P Group ID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(6 + pwdinfo->invitereq_info.ssidlen); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_ssid, pwdinfo->invitereq_info.ssidlen); - p2pielen += pwdinfo->invitereq_info.ssidlen; - - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); - - return; -} - -void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialogToken, u8 status_code) -{ - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_INVIT_RESP; - u8 p2pie[255] = { 0x00 }; - u8 p2pielen = 0; - u16 len_channellist_attr = 0; - 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); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); - - 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); - - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101005 */ - /* According to the P2P Specification, the P2P Invitation response frame should contain 5 P2P attributes */ - /* 1. Status */ - /* 2. Configuration Timeout */ - /* 3. Operating Channel (Only GO) */ - /* 4. P2P Group BSSID (Only GO) */ - /* 5. Channel List */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - /* When status code is P2P_STATUS_FAIL_INFO_UNAVAILABLE. */ - /* Sent the event receiving the P2P Invitation Req frame to DMP UI. */ - /* DMP had to compare the MAC address to find out the profile. */ - /* So, the WiFi driver will send the P2P_STATUS_FAIL_INFO_UNAVAILABLE to NB. */ - /* If the UI found the corresponding profile, the WiFi driver sends the P2P Invitation Req */ - /* to NB to rebuild the persistent group. */ - p2pie[p2pielen++] = status_code; - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ - - if (status_code == P2P_STATUS_SUCCESS) { - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* The P2P Invitation request frame asks this Wi-Fi device to be the P2P GO */ - /* In this case, the P2P Invitation response frame should carry the two more P2P attributes. */ - /* First one is operating channel attribute. */ - /* Second one is P2P Group BSSID attribute. */ - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - - - /* P2P Group BSSID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 - + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes - + get_reg_classes_full_count(&pmlmeext->channel_list); - - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - { - int i, j; - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - } - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); - - return; -} - -void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidlen, u8 *pdev_raddr) -{ - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = 1; - u8 oui_subtype = P2P_PROVISION_DISC_REQ; - u8 wpsie[100] = { 0x00 }; - u8 wpsielen = 0; - __be32 p2poui = cpu_to_be32(P2POUI); - u32 p2pielen = 0; - 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); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - DBG_88E("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, pdev_raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, pdev_raddr, ETH_ALEN); - - 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); - - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); - - p2pielen = build_prov_disc_request_p2p_ie(pwdinfo, pframe, pssid, ussidlen, pdev_raddr); - - pframe += p2pielen; - pattrib->pktlen += p2pielen; - - wpsielen = 0; - /* WPS OUI */ - *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Config Method */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); - wpsielen += 2; - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); - - return; -} - -static u8 is_matched_in_profilelist(u8 *peermacaddr, struct profile_info *profileinfo) -{ - u8 i, match_result = 0; - - DBG_88E("[%s] peermac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - peermacaddr[0], peermacaddr[1], peermacaddr[2], peermacaddr[3], peermacaddr[4], peermacaddr[5]); - - for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) { - DBG_88E("[%s] profileinfo_mac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - profileinfo->peermac[0], profileinfo->peermac[1], profileinfo->peermac[2], profileinfo->peermac[3], profileinfo->peermac[4], profileinfo->peermac[5]); - if (_rtw_memcmp(peermacaddr, profileinfo->peermac, ETH_ALEN)) { - match_result = 1; - DBG_88E("[%s] Match!\n", __func__); - break; - } - } - return match_result; -} - -void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct rtw_ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - unsigned char *mac; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - u16 beacon_interval = 100; - u16 capInfo = 0; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 wpsie[255] = { 0x00 }; - u32 wpsielen = 0, p2pielen = 0; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - - mac = myid(&(padapter->eeprompriv)); - - fctrl = &(pwlanhdr->frame_ctl); - *(fctrl) = 0; - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, mac, ETH_ALEN); - - /* Use the device address for BSSID field. */ - memcpy(pwlanhdr->addr3, mac, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(fctrl, WIFI_PROBERSP); - - pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = pattrib->hdrlen; - pframe += pattrib->hdrlen; - - /* timestamp will be inserted by hardware */ - pframe += 8; - pattrib->pktlen += 8; - - /* beacon interval: 2 bytes */ - memcpy(pframe, (unsigned char *)&beacon_interval, 2); - pframe += 2; - pattrib->pktlen += 2; - - /* capability info: 2 bytes */ - /* ESS and IBSS bits must be 0 (defined in the 3.1.2.1.1 of WiFi Direct Spec) */ - capInfo |= cap_ShortPremble; - capInfo |= cap_ShortSlot; - - memcpy(pframe, (unsigned char *)&capInfo, 2); - pframe += 2; - pattrib->pktlen += 2; - - - /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, 7, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); - - /* supported rates... */ - /* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen); - - /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&pwdinfo->listen_channel, &pattrib->pktlen); - - /* Todo: WPS IE */ - /* Noted by Albert 20100907 */ - /* According to the WPS specification, all the WPS attribute is presented by Big Endian. */ - - wpsielen = 0; - /* WPS OUI */ - *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* WiFi Simple Config State */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SIMPLE_CONF_STATE); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_WSC_STATE_NOT_CONFIG; /* Not Configured. */ - - /* Response Type */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_RESP_TYPE); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_RESPONSE_TYPE_8021X; - - /* UUID-E */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); - wpsielen += 0x10; - - /* Manufacturer */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MANUFACTURER); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0007); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "Realtek", 7); - wpsielen += 7; - - /* Model Name */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NAME); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0006); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "8188EU", 6); - wpsielen += 6; - - /* Model Number */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NUMBER); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = 0x31; /* character 1 */ - - /* Serial Number */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SERIAL_NUMBER); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(ETH_ALEN); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "123456" , ETH_ALEN); - wpsielen += ETH_ALEN; - - /* Primary Device Type */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008); - wpsielen += 2; - - /* Value: */ - /* Category ID */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - wpsielen += 2; - - /* OUI */ - *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* Sub Category ID */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - wpsielen += 2; - - /* Device Name */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len); - wpsielen += 2; - - /* Value: */ - if (pwdinfo->device_name_len) { - memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len); - wpsielen += pwdinfo->device_name_len; - } - - /* Config Method */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - wpsielen += 2; - - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); - - - p2pielen = build_probe_resp_p2p_ie(pwdinfo, pframe); - pframe += p2pielen; - pattrib->pktlen += p2pielen; - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); - - return; -} - -static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) -{ - int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct rtw_ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - 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; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - - mac = myid(&(padapter->eeprompriv)); - - fctrl = &(pwlanhdr->frame_ctl); - *(fctrl) = 0; - - if (da) { - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr3, da, ETH_ALEN); - } else { - if ((pwdinfo->p2p_info.scan_op_ch_only) || (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { - /* This two flags will be set when this is only the P2P client mode. */ - memcpy(pwlanhdr->addr1, pwdinfo->p2p_peer_interface_addr, ETH_ALEN); - 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); - } - } - memcpy(pwlanhdr->addr2, mac, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_PROBEREQ); - - pframe += sizeof (struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) - pframe = rtw_set_ie(pframe, _SSID_IE_, pwdinfo->tx_prov_disc_info.ssid.SsidLength, pwdinfo->tx_prov_disc_info.ssid.Ssid, &(pattrib->pktlen)); - else - pframe = rtw_set_ie(pframe, _SSID_IE_, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &(pattrib->pktlen)); - - /* Use the OFDM rate in the P2P probe request frame. (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen); - - - /* WPS IE */ - /* Noted by Albert 20110221 */ - /* According to the WPS specification, all the WPS attribute is presented by Big Endian. */ - - wpsielen = 0; - /* WPS OUI */ - *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - if (pmlmepriv->wps_probe_req_ie == NULL) { - /* UUID-E */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); - wpsielen += 0x10; - - /* Config Method */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - wpsielen += 2; - } - - /* Device Name */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len); - wpsielen += pwdinfo->device_name_len; - - /* Primary Device Type */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008); - wpsielen += 2; - - /* Value: */ - /* Category ID */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_RTK_WIDI); - wpsielen += 2; - - /* OUI */ - *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* Sub Category ID */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_RTK_DMP); - wpsielen += 2; - - /* Device Password ID */ - /* Type: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); /* Registrar-specified */ - wpsielen += 2; - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110221 */ - /* According to the P2P Specification, the probe request frame should contain 5 P2P attributes */ - /* 1. P2P Capability */ - /* 2. P2P Device ID if this probe request wants to find the specific P2P device */ - /* 3. Listen Channel */ - /* 4. Extended Listen Timing */ - /* 5. Operating Channel if this WiFi is working as the group owner now */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - - /* Listen Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->listen_channel; /* listen channel */ - - - /* Extended Listen Timing */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Operating Channel (if this WiFi is working as the group owner now) */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - } - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); - - if (pmlmepriv->wps_probe_req_ie != NULL) { - /* WPS IE */ - memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; - pframe += pmlmepriv->wps_probe_req_ie_len; - } - - pattrib->last_txcmdsz = pattrib->pktlen; - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("issuing probe_req, tx_len=%d\n", pattrib->last_txcmdsz)); - - if (wait_ack) { - ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else { - dump_mgntframe(padapter, pmgntframe); - ret = _SUCCESS; - } - -exit: - return ret; -} - -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 = rtw_get_current_time(); - - do { - ret = _issue_probereq_p2p(adapter, da, wait_ms > 0 ? true : false); - - i++; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(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(union recv_frame *recv_frame, s32 token) -{ - struct adapter *adapter = recv_frame->u.hdr.adapter; + struct adapter *adapter = recv_frame->adapter; struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); - u8 *frame = recv_frame->u.hdr.rx_data; - u16 seq_ctrl = ((recv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | - (recv_frame->u.hdr.attrib.frag_num & 0xf); + u8 *frame = recv_frame->rx_data; + u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | + (recv_frame->attrib.frag_num & 0xf); if (GetRetry(frame)) { if (token >= 0) { @@ -3893,21 +1709,11 @@ static s32 rtw_action_public_decache(union recv_frame *recv_frame, s32 token) return _SUCCESS; } -static unsigned int on_action_public_p2p(union recv_frame *precv_frame) +static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) { - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body; u8 dialogToken = 0; -#ifdef CONFIG_88EU_P2P - struct adapter *padapter = precv_frame->u.hdr.adapter; - uint len = precv_frame->u.hdr.len; - u8 *p2p_ie; - u32 p2p_ielen; - 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)); dialogToken = frame_body[7]; @@ -3915,291 +1721,25 @@ static unsigned int on_action_public_p2p(union 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)) - return _SUCCESS; - - len -= sizeof(struct rtw_ieee80211_hdr_3addr); - - switch (frame_body[6]) { /* OUI Subtype */ - case P2P_GO_NEGO_REQ: - DBG_88E("[%s] Got GO Nego Req Frame\n", __func__); - _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) { - /* Commented by Albert 20110526 */ - /* In this case, this means the previous nego fail doesn't be reset yet. */ - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - /* Restore the previous p2p state */ - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - DBG_88E("[%s] Restore the previous p2p state to %d\n", __func__, rtw_p2p_state(pwdinfo)); - } - - /* Commented by Kurt 20110902 */ - /* Add if statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - - /* Commented by Kurt 20120113 */ - /* Get peer_dev_addr here if peer doesn't issue prov_disc frame. */ - if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, ETH_ALEN)) - memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN); - - result = process_p2p_group_negotation_req(pwdinfo, frame_body, len); - issue_p2p_GO_response(padapter, GetAddr2Ptr(pframe), frame_body, len, result); - - /* Commented by Albert 20110718 */ - /* No matter negotiating or negotiation failure, the driver should set up the restore P2P state timer. */ - _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); - break; - case P2P_GO_NEGO_RESP: - DBG_88E("[%s] Got GO Nego Resp Frame\n", __func__); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { - /* Commented by Albert 20110425 */ - /* The restore timer is enabled when issuing the nego request frame of rtw_p2p_connect function. */ - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - pwdinfo->nego_req_info.benable = false; - result = process_p2p_group_negotation_resp(pwdinfo, frame_body, len); - issue_p2p_GO_confirm(pwdinfo->padapter, GetAddr2Ptr(pframe), result); - if (P2P_STATUS_SUCCESS == result) { - if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) { - pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch; - pwdinfo->p2p_info.scan_op_ch_only = 1; - _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH); - } - } - /* Reset the dialog token for group negotiation frames. */ - pwdinfo->negotiation_dialog_token = 1; - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); - } else { - DBG_88E("[%s] Skipped GO Nego Resp Frame (p2p_state != P2P_STATE_GONEGO_ING)\n", __func__); - } - break; - case P2P_GO_NEGO_CONF: - DBG_88E("[%s] Got GO Nego Confirm Frame\n", __func__); - result = process_p2p_group_negotation_confirm(pwdinfo, frame_body, len); - if (P2P_STATUS_SUCCESS == result) { - if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) { - pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch; - pwdinfo->p2p_info.scan_op_ch_only = 1; - _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH); - } - } - break; - case P2P_INVIT_REQ: - /* Added by Albert 2010/10/05 */ - /* Received the P2P Invite Request frame. */ - - DBG_88E("[%s] Got invite request frame!\n", __func__); - p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); - if (p2p_ie) { - /* Parse the necessary information from the P2P Invitation Request frame. */ - /* For example: The MAC address of sending this P2P Invitation Request frame. */ - u32 attr_contentlen = 0; - u8 status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - struct group_id_info group_id; - u8 invitation_flag = 0; - - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, &invitation_flag, &attr_contentlen); - if (attr_contentlen) { - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_BSSID, pwdinfo->p2p_peer_interface_addr, &attr_contentlen); - /* Commented by Albert 20120510 */ - /* Copy to the pwdinfo->p2p_peer_interface_addr. */ - /* So that the WFD UI (or Sigma) can get the peer interface address by using the following command. */ - /* #> iwpriv wlan0 p2p_get peer_ifa */ - /* After having the peer interface address, the sigma can find the correct conf file for wpa_supplicant. */ - - if (attr_contentlen) { - DBG_88E("[%s] GO's BSSID = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], - pwdinfo->p2p_peer_interface_addr[2], pwdinfo->p2p_peer_interface_addr[3], - pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); - } - - if (invitation_flag & P2P_INVITATION_FLAGS_PERSISTENT) { - /* Re-invoke the persistent group. */ - - _rtw_memset(&group_id, 0x00, sizeof(struct group_id_info)); - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); - if (attr_contentlen) { - if (_rtw_memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { - /* The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - status_code = P2P_STATUS_SUCCESS; - } else { - /* The p2p device sending this p2p invitation request wants to be the persistent GO. */ - if (is_matched_in_profilelist(pwdinfo->p2p_peer_interface_addr, &pwdinfo->profileinfo[0])) { - u8 operatingch_info[5] = { 0x00 }; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { - if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, (u32)operatingch_info[4])) { - /* The operating channel is acceptable for this device. */ - pwdinfo->rx_invitereq_info.operation_ch[0] = operatingch_info[4]; - pwdinfo->rx_invitereq_info.scan_op_ch_only = 1; - _set_timer(&pwdinfo->reset_ch_sitesurvey, P2P_RESET_SCAN_CH); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - status_code = P2P_STATUS_SUCCESS; - } else { - /* The operating channel isn't supported by this device. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - status_code = P2P_STATUS_FAIL_NO_COMMON_CH; - _set_timer(&pwdinfo->restore_p2p_state_timer, 3000); - } - } else { - /* Commented by Albert 20121130 */ - /* Intel will use the different P2P IE to store the operating channel information */ - /* Workaround for Intel WiDi 3.5 */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - status_code = P2P_STATUS_SUCCESS; - } - } else { - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - status_code = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; - } - } - } else { - DBG_88E("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } else { - /* Received the invitation to join a P2P group. */ - - _rtw_memset(&group_id, 0x00, sizeof(struct group_id_info)); - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); - if (attr_contentlen) { - if (_rtw_memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { - /* In this case, the GO can't be myself. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } else { - /* The p2p device sending this p2p invitation request wants to join an existing P2P group */ - /* Commented by Albert 2012/06/28 */ - /* In this case, this Wi-Fi device should use the iwpriv command to get the peer device address. */ - /* The peer device address should be the destination address for the provisioning discovery request. */ - /* Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */ - /* The peer interface address should be the address for WPS mac address */ - memcpy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr , ETH_ALEN); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN); - status_code = P2P_STATUS_SUCCESS; - } - } else { - DBG_88E("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - } else { - DBG_88E("[%s] P2P Invitation Flags Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - - DBG_88E("[%s] status_code = %d\n", __func__, status_code); - - pwdinfo->inviteresp_info.token = frame_body[7]; - issue_p2p_invitation_response(padapter, GetAddr2Ptr(pframe), pwdinfo->inviteresp_info.token, status_code); - } - break; - case P2P_INVIT_RESP: { - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - - DBG_88E("[%s] Got invite response frame!\n", __func__); - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); - if (p2p_ie) { - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - - if (attr_contentlen == 1) { - DBG_88E("[%s] Status = %d\n", __func__, attr_content); - pwdinfo->invitereq_info.benable = false; - - if (attr_content == P2P_STATUS_SUCCESS) { - if (_rtw_memcmp(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv), ETH_ALEN)) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } else { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_OK); - } else { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - } else { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - } else { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL)) - _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); - break; - } - case P2P_DEVDISC_REQ: - process_p2p_devdisc_req(pwdinfo, pframe, len); - break; - case P2P_DEVDISC_RESP: - process_p2p_devdisc_resp(pwdinfo, pframe, len); - break; - case P2P_PROVISION_DISC_REQ: - DBG_88E("[%s] Got Provisioning Discovery Request Frame\n", __func__); - process_p2p_provdisc_req(pwdinfo, pframe, len); - memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN); - - /* 20110902 Kurt */ - /* Add the following statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ); - _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); - break; - case P2P_PROVISION_DISC_RESP: - /* Commented by Albert 20110707 */ - /* Should we check the pwdinfo->tx_prov_disc_info.bsent flag here?? */ - DBG_88E("[%s] Got Provisioning Discovery Response Frame\n", __func__); - /* Commented by Albert 20110426 */ - /* The restore timer is enabled when issuing the provisioing request frame in rtw_p2p_prov_disc function. */ - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_RSP); - process_p2p_provdisc_resp(pwdinfo, pframe); - _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); - break; - } -#endif /* CONFIG_88EU_P2P */ - return _SUCCESS; } -static unsigned int on_action_public_vendor(union recv_frame *precv_frame) +static unsigned int on_action_public_vendor(struct recv_frame *precv_frame) { unsigned int ret = _FAIL; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); - if (_rtw_memcmp(frame_body + 2, P2P_OUI, 4) == true) { + if (!memcmp(frame_body + 2, P2P_OUI, 4)) ret = on_action_public_p2p(precv_frame); - } return ret; } -static unsigned int on_action_public_default(union recv_frame *precv_frame, u8 action) +static unsigned int on_action_public_default(struct recv_frame *precv_frame, u8 action) { unsigned int ret = _FAIL; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); u8 token; @@ -4214,15 +1754,15 @@ exit: return ret; } -unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) { unsigned int ret = _FAIL; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); u8 category, action; /* check RA matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) goto exit; category = frame_body[0]; @@ -4243,68 +1783,28 @@ exit: return ret; } -unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_ht(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_wmm(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction_wmm(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction_p2p(struct adapter *padapter, union recv_frame *precv_frame) +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->u.hdr.rx_data; - uint len = precv_frame->u.hdr.len; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - - DBG_88E("%s\n", __func__); - - /* check RA matches or not */ - if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ - return _SUCCESS; - - frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - - category = frame_body[0]; - if (category != RTW_WLAN_CATEGORY_P2P) - return _SUCCESS; - - if (be32_to_cpu(*((__be32 *)(frame_body + 1))) != P2POUI) - return _SUCCESS; - - len -= sizeof(struct rtw_ieee80211_hdr_3addr); - OUI_Subtype = frame_body[5]; - - switch (OUI_Subtype) { - case P2P_NOTICE_OF_ABSENCE: - break; - case P2P_PRESENCE_REQUEST: - process_p2p_presence_req(pwdinfo, pframe, len); - break; - case P2P_PRESENCE_RESPONSE: - break; - case P2P_GO_DISC_REQUEST: - break; - default: - break; - } -#endif /* CONFIG_88EU_P2P */ return _SUCCESS; } -unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame) { int i; unsigned char category; struct action_handler *ptable; unsigned char *frame_body; - u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *pframe = precv_frame->rx_data; frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); @@ -4318,7 +1818,7 @@ unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; } -unsigned int DoReserved(struct adapter *padapter, union recv_frame *precv_frame) +unsigned int DoReserved(struct adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } @@ -4349,7 +1849,7 @@ struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv) /**************************************************************************** -Following are some TX fuctions for WiFi MLME +Following are some TX functions for WiFi MLME *****************************************************************************/ @@ -4365,7 +1865,7 @@ void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattri { struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - _rtw_memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); + memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); pattrib->hdrlen = 24; pattrib->nr_frags = 1; @@ -4419,7 +1919,7 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntfr if (ret == _SUCCESS) ret = rtw_sctx_wait(&sctx); - return ret; + return ret; } s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe) @@ -4440,7 +1940,7 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg } pxmitpriv->ack_tx = false; - _exit_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + mutex_unlock(&pxmitpriv->ack_tx_mutex); return ret; } @@ -4468,7 +1968,7 @@ static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) break; } case 2: - _rtw_memset(&ssid_ie[2], 0, ssid_len_ori); + memset(&ssid_ie[2], 0, ssid_len_ori); break; default: break; @@ -4487,25 +1987,19 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) __le16 *fctrl; unsigned int rate_len; struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); -#if defined(CONFIG_88EU_AP_MODE) - unsigned long irqL; -#endif /* if defined (CONFIG_88EU_AP_MODE) */ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); 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 == NULL) { DBG_88E("%s, alloc mgnt frame fail\n", __func__); return; } -#if defined (CONFIG_88EU_AP_MODE) - _enter_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); +#if defined(CONFIG_88EU_AP_MODE) + spin_lock_bh(&pmlmepriv->bcn_update_lock); #endif /* if defined (CONFIG_88EU_AP_MODE) */ /* update attribute */ @@ -4513,7 +2007,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) update_mgntframe_attrib(padapter, pattrib); pattrib->qsel = 0x10; - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -4531,111 +2025,29 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) SetFrameSubType(pframe, WIFI_BEACON); pframe += sizeof(struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + 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; - wpsie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wpsielen); - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wpsie && wpsielen > 0) { - uint wps_offset, remainder_ielen; - u8 *premainder_ie, *pframe_wscie; - - wps_offset = (uint)(wpsie - cur_network->IEs); - premainder_ie = wpsie + wpsielen; - remainder_ielen = cur_network->IELength - wps_offset - wpsielen; - pframe_wscie = pframe + wps_offset; - memcpy(pframe, cur_network->IEs, wps_offset+wpsielen); - pframe += (wps_offset + wpsielen); - pattrib->pktlen += (wps_offset + wpsielen); - - /* now pframe is end of wsc ie, insert Primary Device Type & Device Name */ - /* Primary Device Type */ - /* Type: */ - *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - insert_len += 2; - - /* Length: */ - *(__be16 *)(pframe + insert_len) = cpu_to_be16(0x0008); - insert_len += 2; - - /* Value: */ - /* Category ID */ - *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - insert_len += 2; - - /* OUI */ - *(__be32 *)(pframe + insert_len) = cpu_to_be32(WPSOUI); - insert_len += 4; - - /* Sub Category ID */ - *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - insert_len += 2; - - /* Device Name */ - /* Type: */ - *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - insert_len += 2; - - /* Length: */ - *(__be16 *)(pframe + insert_len) = cpu_to_be16(pwdinfo->device_name_len); - insert_len += 2; - - /* Value: */ - memcpy(pframe + insert_len, pwdinfo->device_name, pwdinfo->device_name_len); - insert_len += pwdinfo->device_name_len; - - /* update wsc ie length */ - *(pframe_wscie+1) = (wpsielen-2) + insert_len; - - /* pframe move to end */ - pframe += insert_len; - pattrib->pktlen += insert_len; - - /* copy remainder_ie to pframe */ - memcpy(pframe, premainder_ie, remainder_ielen); - pframe += remainder_ielen; - pattrib->pktlen += remainder_ielen; - } else -#endif /* CONFIG_88EU_P2P */ - { - int len_diff; - memcpy(pframe, cur_network->IEs, cur_network->IELength); - len_diff = update_hidden_ssid( - pframe+_BEACON_IE_OFFSET_ - , cur_network->IELength-_BEACON_IE_OFFSET_ - , pmlmeinfo->hidden_ssid_mode + int len_diff; + u8 *wps_ie; + uint wps_ielen; + u8 sr = 0; + memcpy(pframe, cur_network->IEs, cur_network->IELength); + len_diff = update_hidden_ssid( + pframe+_BEACON_IE_OFFSET_ + , cur_network->IELength-_BEACON_IE_OFFSET_ + , pmlmeinfo->hidden_ssid_mode ); - pframe += (cur_network->IELength+len_diff); - pattrib->pktlen += (cur_network->IELength+len_diff); - } - - { - u8 *wps_ie; - uint wps_ielen; - u8 sr = 0; - wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof (struct rtw_ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, - pattrib->pktlen-sizeof (struct rtw_ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); - if (wps_ie && wps_ielen > 0) - rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); - if (sr != 0) - set_fwstate(pmlmepriv, WIFI_UNDER_WPS); - else - _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); - - pframe += len; - pattrib->pktlen += len; - } -#endif /* CONFIG_88EU_P2P */ + pframe += (cur_network->IELength+len_diff); + pattrib->pktlen += (cur_network->IELength+len_diff); + wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct rtw_ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, + pattrib->pktlen-sizeof(struct rtw_ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); + if (wps_ie && wps_ielen > 0) + rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); + if (sr != 0) + set_fwstate(pmlmepriv, WIFI_UNDER_WPS); + else + _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS); goto _issue_bcn; } @@ -4687,10 +2099,10 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* todo:HT for adhoc */ _issue_bcn: -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) pmlmepriv->update_bcn = false; - _exit_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); + spin_unlock_bh(&pmlmepriv->bcn_update_lock); #endif /* if defined (CONFIG_88EU_AP_MODE) */ if ((pattrib->pktlen + TXDESC_SIZE) > 512) { @@ -4716,7 +2128,7 @@ 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) +#if defined(CONFIG_88EU_AP_MODE) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -4725,9 +2137,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p 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 == NULL) { @@ -4739,7 +2148,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -4852,16 +2261,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); - - pframe += len; - pattrib->pktlen += len; - } -#endif /* CONFIG_88EU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); @@ -4896,7 +2295,7 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -4922,8 +2321,8 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_PROBEREQ); - pframe += sizeof (struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); if (pssid) pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); @@ -4972,7 +2371,7 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, { int ret; int i = 0; - u32 start = rtw_get_current_time(); + u32 start = jiffies; do { ret = _issue_probereq(padapter, pssid, da, wait_ms > 0 ? true : false); @@ -4983,7 +2382,7 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); @@ -5006,7 +2405,7 @@ exit: return ret; } -/* if psta == NULL, indiate we are station(client) now... */ +/* if psta == NULL, indicate we are station(client) now... */ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status) { struct xmit_frame *pmgntframe; @@ -5032,7 +2431,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -5161,9 +2560,6 @@ 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__); @@ -5176,7 +2572,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -5245,7 +2641,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) { pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if (pbuf && _rtw_memcmp(pbuf+2, WMM_PARA_IE, 6)) { + if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); pattrib->pktlen += (ie_len+2); @@ -5268,16 +2664,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; - - len = build_assoc_resp_p2p_ie(pwdinfo, pframe, pstat->p2p_status_code); - - pframe += len; - pattrib->pktlen += len; - } -#endif /* CONFIG_88EU_P2P */ pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); #endif @@ -5301,11 +2687,6 @@ 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 == NULL) @@ -5315,7 +2696,7 @@ void issue_assocreq(struct adapter *padapter) pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -5450,14 +2831,14 @@ void issue_assocreq(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if ((_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) || - (_rtw_memcmp(pIE->data, WMM_OUI, 4)) || - (_rtw_memcmp(pIE->data, WPS_OUI, 4))) { + if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || + (!memcmp(pIE->data, WMM_OUI, 4)) || + (!memcmp(pIE->data, WPS_OUI, 4))) { if (!padapter->registrypriv.wifi_spec) { /* Commented by Kurt 20110629 */ /* In some older APs, WPS handshake */ /* would be fail if we append vender extensions informations to AP */ - if (_rtw_memcmp(pIE->data, WPS_OUI, 4)) + if (!memcmp(pIE->data, WPS_OUI, 4)) pIE->Length = 14; } pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &(pattrib->pktlen)); @@ -5472,137 +2853,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 */ - - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101109 */ - /* According to the P2P Specification, the association request frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Extended Listen Timing */ - /* 3. Device Info */ - /* Commented by Albert 20110516 */ - /* 4. P2P Interface */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - - /* Extended Listen Timing */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - if ((pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) || - (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN)) - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); - else - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* P2P Interface */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTERFACE; - - /* Length: */ - *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x000D); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); /* P2P Device Address */ - p2pielen += ETH_ALEN; - - p2pie[p2pielen++] = 1; /* P2P Interface Address Count */ - - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); /* P2P Interface Address List */ - p2pielen += ETH_ALEN; - - 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); @@ -5617,7 +2867,7 @@ exit: return; } -/* when wait_ack is ture, this function shoule be called at process context */ +/* when wait_ack is true, this function should be called at process context */ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int wait_ack) { int ret = _FAIL; @@ -5646,7 +2896,7 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned update_mgntframe_attrib(padapter, pattrib); pattrib->retry_ctrl = false; - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -5687,17 +2937,17 @@ exit: } -/* when wait_ms > 0 , this function shoule be called at process context */ +/* when wait_ms > 0 , this function should be called at process context */ /* da == NULL for station mode */ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms) { int ret; int i = 0; - u32 start = rtw_get_current_time(); + u32 start = jiffies; struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* da == NULL, assum it's null data for sta to ap*/ + /* da == NULL, assume it's null data for sta to ap*/ if (da == NULL) da = get_my_bssid(&(pmlmeinfo->network)); @@ -5710,7 +2960,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); if (ret != _FAIL) { @@ -5732,7 +2982,7 @@ exit: return ret; } -/* when wait_ack is ture, this function shoule be called at process context */ +/* when wait_ack is true, this function should be called at process context */ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int wait_ack) { int ret = _FAIL; @@ -5762,7 +3012,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 pattrib->ack_policy = 0; pattrib->mdata = 0; - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -5810,17 +3060,17 @@ exit: return ret; } -/* when wait_ms > 0 , this function shoule be called at process context */ +/* when wait_ms > 0 , this function should be called at process context */ /* da == NULL for station mode */ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms) { int ret; int i = 0; - u32 start = rtw_get_current_time(); + u32 start = jiffies; struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* da == NULL, assum it's null data for sta to ap*/ + /* da == NULL, assume it's null data for sta to ap*/ if (da == NULL) da = get_my_bssid(&(pmlmeinfo->network)); @@ -5833,7 +3083,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); if (ret != _FAIL) { @@ -5867,16 +3117,6 @@ 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 == NULL) @@ -5887,7 +3127,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s update_mgntframe_attrib(padapter, pattrib); pattrib->retry_ctrl = false; - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -5934,7 +3174,7 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int { int ret; int i = 0; - u32 start = rtw_get_current_time(); + u32 start = jiffies; do { ret = _issue_deauth(padapter, da, reason, wait_ms > 0 ? true : false); @@ -5945,7 +3185,7 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); if (ret != _FAIL) { @@ -5967,7 +3207,7 @@ exit: return ret; } -void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) +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; @@ -5989,7 +3229,7 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -6018,7 +3258,7 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u 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_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)); @@ -6059,7 +3299,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -6114,17 +3354,26 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch case 1: /* ADDBA rsp */ 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); - if (MAX_AMPDU_FACTOR_64K == max_rx_ampdu_factor) - BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ - else if (MAX_AMPDU_FACTOR_32K == max_rx_ampdu_factor) - BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0800); /* 32 buffer size */ - else if (MAX_AMPDU_FACTOR_16K == max_rx_ampdu_factor) - BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0400); /* 16 buffer size */ - else if (MAX_AMPDU_FACTOR_8K == max_rx_ampdu_factor) - BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0200); /* 8 buffer size */ - else - BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ + switch (max_rx_ampdu_factor) { + case MAX_AMPDU_FACTOR_64K: + BA_para_set |= 0x1000; /* 64 buffer size */ + break; + case MAX_AMPDU_FACTOR_32K: + BA_para_set |= 0x0800; /* 32 buffer size */ + break; + case MAX_AMPDU_FACTOR_16K: + BA_para_set |= 0x0400; /* 16 buffer size */ + break; + case MAX_AMPDU_FACTOR_8K: + BA_para_set |= 0x0200; /* 8 buffer size */ + break; + default: + BA_para_set |= 0x1000; /* 64 buffer size */ + break; + } if (pregpriv->ampdu_amsdu == 0)/* disabled */ BA_para_set = BA_para_set & ~BIT(0); @@ -6156,7 +3405,6 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch static void issue_action_BSSCoexistPacket(struct adapter *padapter) { - unsigned long irqL; struct list_head *plist, *phead; unsigned char category, action; struct xmit_frame *pmgntframe; @@ -6193,7 +3441,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -6227,26 +3475,23 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) /* */ - _rtw_memset(ICS, 0, sizeof(ICS)); + memset(ICS, 0, sizeof(ICS)); if (pmlmepriv->num_sta_no_ht > 0) { int i; - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); + plist = phead->next; - while (1) { + while (phead != plist) { int len; u8 *p; struct wlan_bssid_ex *pbss_network; - if (rtw_end_of_queue_search(phead, plist)) - break; + pnetwork = container_of(plist, struct wlan_network, list); - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - - plist = get_next(plist); + plist = plist->next; pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; @@ -6261,7 +3506,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) ICS[0][0] = 1; } } - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); for (i = 0; i < 8; i++) { if (ICS[i][0] == 1) { @@ -6338,14 +3583,14 @@ unsigned int send_beacon(struct adapter *padapter) int issue = 0; int poll = 0; - u32 start = rtw_get_current_time(); + u32 start = jiffies; rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); do { issue_beacon(padapter, 100); issue++; do { - rtw_yield_os(); + yield(); rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); poll++; } while ((poll%10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); @@ -6367,7 +3612,7 @@ unsigned int send_beacon(struct adapter *padapter) /**************************************************************************** -Following are some utitity fuctions for WiFi MLME +Following are some utility functions for WiFi MLME *****************************************************************************/ @@ -6378,38 +3623,15 @@ void site_survey(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u32 initialgain = 0; + struct rtw_ieee80211_channel *ch; -#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)) { - if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { - survey_channel = pwdinfo->rx_invitereq_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; - } else { - survey_channel = pwdinfo->p2p_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; - } - ScanType = SCAN_ACTIVE; - } else if (rtw_p2p_findphase_ex_is_social(pwdinfo)) { - /* Commented by Albert 2011/06/03 */ - /* The driver is in the find phase, it should go through the social channel. */ - int ch_set_idx; - survey_channel = pwdinfo->social_chan[pmlmeext->sitesurvey_res.channel_idx]; - ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, survey_channel); - if (ch_set_idx >= 0) - ScanType = pmlmeext->channel_set[ch_set_idx].ScanType; - else - ScanType = SCAN_ACTIVE; - } else -#endif /* CONFIG_88EU_P2P */ - { - 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]; - survey_channel = ch->hw_value; - ScanType = (ch->flags & RTW_IEEE80211_CHAN_PASSIVE_SCAN) ? SCAN_PASSIVE : SCAN_ACTIVE; - } + if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) { + ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; + survey_channel = ch->hw_value; + ScanType = (ch->flags & RTW_IEEE80211_CHAN_PASSIVE_SCAN) ? SCAN_PASSIVE : SCAN_ACTIVE; } + if (survey_channel != 0) { /* PAUSE 4-AC Queue when site_survey */ /* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ @@ -6421,143 +3643,102 @@ void site_survey(struct adapter *padapter) 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 */ - { - int i; - for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { - if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { - /* todo: to issue two probe req??? */ - issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); - /* rtw_msleep_os(SURVEY_TO>>1); */ - issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); - } - } - - if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + int i; + for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { + if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { /* todo: to issue two probe req??? */ - issue_probereq(padapter, NULL, NULL); - /* rtw_msleep_os(SURVEY_TO>>1); */ - issue_probereq(padapter, NULL, NULL); + issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); + /* msleep(SURVEY_TO>>1); */ + issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); } } + + if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + /* todo: to issue two probe req??? */ + issue_probereq(padapter, NULL, NULL); + /* msleep(SURVEY_TO>>1); */ + issue_probereq(padapter, NULL, NULL); + } + + if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + /* todo: to issue two probe req??? */ + issue_probereq(padapter, NULL, NULL); + /* msleep(SURVEY_TO>>1); */ + issue_probereq(padapter, NULL, NULL); + } } 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. */ - /* This will let the following flow to run the scanning end. */ - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); - } + /* 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 better one to do connection. */ + if (rtw_hal_antdiv_before_linked(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; } - if (rtw_p2p_findphase_ex_is_needed(pwdinfo)) { - /* Set the P2P State to the listen state of find phase and set the current channel to the listen channel */ - set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN); - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; - initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg(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); */ + /* switch back to the original channel */ - _set_timer(&pwdinfo->find_phase_timer, (u32)((u32)(pwdinfo->listen_dwell) * 100)); - } else -#endif /* CONFIG_88EU_P2P */ - { - /* 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)) { - 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 */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; + /* flush 4-AC Queue after site_survey */ + /* val8 = 0; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ - /* switch back to the original channel */ + /* config MSR */ + Set_MSR(padapter, (pmlmeinfo->state & 0x3)); -#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 */ + initialgain = 0xff; /* restore RX GAIN */ + rtw_hal_set_hwreg(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); */ - /* flush 4-AC Queue after site_survey */ - /* val8 = 0; */ - /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + if (is_client_associated_to_ap(padapter)) + issue_nulldata(padapter, NULL, 0, 3, 500); - /* config MSR */ - Set_MSR(padapter, (pmlmeinfo->state & 0x3)); + val8 = 0; /* survey done */ + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); - initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg(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); */ + report_surveydone_event(padapter); - if (is_client_associated_to_ap(padapter)) - issue_nulldata(padapter, NULL, 0, 3, 500); + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - val8 = 0; /* survey done */ - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); - - report_surveydone_event(padapter); - - pmlmeext->chan_scan_time = SURVEY_TO; - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); - } + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); } return; } /* collect bss info from Beacon and Probe request/response frames. */ -u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, struct wlan_bssid_ex *bssid) +u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) { int i; u32 len; u8 *p; u16 val16, subtype; - u8 *pframe = precv_frame->u.hdr.rx_data; - u32 packet_len = precv_frame->u.hdr.len; + u8 *pframe = precv_frame->rx_data; + u32 packet_len = precv_frame->len; u8 ie_offset; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - __le32 le32_tmp; len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); if (len > MAX_IE_SZ) return _FAIL; - _rtw_memset(bssid, 0, sizeof(struct wlan_bssid_ex)); + memset(bssid, 0, sizeof(struct wlan_bssid_ex)); subtype = GetFrameSubType(pframe); @@ -6584,10 +3765,10 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str bssid->IELength = len; memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength); - /* get the signal strength */ - bssid->Rssi = precv_frame->u.hdr.attrib.phy_info.recvpower; /* in dBM.raw data */ - bssid->PhyInfo.SignalQuality = precv_frame->u.hdr.attrib.phy_info.SignalQuality;/* in percentage */ - bssid->PhyInfo.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ + /* get the signal strength in dBM.raw data */ + bssid->Rssi = precv_frame->attrib.phy_info.recvpower; + 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); /* checking SSID */ @@ -6597,18 +3778,18 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str return _FAIL; } - if (*(p + 1)) { + if (len) { if (len > NDIS_802_11_LENGTH_SSID) { DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); return _FAIL; } - memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); - bssid->Ssid.SsidLength = *(p + 1); + memcpy(bssid->Ssid.Ssid, (p + 2), len); + bssid->Ssid.SsidLength = len; } else { bssid->Ssid.SsidLength = 0; } - _rtw_memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); /* checking rate info... */ i = 0; @@ -6664,8 +3845,8 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str return _SUCCESS; } - memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->IEs), 2); - bssid->Configuration.BeaconPeriod = le32_to_cpu(le32_tmp); + bssid->Configuration.BeaconPeriod = + get_unaligned_le16(rtw_get_beacon_interval_from_ie(bssid->IEs)); val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); @@ -6719,7 +3900,7 @@ void start_create_ibss(struct adapter *padapter) /* update wireless mode */ update_wireless_mode(padapter); - /* udpate capability */ + /* update capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); if (caps&cap_IBSS) {/* adhoc master */ @@ -6771,7 +3952,7 @@ void start_clnt_join(struct adapter *padapter) /* update wireless mode */ update_wireless_mode(padapter); - /* udpate capability */ + /* update capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); if (caps&cap_ESS) { @@ -6816,7 +3997,7 @@ void start_clnt_auth(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); pmlmeinfo->state &= (~WIFI_FW_AUTH_NULL); pmlmeinfo->state |= WIFI_FW_AUTH_STATE; @@ -6847,7 +4028,7 @@ void start_clnt_assoc(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); pmlmeinfo->state &= (~(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE)); pmlmeinfo->state |= (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE); @@ -6863,7 +4044,7 @@ unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); /* check A3 */ - if (!(_rtw_memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + if (memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) return _SUCCESS; DBG_88E("%s\n", __func__); @@ -6912,7 +4093,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid p = ie; ie += len; - _rtw_memset(country, 0, 4); + memset(country, 0, 4); memcpy(country, p, 3); p += 3; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, @@ -6937,7 +4118,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid memcpy(chplan_sta, pmlmeext->channel_set, sizeof(chplan_sta)); - _rtw_memset(pmlmeext->channel_set, 0, sizeof(pmlmeext->channel_set)); + memset(pmlmeext->channel_set, 0, sizeof(pmlmeext->channel_set)); chplan_new = pmlmeext->channel_set; i = 0; @@ -7040,7 +4221,8 @@ Following are the functions to report events *****************************************************************************/ -void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame) +void report_survey_event(struct adapter *padapter, + struct recv_frame *precv_frame) { struct cmd_obj *pcmd_obj; u8 *pevtcmd; @@ -7049,8 +4231,6 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame struct C2HEvent_Header *pc2h_evt_hdr; struct mlme_ext_priv *pmlmeext; struct cmd_priv *pcmdpriv; - /* u8 *pframe = precv_frame->u.hdr.rx_data; */ - /* uint len = precv_frame->u.hdr.len; */ if (!padapter) return; @@ -7059,18 +4239,18 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); if (pevtcmd == NULL) { kfree(pcmd_obj); return; } - _rtw_init_listhead(&pcmd_obj->list); + INIT_LIST_HEAD(&pcmd_obj->list); pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; @@ -7082,7 +4262,7 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct survey_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_Survey); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); @@ -7111,18 +4291,18 @@ void report_surveydone_event(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_KERNEL); if (pevtcmd == NULL) { kfree(pcmd_obj); return; } - _rtw_init_listhead(&pcmd_obj->list); + INIT_LIST_HEAD(&pcmd_obj->list); pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; @@ -7134,7 +4314,7 @@ void report_surveydone_event(struct adapter *padapter) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct surveydone_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_SurveyDone); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; @@ -7157,18 +4337,18 @@ void report_join_res(struct adapter *padapter, int res) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); if (pevtcmd == NULL) { kfree(pcmd_obj); return; } - _rtw_init_listhead(&pcmd_obj->list); + INIT_LIST_HEAD(&pcmd_obj->list); pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; @@ -7180,7 +4360,7 @@ void report_join_res(struct adapter *padapter, int res) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct joinbss_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_JoinBss); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); @@ -7210,18 +4390,18 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_KERNEL); if (pevtcmd == NULL) { kfree(pcmd_obj); return; } - _rtw_init_listhead(&pcmd_obj->list); + INIT_LIST_HEAD(&pcmd_obj->list); pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; @@ -7233,7 +4413,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stadel_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_DelSTA); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); @@ -7265,18 +4445,18 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_KERNEL); if (pevtcmd == NULL) { kfree(pcmd_obj); return; } - _rtw_init_listhead(&pcmd_obj->list); + INIT_LIST_HEAD(&pcmd_obj->list); pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; @@ -7288,7 +4468,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stassoc_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_AddSTA); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); @@ -7385,7 +4565,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) /* turn on dynamic functions */ Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); - /* update IOT-releated issue */ + /* update IOT-related issue */ update_IOT_info(padapter); rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); @@ -7393,7 +4573,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) /* BCN interval */ rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); - /* udpate capability */ + /* update capability */ update_capinfo(padapter, pmlmeinfo->capability); /* WMM, Update EDCA param */ @@ -7495,7 +4675,7 @@ void mlmeext_sta_del_event_callback(struct adapter *padapter) /* set MSR to no link state -> infra. mode */ Set_MSR(padapter, _HW_STATE_STATION_); - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); } } @@ -7550,8 +4730,6 @@ void linked_status_chk(struct adapter *padapter) if (padapter->bRxRSSIDisplay) _linked_rx_signal_strehgth_display(padapter); - rtw_hal_sreset_linked_status_check(padapter); - if (is_client_associated_to_ap(padapter)) { /* linked infrastructure client mode */ @@ -7562,9 +4740,6 @@ void linked_status_chk(struct adapter *padapter) psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); if (psta != NULL) { 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; @@ -7656,15 +4831,13 @@ void linked_status_chk(struct adapter *padapter) } } -void survey_timer_hdl(struct adapter *padapter) +void survey_timer_hdl(void *function_context) { + struct adapter *padapter = function_context; struct cmd_obj *ph2c; 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) { @@ -7672,31 +4845,18 @@ 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; - DBG_88E("%s idx:%d, cnt:%u\n", __func__ - , pmlmeext->sitesurvey_res.channel_idx - , pwdinfo->find_phase_state_exchange_cnt - ); - } else - #endif - { - pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; - DBG_88E("%s idx:%d\n", __func__ - , pmlmeext->sitesurvey_res.channel_idx - ); - } + pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; + DBG_88E("%s idx:%d\n", __func__ + , pmlmeext->sitesurvey_res.channel_idx); pmlmeext->scan_abort = false;/* reset */ } - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) goto exit_survey_timer_hdl; - psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); if (psurveyPara == NULL) { kfree(ph2c); goto exit_survey_timer_hdl; @@ -7711,8 +4871,9 @@ exit_survey_timer_hdl: return; } -void link_timer_hdl(struct adapter *padapter) +void link_timer_hdl(void *function_context) { + struct adapter *padapter = (struct adapter *)function_context; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -7747,8 +4908,9 @@ void link_timer_hdl(struct adapter *padapter) return; } -void addba_timer_hdl(struct sta_info *psta) +void addba_timer_hdl(void *function_context) { + struct sta_info *psta = function_context; struct ht_priv *phtpriv; if (!psta) @@ -7798,11 +4960,11 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); - struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; + struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; /* u32 initialgain; */ - if (pparm->network.InfrastructureMode == Ndis802_11APMode) { + if (pparm->InfrastructureMode == Ndis802_11APMode) { #ifdef CONFIG_88EU_AP_MODE if (pmlmeinfo->state == WIFI_FW_AP_STATE) { @@ -7813,7 +4975,7 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) } /* below is for ad-hoc master */ - if (pparm->network.InfrastructureMode == Ndis802_11IBSS) { + if (pparm->InfrastructureMode == Ndis802_11IBSS) { rtw_joinbss_reset(padapter); pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; @@ -7835,7 +4997,7 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) /* rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ /* cancel link timer */ - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); /* clear CAM */ flush_all_cam_entry(padapter); @@ -7862,7 +5024,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); - struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; + struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; u32 i; /* check already connecting to AP or not */ @@ -7875,7 +5037,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) /* clear CAM */ flush_all_cam_entry(padapter); - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); /* set MSR to nolink -> infra. mode */ Set_MSR(padapter, _HW_STATE_STATION_); @@ -7884,7 +5046,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); } - rtw_antenna_select_cmd(padapter, pparm->network.PhyInfo.Optimum_antenna, false); + rtw_antenna_select_cmd(padapter, pparm->PhyInfo.Optimum_antenna, false); rtw_joinbss_reset(padapter); @@ -7914,7 +5076,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ - if (_rtw_memcmp(pIE->data, WMM_OUI, 4)) + if (!memcmp(pIE->data, WMM_OUI, 4)) pmlmeinfo->WMM_enable = 1; break; case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ @@ -7961,7 +5123,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); /* cancel link timer */ - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); start_clnt_join(padapter); @@ -8005,7 +5167,7 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) flush_all_cam_entry(padapter); - _cancel_timer_ex(&pmlmeext->link_timer); + del_timer_sync(&pmlmeext->link_timer); rtw_free_uc_swdec_pending_queue(padapter); @@ -8020,7 +5182,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; /* clear out first */ - _rtw_memset(out, 0, sizeof(struct rtw_ieee80211_channel)*out_num); + memset(out, 0, sizeof(struct rtw_ieee80211_channel)*out_num); /* acquire channels from in */ j = 0; @@ -8028,7 +5190,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value); if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) && set_idx >= 0) { - memcpy(&out[j], &in[i], sizeof(struct rtw_ieee80211_channel)); + out[j] = in[i]; if (pmlmeext->channel_set[set_idx].ScanType == SCAN_PASSIVE) out[j].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN; @@ -8063,10 +5225,6 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) 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); @@ -8112,14 +5270,7 @@ 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)); @@ -8266,34 +5417,33 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) u8 set_tx_beacon_cmd(struct adapter *padapter) { struct cmd_obj *ph2c; - struct Tx_Beacon_param *ptxBeacon_parm; + struct wlan_bssid_ex *ptxBeacon_parm; struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 res = _SUCCESS; int len_diff = 0; -_func_enter_; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { res = _FAIL; goto exit; } - ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); + ptxBeacon_parm = kzalloc(sizeof(struct wlan_bssid_ex), GFP_KERNEL); if (ptxBeacon_parm == NULL) { kfree(ph2c); res = _FAIL; goto exit; } - memcpy(&(ptxBeacon_parm->network), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + memcpy(ptxBeacon_parm, &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); - len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_, - ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_, + len_diff = update_hidden_ssid(ptxBeacon_parm->IEs+_BEACON_IE_OFFSET_, + ptxBeacon_parm->IELength-_BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); - ptxBeacon_parm->network.IELength += len_diff; + ptxBeacon_parm->IELength += len_diff; init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, GEN_CMD_CODE(_TX_Beacon)); @@ -8302,7 +5452,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -8313,7 +5462,6 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) u16 evt_sz; uint *peventbuf; void (*event_callback)(struct adapter *dev, u8 *pbuf); - struct evt_priv *pevt_priv = &(padapter->evtpriv); peventbuf = (uint *)pbuf; evt_sz = (u16)(*peventbuf&0xffff); @@ -8334,29 +5482,18 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) goto _abort_event_; } - ATOMIC_INC(&pevt_priv->event_seq); - peventbuf += 2; if (peventbuf) { event_callback = wlanevents[evt_code].event_callback; event_callback(padapter, (u8 *)peventbuf); - pevt_priv->evt_done_cnt++; } _abort_event_: return H2C_SUCCESS; } -u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - if (!pbuf) - return H2C_PARAMETERS_ERROR; - - return H2C_SUCCESS; -} - u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) { if (send_beacon(padapter) == _FAIL) { @@ -8365,7 +5502,6 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) } #ifdef CONFIG_88EU_AP_MODE else { /* tx bc/mc frames after update TIM */ - unsigned long irqL; struct sta_info *psta_bmc; struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; @@ -8377,18 +5513,18 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { - rtw_msleep_os(10);/* 10ms, ATIM(HIQ) Windows */ - _enter_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + msleep(10);/* 10ms, ATIM(HIQ) Windows */ + spin_lock_bh(&psta_bmc->sleep_q.lock); xmitframe_phead = get_list_head(&psta_bmc->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; - while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); psta_bmc->sleepq_len--; if (psta_bmc->sleepq_len > 0) @@ -8400,12 +5536,12 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) pxmitframe->attrib.qsel = 0x11;/* HIQ */ - _exit_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + spin_unlock_bh(&psta_bmc->sleep_q.lock); if (rtw_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); - _enter_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + spin_lock_bh(&psta_bmc->sleep_q.lock); } - _exit_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + spin_unlock_bh(&psta_bmc->sleep_q.lock); } } #endif @@ -8450,33 +5586,3 @@ u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; } - -u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - if (!pbuf) - return H2C_PARAMETERS_ERROR; - return H2C_SUCCESS; -} - -u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - return H2C_REJECTED; -} - -/* TDLS_WRCR : write RCR DATA BIT */ -/* TDLS_SD_PTI : issue peer traffic indication */ -/* TDLS_CS_OFF : go back to the channel linked with AP, terminating channel switch procedure */ -/* TDLS_INIT_CH_SEN : init channel sensing, receive all data and mgnt frame */ -/* TDLS_DONE_CH_SEN: channel sensing and report candidate channel */ -/* TDLS_OFF_CH : first time set channel to off channel */ -/* TDLS_BASE_CH : go back tp the channel linked with AP when set base channel as target channel */ -/* TDLS_P_OFF_CH : periodically go to off channel */ -/* TDLS_P_BASE_CH : periodically go back to base channel */ -/* TDLS_RS_RCR : restore RCR */ -/* TDLS_CKALV_PH1 : check alive timer phase1 */ -/* TDLS_CKALV_PH2 : check alive timer phase2 */ -/* TDLS_FREE_STA : free tdls sta */ -u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - return H2C_REJECTED; -} diff --git a/core/rtw_mp.c b/core/rtw_mp.c deleted file mode 100644 index 9832dcb..0000000 --- a/core/rtw_mp.c +++ /dev/null @@ -1,997 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - *published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _RTW_MP_C_ - -#include - -#include "odm_precomp.h" -#include "rtl8188e_hal.h" - -u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz) -{ - u32 val = 0; - - switch (sz) { - case 1: - val = rtw_read8(padapter, addr); - break; - case 2: - val = rtw_read16(padapter, addr); - break; - case 4: - val = rtw_read32(padapter, addr); - break; - default: - val = 0xffffffff; - break; - } - - return val; -} - -void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz) -{ - switch (sz) { - 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: - break; - } -} - -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; - - _rtw_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; - _rtw_memset(pattrib, 0, sizeof(struct pkt_attrib)); - desc = &pmptx->desc; - _rtw_memset(desc, 0, TXDESC_SIZE); - - pattrib->ether_type = 0x8712; - _rtw_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; - - unsigned long irqL; - 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 */ -/* _rtw_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; - - _enter_critical_bh(&pmlmepriv->lock, &irqL); - - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) - goto end_of_mp_start_test; - - /* init mp_start_test status */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - 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 == NULL) { - RT_TRACE(_module_mp_, _drv_err_, ("mp_start_test: Can't alloc sta_info!\n")); - 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: - - _exit_critical_bh(&pmlmepriv->lock, &irqL); - - 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; - - unsigned long irqL; - - if (pmppriv->mode == MP_ON) { - pmppriv->bSetTxPower = 0; - _enter_critical_bh(&pmlmepriv->lock, &irqL); - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false) - 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 */ - _rtw_memset(tgt_network, 0, sizeof(struct wlan_network)); - - _clr_fwstate_(pmlmepriv, WIFI_MP_STATE); - -end_of_mp_stop_test: - - _exit_critical_bh(&pmlmepriv->lock, &irqL); - } -} - -/*---------------------------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 == NULL) - return NULL; - - pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (pxmitbuf == NULL) { - 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 == NULL) { - if (pmptx->stop || - padapter->bSurpriseRemoved || - padapter->bDriverStopped) { - goto exit; - } else { - rtw_msleep_os(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; - s32 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_MCAST(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 = rtw_zmalloc(pmp_priv->tx.buf_size); - if (pmp_priv->tx.pallocated_buf == NULL) { - 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); - _rtw_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; - } - - _rtw_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 | ADF | AMF | HTC_LOC_CTRL | APP_MIC | APP_PHYSTS; - - pHalData->ReceiveConfig |= ACRC32; - - 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); - rtw_mdelay_os(1); - psd_val |= 0x00400000; - - rtw_write32(pAdapter, 0x808, psd_val); - rtw_mdelay_os(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)) { - RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! interface not opened!\n")); - return 0; - } - - if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { - RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! not in MP mode!\n")); - 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); - } - - _rtw_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, "%s%x ", data, psd_data); - i++; - } - - rtw_msleep_os(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 = 20000; - num_xmit_extbuf = 1; - } - - 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++; - } - - if (pxmitpriv->pallocated_xmit_extbuf) - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - - if (padapter->registrypriv.mp_mode == 0) { - max_xmit_extbuf_size = 20000; - num_xmit_extbuf = 1; - } 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 = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - - if (pxmitpriv->pallocated_xmit_extbuf == NULL) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); - 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++) { - _rtw_init_listhead(&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; - } - - rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); - pxmitbuf++; - } - - pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; - -exit: - ; -} diff --git a/core/rtw_mp_ioctl.c b/core/rtw_mp_ioctl.c deleted file mode 100644 index f06312c..0000000 --- a/core/rtw_mp_ioctl.c +++ /dev/null @@ -1,1508 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _RTW_MP_IOCTL_C_ - -#include -#include -#include - -/* include */ -#include - - -/* 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); - -_func_enter_; - - 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; - RT_TRACE(_module_mp_, _drv_info_, ("-query Wireless Mode=%d\n", Adapter->registrypriv.wireless_mode)); - } else { - status = NDIS_STATUS_NOT_ACCEPTED; - } - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_bb_reg_hdl\n")); - - 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; - - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_write_bb_reg_hdl: offset=0x%03X value=0x%08X\n", - offset, value)); - - _irqlevel_changed_(&oldirql, LOWER); - write_bbreg(Adapter, offset, 0xFFFFFFFF, value); - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_bb_reg_hdl\n")); - - 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; - - RT_TRACE(_module_mp_, _drv_notice_, - ("-rtl8188eu_oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n", - offset, value)); -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_rf_reg_hdl\n")); - - 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 >= MAX_RF_PATH_NUMS) - 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; - - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_write_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", - path, offset, value)); - - _irqlevel_changed_(&oldirql, LOWER); - write_rfreg(Adapter, path, offset, value); - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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; - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_rf_reg_hdl\n")); - - 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 >= MAX_RF_PATH_NUMS) - 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; - - RT_TRACE(_module_mp_, _drv_notice_, - ("-rtl8188eu_oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", - path, offset, value)); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_set_data_rate_hdl\n")); - - 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 */ - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue)); - if (ratevalue >= MPT_RATE_LAST) - return NDIS_STATUS_INVALID_DATA; - - Adapter->mppriv.rateidx = ratevalue; - - _irqlevel_changed_(&oldirql, LOWER); - SetDataRate(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_start_test_hdl\n")); - - 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); - - RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode)); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+Set OID_RT_PRO_STOP_TEST\n")); - - 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); - - RT_TRACE(_module_mp_, _drv_notice_, ("-Set OID_RT_PRO_STOP_TEST\n")); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl\n")); - - 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); - RT_TRACE(_module_mp_, _drv_notice_, ("rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel)); - if (Channel > 14) - return NDIS_STATUS_NOT_ACCEPTED; - Adapter->mppriv.channel = Channel; - - _irqlevel_changed_(&oldirql, LOWER); - SetChannel(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_info_, - ("+rtl8188eu_oid_rt_set_bandwidth_hdl\n")); - - 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); - - RT_TRACE(_module_mp_, _drv_notice_, - ("-rtl8188eu_oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n", - bandwidth, channel_offset)); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_antenna_bb_hdl\n")); - - 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); - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_set_antenna_bb_hdl: tx_ant=0x%04x rx_ant=0x%04x\n", - Adapter->mppriv.antenna_tx, Adapter->mppriv.antenna_rx)); - - _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; - } - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_set_tx_power_control_hdl\n")); - - 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; - - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_set_tx_power_control_hdl: idx=0x%2x\n", - Adapter->mppriv.txpoweridx)); - - _irqlevel_changed_(&oldirql, LOWER); - SetTxPower(Adapter); - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - 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; - } - -_func_exit_; - - 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); - -_func_enter_; - - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl.\n")); - 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; - RT_TRACE(_module_mp_, _drv_alert_, ("recv_ok:%d\n", Adapter->mppriv.rx_pktcount)); - } else { - status = NDIS_STATUS_INVALID_LENGTH; - } - -_func_exit_; - - 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); - -_func_enter_; - - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl.\n")); - 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; - RT_TRACE(_module_mp_, _drv_alert_, ("recv_err:%d\n", Adapter->mppriv.rx_crcerrpktcount)); - } else { - status = NDIS_STATUS_INVALID_LENGTH; - } - -_func_exit_; - - 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); - -_func_enter_; - - if (poid_par_priv->type_of_oid != SET_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - - RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl.\n")); - Adapter->mppriv.tx_pktcount = 0; - -_func_exit_; - - 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); - -_func_enter_; - - 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; - } - -_func_exit_; - - 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); - -_func_enter_; - - 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); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl\n")); - - 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; - - RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf)); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl\n")); - - 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; - - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n", - *(u32 *)poid_par_priv->information_buf)); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_continuous_tx_hdl\n")); - - 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__); - rtw_msleep_os(5); - } - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(Adapter); - } - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl\n")); - - 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__); - rtw_msleep_os(5); - } - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(Adapter); - } - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl\n")); - - 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__); - rtw_msleep_os(5); - } - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(Adapter); - } - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl\n")); - - 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); - -_func_exit_; - - 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; -_func_enter_; - - 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); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_info_, - ("+rtl8188eu_oid_rt_pro_read_register_hdl\n")); - - 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; - } - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_read_register_hdl: offset:0x%04X value:0x%X\n", - offset, RegRWStruct->value)); - - _irqlevel_changed_(&oldirql, RAISE); - - *poid_par_priv->bytes_rw = width; - -_func_exit_; - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) -{ - struct mp_rw_reg *RegRWStruct; - u32 offset, width, value; - int status = NDIS_STATUS_SUCCESS; - struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_info_, - ("+rtl8188eu_oid_rt_pro_write_register_hdl\n")); - - 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; - width = RegRWStruct->width; - 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); - - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n", - offset, width, value)); - -_func_exit_; - - 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; - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+OID_RT_PRO_SET_DATA_RATE_EX\n")); - - 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); - -_func_exit_; - - 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); - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_get_thermal_meter_hdl\n")); - - 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); - -_func_exit_; - - 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); - - -_func_enter_; - - 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; - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_set_power_tracking_hdl: enable =%d\n", enable)); - - SetPowerTracking(Adapter, enable); - } else { - GetPowerTracking(Adapter, (u8 *)poid_par_priv->information_buf); - } - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - -_func_enter_; - - 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; - - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_read_efuse_hd: buf_len=%d addr=%d cnts=%d\n", - poid_par_priv->information_buf_len, addr, cnts)); - - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - - if ((addr + cnts) > max_available_size) { - RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: parameter error!\n")); - return NDIS_STATUS_NOT_ACCEPTED; - } - - _irqlevel_changed_(&oldirql, LOWER); - if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) { - RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: rtw_efuse_access FAIL!\n")); - status = NDIS_STATUS_FAILURE; - } else { - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - 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); - - -_func_enter_; - - 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; - - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_write_efuse_hdl: buf_len=%d addr=0x%04x cnts=%d\n", - poid_par_priv->information_buf_len, addr, cnts)); - - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - - if ((addr + cnts) > max_available_size) { - RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_write_efuse_hdl: parameter error")); - 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); - -_func_exit_; - - 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); - -_func_enter_; - - *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) { - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Read offset=0x%x\n",\ - ppgpkt->offset)); - - Efuse_PowerSwitch(Adapter, false, true); - if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false) == true) - *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - else - status = NDIS_STATUS_FAILURE; - Efuse_PowerSwitch(Adapter, false, false); - } else { - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Write offset=0x%x word_en=0x%x\n",\ - ppgpkt->offset, ppgpkt->word_en)); - - Efuse_PowerSwitch(Adapter, true, true); - if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false) == true) - *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); - - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status)); - -_func_exit_; - - 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); - -_func_enter_; - - 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; - } -_func_exit_; - - 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); - -_func_enter_; - - 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; - - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n", - *(int *)poid_par_priv->information_buf, status)); - -_func_exit_; - - return status; -} -/* */ -int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) -{ - int status; - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_efuse_hdl\n")); - - 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); - - RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_efuse_hdl: status=0x%08X\n", status)); - -_func_exit_; - - 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; - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_efuse_map_hdl\n")); - - 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) { - RT_TRACE(_module_mp_, _drv_info_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ\n")); - - if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) { - *poid_par_priv->bytes_rw = maplen; - } else { - RT_TRACE(_module_mp_, _drv_err_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ fail\n")); - status = NDIS_STATUS_FAILURE; - } - } else { - /* SET_OID */ - RT_TRACE(_module_mp_, _drv_info_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE\n")); - - if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) { - *poid_par_priv->bytes_rw = maplen; - } else { - RT_TRACE(_module_mp_, _drv_err_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE fail\n")); - status = NDIS_STATUS_FAILURE; - } - } - - _irqlevel_changed_(&oldirql, RAISE); - - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status)); - -_func_exit_; - - 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) -{ - u8 rx_pkt_type; - int status = NDIS_STATUS_SUCCESS; - -_func_enter_; - - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_set_rx_packet_type_hdl\n")); - - 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; - - rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/* 4 */ - - RT_TRACE(_module_mp_, _drv_info_, ("rx_pkt_type: %x\n", rx_pkt_type)); -_func_exit_; - - 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; - - RT_TRACE(_module_mp_, _drv_notice_, ("+%s\n", __func__)); - - 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; - -_func_enter_; - - if (poid_par_priv->type_of_oid != SET_OID) { - status = NDIS_STATUS_NOT_ACCEPTED; - return status; - } - - RT_TRACE(_module_mp_, _drv_info_, - ("\n ===> Setrtl8188eu_oid_rt_set_power_down_hdl.\n")); - - _irqlevel_changed_(&oldirql, LOWER); - - /* CALL the power_down function */ - _irqlevel_changed_(&oldirql, RAISE); - -_func_exit_; - - return status; -} -/* */ -int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv) -{ - return 0; -} diff --git a/core/rtw_p2p.c b/core/rtw_p2p.c deleted file mode 100644 index f46cab1..0000000 --- a/core/rtw_p2p.c +++ /dev/null @@ -1,2064 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _RTW_P2P_C_ - -#include -#include -#include - -#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; - - for (i = 0; i < ch_cnt; i++) { - if (ch_list[i] == desired_ch) { - found = 1; - break; - } - } - return found; -} - -static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - unsigned long irqL; - struct list_head *phead, *plist; - u32 len = 0; - u16 attr_len = 0; - u8 tmplen, *pdata_attr, *pstart, *pcur; - struct sta_info *psta = NULL; - struct adapter *padapter = pwdinfo->padapter; - struct sta_priv *pstapriv = &padapter->stapriv; - - DBG_88E("%s\n", __func__); - - pdata_attr = rtw_zmalloc(MAX_P2P_IE_LEN); - - pstart = pdata_attr; - pcur = pdata_attr; - - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - phead = &pstapriv->asoc_list; - plist = get_next(phead); - - /* look up sta asoc_queue */ - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); - - plist = get_next(plist); - - - if (psta->is_p2p_device) { - tmplen = 0; - - pcur++; - - /* P2P device address */ - memcpy(pcur, psta->dev_addr, ETH_ALEN); - pcur += ETH_ALEN; - - /* P2P interface address */ - memcpy(pcur, psta->hwaddr, ETH_ALEN); - pcur += ETH_ALEN; - - *pcur = psta->dev_cap; - pcur++; - - /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */ - RTW_PUT_BE16(pcur, psta->config_methods); - pcur += 2; - - memcpy(pcur, psta->primary_dev_type, 8); - pcur += 8; - - *pcur = psta->num_of_secdev_type; - pcur++; - - memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type*8); - pcur += psta->num_of_secdev_type*8; - - if (psta->dev_name_len > 0) { - /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - RTW_PUT_BE16(pcur, WPS_ATTR_DEVICE_NAME); - pcur += 2; - - /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */ - RTW_PUT_BE16(pcur, psta->dev_name_len); - pcur += 2; - - memcpy(pcur, psta->dev_name, psta->dev_name_len); - pcur += psta->dev_name_len; - } - - - tmplen = (u8)(pcur-pstart); - - *pstart = (tmplen-1); - - attr_len += tmplen; - - /* pstart += tmplen; */ - pstart = pcur; - } - } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); - - if (attr_len > 0) - len = rtw_set_p2p_attr_content(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr); - - kfree(pdata_attr); - return len; -} - -static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct rtw_ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_DISC_REQUEST; - u8 dialogToken = 0; - - DBG_88E("[%s]\n", __func__); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); - - 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); - - /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); - - /* there is no IE in this P2P action frame */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); -} - -static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct rtw_ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_DEVDISC_RESP; - u8 p2pie[8] = { 0x00 }; - u32 p2pielen = 0; - - DBG_88E("[%s]\n", __func__); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->device_addr, ETH_ALEN); - - 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); - - /* Build P2P public action frame header */ - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); - - - /* Build P2P IE */ - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* P2P_ATTR_STATUS */ - p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); -} - -static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, u8 *frame_body, u16 config_method) -{ - struct adapter *padapter = pwdinfo->padapter; - unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PROVISION_DISC_RESP; - u8 wpsie[100] = { 0x00 }; - u8 wpsielen = 0; - 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); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); - - 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); - - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); - - wpsielen = 0; - /* WPS OUI */ - RTW_PUT_BE32(wpsie, WPSOUI); - wpsielen += 4; - - /* Config Method */ - /* Type: */ - RTW_PUT_BE16(wpsie + wpsielen, WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - RTW_PUT_BE16(wpsie + wpsielen, 0x0002); - wpsielen += 2; - - /* Value: */ - RTW_PUT_BE16(wpsie + wpsielen, config_method); - wpsielen += 2; - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); - - return; -} - -static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct rtw_ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ - __be32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PRESENCE_RESPONSE; - u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; - u8 noa_attr_content[32] = { 0x00 }; - u32 p2pielen = 0; - - DBG_88E("[%s]\n", __func__); - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - _rtw_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, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); - - 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); - - /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); - - - /* Add P2P IE header */ - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Add Status attribute in P2P IE */ - p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - - /* Add NoA attribute in P2P IE */ - noa_attr_content[0] = 0x1;/* index */ - noa_attr_content[1] = 0x0;/* CTWindow and OppPS Parameters */ - - /* todo: Notice of Absence Descriptor(s) */ - - p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); - - - - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &(pattrib->pktlen)); - - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); -} - -u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; - u16 capability = 0; - u32 len = 0, p2pielen = 0; - __le16 le_tmp; - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - - /* According to the P2P Specification, the beacon frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. P2P Device ID */ - /* 3. Notice of Absence (NOA) */ - - /* P2P Capability ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - /* Be able to participate in additional P2P Groups and */ - /* support the P2P Invitation Procedure */ - /* Group Capability Bitmap, 1 byte */ - capability = P2P_DEVCAP_INVITATION_PROC|P2P_DEVCAP_CLIENT_DISCOVERABILITY; - capability |= ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8); - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - capability |= (P2P_GRPCAP_GROUP_FORMATION<<8); - - le_tmp = cpu_to_le16(capability); - p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8 *)&le_tmp); - - /* P2P Device ID ATTR */ - p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_DEVICE_ID, ETH_ALEN, pwdinfo->device_addr); - - /* Notice of Absence ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - - pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); - return len; -} - -u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20100907 */ - /* According to the P2P Specification, the probe response frame should contain 5 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Extended Listen Timing */ - /* 3. Notice of Absence (NOA) (Only GO needs this) */ - /* 4. Device Info */ - /* 5. Group Info (Only GO need this) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ - RTW_PUT_LE16(p2pie + p2pielen, 0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - p2pie[p2pielen] = (P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - p2pie[p2pielen] |= P2P_GRPCAP_GROUP_FORMATION; - - p2pielen++; - } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - } - - /* Extended Listen Timing ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */ - RTW_PUT_LE16(p2pie + p2pielen, 0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ - RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ - RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); - p2pielen += 2; - - - /* Notice of Absence ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - - /* Device Info ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ - RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */ - RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->supported_wps_cm); - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ - RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ - RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* Group Info ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen); - - - pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); - - - return len; -} - -u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 *pssid, u8 ussidlen, u8 *pdev_raddr) -{ - u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110301 */ - /* According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Device Info */ - /* 3. Group ID (When joining an operating P2P Group) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ - RTW_PUT_LE16(p2pie + p2pielen, 0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - - - /* Device Info ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ - RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) { - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_PBC); - } else { - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_DISPLAY); - } - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ - RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ - RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - /* Added by Albert 2011/05/19 */ - /* In this case, the pdev_raddr is the device address of the group owner. */ - - /* P2P Group ID ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */ - RTW_PUT_LE16(p2pie + p2pielen, ETH_ALEN + ussidlen); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pdev_raddr, ETH_ALEN); - p2pielen += ETH_ALEN; - - memcpy(p2pie + p2pielen, pssid, ussidlen); - p2pielen += ussidlen; - } - - pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); - - - return len; -} - - -u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code) -{ - u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* According to the P2P Specification, the Association response frame should contain 2 P2P attributes */ - /* 1. Status */ - /* 2. Extended Listen Timing (optional) */ - - - /* Status ATTR */ - p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status_code); - - - /* Extended Listen Timing ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - - pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); - - 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; - u32 ret = false; - u8 *p2pie; - u32 p2pielen = 0; - int ssid_len = 0, rate_cnt = 0; - - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SUPPORTEDRATES_IE_, (int *)&rate_cnt, - len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); - - if (rate_cnt <= 4) { - int i, g_rate = 0; - - for (i = 0; i < rate_cnt; i++) { - if (((*(p + 2 + i) & 0xff) != 0x02) && - ((*(p + 2 + i) & 0xff) != 0x04) && - ((*(p + 2 + i) & 0xff) != 0x0B) && - ((*(p + 2 + i) & 0xff) != 0x16)) - g_rate = 1; - } - - if (g_rate == 0) { - /* There is no OFDM rate included in SupportedRates IE of this probe request frame */ - /* The driver should response this probe request. */ - return ret; - } - } else { - /* rate_cnt > 4 means the SupportRates IE contains the OFDM rate because the count of CCK rates are 4. */ - /* We should proceed the following check for this probe request. */ - } - - /* Added comments by Albert 20100906 */ - /* There are several items we should check here. */ - /* 1. This probe request frame must contain the P2P IE. (Done) */ - /* 2. This probe request frame must contain the wildcard SSID. (Done) */ - /* 3. Wildcard BSSID. (Todo) */ - /* 4. Destination Address. (Done in mgt_dispatcher function) */ - /* 5. Requested Device Type in WSC IE. (Todo) */ - /* 6. Device ID attribute in P2P IE. (Todo) */ - - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ssid_len, - len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); - - ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_ , len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_ , NULL, &p2pielen); - if (p2pie) { - if ((p != NULL) && _rtw_memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid , 7)) { - /* todo: */ - /* Check Requested Device Type attributes in WSC IE. */ - /* Check Device ID attribute in P2P IE */ - - ret = true; - } else if ((p != NULL) && (ssid_len == 0)) { - ret = true; - } - } else { - /* non -p2p device */ - } - } - - - return ret; -} - -u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta) -{ - u8 status_code = P2P_STATUS_SUCCESS; - u8 *pbuf, *pattr_content = NULL; - u32 attr_contentlen = 0; - u16 cap_attr = 0; - unsigned short frame_type, ie_offset = 0; - u8 *ies; - u32 ies_len; - u8 *p2p_ie; - u32 p2p_ielen = 0; - __be16 be_tmp; - __le16 le_tmp; - - if (!rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - return P2P_STATUS_FAIL_REQUEST_UNABLE; - - frame_type = GetFrameSubType(pframe); - if (frame_type == WIFI_ASSOCREQ) - ie_offset = _ASOCREQ_IE_OFFSET_; - else /* WIFI_REASSOCREQ */ - ie_offset = _REASOCREQ_IE_OFFSET_; - - ies = pframe + WLAN_HDR_A3_LEN + ie_offset; - ies_len = len - WLAN_HDR_A3_LEN - ie_offset; - - p2p_ie = rtw_get_p2p_ie(ies , ies_len , NULL, &p2p_ielen); - - if (!p2p_ie) { - DBG_88E("[%s] P2P IE not Found!!\n", __func__); - status_code = P2P_STATUS_FAIL_INVALID_PARAM; - } else { - DBG_88E("[%s] P2P IE Found!!\n", __func__); - } - - while (p2p_ie) { - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8 *)&le_tmp, (uint *)&attr_contentlen)) { - DBG_88E("[%s] Got P2P Capability Attr!!\n", __func__); - cap_attr = le16_to_cpu(le_tmp); - psta->dev_cap = cap_attr&0xff; - } - - /* Check Extended Listen Timing ATTR */ - - - /* Check P2P Device Info ATTR */ - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) { - DBG_88E("[%s] Got P2P DEVICE INFO Attr!!\n", __func__); - pattr_content = rtw_zmalloc(attr_contentlen); - pbuf = pattr_content; - if (pattr_content) { - u8 num_of_secdev_type; - u16 dev_name_len; - - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO , pattr_content, (uint *)&attr_contentlen); - - memcpy(psta->dev_addr, pattr_content, ETH_ALEN);/* P2P Device Address */ - - pattr_content += ETH_ALEN; - - memcpy(&be_tmp, pattr_content, 2);/* Config Methods */ - psta->config_methods = be16_to_cpu(be_tmp); - - pattr_content += 2; - - memcpy(psta->primary_dev_type, pattr_content, 8); - - pattr_content += 8; - - num_of_secdev_type = *pattr_content; - pattr_content += 1; - - if (num_of_secdev_type == 0) { - psta->num_of_secdev_type = 0; - } else { - u32 len; - - psta->num_of_secdev_type = num_of_secdev_type; - - len = (sizeof(psta->secdev_types_list) < (num_of_secdev_type*8)) ? - (sizeof(psta->secdev_types_list)) : (num_of_secdev_type*8); - - memcpy(psta->secdev_types_list, pattr_content, len); - - pattr_content += (num_of_secdev_type*8); - } - - - psta->dev_name_len = 0; - if (WPS_ATTR_DEVICE_NAME == be16_to_cpu(*(__be16 *)pattr_content)) { - dev_name_len = be16_to_cpu(*(__be16 *)(pattr_content+2)); - - psta->dev_name_len = (sizeof(psta->dev_name) < dev_name_len) ? sizeof(psta->dev_name) : dev_name_len; - - memcpy(psta->dev_name, pattr_content+4, psta->dev_name_len); - } - kfree(pbuf); - } - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); - } - - return status_code; -} - -u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *frame_body; - u8 status, dialogToken; - struct sta_info *psta = NULL; - struct adapter *padapter = pwdinfo->padapter; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *p2p_ie; - u32 p2p_ielen = 0; - - frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - - dialogToken = frame_body[7]; - status = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; - - p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); - if (p2p_ie) { - u8 groupid[38] = { 0x00 }; - u8 dev_addr[ETH_ALEN] = { 0x00 }; - u32 attr_contentlen = 0; - - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { - if (_rtw_memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && - _rtw_memcmp(pwdinfo->p2p_group_ssid, groupid+ETH_ALEN, pwdinfo->p2p_group_ssid_len)) { - attr_contentlen = 0; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_ID, dev_addr, &attr_contentlen)) { - unsigned long irqL; - struct list_head *phead, *plist; - - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - phead = &pstapriv->asoc_list; - plist = get_next(phead); - - /* look up sta asoc_queue */ - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); - - plist = get_next(plist); - - if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && - _rtw_memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) { - /* issue GO Discoverability Request */ - issue_group_disc_req(pwdinfo, psta->hwaddr); - status = P2P_STATUS_SUCCESS; - break; - } else { - status = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); - } else { - status = P2P_STATUS_FAIL_INVALID_PARAM; - } - } else { - status = P2P_STATUS_FAIL_INVALID_PARAM; - } - } - } - - - /* issue Device Discoverability Response */ - issue_p2p_devdisc_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken); - - return (status == P2P_STATUS_SUCCESS) ? true : false; -} - -u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - return true; -} - -u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *frame_body; - u8 *wpsie; - uint wps_ielen = 0, attr_contentlen = 0; - u16 uconfig_method = 0; - __be16 be_tmp; - - frame_body = (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - - wpsie = rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen); - if (wpsie) { - if (rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_CONF_METHOD, (u8 *)&be_tmp, &attr_contentlen)) { - uconfig_method = be16_to_cpu(be_tmp); - switch (uconfig_method) { - case WPS_CM_DISPLYA: - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); - break; - case WPS_CM_LABEL: - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "lab", 3); - break; - case WPS_CM_PUSH_BUTTON: - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); - break; - case WPS_CM_KEYPAD: - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); - break; - } - issue_p2p_provision_resp(pwdinfo, GetAddr2Ptr(pframe), frame_body, uconfig_method); - } - } - DBG_88E("[%s] config method = %s\n", __func__, pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); - return true; -} - -u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe) -{ - return true; -} - -static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_content, u8 ch_cnt, u8 *peer_ch_list) -{ - u8 i = 0, j = 0; - u8 temp = 0; - u8 ch_no = 0; - ch_content += 3; - ch_cnt -= 3; - - while (ch_cnt > 0) { - ch_content += 1; - ch_cnt -= 1; - temp = *ch_content; - for (i = 0 ; i < temp ; i++, j++) - peer_ch_list[j] = *(ch_content + 1 + i); - ch_content += (temp + 1); - ch_cnt -= (temp + 1); - ch_no += temp ; - } - - return ch_no; -} - -static u8 rtw_p2p_ch_inclusion(struct mlme_ext_priv *pmlmeext, u8 *peer_ch_list, u8 peer_ch_num, u8 *ch_list_inclusioned) -{ - int i = 0, j = 0, temp = 0; - u8 ch_no = 0; - - for (i = 0; i < peer_ch_num; i++) { - for (j = temp; j < pmlmeext->max_chan_nums; j++) { - if (*(peer_ch_list + i) == pmlmeext->channel_set[j].ChannelNum) { - ch_list_inclusioned[ch_no++] = *(peer_ch_list + i); - temp = j; - break; - } - } - } - - return ch_no; -} - -u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - struct adapter *padapter = pwdinfo->padapter; - u8 result = P2P_STATUS_SUCCESS; - u32 p2p_ielen = 0, wps_ielen = 0; - u8 *ies; - u32 ies_len; - u8 *p2p_ie; - u8 *wpsie; - u16 wps_devicepassword_id = 0x0000; - uint wps_devicepassword_id_len = 0; - __be16 be_tmp; - - wpsie = rtw_get_wps_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen); - if (wpsie) { - /* Commented by Kurt 20120113 */ - /* If some device wants to do p2p handshake without sending prov_disc_req */ - /* We have to get peer_req_cm from here. */ - if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { - rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(be_tmp); - - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); - else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); - else - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); - } - } else { - DBG_88E("[%s] WPS IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - return result; - } - - if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) { - result = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INFOR_NOREADY); - return result; - } - - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); - - if (!p2p_ie) { - DBG_88E("[%s] P2P IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - - while (p2p_ie) { - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - u8 ch_content[50] = { 0x00 }; - uint ch_cnt = 0; - u8 peer_ch_list[50] = { 0x00 }; - u8 peer_ch_num = 0; - u8 ch_list_inclusioned[50] = { 0x00 }; - u8 ch_num_inclusioned = 0; - - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); - - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { - DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); - pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ - - if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) { - /* Try to match the tie breaker value */ - if (pwdinfo->intent == P2P_MAX_INTENT) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; - } else { - if (attr_content & 0x01) - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - else - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } else { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Store the group id information. */ - memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - } - } - - - attr_contentlen = 0; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) { - if (attr_contentlen != ETH_ALEN) - _rtw_memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - } - - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, ch_content, &ch_cnt)) { - peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, ch_content, ch_cnt, peer_ch_list); - ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); - - if (ch_num_inclusioned == 0) { - DBG_88E("[%s] No common channel in channel list!\n", __func__); - result = P2P_STATUS_FAIL_NO_COMMON_CH; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, - ch_list_inclusioned, ch_num_inclusioned)) { - u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; - attr_contentlen = 0; - - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - peer_operating_ch = operatingch_info[4]; - - if (rtw_p2p_is_channel_list_ok(peer_operating_ch, - ch_list_inclusioned, ch_num_inclusioned)) { - /** - * Change our operating channel as peer's for compatibility. - */ - pwdinfo->operating_channel = peer_operating_ch; - DBG_88E("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); - } else { - /* Take first channel of ch_list_inclusioned as operating channel */ - pwdinfo->operating_channel = ch_list_inclusioned[0]; - DBG_88E("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); - } - } - } - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); - } - return result; -} - -u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - struct adapter *padapter = pwdinfo->padapter; - u8 result = P2P_STATUS_SUCCESS; - u32 p2p_ielen, wps_ielen; - u8 *ies; - u32 ies_len; - u8 *p2p_ie; - - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - /* Be able to know which one is the P2P GO and which one is P2P client. */ - - if (rtw_get_wps_ie(ies, ies_len, NULL, &wps_ielen)) { - } else { - DBG_88E("[%s] WPS IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - - p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); - if (!p2p_ie) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - } else { - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - u8 operatingch_info[5] = { 0x00 }; - u8 groupid[38]; - u8 peer_ch_list[50] = { 0x00 }; - u8 peer_ch_num = 0; - u8 ch_list_inclusioned[50] = { 0x00 }; - u8 ch_num_inclusioned = 0; - - while (p2p_ie) { /* Found the P2P IE. */ - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - if (attr_contentlen == 1) { - DBG_88E("[%s] Status = %d\n", __func__, attr_content); - if (attr_content == P2P_STATUS_SUCCESS) { - /* Do nothing. */ - } else { - if (P2P_STATUS_FAIL_INFO_UNAVAILABLE == attr_content) { - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INFOR_NOREADY); - } else { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = attr_content; - break; - } - } - - /* Try to get the peer's interface address */ - attr_contentlen = 0; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) { - if (attr_contentlen != ETH_ALEN) - _rtw_memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - } - - /* Try to get the peer's intent and tie breaker value. */ - attr_content = 0x00; - attr_contentlen = 0; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { - DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); - pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ - - if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) { - /* Try to match the tie breaker value */ - if (pwdinfo->intent == P2P_MAX_INTENT) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } else { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - if (attr_content & 0x01) - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - else - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } else { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Store the group id information. */ - memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - } - } - - /* Try to get the operation channel information */ - - attr_contentlen = 0; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { - DBG_88E("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); - pwdinfo->peer_operating_ch = operatingch_info[4]; - } - - /* Try to get the channel list information */ - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, pwdinfo->channel_list_attr, &pwdinfo->channel_list_attr_len)) { - DBG_88E("[%s] channel list attribute found, len = %d\n", __func__, pwdinfo->channel_list_attr_len); - - peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len, peer_ch_list); - ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); - - if (ch_num_inclusioned == 0) { - DBG_88E("[%s] No common channel in channel list!\n", __func__); - result = P2P_STATUS_FAIL_NO_COMMON_CH; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, - ch_list_inclusioned, ch_num_inclusioned)) { - u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; - attr_contentlen = 0; - - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - peer_operating_ch = operatingch_info[4]; - - if (rtw_p2p_is_channel_list_ok(peer_operating_ch, - ch_list_inclusioned, ch_num_inclusioned)) { - /** - * Change our operating channel as peer's for compatibility. - */ - pwdinfo->operating_channel = peer_operating_ch; - DBG_88E("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); - } else { - /* Take first channel of ch_list_inclusioned as operating channel */ - pwdinfo->operating_channel = ch_list_inclusioned[0]; - DBG_88E("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); - } - } - } - } else { - DBG_88E("[%s] channel list attribute not found!\n", __func__); - } - - /* Try to get the group id information if peer is GO */ - attr_contentlen = 0; - _rtw_memset(groupid, 0x00, 38); - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { - memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); - } - } - return result; -} - -u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *ies; - u32 ies_len; - u8 *p2p_ie; - u32 p2p_ielen = 0; - u8 result = P2P_STATUS_SUCCESS; - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); - while (p2p_ie) { /* Found the P2P IE. */ - u8 attr_content = 0x00, operatingch_info[5] = { 0x00 }; - u8 groupid[38] = { 0x00 }; - u32 attr_contentlen = 0; - - pwdinfo->negotiation_dialog_token = 1; - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - if (attr_contentlen == 1) { - DBG_88E("[%s] Status = %d\n", __func__, attr_content); - result = attr_content; - - if (attr_content == P2P_STATUS_SUCCESS) { - u8 bcancelled = 0; - - _cancel_timer(&pwdinfo->restore_p2p_state_timer, &bcancelled); - - /* Commented by Albert 20100911 */ - /* Todo: Need to handle the case which both Intents are the same. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - if ((pwdinfo->intent) > (pwdinfo->peer_intent >> 1)) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } else if ((pwdinfo->intent) < (pwdinfo->peer_intent >> 1)) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } else { - /* Have to compare the Tie Breaker */ - if (pwdinfo->peer_intent & 0x01) - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - else - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } else { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - } - - /* Try to get the group id information */ - attr_contentlen = 0; - _rtw_memset(groupid, 0x00, 38); - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { - DBG_88E("[%s] Ssid = %s, ssidlen = %zu\n", __func__, &groupid[ETH_ALEN], strlen(&groupid[ETH_ALEN])); - memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); - } - - attr_contentlen = 0; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { - DBG_88E("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); - pwdinfo->peer_operating_ch = operatingch_info[4]; - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); - } - return result; -} - -u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *frame_body; - u8 dialogToken = 0; - u8 status = P2P_STATUS_SUCCESS; - - frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); - - dialogToken = frame_body[6]; - - /* todo: check NoA attribute */ - - issue_p2p_presence_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken); - - return true; -} - -static void find_phase_handler(struct adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ndis_802_11_ssid ssid; - unsigned long irqL; - -_func_enter_; - - _rtw_memset((unsigned char *)&ssid, 0, sizeof(struct ndis_802_11_ssid)); - memcpy(ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); - ssid.SsidLength = P2P_WILDCARD_SSID_LEN; - - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); - - _enter_critical_bh(&pmlmepriv->lock, &irqL); - _exit_critical_bh(&pmlmepriv->lock, &irqL); - - -_func_exit_; -} - -void p2p_concurrent_handler(struct adapter *padapter); - -static void restore_p2p_state_handler(struct adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - -_func_enter_; - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { - /* In the P2P client mode, the driver should not switch back to its listen channel */ - /* because this P2P client should stay at the operating channel of P2P GO. */ - set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - } -_func_exit_; -} - -static void pre_tx_invitereq_handler(struct adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; -_func_enter_; - - 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)); - issue_probereq_p2p(padapter, NULL); - _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); - -_func_exit_; -} - -static void pre_tx_provdisc_handler(struct adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; -_func_enter_; - - 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)); - issue_probereq_p2p(padapter, NULL); - _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); - -_func_exit_; -} - -static void pre_tx_negoreq_handler(struct adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; -_func_enter_; - - 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)); - issue_probereq_p2p(padapter, NULL); - _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); - -_func_exit_; -} - -void p2p_protocol_wk_hdl(struct adapter *padapter, int intCmdType) -{ -_func_enter_; - switch (intCmdType) { - case P2P_FIND_PHASE_WK: - find_phase_handler(padapter); - break; - case P2P_RESTORE_STATE_WK: - restore_p2p_state_handler(padapter); - break; - case P2P_PRE_TX_PROVDISC_PROCESS_WK: - pre_tx_provdisc_handler(padapter); - break; - case P2P_PRE_TX_INVITEREQ_PROCESS_WK: - pre_tx_invitereq_handler(padapter); - break; - case P2P_PRE_TX_NEGOREQ_PROCESS_WK: - pre_tx_negoreq_handler(padapter); - break; - } - -_func_exit_; -} - -void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) -{ - u8 *ies; - u32 ies_len; - u8 *p2p_ie; - u32 p2p_ielen = 0; - u8 noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/* NoA length should be n*(13) + 2 */ - u32 attr_contentlen = 0; - - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 find_p2p = false, find_p2p_ps = false; - u8 noa_offset, noa_num, noa_index; - -_func_enter_; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - if (IELength <= _BEACON_IE_OFFSET_) - return; - - ies = IEs + _BEACON_IE_OFFSET_; - ies_len = IELength - _BEACON_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); - - while (p2p_ie) { - find_p2p = true; - /* Get Notice of Absence IE. */ - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_NOA, noa_attr, &attr_contentlen)) { - find_p2p_ps = true; - noa_index = noa_attr[0]; - - if ((pwdinfo->p2p_ps_mode == P2P_PS_NONE) || - (noa_index != pwdinfo->noa_index)) { /* if index change, driver should reconfigure related setting. */ - pwdinfo->noa_index = noa_index; - pwdinfo->opp_ps = noa_attr[1] >> 7; - pwdinfo->ctwindow = noa_attr[1] & 0x7F; - - noa_offset = 2; - noa_num = 0; - /* NoA length should be n*(13) + 2 */ - if (attr_contentlen > 2) { - while (noa_offset < attr_contentlen) { - /* memcpy(&wifidirect_info->noa_count[noa_num], &noa_attr[noa_offset], 1); */ - pwdinfo->noa_count[noa_num] = noa_attr[noa_offset]; - noa_offset += 1; - - memcpy(&pwdinfo->noa_duration[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - memcpy(&pwdinfo->noa_interval[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - memcpy(&pwdinfo->noa_start_time[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - noa_num++; - } - } - pwdinfo->noa_num = noa_num; - - if (pwdinfo->opp_ps == 1) { - pwdinfo->p2p_ps_mode = P2P_PS_CTWINDOW; - /* driver should wait LPS for entering CTWindow */ - if (padapter->pwrctrlpriv.bFwCurrentInPSMode) - p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1); - } else if (pwdinfo->noa_num > 0) { - pwdinfo->p2p_ps_mode = P2P_PS_NOA; - p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1); - } else if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); - } - } - - break; /* find target, just break. */ - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); - } - - if (find_p2p) { - if ((pwdinfo->p2p_ps_mode > P2P_PS_NONE) && !find_p2p_ps) - p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); - } - -_func_exit_; -} - -void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - -_func_enter_; - - /* Pre action for p2p state */ - switch (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)); - - pwdinfo->noa_index = 0; - pwdinfo->ctwindow = 0; - pwdinfo->opp_ps = 0; - pwdinfo->noa_num = 0; - pwdinfo->p2p_ps_mode = P2P_PS_NONE; - 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))); - } - } - break; - case P2P_PS_ENABLE: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - - if (pwdinfo->ctwindow > 0) { - 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))); - } - } - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); - } - break; - case P2P_PS_SCAN: - case P2P_PS_SCAN_DONE: - 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)); - } - break; - default: - break; - } - -_func_exit_; -} - -u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - -_func_enter_; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return res; - - if (enqueue) { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); - if (pdrvextra_cmd_parm == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = P2P_PS_WK_CID; - pdrvextra_cmd_parm->type_size = p2p_ps_state; - pdrvextra_cmd_parm->pbuf = NULL; - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - } else { - p2p_ps_wk_hdl(padapter, p2p_ps_state); - } - -exit: - -_func_exit_; - - return res; -} - -static void reset_ch_sitesurvey_timer_process (void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - DBG_88E("[%s] In\n", __func__); - /* Reset the operation channel information */ - pwdinfo->rx_invitereq_info.operation_ch[0] = 0; - pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; -} - -static void reset_ch_sitesurvey_timer_process2 (void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - DBG_88E("[%s] In\n", __func__); - /* Reset the operation channel information */ - pwdinfo->p2p_info.operation_ch[0] = 0; - pwdinfo->p2p_info.scan_op_ch_only = 0; -} - -static void restore_p2p_state_timer_process (void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - p2p_protocol_wk_cmd(adapter, P2P_RESTORE_STATE_WK); -} - -static void pre_tx_scan_timer_process(void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - unsigned long irqL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - _enter_critical_bh(&pmlmepriv->lock, &irqL); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { - if (pwdinfo->tx_prov_disc_info.benable) { /* the provision discovery request frame is trigger to send or not */ - p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_PROVDISC_PROCESS_WK); - /* issue_probereq_p2p(adapter, NULL); */ - /* _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); */ - } - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { - if (pwdinfo->nego_req_info.benable) - p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_NEGOREQ_PROCESS_WK); - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { - if (pwdinfo->invitereq_info.benable) - p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_INVITEREQ_PROCESS_WK); - } else { - DBG_88E("[%s] p2p_state is %d, ignore!!\n", __func__, rtw_p2p_state(pwdinfo)); - } - - _exit_critical_bh(&pmlmepriv->lock, &irqL); -} - -static void find_phase_timer_process(void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - adapter->wdinfo.find_phase_state_exchange_cnt++; - - p2p_protocol_wk_cmd(adapter, P2P_FIND_PHASE_WK); -} - -void reset_global_wifidirect_info(struct adapter *padapter) -{ - struct wifidirect_info *pwdinfo; - - pwdinfo = &padapter->wdinfo; - pwdinfo->persistent_supported = 0; - pwdinfo->session_available = true; - pwdinfo->wfd_tdls_enable = 0; - pwdinfo->wfd_tdls_weaksec = 0; -} - -void rtw_init_wifidirect_timers(struct adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - _init_timer(&pwdinfo->find_phase_timer, padapter->pnetdev, find_phase_timer_process, padapter); - _init_timer(&pwdinfo->restore_p2p_state_timer, padapter->pnetdev, restore_p2p_state_timer_process, padapter); - _init_timer(&pwdinfo->pre_tx_scan_timer, padapter->pnetdev, pre_tx_scan_timer_process, padapter); - _init_timer(&pwdinfo->reset_ch_sitesurvey, padapter->pnetdev, reset_ch_sitesurvey_timer_process, padapter); - _init_timer(&pwdinfo->reset_ch_sitesurvey2, padapter->pnetdev, reset_ch_sitesurvey_timer_process2, 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 */ - if (dev_addr) - 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) -{ - struct wifidirect_info *pwdinfo; - - pwdinfo = &padapter->wdinfo; - pwdinfo->padapter = padapter; - - /* 1, 6, 11 are the social channel defined in the WiFi Direct specification. */ - pwdinfo->social_chan[0] = 1; - pwdinfo->social_chan[1] = 6; - pwdinfo->social_chan[2] = 11; - pwdinfo->social_chan[3] = 0; /* channel 0 for scanning ending in site survey function. */ - - /* Use the channel 11 as the listen channel */ - pwdinfo->listen_channel = 11; - - if (role == P2P_ROLE_DEVICE) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - pwdinfo->intent = 1; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_LISTEN); - } else if (role == P2P_ROLE_CLIENT) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 1; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - } else if (role == P2P_ROLE_GO) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 15; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - } - -/* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pwdinfo->support_rate[0] = 0x8c; /* 6(B) */ - pwdinfo->support_rate[1] = 0x92; /* 9(B) */ - pwdinfo->support_rate[2] = 0x18; /* 12 */ - pwdinfo->support_rate[3] = 0x24; /* 18 */ - pwdinfo->support_rate[4] = 0x30; /* 24 */ - pwdinfo->support_rate[5] = 0x48; /* 36 */ - pwdinfo->support_rate[6] = 0x60; /* 48 */ - pwdinfo->support_rate[7] = 0x6c; /* 54 */ - - memcpy(pwdinfo->p2p_wildcard_ssid, "DIRECT-", 7); - - _rtw_memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); - pwdinfo->device_name_len = 0; - - _rtw_memset(&pwdinfo->invitereq_info, 0x00, sizeof(struct tx_invite_req_info)); - pwdinfo->invitereq_info.token = 3; /* Token used for P2P invitation request frame. */ - - _rtw_memset(&pwdinfo->inviteresp_info, 0x00, sizeof(struct tx_invite_resp_info)); - pwdinfo->inviteresp_info.token = 0; - - pwdinfo->profileindex = 0; - _rtw_memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); - - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); - - pwdinfo->listen_dwell = (u8) ((rtw_get_current_time() % 3) + 1); - - _rtw_memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info)); - pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE; - - _rtw_memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); - - pwdinfo->device_password_id_for_nego = WPS_DPID_PBC; - pwdinfo->negotiation_dialog_token = 1; - - _rtw_memset(pwdinfo->nego_ssid, 0x00, WLAN_SSID_MAXLEN); - pwdinfo->nego_ssidlen = 0; - - pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; - pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC | WPS_CONFIG_METHOD_KEYPAD; - pwdinfo->channel_list_attr_len = 0; - _rtw_memset(pwdinfo->channel_list_attr, 0x00, 100); - - _rtw_memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, 0x00, 4); - _rtw_memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, '0', 3); - _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - pwdinfo->wfd_tdls_enable = 0; - _rtw_memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - _rtw_memset(pwdinfo->p2p_peer_device_addr, 0x00, ETH_ALEN); - - pwdinfo->rx_invitereq_info.operation_ch[0] = 0; - pwdinfo->rx_invitereq_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ - pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; - pwdinfo->p2p_info.operation_ch[0] = 0; - pwdinfo->p2p_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ - pwdinfo->p2p_info.scan_op_ch_only = 0; -} - -int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) -{ - int ret = _SUCCESS; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) { - /* leave IPS/Autosuspend */ - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } - - /* Added by Albert 2011/03/22 */ - /* In the P2P mode, the driver should not support the b mode. */ - /* So, the Tx packet shouldn't use the CCK rate */ - update_tx_basic_rate(padapter, WIRELESS_11AGN); - - /* Enable P2P function */ - init_wifidirect_info(padapter, role); - - rtw_hal_set_odm_var(padapter, HAL_ODM_P2P_STATE, NULL, true); - } else if (role == P2P_ROLE_DISABLE) { - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } - - /* Disable P2P function */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - _cancel_timer_ex(&pwdinfo->find_phase_timer); - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); - _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); - _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey2); - reset_ch_sitesurvey_timer_process(padapter); - reset_ch_sitesurvey_timer_process2(padapter); - rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE); - _rtw_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); - - /* Restore to initial setting. */ - update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); - } - -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/core/rtw_pwrctrl.c b/core/rtw_pwrctrl.c index b45461f..df463a2 100644 --- a/core/rtw_pwrctrl.c +++ b/core/rtw_pwrctrl.c @@ -22,8 +22,111 @@ #include #include #include +#include #include +static int rtw_hw_suspend(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct net_device *pnetdev = padapter->pnetdev; + + + if ((!padapter->bup) || (padapter->bDriverStopped) || + (padapter->bSurpriseRemoved)) { + DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", + padapter->bup, padapter->bDriverStopped, + padapter->bSurpriseRemoved); + goto error_exit; + } + + /* system suspend */ + LeaveAllPowerSaveMode(padapter); + + DBG_88E("==> rtw_hw_suspend\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + /* s1. */ + if (pnetdev) { + netif_carrier_off(pnetdev); + netif_tx_stop_all_queues(pnetdev); + } + + /* s2. */ + rtw_disassoc_cmd(padapter, 500, false); + + /* s2-2. indicate disconnect to os */ + { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); + + rtw_led_control(padapter, LED_CTL_NO_LINK); + + rtw_os_indicate_disconnect(padapter); + + /* donnot enqueue cmd */ + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); + } + } + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); + + /* s2-4. */ + rtw_free_network_queue(padapter, true); + rtw_ips_dev_unload(padapter); + pwrpriv->rf_pwrstate = rf_off; + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); + + return 0; + +error_exit: + DBG_88E("%s, failed\n", __func__); + return -1; +} + +static int rtw_hw_resume(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct net_device *pnetdev = padapter->pnetdev; + + + /* system resume */ + DBG_88E("==> rtw_hw_resume\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + rtw_reset_drv_sw(padapter); + + if (pm_netdev_open(pnetdev, false) != 0) { + _exit_pwrlock(&pwrpriv->lock); + goto error_exit; + } + + netif_device_attach(pnetdev); + netif_carrier_on(pnetdev); + + if (!netif_queue_stopped(pnetdev)) + netif_start_queue(pnetdev); + else + netif_wake_queue(pnetdev); + + pwrpriv->bkeepfwalive = false; + pwrpriv->brfoffbyhw = false; + + pwrpriv->rf_pwrstate = rf_on; + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); + + + return 0; +error_exit: + DBG_88E("%s, Open net dev failed\n", __func__); + return -1; +} + void ips_enter(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; @@ -100,7 +203,7 @@ int ips_leave(struct adapter *padapter) } } - DBG_88E("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c)); + DBG_88E("==> ips_leave.....LED(0x%08x)...\n", usb_read32(padapter, 0x4c)); pwrpriv->bips_processing = false; pwrpriv->bkeepfwalive = false; @@ -114,46 +217,18 @@ int ips_leave(struct adapter *padapter) 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 >= rtw_get_current_time()) + if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies)) goto exit; if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|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 + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)) 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; exit: @@ -179,7 +254,6 @@ void rtw_ps_processor(struct adapter *padapter) 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; @@ -205,12 +279,11 @@ void rtw_ps_processor(struct adapter *padapter) exit: rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); pwrpriv->ps_processing = false; - return; } static void pwr_state_check_handler(void *FunctionContext) { - struct adapter *padapter = (struct adapter *)FunctionContext; + struct adapter *padapter = FunctionContext; rtw_ps_cmd(padapter); } @@ -226,11 +299,8 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) u8 rpwm; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -_func_enter_; - pslv = PS_STATE(pslv); - if (pwrpriv->btcoex_rfon) { if (pslv < PS_STATE_S4) pslv = PS_STATE_S3; @@ -274,8 +344,6 @@ _func_enter_; pwrpriv->tog += 0x80; pwrpriv->cpwm = pslv; - -_func_exit_; } static u8 PS_RDY_CHECK(struct adapter *padapter) @@ -285,7 +353,7 @@ static u8 PS_RDY_CHECK(struct adapter *padapter) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - curr_time = rtw_get_current_time(); + curr_time = jiffies; delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp; if (delta_time < LPS_DELAY_TIME) @@ -309,11 +377,6 @@ 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 */ - -_func_enter_; RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: PowerMode=%d Smart_PS=%d\n", @@ -335,16 +398,6 @@ _func_enter_; /* 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)); - 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; @@ -352,18 +405,9 @@ _func_enter_; 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)); - -#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); } } - -_func_exit_; } /* @@ -379,7 +423,7 @@ s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) s32 err = 0; - start_time = rtw_get_current_time(); + start_time = jiffies; while (1) { rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); if (bAwake) @@ -396,7 +440,7 @@ s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) DBG_88E("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms); break; } - rtw_usleep_os(100); + msleep(1); } return err; @@ -410,8 +454,6 @@ void LPS_Enter(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -_func_enter_; - if (PS_RDY_CHECK(padapter) == false) return; @@ -428,8 +470,6 @@ _func_enter_; pwrpriv->LpsIdleCount++; } } - -_func_exit_; } #define LPS_LEAVE_TIMEOUT_MS 100 @@ -440,8 +480,6 @@ void LPS_Leave(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -_func_enter_; - if (pwrpriv->bLeisurePs) { if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0); @@ -452,8 +490,6 @@ _func_enter_; } pwrpriv->bpower_saving = false; - -_func_exit_; } /* */ @@ -465,23 +501,14 @@ void LeaveAllPowerSaveMode(struct adapter *Adapter) struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); u8 enqueue = 0; -_func_enter_; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */ - p2p_ps_wk_cmd(Adapter, P2P_PS_DISABLE, enqueue); - + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue); - } - -_func_exit_; } void rtw_init_pwrctrl_priv(struct adapter *padapter) { struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; -_func_enter_; - _init_pwrlock(&pwrctrlpriv->lock); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts = 0; @@ -499,7 +526,7 @@ _func_enter_; pwrctrlpriv->LpsIdleCount = 0; if (padapter->registrypriv.mp_mode == 1) - pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE ; + pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; else pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; @@ -518,40 +545,18 @@ _func_enter_; pwrctrlpriv->btcoex_rfon = false; _init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter); - -_func_exit_; } -void rtw_free_pwrctrl_priv(struct adapter *adapter) -{ - struct pwrctrl_priv *pwrctrlpriv = &adapter->pwrctrlpriv; - -_func_enter_; - - _free_pwrlock(&pwrctrlpriv->lock); - -_func_exit_; -} - -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 = rtw_get_current_time() + rtw_ms_to_systime(ms); + pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ms); } /* * rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend * @adapter: pointer to struct adapter structure -* @ips_deffer_ms: the ms wiil prevent from falling into IPS after wakeup +* @ips_deffer_ms: the ms will prevent from falling into IPS after wakeup * Return _SUCCESS or _FAIL */ @@ -559,17 +564,19 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long expires; int ret = _SUCCESS; - if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms)) - pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms); + expires = jiffies + msecs_to_jiffies(ips_deffer_ms); + if (time_before(pwrpriv->ips_deny_time, expires)) + pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); { - u32 start = rtw_get_current_time(); + u32 start = jiffies; if (pwrpriv->ps_processing) { DBG_88E("%s wait ps_processing...\n", __func__); while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000) - rtw_msleep_os(10); + usleep_range(1000, 3000); if (pwrpriv->ps_processing) DBG_88E("%s wait ps_processing timeout\n", __func__); else @@ -616,8 +623,9 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal } exit: - if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms)) - pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms); + expires = jiffies + msecs_to_jiffies(ips_deffer_ms); + if (time_before(pwrpriv->ips_deny_time, expires)) + pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); return ret; } diff --git a/core/rtw_recv.c b/core/rtw_recv.c index adacbde..bd79e9e 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -23,11 +23,11 @@ #include #include #include -#include -#include -#include -#include #include +#include + +#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ +#define LLC_HEADER_SIZE 6 /* LLC Header Length */ static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; @@ -45,28 +45,23 @@ void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { -_func_enter_; - _rtw_memset((u8 *)psta_recvpriv, 0, sizeof (struct sta_recv_priv)); + memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv)); - _rtw_spinlock_init(&psta_recvpriv->lock); + spin_lock_init(&psta_recvpriv->lock); _rtw_init_queue(&psta_recvpriv->defrag_q); -_func_exit_; } int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) { int i; - union recv_frame *precvframe; + struct recv_frame *precvframe; int res = _SUCCESS; -_func_enter_; - _rtw_spinlock_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); @@ -75,9 +70,7 @@ _func_enter_; precvpriv->free_recvframe_cnt = NR_RECVFRAME; - rtw_os_recv_resource_init(precvpriv, padapter); - - precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); if (precvpriv->pallocated_frame_buf == NULL) { res = _FAIL; @@ -86,24 +79,23 @@ _func_enter_; precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); - precvframe = (union recv_frame *)precvpriv->precv_frame_buf; + precvframe = (struct recv_frame *)precvpriv->precv_frame_buf; for (i = 0; i < NR_RECVFRAME; i++) { - _rtw_init_listhead(&(precvframe->u.list)); + INIT_LIST_HEAD(&(precvframe->list)); - rtw_list_insert_tail(&(precvframe->u.list), &(precvpriv->free_recv_queue.queue)); + list_add_tail(&(precvframe->list), + &(precvpriv->free_recv_queue.queue)); res = rtw_os_recv_resource_alloc(padapter, precvframe); - precvframe->u.hdr.len = 0; + precvframe->len = 0; - precvframe->u.hdr.adapter = padapter; + precvframe->adapter = padapter; precvframe++; } precvpriv->rx_pending_cnt = 1; - _rtw_init_sema(&precvpriv->allrxreturnevt, 0); - res = rtw_hal_init_recv_priv(padapter); _init_timer(&precvpriv->signal_stat_timer, padapter->pnetdev, RTW_TIMER_HDL_NAME(signal_stat), padapter); @@ -113,60 +105,43 @@ _func_enter_; rtw_set_signal_stat_timer(precvpriv); exit: -_func_exit_; return res; } -static void rtw_mfree_recv_priv_lock(struct recv_priv *precvpriv) -{ - _rtw_spinlock_free(&precvpriv->lock); - _rtw_spinlock_free(&precvpriv->free_recv_queue.lock); - _rtw_spinlock_free(&precvpriv->recv_pending_queue.lock); - - _rtw_spinlock_free(&precvpriv->free_recv_buf_queue.lock); -} - -void _rtw_free_recv_priv (struct recv_priv *precvpriv) +void _rtw_free_recv_priv(struct recv_priv *precvpriv) { struct adapter *padapter = precvpriv->adapter; -_func_enter_; rtw_free_uc_swdec_pending_queue(padapter); - rtw_mfree_recv_priv_lock(precvpriv); - - rtw_os_recv_resource_free(precvpriv); - if (precvpriv->pallocated_frame_buf) { - rtw_vmfree(precvpriv->pallocated_frame_buf, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + vfree(precvpriv->pallocated_frame_buf); } rtw_hal_free_recv_priv(padapter); -_func_exit_; } -union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) { - union recv_frame *precvframe; + struct recv_frame *hdr; struct list_head *plist, *phead; struct adapter *padapter; struct recv_priv *precvpriv; -_func_enter_; - if (_rtw_queue_empty(pfree_recv_queue)) { - precvframe = NULL; + if (list_empty(&pfree_recv_queue->queue)) { + hdr = NULL; } else { phead = get_list_head(pfree_recv_queue); - plist = get_next(phead); + plist = phead->next; - precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + hdr = container_of(plist, struct recv_frame, list); - rtw_list_delete(&precvframe->u.hdr.list); - padapter = precvframe->u.hdr.adapter; + list_del_init(&hdr->list); + padapter = hdr->adapter; if (padapter != NULL) { precvpriv = &padapter->recvpriv; if (pfree_recv_queue == &precvpriv->free_recv_queue) @@ -174,97 +149,90 @@ _func_enter_; } } -_func_exit_; - return precvframe; + return (struct recv_frame *)hdr; } -union recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue) { - unsigned long irqL; - union recv_frame *precvframe; + struct recv_frame *precvframe; - _enter_critical_bh(&pfree_recv_queue->lock, &irqL); + spin_lock_bh(&pfree_recv_queue->lock); precvframe = _rtw_alloc_recvframe(pfree_recv_queue); - _exit_critical_bh(&pfree_recv_queue->lock, &irqL); + spin_unlock_bh(&pfree_recv_queue->lock); return precvframe; } -void rtw_init_recvframe(union recv_frame *precvframe, struct recv_priv *precvpriv) +void rtw_init_recvframe(struct recv_frame *precvframe, struct recv_priv *precvpriv) { /* Perry: This can be removed */ - _rtw_init_listhead(&precvframe->u.hdr.list); + INIT_LIST_HEAD(&precvframe->list); - precvframe->u.hdr.len = 0; + precvframe->len = 0; } -int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_queue) +int rtw_free_recvframe(struct recv_frame *precvframe, + struct __queue *pfree_recv_queue) { - unsigned long irqL; struct adapter *padapter; struct recv_priv *precvpriv; -_func_enter_; if (!precvframe) return _FAIL; - padapter = precvframe->u.hdr.adapter; + padapter = precvframe->adapter; precvpriv = &padapter->recvpriv; - if (precvframe->u.hdr.pkt) { - dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */ - precvframe->u.hdr.pkt = NULL; + if (precvframe->pkt) { + dev_kfree_skb_any(precvframe->pkt);/* free skb by driver */ + precvframe->pkt = NULL; } - _enter_critical_bh(&pfree_recv_queue->lock, &irqL); + spin_lock_bh(&pfree_recv_queue->lock); - rtw_list_delete(&(precvframe->u.hdr.list)); + list_del_init(&(precvframe->list)); - precvframe->u.hdr.len = 0; + precvframe->len = 0; - rtw_list_insert_tail(&(precvframe->u.hdr.list), get_list_head(pfree_recv_queue)); + list_add_tail(&(precvframe->list), get_list_head(pfree_recv_queue)); if (padapter != NULL) { if (pfree_recv_queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt++; } - _exit_critical_bh(&pfree_recv_queue->lock, &irqL); + spin_unlock_bh(&pfree_recv_queue->lock); -_func_exit_; return _SUCCESS; } -int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) +int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) { - struct adapter *padapter = precvframe->u.hdr.adapter; + struct adapter *padapter = precvframe->adapter; struct recv_priv *precvpriv = &padapter->recvpriv; -_func_enter_; - rtw_list_delete(&(precvframe->u.hdr.list)); - rtw_list_insert_tail(&(precvframe->u.hdr.list), get_list_head(queue)); + list_del_init(&(precvframe->list)); + list_add_tail(&(precvframe->list), get_list_head(queue)); if (padapter != NULL) { if (queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt++; } -_func_exit_; return _SUCCESS; } -int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) +int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) { int ret; - unsigned long irqL; - _enter_critical_bh(&queue->lock, &irqL); + spin_lock_bh(&queue->lock); ret = _rtw_enqueue_recvframe(precvframe, queue); - _exit_critical_bh(&queue->lock, &irqL); + spin_unlock_bh(&queue->lock); return ret; } @@ -279,32 +247,30 @@ using spinlock to protect void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) { - union recv_frame *precvframe; + struct recv_frame *hdr; struct list_head *plist, *phead; -_func_enter_; spin_lock(&pframequeue->lock); phead = get_list_head(pframequeue); - plist = get_next(phead); + plist = phead->next; - while (rtw_end_of_queue_search(phead, plist) == false) { - precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + while (phead != plist) { + hdr = container_of(plist, struct recv_frame, list); - plist = get_next(plist); + plist = plist->next; - rtw_free_recvframe(precvframe, pfree_recv_queue); + rtw_free_recvframe((struct recv_frame *)hdr, pfree_recv_queue); } spin_unlock(&pframequeue->lock); -_func_exit_; } u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) { u32 cnt = 0; - union recv_frame *pending_frame; + struct recv_frame *pending_frame; while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue); DBG_88E("%s: dequeue uc_swdec_pending_queue\n", __func__); @@ -314,58 +280,8 @@ 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) -{ - unsigned long irqL; - - _enter_critical_bh(&queue->lock, &irqL); - - rtw_list_delete(&precvbuf->list); - rtw_list_insert_head(&precvbuf->list, get_list_head(queue)); - - _exit_critical_bh(&queue->lock, &irqL); - - return _SUCCESS; -} - -int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) -{ - unsigned long irqL; - _enter_critical_ex(&queue->lock, &irqL); - - rtw_list_delete(&precvbuf->list); - - rtw_list_insert_tail(&precvbuf->list, get_list_head(queue)); - _exit_critical_ex(&queue->lock, &irqL); - return _SUCCESS; -} - -struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) -{ - unsigned long irqL; - struct recv_buf *precvbuf; - struct list_head *plist, *phead; - - _enter_critical_ex(&queue->lock, &irqL); - - if (_rtw_queue_empty(queue)) { - precvbuf = NULL; - } else { - phead = get_list_head(queue); - - plist = get_next(phead); - - precvbuf = LIST_CONTAINOR(plist, struct recv_buf, list); - - rtw_list_delete(&precvbuf->list); - } - - _exit_critical_ex(&queue->lock, &irqL); - - return precvbuf; -} - -static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) +static int recvframe_chkmic(struct adapter *adapter, + struct recv_frame *precvframe) { int i, res = _SUCCESS; u32 datalen; @@ -374,12 +290,11 @@ static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvfra u8 *pframe, *payload, *pframemic; u8 *mickey; struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -_func_enter_; stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); @@ -391,23 +306,24 @@ _func_enter_; /* calculate mic code */ if (stainfo != NULL) { if (IS_MCAST(prxattrib->ra)) { - mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; - - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); - if (!psecuritypriv) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); goto exit; } + mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); } else { mickey = &stainfo->dot11tkiprxmickey.skey[0]; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); } - datalen = precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ - pframe = precvframe->u.hdr.rx_data; + /* icv_len included the mic code */ + datalen = precvframe->len-prxattrib->hdrlen - + prxattrib->iv_len-prxattrib->icv_len-8; + pframe = precvframe->rx_data; payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len)); @@ -440,16 +356,30 @@ _func_enter_; *(pframemic-10), *(pframemic-9))); { uint i; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet (len=%d)======\n", precvframe->u.hdr.len)); - for (i = 0; i < precvframe->u.hdr.len; i = i+8) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", - *(precvframe->u.hdr.rx_data+i), *(precvframe->u.hdr.rx_data+i+1), - *(precvframe->u.hdr.rx_data+i+2), *(precvframe->u.hdr.rx_data+i+3), - *(precvframe->u.hdr.rx_data+i+4), *(precvframe->u.hdr.rx_data+i+5), - *(precvframe->u.hdr.rx_data+i+6), *(precvframe->u.hdr.rx_data+i+7))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n ======demp packet (len=%d)======\n", + precvframe->len)); + for (i = 0; i < precvframe->len; i += 8) { + RT_TRACE(_module_rtl871x_recv_c_, + _drv_err_, + ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", + *(precvframe->rx_data+i), + *(precvframe->rx_data+i+1), + *(precvframe->rx_data+i+2), + *(precvframe->rx_data+i+3), + *(precvframe->rx_data+i+4), + *(precvframe->rx_data+i+5), + *(precvframe->rx_data+i+6), + *(precvframe->rx_data+i+7))); } - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ====== demp packet end [len=%d]======\n", precvframe->u.hdr.len)); - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n hrdlen=%d,\n", prxattrib->hdrlen)); + RT_TRACE(_module_rtl871x_recv_c_, + _drv_err_, + ("\n ====== demp packet end [len=%d]======\n", + precvframe->len)); + RT_TRACE(_module_rtl871x_recv_c_, + _drv_err_, + ("\n hrdlen=%d,\n", + prxattrib->hdrlen)); } RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, @@ -487,24 +417,23 @@ _func_enter_; exit: -_func_exit_; return res; } /* decrypt and set the ivlen, icvlen of the recv_frame */ -static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame) +static struct recv_frame *decryptor(struct adapter *padapter, + struct recv_frame *precv_frame) { - struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &precv_frame->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; - union recv_frame *return_packet = precv_frame; + struct recv_frame *return_packet = precv_frame; u32 res = _SUCCESS; -_func_enter_; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted=%x prxattrib->encrypt=0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt)); if (prxattrib->encrypt > 0) { - u8 *iv = precv_frame->u.hdr.rx_data+prxattrib->hdrlen; + u8 *iv = precv_frame->rx_data+prxattrib->hdrlen; prxattrib->key_index = (((iv[3])>>6)&0x3); if (prxattrib->key_index > WEP_KEYS) { @@ -550,54 +479,51 @@ _func_enter_; return_packet = NULL; } -_func_exit_; return return_packet; } /* set the security information in the recv_frame */ -static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame) +static struct recv_frame *portctrl(struct adapter *adapter, + struct recv_frame *precv_frame) { - u8 *psta_addr = NULL, *ptr; + u8 *psta_addr, *ptr; uint auth_alg; - struct recv_frame_hdr *pfhdr; + struct recv_frame *pfhdr; struct sta_info *psta; struct sta_priv *pstapriv; - union recv_frame *prtnframe; - u16 ether_type = 0; + struct recv_frame *prtnframe; + u16 ether_type; u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; __be16 be_tmp; -_func_enter_; pstapriv = &adapter->stapriv; - psta = rtw_get_stainfo(pstapriv, psta_addr); auth_alg = adapter->securitypriv.dot11AuthAlgrthm; - ptr = get_recvframe_data(precv_frame); - pfhdr = &precv_frame->u.hdr; + ptr = precv_frame->rx_data; + pfhdr = precv_frame; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; + psta = rtw_get_stainfo(pstapriv, psta_addr); prtnframe = NULL; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm=%d\n", adapter->securitypriv.dot11AuthAlgrthm)); if (auth_alg == 2) { + /* get ether_type */ + ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; + memcpy(&be_tmp, ptr, 2); + ether_type = ntohs(be_tmp); + if ((psta != NULL) && (psta->ieee8021x_blocked)) { /* blocked */ /* only accept EAPOL frame */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==1\n")); - prtnframe = precv_frame; - - /* get ether_type */ - ptr = ptr+pfhdr->attrib.hdrlen+pfhdr->attrib.iv_len+LLC_HEADER_SIZE; - memcpy(&be_tmp, ptr, 2); - ether_type = ntohs(be_tmp); - if (ether_type == eapol_type) { prtnframe = precv_frame; } else { @@ -609,7 +535,9 @@ _func_enter_; /* allowed */ /* check decryption status, and decrypt the frame if needed */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==0\n")); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:precv_frame->hdr.attrib.privacy=%x\n", precv_frame->u.hdr.attrib.privacy)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("portctrl:precv_frame->hdr.attrib.privacy=%x\n", + precv_frame->attrib.privacy)); if (pattrib->bdecrypted == 0) RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:prxstat->decrypted=%x\n", pattrib->bdecrypted)); @@ -629,19 +557,18 @@ _func_enter_; prtnframe = precv_frame; } -_func_exit_; return prtnframe; } -static int recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache) +static int recv_decache(struct recv_frame *precv_frame, u8 bretry, + struct stainfo_rxcache *prxcache) { - int tid = precv_frame->u.hdr.attrib.priority; + int tid = precv_frame->attrib.priority; - u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | - (precv_frame->u.hdr.attrib.frag_num & 0xf); + u16 seq_ctrl = ((precv_frame->attrib.seq_num&0xffff) << 4) | + (precv_frame->attrib.frag_num & 0xf); -_func_enter_; if (tid > 15) { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, (tid>15)! seq_ctrl=0x%x, tid=0x%x\n", seq_ctrl, tid)); @@ -659,18 +586,17 @@ _func_enter_; prxcache->tid_rxseq[tid] = seq_ctrl; -_func_exit_; return _SUCCESS; } -void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame); -void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame) +static void process_pwrbit_data(struct adapter *padapter, + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE unsigned char pwrbit; - u8 *ptr = precv_frame->u.hdr.rx_data; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; @@ -691,10 +617,11 @@ void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame #endif } -static void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame) +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->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; @@ -746,15 +673,17 @@ static void process_wmmps_data(struct adapter *padapter, union recv_frame *precv #endif } -static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta) +static void count_rx_stats(struct adapter *padapter, + struct recv_frame *prframe, + struct sta_info *sta) { int sz; struct sta_info *psta = NULL; struct stainfo_stats *pstats = NULL; - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &prframe->attrib; struct recv_priv *precvpriv = &padapter->recvpriv; - sz = get_recvframe_len(prframe); + sz = prframe->len; precvpriv->rx_bytes += sz; padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; @@ -765,7 +694,7 @@ static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, if (sta) psta = sta; else - psta = prframe->u.hdr.psta; + psta = prframe->psta; if (psta) { pstats = &psta->sta_stats; @@ -777,15 +706,16 @@ static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, int sta2sta_data_frame( struct adapter *adapter, - union recv_frame *precv_frame, + struct recv_frame *precv_frame, struct sta_info **psta ); -int sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, struct sta_info **psta) +int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, + struct sta_info **psta) { - u8 *ptr = precv_frame->u.hdr.rx_data; + u8 *ptr = precv_frame->rx_data; int ret = _SUCCESS; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *mybssid = get_bssid(pmlmepriv); @@ -793,25 +723,24 @@ int sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, s u8 *sta_addr = NULL; int bmcast = IS_MCAST(pattrib->dst); -_func_enter_; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { /* filter packets that SA is myself or multicast or broadcast */ - if (_rtw_memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); ret = _FAIL; goto exit; } - if ((!_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { ret = _FAIL; goto exit; } - if (_rtw_memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - _rtw_memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - !_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { ret = _FAIL; goto exit; } @@ -819,7 +748,7 @@ _func_enter_; sta_addr = pattrib->src; } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ - if (!_rtw_memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { + if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid!=TA under STATION_MODE; drop pkt\n")); ret = _FAIL; goto exit; @@ -834,7 +763,7 @@ _func_enter_; } } else { /* not mc-frame */ /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ - if (!_rtw_memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { + if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { ret = _FAIL; goto exit; } @@ -860,26 +789,21 @@ _func_enter_; if (*psta == NULL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n")); - if (adapter->registrypriv.mp_mode == 1) { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) - adapter->mppriv.rx_pktloss++; - } ret = _FAIL; goto exit; } exit: -_func_exit_; return ret; } -static int ap2sta_data_frame ( +static int ap2sta_data_frame( struct adapter *adapter, - union recv_frame *precv_frame, + struct recv_frame *precv_frame, struct sta_info **psta) { - u8 *ptr = precv_frame->u.hdr.rx_data; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; int ret = _SUCCESS; struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -887,20 +811,19 @@ static int ap2sta_data_frame ( u8 *myhwaddr = myid(&adapter->eeprompriv); int bmcast = IS_MCAST(pattrib->dst); -_func_enter_; if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && (check_fwstate(pmlmepriv, _FW_LINKED) == true || check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { /* filter packets that SA is myself or multicast or broadcast */ - if (_rtw_memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); ret = _FAIL; goto exit; } /* da should be for me */ - if ((!_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, (" ap2sta_data_frame: compare DA fail; DA=%pM\n", (pattrib->dst))); ret = _FAIL; @@ -908,9 +831,9 @@ _func_enter_; } /* check BSSID */ - if (_rtw_memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - _rtw_memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || - (!_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { + if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, (" ap2sta_data_frame: compare BSSID fail ; BSSID=%pM\n", (pattrib->bssid))); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid=%pM\n", (mybssid))); @@ -966,7 +889,7 @@ _func_enter_; ret = RTW_RX_HANDLED; goto exit; } else { - if (_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { + if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ if (*psta == NULL) { DBG_88E("issue_deauth to the ap =%pM for the reason(7)\n", (pattrib->bssid)); @@ -980,27 +903,25 @@ _func_enter_; exit: -_func_exit_; return ret; } static int sta2ap_data_frame(struct adapter *adapter, - union recv_frame *precv_frame, + struct recv_frame *precv_frame, struct sta_info **psta) { - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *ptr = precv_frame->u.hdr.rx_data; + u8 *ptr = precv_frame->rx_data; unsigned char *mybssid = get_bssid(pmlmepriv); int ret = _SUCCESS; -_func_enter_; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ - if (!_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { ret = _FAIL; goto exit; } @@ -1030,7 +951,7 @@ _func_enter_; } } else { u8 *myhwaddr = myid(&adapter->eeprompriv); - if (!_rtw_memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { + if (memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { ret = RTW_RX_HANDLED; goto exit; } @@ -1042,25 +963,23 @@ _func_enter_; exit: -_func_exit_; return ret; } static int validate_recv_ctrl_frame(struct adapter *padapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->u.hdr.rx_data; - /* uint len = precv_frame->u.hdr.len; */ + u8 *pframe = precv_frame->rx_data; if (GetFrameType(pframe) != WIFI_CTRL_TYPE) return _FAIL; /* receive the frames that ra(a1) is my address */ - if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) return _FAIL; /* only handle ps-poll */ @@ -1108,21 +1027,20 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, } if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) { - unsigned long irqL; struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; - _enter_critical_bh(&psta->sleep_q.lock, &irqL); + spin_lock_bh(&psta->sleep_q.lock); xmitframe_phead = get_list_head(&psta->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; - if ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + if (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); psta->sleepq_len--; @@ -1133,15 +1051,15 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, pxmitframe->attrib.triggered = 1; - _exit_critical_bh(&psta->sleep_q.lock, &irqL); + spin_unlock_bh(&psta->sleep_q.lock); if (rtw_hal_xmit(padapter, pxmitframe) == true) rtw_os_xmit_complete(padapter, pxmitframe); - _enter_critical_bh(&psta->sleep_q.lock, &irqL); + spin_lock_bh(&psta->sleep_q.lock); if (psta->sleepq_len == 0) { pstapriv->tim_bitmap &= ~BIT(psta->aid); - /* upate BCN for TIM IE */ + /* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ update_beacon(padapter, _TIM_IE_, NULL, false); } @@ -1159,13 +1077,13 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, pstapriv->tim_bitmap &= ~BIT(psta->aid); - /* upate BCN for TIM IE */ + /* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ update_beacon(padapter, _TIM_IE_, NULL, false); } } - _exit_critical_bh(&psta->sleep_q.lock, &irqL); + spin_unlock_bh(&psta->sleep_q.lock); } } @@ -1174,10 +1092,11 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, return _FAIL; } -union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame); +struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, + struct recv_frame *precv_frame); static int validate_recv_mgnt_frame(struct adapter *padapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { struct sta_info *psta; @@ -1190,18 +1109,20 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, } /* for rx pkt statistics */ - psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->u.hdr.rx_data)); + psta = rtw_get_stainfo(&padapter->stapriv, + GetAddr2Ptr(precv_frame->rx_data)); if (psta) { psta->sta_stats.rx_mgnt_pkts++; - if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_BEACON) { + if (GetFrameSubType(precv_frame->rx_data) == WIFI_BEACON) { psta->sta_stats.rx_beacon_pkts++; - } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBEREQ) { + } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBEREQ) { psta->sta_stats.rx_probereq_pkts++; - } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBERSP) { - if (_rtw_memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN) == true) + } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBERSP) { + if (!memcmp(padapter->eeprompriv.mac_addr, + GetAddr1Ptr(precv_frame->rx_data), ETH_ALEN)) psta->sta_stats.rx_probersp_pkts++; - else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) || - is_multicast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data))) + else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->rx_data)) || + is_multicast_mac_addr(GetAddr1Ptr(precv_frame->rx_data))) psta->sta_stats.rx_probersp_bm_pkts++; else psta->sta_stats.rx_probersp_uo_pkts++; @@ -1214,17 +1135,16 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, } static int validate_recv_data_frame(struct adapter *adapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { u8 bretry; u8 *psa, *pda, *pbssid; struct sta_info *psta = NULL; - u8 *ptr = precv_frame->u.hdr.rx_data; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; struct security_priv *psecuritypriv = &adapter->securitypriv; int ret = _SUCCESS; -_func_enter_; bretry = GetRetry(ptr); pda = get_da(ptr); @@ -1282,7 +1202,7 @@ _func_enter_; /* psta->rssi = prxcmd->rssi; */ /* psta->signal_quality = prxcmd->sq; */ - precv_frame->u.hdr.psta = psta; + precv_frame->psta = psta; pattrib->amsdu = 0; pattrib->ack_policy = 0; @@ -1303,7 +1223,7 @@ _func_enter_; if (pattrib->order)/* HT-CTRL 11n */ pattrib->hdrlen += 4; - precv_frame->u.hdr.preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; + precv_frame->preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; /* decache, drop duplicate recv packets */ if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) { @@ -1329,12 +1249,12 @@ _func_enter_; exit: -_func_exit_; return ret; } -static int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame) +static int validate_recv_frame(struct adapter *adapter, + struct recv_frame *precv_frame) { /* shall check frame subtype, to / from ds, da, bssid */ @@ -1344,12 +1264,11 @@ static int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_ u8 subtype; int retval = _SUCCESS; u8 bDumpRxPkt; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; - u8 *ptr = precv_frame->u.hdr.rx_data; - u8 ver = (unsigned char) (*ptr)&0x3; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + u8 *ptr = precv_frame->rx_data; + u8 ver = (unsigned char)(*ptr)&0x3; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; -_func_enter_; if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { int ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, rtw_get_oper_ch(adapter)); @@ -1439,14 +1358,13 @@ _func_enter_; exit: -_func_exit_; return retval; } /* remove the wlanhdr and add the eth_hdr */ -static int wlanhdr_to_ethhdr (union recv_frame *precvframe) +static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) { int rmv_len; u16 eth_type, len; @@ -1455,14 +1373,10 @@ static int wlanhdr_to_ethhdr (union recv_frame *precvframe) u8 *psnap_type; struct ieee80211_snap_hdr *psnap; - int ret = _SUCCESS; - struct adapter *adapter = precvframe->u.hdr.adapter; + struct adapter *adapter = precvframe->adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - u8 *ptr = get_recvframe_data(precvframe); /* point to frame_ctrl field */ - struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; - -_func_enter_; + u8 *ptr = precvframe->rx_data; + struct rx_pkt_attrib *pattrib = &precvframe->attrib; if (pattrib->encrypt) recvframe_pull_tail(precvframe, pattrib->icv_len); @@ -1470,10 +1384,10 @@ _func_enter_; psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; /* convert hdr + possible LLC headers into Ethernet header */ - if ((_rtw_memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && - (_rtw_memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) && - (_rtw_memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2) == false)) || - _rtw_memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { + if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && + (!memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) && + (!memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2) == false)) || + !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ bsnaphdr = true; } else { @@ -1482,7 +1396,7 @@ _func_enter_; } rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); - len = precvframe->u.hdr.len - rmv_len; + len = precvframe->len - rmv_len; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n===pattrib->hdrlen: %x, pattrib->iv_len:%x===\n\n", pattrib->hdrlen, pattrib->iv_len)); @@ -1513,30 +1427,29 @@ _func_enter_; memcpy(ptr+12, &be_tmp, 2); } -_func_exit_; - return ret; + return _SUCCESS; } /* perform defrag */ -static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q) +static struct recv_frame *recvframe_defrag(struct adapter *adapter, + struct __queue *defrag_q) { struct list_head *plist, *phead; u8 wlanhdr_offset; u8 curfragnum; - struct recv_frame_hdr *pfhdr, *pnfhdr; - union recv_frame *prframe, *pnextrframe; + struct recv_frame *pfhdr, *pnfhdr; + struct recv_frame *prframe, *pnextrframe; struct __queue *pfree_recv_queue; -_func_enter_; curfragnum = 0; pfree_recv_queue = &adapter->recvpriv.free_recv_queue; phead = get_list_head(defrag_q); - plist = get_next(phead); - prframe = LIST_CONTAINOR(plist, union recv_frame, u); - pfhdr = &prframe->u.hdr; - rtw_list_delete(&(prframe->u.list)); + plist = phead->next; + pfhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)pfhdr; + list_del_init(&(prframe->list)); if (curfragnum != pfhdr->attrib.frag_num) { /* the first fragment number must be 0 */ @@ -1551,11 +1464,11 @@ _func_enter_; plist = get_list_head(defrag_q); - plist = get_next(plist); + plist = plist->next; - while (rtw_end_of_queue_search(phead, plist) == false) { - pnextrframe = LIST_CONTAINOR(plist, union recv_frame , u); - pnfhdr = &pnextrframe->u.hdr; + while (phead != plist) { + pnfhdr = container_of(plist, struct recv_frame, list); + pnextrframe = (struct recv_frame *)pnfhdr; /* check the fragment sequence (2nd ~n fragment frame) */ @@ -1585,7 +1498,7 @@ _func_enter_; recvframe_put(prframe, pnfhdr->len); pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len; - plist = get_next(plist); + plist = plist->next; } /* free the defrag_q queue and return the prframe */ @@ -1593,29 +1506,28 @@ _func_enter_; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n")); -_func_exit_; return prframe; } /* check if need to defrag, if needed queue the frame to defrag_q */ -union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame) +struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, + struct recv_frame *precv_frame) { u8 ismfrag; u8 fragnum; u8 *psta_addr; - struct recv_frame_hdr *pfhdr; + struct recv_frame *pfhdr; struct sta_info *psta; struct sta_priv *pstapriv; struct list_head *phead; - union recv_frame *prtnframe = NULL; + struct recv_frame *prtnframe = NULL; struct __queue *pfree_recv_queue, *pdefrag_q; -_func_enter_; pstapriv = &padapter->stapriv; - pfhdr = &precv_frame->u.hdr; + pfhdr = precv_frame; pfree_recv_queue = &padapter->recvpriv.free_recv_queue; @@ -1646,7 +1558,7 @@ _func_enter_; if (pdefrag_q != NULL) { if (fragnum == 0) { /* the first fragment */ - if (_rtw_queue_empty(pdefrag_q) == false) { + if (!list_empty(&pdefrag_q->queue)) { /* free current defrag_q */ rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue); } @@ -1655,7 +1567,7 @@ _func_enter_; /* Then enqueue the 0~(n-1) fragment into the defrag_q */ phead = get_list_head(pdefrag_q); - rtw_list_insert_tail(&pfhdr->list, phead); + list_add_tail(&pfhdr->list, phead); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Enqueuq: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); @@ -1673,7 +1585,7 @@ _func_enter_; /* enqueue the last fragment */ if (pdefrag_q != NULL) { phead = get_list_head(pdefrag_q); - rtw_list_insert_tail(&pfhdr->list, phead); + list_add_tail(&pfhdr->list, phead); /* call recvframe_defrag to defrag */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); @@ -1687,7 +1599,7 @@ _func_enter_; } } - if ((prtnframe != NULL) && (prtnframe->u.hdr.attrib.privacy)) { + if ((prtnframe != NULL) && (prtnframe->attrib.privacy)) { /* after defrag we must check tkip mic code */ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe)==_FAIL\n")); @@ -1696,12 +1608,11 @@ _func_enter_; } } -_func_exit_; return prtnframe; } -static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) +static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) { int a_len, padding_len; u16 eth_type, nSubframe_Length; @@ -1712,23 +1623,22 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; struct recv_priv *precvpriv = &padapter->recvpriv; struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); - int ret = _SUCCESS; nr_subframes = 0; - pattrib = &prframe->u.hdr.attrib; + pattrib = &prframe->attrib; - recvframe_pull(prframe, prframe->u.hdr.attrib.hdrlen); + recvframe_pull(prframe, prframe->attrib.hdrlen); - if (prframe->u.hdr.attrib.iv_len > 0) - recvframe_pull(prframe, prframe->u.hdr.attrib.iv_len); + if (prframe->attrib.iv_len > 0) + recvframe_pull(prframe, prframe->attrib.iv_len); - a_len = prframe->u.hdr.len; + a_len = prframe->len; - pdata = prframe->u.hdr.rx_data; + pdata = prframe->rx_data; while (a_len > ETH_HLEN) { /* Offset 12 denote 2 mac address */ - nSubframe_Length = RTW_GET_BE16(pdata + 12); + nSubframe_Length = get_unaligned_be16(pdata + 12); if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { DBG_88E("nRemain_Length is %d and nSubframe_Length is : %d\n", a_len, nSubframe_Length); @@ -1746,7 +1656,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); memcpy(data_ptr, pdata, nSubframe_Length); } else { - sub_skb = skb_clone(prframe->u.hdr.pkt, GFP_ATOMIC); + sub_skb = skb_clone(prframe->pkt, GFP_ATOMIC); if (sub_skb) { sub_skb->data = pdata; sub_skb->len = nSubframe_Length; @@ -1783,11 +1693,11 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) for (i = 0; i < nr_subframes; i++) { sub_skb = subframes[i]; /* convert hdr + possible LLC headers into Ethernet header */ - eth_type = RTW_GET_BE16(&sub_skb->data[6]); + eth_type = get_unaligned_be16(&sub_skb->data[6]); if (sub_skb->len >= 8 && - ((_rtw_memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) && + ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) && eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || - _rtw_memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) { + !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) { /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); @@ -1802,21 +1712,21 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) } /* Indicate the packets to upper layer */ - /* Insert NAT2.5 RX here! */ - sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev); - sub_skb->dev = padapter->pnetdev; + /* Insert NAT2.5 RX here! */ + sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev); + sub_skb->dev = padapter->pnetdev; - sub_skb->ip_summed = CHECKSUM_NONE; + sub_skb->ip_summed = CHECKSUM_NONE; - netif_rx(sub_skb); - } + netif_rx(sub_skb); + } exit: - prframe->u.hdr.len = 0; + prframe->len = 0; rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */ - return ret; + return _SUCCESS; } static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num) @@ -1849,70 +1759,72 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_n return true; } -int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe); -int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe) +static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, + struct recv_frame *prframe) { - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &prframe->attrib; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; struct list_head *phead, *plist; - union recv_frame *pnextrframe; + struct recv_frame *hdr; struct rx_pkt_attrib *pnextattrib; phead = get_list_head(ppending_recvframe_queue); - plist = get_next(phead); + plist = phead->next; - while (rtw_end_of_queue_search(phead, plist) == false) { - pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); - pnextattrib = &pnextrframe->u.hdr.attrib; + while (phead != plist) { + hdr = container_of(plist, struct recv_frame, list); + pnextattrib = &hdr->attrib; if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) - plist = get_next(plist); + plist = plist->next; else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) return false; else break; } - rtw_list_delete(&(prframe->u.hdr.list)); + list_del_init(&(prframe->list)); - rtw_list_insert_tail(&(prframe->u.hdr.list), plist); + list_add_tail(&(prframe->list), plist); return true; } static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced) { struct list_head *phead, *plist; - union recv_frame *prframe; + struct recv_frame *prframe; + struct recv_frame *prhdr; struct rx_pkt_attrib *pattrib; int bPktInBuf = false; struct recv_priv *precvpriv = &padapter->recvpriv; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; phead = get_list_head(ppending_recvframe_queue); - plist = get_next(phead); + plist = phead->next; /* Handling some condition for forced indicate case. */ if (bforced) { - if (rtw_is_list_empty(phead)) + if (list_empty(phead)) return true; - prframe = LIST_CONTAINOR(plist, union recv_frame, u); - pattrib = &prframe->u.hdr.attrib; + prhdr = container_of(plist, struct recv_frame, list); + pattrib = &prhdr->attrib; preorder_ctrl->indicate_seq = pattrib->seq_num; } /* Prepare indication list and indication. */ /* Check if there is any packet need indicate. */ - while (!rtw_is_list_empty(phead)) { - prframe = LIST_CONTAINOR(plist, union recv_frame, u); - pattrib = &prframe->u.hdr.attrib; + while (!list_empty(phead)) { + prhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)prhdr; + pattrib = &prframe->attrib; if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_indicatepkts_in_order: indicate=%d seq=%d amsdu=%d\n", preorder_ctrl->indicate_seq, pattrib->seq_num, pattrib->amsdu)); - plist = get_next(plist); - rtw_list_delete(&(prframe->u.hdr.list)); + plist = plist->next; + list_del_init(&(prframe->list)); if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; @@ -1941,12 +1853,12 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor return bPktInBuf; } -static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe) +static int recv_indicatepkt_reorder(struct adapter *padapter, + struct recv_frame *prframe) { - unsigned long irql; int retval = _SUCCESS; - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; - struct recv_reorder_ctrl *preorder_ctrl = prframe->u.hdr.preorder_ctrl; + struct rx_pkt_attrib *pattrib = &prframe->attrib; + struct recv_reorder_ctrl *preorder_ctrl = prframe->preorder_ctrl; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; if (!pattrib->amsdu) { @@ -1984,7 +1896,7 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame * } } - _enter_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_lock_bh(&ppending_recvframe_queue->lock); RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_indicatepkt_reorder: indicate=%d seq=%d\n", @@ -1994,7 +1906,7 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame * if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) { rtw_recv_indicatepkt(padapter, prframe); - _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_unlock_bh(&ppending_recvframe_queue->lock); goto _success_exit; } @@ -2016,10 +1928,10 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame * /* recv_indicatepkts_in_order(padapter, preorder_ctrl, true); */ if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false)) { _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); - _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_unlock_bh(&ppending_recvframe_queue->lock); } else { - _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); - _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + spin_unlock_bh(&ppending_recvframe_queue->lock); + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); } _success_exit: @@ -2028,40 +1940,36 @@ _success_exit: _err_exit: - _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_unlock_bh(&ppending_recvframe_queue->lock); return _FAIL; } void rtw_reordering_ctrl_timeout_handler(void *pcontext) { - unsigned long irql; - struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)pcontext; + struct recv_reorder_ctrl *preorder_ctrl = pcontext; struct adapter *padapter = preorder_ctrl->padapter; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; if (padapter->bDriverStopped || padapter->bSurpriseRemoved) return; - _enter_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_lock_bh(&ppending_recvframe_queue->lock); if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true) _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); - _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_unlock_bh(&ppending_recvframe_queue->lock); } -static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe) +static int process_recv_indicatepkts(struct adapter *padapter, + struct recv_frame *prframe) { int retval = _SUCCESS; - /* struct recv_priv *precvpriv = &padapter->recvpriv; */ - /* struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; */ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; if (phtpriv->ht_option) { /* B/G/N Mode */ - /* prframe->u.hdr.preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */ - if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { /* including perform A-MPDU Rx Ordering Buffer Control */ if ((!padapter->bDriverStopped) && @@ -2071,7 +1979,7 @@ static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame } } } else { /* B/G mode */ - retval = wlanhdr_to_ethhdr (prframe); + retval = wlanhdr_to_ethhdr(prframe); if (retval != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n")); return retval; @@ -2094,28 +2002,11 @@ static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame return retval; } -static int recv_func_prehandle(struct adapter *padapter, union recv_frame *rframe) +static int recv_func_prehandle(struct adapter *padapter, + struct recv_frame *rframe) { int ret = _SUCCESS; - struct rx_pkt_attrib *pattrib = &rframe->u.hdr.attrib; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (padapter->registrypriv.mp_mode == 1) { - if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) { /* padapter->mppriv.check_mp_pkt == 0)) */ - if (pattrib->crc_err == 1) - padapter->mppriv.rx_crcerrpktcount++; - else - padapter->mppriv.rx_pktcount++; - - if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_alert_, ("MP - Not in loopback mode , drop pkt\n")); - 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); @@ -2129,10 +2020,11 @@ exit: return ret; } -static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prframe) +static int recv_func_posthandle(struct adapter *padapter, + struct recv_frame *prframe) { int ret = _SUCCESS; - union recv_frame *orig_prframe = prframe; + struct recv_frame *orig_prframe = prframe; struct recv_priv *precvpriv = &padapter->recvpriv; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; @@ -2174,16 +2066,16 @@ _recv_data_drop: return ret; } -static int recv_func(struct adapter *padapter, union recv_frame *rframe) +static int recv_func(struct adapter *padapter, struct recv_frame *rframe) { int ret; - struct rx_pkt_attrib *prxattrib = &rframe->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &rframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *mlmepriv = &padapter->mlmepriv; /* check if need to handle uc_swdec_pending_queue*/ if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) { - union recv_frame *pending_frame; + struct recv_frame *pending_frame; while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) { if (recv_func_posthandle(padapter, pending_frame) == _SUCCESS) @@ -2212,15 +2104,14 @@ exit: return ret; } -s32 rtw_recv_entry(union recv_frame *precvframe) +s32 rtw_recv_entry(struct recv_frame *precvframe) { struct adapter *padapter; struct recv_priv *precvpriv; s32 ret = _SUCCESS; -_func_enter_; - padapter = precvframe->u.hdr.adapter; + padapter = precvframe->adapter; precvpriv = &padapter->recvpriv; @@ -2232,17 +2123,10 @@ _func_enter_; precvpriv->rx_pkts++; -_func_exit_; return ret; _recv_entry_drop: - - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.rx_pktloss = precvpriv->rx_drop; - -_func_exit_; - return ret; } @@ -2263,13 +2147,13 @@ void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) } else { if (recvpriv->signal_strength_data.update_req == 0) {/* update_req is clear, means we got rx */ avg_signal_strength = recvpriv->signal_strength_data.avg_val; - /* after avg_vals are accquired, we can re-stat the signal values */ + /* after avg_vals are acquired, we can re-stat the signal values */ recvpriv->signal_strength_data.update_req = 1; } if (recvpriv->signal_qual_data.update_req == 0) {/* update_req is clear, means we got rx */ avg_signal_qual = recvpriv->signal_qual_data.avg_val; - /* after avg_vals are accquired, we can re-stat the signal values */ + /* after avg_vals are acquired, we can re-stat the signal values */ recvpriv->signal_qual_data.update_req = 1; } diff --git a/core/rtw_security.c b/core/rtw_security.c index e088457..bd8d60a 100644 --- a/core/rtw_security.c +++ b/core/rtw_security.c @@ -41,7 +41,6 @@ static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) u32 stateindex; u8 *state; u32 counter; -_func_enter_; state = parc4ctx->state; parc4ctx->x = 0; parc4ctx->y = 0; @@ -58,7 +57,6 @@ _func_enter_; if (++keyindex >= key_len) keyindex = 0; } -_func_exit_; } static u32 arcfour_byte(struct arc4context *parc4ctx) @@ -67,7 +65,6 @@ static u32 arcfour_byte(struct arc4context *parc4ctx) u32 y; u32 sx, sy; u8 *state; -_func_enter_; state = parc4ctx->state; x = (parc4ctx->x + 1) & 0xff; sx = state[x]; @@ -77,17 +74,14 @@ _func_enter_; parc4ctx->y = y; state[y] = (u8)sx; state[x] = (u8)sy; -_func_exit_; return state[(sx + sy) & 0xff]; } static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) { u32 i; -_func_enter_; for (i = 0; i < len; i++) dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); -_func_exit_; } static int bcrc32initialized; @@ -102,9 +96,8 @@ static u8 crc32_reverseBit(u8 data) static void crc32_init(void) { -_func_enter_; if (bcrc32initialized == 1) { - goto exit; + return; } else { int i, j; u32 c; @@ -126,15 +119,12 @@ _func_enter_; } bcrc32initialized = 1; } -exit: -_func_exit_; } static __le32 getcrc32(u8 *buf, int len) { u8 *p; u32 crc; -_func_enter_; if (bcrc32initialized == 0) crc32_init(); @@ -142,7 +132,6 @@ _func_enter_; for (p = buf; len > 0; ++p, --len) crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); -_func_exit_; return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ } @@ -165,7 +154,6 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; -_func_enter_; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return; @@ -201,12 +189,11 @@ _func_enter_; arcfour_encrypt(&mycontext, payload+length, crc, 4); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4((size_t)(pframe)); + pframe = (u8 *)round_up((size_t)(pframe), 4); } } } -_func_exit_; } void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) @@ -218,12 +205,11 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) u32 keylength; u8 *pframe, *payload, *iv, wepkey[16]; u8 keyindex; - struct rx_pkt_attrib *prxattrib = &(((union recv_frame *)precvframe)->u.hdr.attrib); + struct rx_pkt_attrib *prxattrib = &(((struct recv_frame *)precvframe)->attrib); struct security_priv *psecuritypriv = &padapter->securitypriv; -_func_enter_; - pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* start to decrypt recvframe */ if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { @@ -232,7 +218,7 @@ _func_enter_; keylength = psecuritypriv->dot11DefKeylen[keyindex]; memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength); - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; @@ -252,7 +238,6 @@ _func_enter_; &crc, &payload[length-4])); } } -_func_exit_; return; } @@ -263,10 +248,8 @@ static u32 secmicgetuint32(u8 *p) { s32 i; u32 res = 0; -_func_enter_; for (i = 0; i < 4; i++) res |= ((u32)(*p++)) << (8*i); -_func_exit_; return res; } @@ -274,39 +257,32 @@ static void secmicputuint32(u8 *p, u32 val) /* Convert from Us3232 to Byte[] in a portable way */ { long i; -_func_enter_; for (i = 0; i < 4; i++) { - *p++ = (u8) (val & 0xff); + *p++ = (u8)(val & 0xff); val >>= 8; } -_func_exit_; } static void secmicclear(struct mic_data *pmicdata) { /* Reset the state to the empty message. */ -_func_enter_; pmicdata->L = pmicdata->K0; pmicdata->R = pmicdata->K1; pmicdata->nBytesInM = 0; pmicdata->M = 0; -_func_exit_; } void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) { /* Set the key */ -_func_enter_; pmicdata->K0 = secmicgetuint32(key); pmicdata->K1 = secmicgetuint32(key + 4); /* and reset the message */ secmicclear(pmicdata); -_func_exit_; } void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b) { -_func_enter_; /* Append the byte to our word-sized buffer */ pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); pmicdata->nBytesInM++; @@ -325,23 +301,19 @@ _func_enter_; pmicdata->M = 0; pmicdata->nBytesInM = 0; } -_func_exit_; } void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nbytes) { -_func_enter_; /* This is simple */ while (nbytes > 0) { rtw_secmicappendbyte(pmicdata, *src++); nbytes--; } -_func_exit_; } void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) { -_func_enter_; /* Append the minimum padding */ rtw_secmicappendbyte(pmicdata, 0x5a); rtw_secmicappendbyte(pmicdata, 0); @@ -356,14 +328,12 @@ _func_enter_; secmicputuint32(dst+4, pmicdata->R); /* Reset to the empty message. */ secmicclear(pmicdata); -_func_exit_; } void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) { struct mic_data micdata; u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; -_func_enter_; rtw_secmicsetkey(&micdata, key); priority[0] = pri; @@ -386,7 +356,6 @@ _func_enter_; rtw_secmicappend(&micdata, data, data_len); rtw_secgetmic(&micdata, mic_code); -_func_exit_; } @@ -505,7 +474,6 @@ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) { int i; -_func_enter_; /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ p1k[0] = Lo16(iv32); p1k[1] = Hi16(iv32); @@ -523,7 +491,6 @@ _func_enter_; p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ } -_func_exit_; } /* @@ -553,7 +520,6 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) { int i; u16 PPK[6]; /* temporary key for mixing */ -_func_enter_; /* Note: all adds in the PPK[] equations below are mod 2**16 */ for (i = 0; i < 5; i++) PPK[i] = p1k[i]; /* first, copy P1K to PPK */ @@ -590,7 +556,6 @@ _func_enter_; rc4key[4+2*i] = Lo8(PPK[i]); rc4key[5+2*i] = Hi8(PPK[i]); } -_func_exit_; } /* The hlen isn't include the IV */ @@ -612,7 +577,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; -_func_enter_; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -657,14 +621,14 @@ _func_enter_; arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, payload+length, crc, 4); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, payload+length, crc, 4); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4((size_t)(pframe)); + pframe = (u8 *)round_up((size_t)(pframe), 4); } } } else { @@ -672,7 +636,6 @@ _func_enter_; res = _FAIL; } } -_func_exit_; return res; } @@ -690,13 +653,12 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; -_func_enter_; - pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* 4 start to decrypt recvframe */ if (prxattrib->encrypt == _TKIP_) { @@ -716,7 +678,7 @@ _func_enter_; iv = pframe+prxattrib->hdrlen; payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; GET_TKIP_PN(iv, dot11txpn); @@ -747,7 +709,6 @@ _func_enter_; res = _FAIL; } } -_func_exit_; exit: return res; } @@ -821,19 +782,15 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext); static void xor_128(u8 *a, u8 *b, u8 *out) { int i; -_func_enter_; for (i = 0; i < 16; i++) out[i] = a[i] ^ b[i]; -_func_exit_; } static void xor_32(u8 *a, u8 *b, u8 *out) { int i; -_func_enter_; for (i = 0; i < 4; i++) out[i] = a[i] ^ b[i]; -_func_exit_; } static u8 sbox(u8 a) @@ -849,7 +806,6 @@ static void next_key(u8 *key, int round) 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x36, 0x36 }; -_func_enter_; sbox_key[0] = sbox(key[13]); sbox_key[1] = sbox(key[14]); sbox_key[2] = sbox(key[15]); @@ -863,21 +819,17 @@ _func_enter_; xor_32(&key[4], &key[0], &key[4]); xor_32(&key[8], &key[4], &key[8]); xor_32(&key[12], &key[8], &key[12]); -_func_exit_; } static void byte_sub(u8 *in, u8 *out) { int i; -_func_enter_; for (i = 0; i < 16; i++) out[i] = sbox(in[i]); -_func_exit_; } static void shift_row(u8 *in, u8 *out) { -_func_enter_; out[0] = in[0]; out[1] = in[5]; out[2] = in[10]; @@ -894,7 +846,6 @@ _func_enter_; out[13] = in[1]; out[14] = in[6]; out[15] = in[11]; -_func_exit_; } static void mix_column(u8 *in, u8 *out) @@ -908,7 +859,6 @@ static void mix_column(u8 *in, u8 *out) u8 rotr[4]; u8 temp[4]; u8 tempb[4]; -_func_enter_; for (i = 0 ; i < 4; i++) { if ((in[i] & 0x80) == 0x80) add1b[i] = 0x1b; @@ -952,7 +902,6 @@ _func_enter_; xor_32(add1bf7, rotr, temp); xor_32(swap_halfs, rotl, tempb); xor_32(temp, tempb, out); -_func_exit_; } static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) @@ -962,7 +911,6 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) u8 intermediatea[16]; u8 intermediateb[16]; u8 round_key[16]; -_func_enter_; for (i = 0; i < 16; i++) round_key[i] = key[i]; for (round = 0; round < 11; round++) { @@ -984,7 +932,6 @@ _func_enter_; next_key(round_key, round); } } -_func_exit_; } /************************************************/ @@ -995,7 +942,6 @@ static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, uint payload_length, u8 *pn_vector) { int i; -_func_enter_; mic_iv[0] = 0x59; if (qc_exists && a4_exists) mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ @@ -1007,9 +953,8 @@ _func_enter_; mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ for (i = 8; i < 14; i++) mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ - mic_iv[14] = (unsigned char) (payload_length / 256); - mic_iv[15] = (unsigned char) (payload_length % 256); -_func_exit_; + mic_iv[14] = (unsigned char)(payload_length / 256); + mic_iv[15] = (unsigned char)(payload_length % 256); } /************************************************/ @@ -1019,7 +964,6 @@ _func_exit_; /************************************************/ static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu) { -_func_enter_; mic_header1[0] = (u8)((header_length - 2) / 256); mic_header1[1] = (u8)((header_length - 2) % 256); mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ @@ -1036,7 +980,6 @@ _func_enter_; mic_header1[13] = mpdu[13]; mic_header1[14] = mpdu[14]; mic_header1[15] = mpdu[15]; -_func_exit_; } /************************************************/ @@ -1047,7 +990,6 @@ _func_exit_; static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists) { int i; -_func_enter_; for (i = 0; i < 16; i++) mic_header2[i] = 0x00; @@ -1079,7 +1021,6 @@ _func_enter_; mic_header2[15] = mpdu[31] & 0x00; } -_func_exit_; } /************************************************/ @@ -1090,7 +1031,6 @@ _func_exit_; static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c) { int i; -_func_enter_; for (i = 0; i < 16; i++) ctr_preload[i] = 0x00; i = 0; @@ -1105,9 +1045,8 @@ _func_enter_; ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ for (i = 8; i < 14; i++) ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ - ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */ - ctr_preload[15] = (unsigned char) (c % 256); -_func_exit_; + ctr_preload[14] = (unsigned char)(c / 256); /* Ctr */ + ctr_preload[15] = (unsigned char)(c % 256); } /************************************/ @@ -1117,10 +1056,8 @@ _func_exit_; static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) { int i; -_func_enter_; for (i = 0; i < 16; i++) out[i] = ina[i] ^ inb[i]; -_func_exit_; } static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) @@ -1142,16 +1079,15 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); -_func_enter_; frsubtype = frsubtype>>4; - _rtw_memset((void *)mic_iv, 0, 16); - _rtw_memset((void *)mic_header1, 0, 16); - _rtw_memset((void *)mic_header2, 0, 16); - _rtw_memset((void *)ctr_preload, 0, 16); - _rtw_memset((void *)chain_buffer, 0, 16); - _rtw_memset((void *)aes_out, 0, 16); - _rtw_memset((void *)padded_buffer, 0, 16); + memset((void *)mic_iv, 0, 16); + memset((void *)mic_header1, 0, 16); + memset((void *)mic_header2, 0, 16); + memset((void *)ctr_preload, 0, 16); + memset((void *)chain_buffer, 0, 16); + memset((void *)aes_out, 0, 16); + memset((void *)padded_buffer, 0, 16); if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) a4_exists = 0; @@ -1217,7 +1153,7 @@ _func_enter_; /* Insert MIC into payload */ for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + pframe[payload_index+j] = mic[j]; payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { @@ -1253,7 +1189,6 @@ _func_enter_; bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < 8; j++) pframe[payload_index++] = chain_buffer[j]; -_func_exit_; return _SUCCESS; } @@ -1274,7 +1209,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) /* uint offset = 0; */ u32 res = _SUCCESS; -_func_enter_; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return _FAIL; @@ -1285,7 +1219,7 @@ _func_enter_; pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if ((pattrib->encrypt == _AES_)) { + if (pattrib->encrypt == _AES_) { if (pattrib->psta) stainfo = pattrib->psta; else @@ -1304,11 +1238,11 @@ _func_enter_; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); } else{ - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); pframe += pxmitpriv->frag_len; - pframe = (u8 *)RND4((size_t)(pframe)); + pframe = (u8 *)round_up((size_t)(pframe), 8); } } } else{ @@ -1318,7 +1252,6 @@ _func_enter_; } -_func_exit_; return res; } @@ -1344,16 +1277,15 @@ static int aes_decipher(u8 *key, uint hdrlen, /* uint offset = 0; */ uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); -_func_enter_; frsubtype = frsubtype>>4; - _rtw_memset((void *)mic_iv, 0, 16); - _rtw_memset((void *)mic_header1, 0, 16); - _rtw_memset((void *)mic_header2, 0, 16); - _rtw_memset((void *)ctr_preload, 0, 16); - _rtw_memset((void *)chain_buffer, 0, 16); - _rtw_memset((void *)aes_out, 0, 16); - _rtw_memset((void *)padded_buffer, 0, 16); + memset((void *)mic_iv, 0, 16); + memset((void *)mic_header1, 0, 16); + memset((void *)mic_header2, 0, 16); + memset((void *)ctr_preload, 0, 16); + memset((void *)chain_buffer, 0, 16); + memset((void *)aes_out, 0, 16); + memset((void *)padded_buffer, 0, 16); /* start to decrypt the payload */ @@ -1514,7 +1446,6 @@ _func_enter_; res = _FAIL; } } -_func_exit_; return res; } @@ -1524,13 +1455,12 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) int length; u8 *pframe, *prwskey; /* *payload,*iv */ struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; -_func_enter_; - pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* 4 start to encrypt each fragment */ - if ((prxattrib->encrypt == _AES_)) { + if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo != NULL) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); @@ -1552,14 +1482,13 @@ _func_enter_; } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; } - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); } else { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); res = _FAIL; } } -_func_exit_; exit: return res; } @@ -1750,30 +1679,3 @@ do { \ 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; - -_func_enter_; - - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler ^^^\n")); - - padapter->securitypriv.busetkipkey = true; - - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler padapter->securitypriv.busetkipkey=%d^^^\n", padapter->securitypriv.busetkipkey)); - -_func_exit_; -} diff --git a/core/rtw_sreset.c b/core/rtw_sreset.c index 298f754..cd4e344 100644 --- a/core/rtw_sreset.c +++ b/core/rtw_sreset.c @@ -19,27 +19,14 @@ ******************************************************************************/ #include +#include 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) @@ -50,9 +37,7 @@ u8 sreset_get_wifi_status(struct adapter *padapter) u8 status = WIFI_STATUS_SUCCESS; u32 val32 = 0; - if (psrtpriv->silent_reset_inprogress) - return status; - val32 = rtw_read32(padapter, REG_TXDMA_STATUS); + val32 = usb_read32(padapter, REG_TXDMA_STATUS); if (val32 == 0xeaeaeaea) { psrtpriv->Wifi_Error_Status = WIFI_IF_NOT_EXIST; } else if (val32 != 0) { diff --git a/core/rtw_sta_mgt.c b/core/rtw_sta_mgt.c index 7cd30cc..dc9d0dd 100644 --- a/core/rtw_sta_mgt.c +++ b/core/rtw_sta_mgt.c @@ -25,15 +25,15 @@ #include #include #include +#include static void _rtw_init_stainfo(struct sta_info *psta) { -_func_enter_; - _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info)); + memset((u8 *)psta, 0, sizeof(struct sta_info)); - _rtw_spinlock_init(&psta->lock); - _rtw_init_listhead(&psta->list); - _rtw_init_listhead(&psta->hash_list); + spin_lock_init(&psta->lock); + INIT_LIST_HEAD(&psta->list); + INIT_LIST_HEAD(&psta->hash_list); _rtw_init_queue(&psta->sleep_q); psta->sleepq_len = 0; @@ -42,9 +42,9 @@ _func_enter_; #ifdef CONFIG_88EU_AP_MODE - _rtw_init_listhead(&psta->asoc_list); + INIT_LIST_HEAD(&psta->asoc_list); - _rtw_init_listhead(&psta->auth_list); + INIT_LIST_HEAD(&psta->auth_list); psta->expire_to = 0; @@ -69,7 +69,6 @@ _func_enter_; #endif /* CONFIG_88EU_AP_MODE */ -_func_exit_; } u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) @@ -77,9 +76,8 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) struct sta_info *psta; s32 i; -_func_enter_; - pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4); + pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4); if (!pstapriv->pallocated_stainfo_buf) return _FAIL; @@ -89,7 +87,7 @@ _func_enter_; _rtw_init_queue(&pstapriv->free_sta_queue); - _rtw_spinlock_init(&pstapriv->sta_hash_lock); + spin_lock_init(&pstapriv->sta_hash_lock); pstapriv->asoc_sta_count = 0; _rtw_init_queue(&pstapriv->sleep_q); @@ -100,9 +98,9 @@ _func_enter_; for (i = 0; i < NUM_STA; i++) { _rtw_init_stainfo(psta); - _rtw_init_listhead(&(pstapriv->sta_hash[i])); + INIT_LIST_HEAD(&(pstapriv->sta_hash[i])); - rtw_list_insert_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); + list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); psta++; } @@ -112,10 +110,10 @@ _func_enter_; pstapriv->sta_dz_bitmap = 0; pstapriv->tim_bitmap = 0; - _rtw_init_listhead(&pstapriv->asoc_list); - _rtw_init_listhead(&pstapriv->auth_list); - _rtw_spinlock_init(&pstapriv->asoc_list_lock); - _rtw_spinlock_init(&pstapriv->auth_list_lock); + INIT_LIST_HEAD(&pstapriv->asoc_list); + INIT_LIST_HEAD(&pstapriv->auth_list); + spin_lock_init(&pstapriv->asoc_list_lock); + spin_lock_init(&pstapriv->auth_list_lock); pstapriv->asoc_list_cnt = 0; pstapriv->auth_list_cnt = 0; @@ -125,7 +123,6 @@ _func_enter_; pstapriv->max_num_sta = NUM_STA; #endif -_func_exit_; return _SUCCESS; } @@ -148,136 +145,71 @@ inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); } -void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv); -void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv) -{ -_func_enter_; - - _rtw_spinlock_free(&psta_xmitpriv->lock); - - _rtw_spinlock_free(&(psta_xmitpriv->be_q.sta_pending.lock)); - _rtw_spinlock_free(&(psta_xmitpriv->bk_q.sta_pending.lock)); - _rtw_spinlock_free(&(psta_xmitpriv->vi_q.sta_pending.lock)); - _rtw_spinlock_free(&(psta_xmitpriv->vo_q.sta_pending.lock)); -_func_exit_; -} - -static void _rtw_free_sta_recv_priv_lock(struct sta_recv_priv *psta_recvpriv) -{ -_func_enter_; - - _rtw_spinlock_free(&psta_recvpriv->lock); - - _rtw_spinlock_free(&(psta_recvpriv->defrag_q.lock)); - -_func_exit_; -} - -void rtw_mfree_stainfo(struct sta_info *psta); -void rtw_mfree_stainfo(struct sta_info *psta) -{ -_func_enter_; - - if (&psta->lock != NULL) - _rtw_spinlock_free(&psta->lock); - - _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); - _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); - -_func_exit_; -} - /* this function is used to free the memory of lock || sema for all stainfos */ -void rtw_mfree_all_stainfo(struct sta_priv *pstapriv); -void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) +static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) { - unsigned long irql; struct list_head *plist, *phead; struct sta_info *psta = NULL; -_func_enter_; - _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + spin_lock_bh(&pstapriv->sta_hash_lock); phead = get_list_head(&pstapriv->free_sta_queue); - plist = get_next(phead); + plist = phead->next; - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info , list); - plist = get_next(plist); - - rtw_mfree_stainfo(psta); + while (phead != plist) { + psta = container_of(plist, struct sta_info , list); + plist = plist->next; } - _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); + spin_unlock_bh(&pstapriv->sta_hash_lock); -_func_exit_; } static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) { -#ifdef CONFIG_88EU_AP_MODE - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; -#endif - rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */ - - _rtw_spinlock_free(&pstapriv->free_sta_queue.lock); - - _rtw_spinlock_free(&pstapriv->sta_hash_lock); - _rtw_spinlock_free(&pstapriv->wakeup_q.lock); - _rtw_spinlock_free(&pstapriv->sleep_q.lock); - -#ifdef CONFIG_88EU_AP_MODE - _rtw_spinlock_free(&pstapriv->asoc_list_lock); - _rtw_spinlock_free(&pstapriv->auth_list_lock); - _rtw_spinlock_free(&pacl_list->acl_node_q.lock); -#endif } u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) { - unsigned long irql; struct list_head *phead, *plist; struct sta_info *psta = NULL; struct recv_reorder_ctrl *preorder_ctrl; int index; -_func_enter_; if (pstapriv) { /* delete all reordering_ctrl_timer */ - _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { phead = &(pstapriv->sta_hash[index]); - plist = get_next(phead); + plist = phead->next; - while ((rtw_end_of_queue_search(phead, plist)) == false) { + while (phead != plist) { int i; - psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); - plist = get_next(plist); + psta = container_of(plist, struct sta_info , hash_list); + plist = plist->next; for (i = 0; i < 16; i++) { preorder_ctrl = &psta->recvreorder_ctrl[i]; - _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); } } } - _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); + spin_unlock_bh(&pstapriv->sta_hash_lock); /*===============================*/ rtw_mfree_sta_priv_lock(pstapriv); if (pstapriv->pallocated_stainfo_buf) - rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4); - } + vfree(pstapriv->pallocated_stainfo_buf); + } -_func_exit_; return _SUCCESS; } struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { - unsigned long irql, irql2; s32 index; struct list_head *phash_list; struct sta_info *psta; @@ -286,19 +218,18 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) int i = 0; u16 wRxSeqInitialValue = 0xffff; -_func_enter_; pfree_sta_queue = &pstapriv->free_sta_queue; - _enter_critical_bh(&(pfree_sta_queue->lock), &irql); + spin_lock_bh(&(pfree_sta_queue->lock)); - if (_rtw_queue_empty(pfree_sta_queue) == true) { - _exit_critical_bh(&(pfree_sta_queue->lock), &irql); + if (list_empty(&pfree_sta_queue->queue)) { + spin_unlock_bh(&pfree_sta_queue->lock); psta = NULL; } else { - psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list); - rtw_list_delete(&(psta->list)); - _exit_critical_bh(&(pfree_sta_queue->lock), &irql); + psta = container_of((&pfree_sta_queue->queue)->next, struct sta_info, list); + list_del_init(&(psta->list)); + spin_unlock_bh(&pfree_sta_queue->lock); _rtw_init_stainfo(psta); memcpy(psta->hwaddr, hwaddr, ETH_ALEN); index = wifi_mac_hash(hwaddr); @@ -310,13 +241,13 @@ _func_enter_; } phash_list = &(pstapriv->sta_hash[index]); - _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + spin_lock_bh(&(pstapriv->sta_hash_lock)); - rtw_list_insert_tail(&psta->hash_list, phash_list); + list_add_tail(&psta->hash_list, phash_list); - pstapriv->asoc_sta_count++ ; + pstapriv->asoc_sta_count++; - _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + spin_unlock_bh(&pstapriv->sta_hash_lock); /* Commented by Albert 2009/08/13 */ /* For the SMC router, the sequence number of first packet of WPS handshake will be 0. */ @@ -358,9 +289,6 @@ _func_enter_; } exit: - -_func_exit_; - return psta; } @@ -368,14 +296,12 @@ _func_exit_; u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) { int i; - unsigned long irql0; struct __queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; struct sta_xmit_priv *pstaxmitpriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct sta_priv *pstapriv = &padapter->stapriv; -_func_enter_; if (psta == NULL) goto exit; @@ -384,30 +310,30 @@ _func_enter_; pstaxmitpriv = &psta->sta_xmitpriv; - _enter_critical_bh(&pxmitpriv->lock, &irql0); + spin_lock_bh(&pxmitpriv->lock); rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q); psta->sleepq_len = 0; rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->vo_q.tx_pending)); + list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->vi_q.tx_pending)); + list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->bk_q.tx_pending)); + list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&(pstaxmitpriv->be_q.tx_pending)); - _exit_critical_bh(&pxmitpriv->lock, &irql0); + spin_unlock_bh(&pxmitpriv->lock); - rtw_list_delete(&psta->hash_list); + list_del_init(&psta->hash_list); RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo with hwaddr=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", pstapriv->asoc_sta_count , psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5])); pstapriv->asoc_sta_count--; @@ -415,38 +341,39 @@ _func_enter_; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); _rtw_init_sta_recv_priv(&psta->sta_recvpriv); - _cancel_timer_ex(&psta->addba_retry_timer); + del_timer_sync(&psta->addba_retry_timer); /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ - for (i = 0; i < 16 ; i++) { - unsigned long irql; + for (i = 0; i < 16; i++) { struct list_head *phead, *plist; - union recv_frame *prframe; + struct recv_frame *prhdr; + struct recv_frame *prframe; struct __queue *ppending_recvframe_queue; struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; preorder_ctrl = &psta->recvreorder_ctrl[i]; - _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; - _enter_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_lock_bh(&ppending_recvframe_queue->lock); phead = get_list_head(ppending_recvframe_queue); - plist = get_next(phead); + plist = phead->next; - while (!rtw_is_list_empty(phead)) { - prframe = LIST_CONTAINOR(plist, union recv_frame, u); + while (!list_empty(phead)) { + prhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)prhdr; - plist = get_next(plist); + plist = plist->next; - rtw_list_delete(&(prframe->u.hdr.list)); + list_del_init(&(prframe->list)); rtw_free_recvframe(prframe, pfree_recv_queue); } - _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + spin_unlock_bh(&ppending_recvframe_queue->lock); } if (!(psta->state & WIFI_AP_STATE)) @@ -454,12 +381,12 @@ _func_enter_; #ifdef CONFIG_88EU_AP_MODE - _enter_critical_bh(&pstapriv->auth_list_lock, &irql0); - if (!rtw_is_list_empty(&psta->auth_list)) { - rtw_list_delete(&psta->auth_list); + spin_lock_bh(&pstapriv->auth_list_lock); + if (!list_empty(&psta->auth_list)) { + list_del_init(&psta->auth_list); pstapriv->auth_list_cnt--; } - _exit_critical_bh(&pstapriv->auth_list_lock, &irql0); + spin_unlock_bh(&pstapriv->auth_list_lock); psta->expire_to = 0; @@ -485,13 +412,12 @@ _func_enter_; #endif /* CONFIG_88EU_AP_MODE */ - _enter_critical_bh(&(pfree_sta_queue->lock), &irql0); - rtw_list_insert_tail(&psta->list, get_list_head(pfree_sta_queue)); - _exit_critical_bh(&(pfree_sta_queue->lock), &irql0); + 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); exit: -_func_exit_; return _SUCCESS; } @@ -499,52 +425,43 @@ _func_exit_; /* free all stainfo which in sta_hash[all] */ void rtw_free_all_stainfo(struct adapter *padapter) { - unsigned long irql; struct list_head *plist, *phead; s32 index; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); -_func_enter_; if (pstapriv->asoc_sta_count == 1) - goto exit; + return; - _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { phead = &(pstapriv->sta_hash[index]); - plist = get_next(phead); + plist = phead->next; - while ((!rtw_end_of_queue_search(phead, plist))) { - psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); + while (phead != plist) { + psta = container_of(plist, struct sta_info , hash_list); - plist = get_next(plist); + plist = plist->next; if (pbcmc_stainfo != psta) rtw_free_stainfo(padapter , psta); } } - - _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); - -exit: - -_func_exit_; + spin_unlock_bh(&pstapriv->sta_hash_lock); } /* any station allocated can be searched by hash list */ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { - unsigned long irql; struct list_head *plist, *phead; struct sta_info *psta = NULL; u32 index; u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -_func_enter_; if (hwaddr == NULL) return NULL; @@ -556,24 +473,23 @@ _func_enter_; index = wifi_mac_hash(addr); - _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + spin_lock_bh(&pstapriv->sta_hash_lock); phead = &(pstapriv->sta_hash[index]); - plist = get_next(phead); + plist = phead->next; - while ((!rtw_end_of_queue_search(phead, plist))) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + while (phead != plist) { + psta = container_of(plist, struct sta_info, hash_list); - if ((_rtw_memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) { + if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) { /* if found the matched address */ break; } psta = NULL; - plist = get_next(plist); + plist = plist->next; } - _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); -_func_exit_; + spin_unlock_bh(&pstapriv->sta_hash_lock); return psta; } @@ -584,7 +500,6 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) unsigned char bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sta_priv *pstapriv = &padapter->stapriv; -_func_enter_; psta = rtw_alloc_stainfo(pstapriv, bcast_addr); @@ -598,7 +513,6 @@ _func_enter_; psta->mac_id = 1; exit: -_func_exit_; return res; } @@ -607,9 +521,7 @@ struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -_func_enter_; psta = rtw_get_stainfo(pstapriv, bc_addr); -_func_exit_; return psta; } @@ -617,7 +529,6 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) { u8 res = true; #ifdef CONFIG_88EU_AP_MODE - unsigned long irql; struct list_head *plist, *phead; struct rtw_wlan_acl_node *paclnode; u8 match = false; @@ -625,21 +536,21 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct __queue *pacl_node_q = &pacl_list->acl_node_q; - _enter_critical_bh(&(pacl_node_q->lock), &irql); + spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); - plist = get_next(phead); - while ((!rtw_end_of_queue_search(phead, plist))) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); - plist = get_next(plist); + plist = phead->next; + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; - if (_rtw_memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { + if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { if (paclnode->valid) { match = true; break; } } } - _exit_critical_bh(&(pacl_node_q->lock), &irql); + spin_unlock_bh(&pacl_node_q->lock); if (pacl_list->mode == 1)/* accept unless in deny list */ res = (match) ? false : true; diff --git a/core/rtw_wlan_util.c b/core/rtw_wlan_util.c index fe67fe0..324c1a7 100644 --- a/core/rtw_wlan_util.c +++ b/core/rtw_wlan_util.c @@ -80,7 +80,7 @@ int cckratesonly_included(unsigned char *rate, int ratelen) for (i = 0; i < ratelen; i++) { if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) - return false; + return false; } return true; @@ -239,7 +239,7 @@ void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrat { unsigned char supportedrates[NumRates]; - _rtw_memset(supportedrates, 0, NumRates); + memset(supportedrates, 0, NumRates); *bssrate_len = ratetbl2rateset(padapter, supportedrates); memcpy(pbssrate, supportedrates, *bssrate_len); } @@ -541,7 +541,7 @@ void flush_all_cam_entry(struct adapter *padapter) rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); - _rtw_memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); + memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); } int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) @@ -766,7 +766,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) for (i = 0; i < (pIE->Length); i++) { if (i != 2) { - /* Got the endian issue here. */ + /* Got the endian issue here. */ pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); } else { /* modify from fw by Thomas 2010/11/17 */ @@ -912,12 +912,12 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) unsigned char *pbuf; u32 wpa_ielen = 0; u8 *pbssid = GetAddr3Ptr(pframe); - u32 hidden_ssid = 0; struct HT_info_element *pht_info = NULL; struct rtw_ieee80211_ht_cap *pht_cap = NULL; u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; + int ssid_len; if (is_client_associated_to_ap(Adapter) == false) return true; @@ -929,13 +929,13 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) return _FAIL; } - if (_rtw_memcmp(cur_network->network.MacAddress, pbssid, 6) == false) { + if (!memcmp(cur_network->network.MacAddress, pbssid, 6) == false) { DBG_88E("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n%pM %pM\n", (pbssid), (cur_network->network.MacAddress)); return true; } - bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex)); + bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); subtype = GetFrameSubType(pframe) >> 4; @@ -999,28 +999,22 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } /* checking SSID */ + ssid_len = 0; p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); - if (p == NULL) { - DBG_88E("%s marc: cannot find SSID for survey event\n", __func__); - hidden_ssid = true; - } else { - hidden_ssid = false; - } - - if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) { - memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); - bssid->Ssid.SsidLength = *(p + 1); - } else { - bssid->Ssid.SsidLength = 0; - bssid->Ssid.Ssid[0] = '\0'; + if (p) { + ssid_len = *(p + 1); + if (ssid_len > NDIS_802_11_LENGTH_SSID) + ssid_len = 0; } + memcpy(bssid->Ssid.Ssid, (p + 2), ssid_len); + bssid->Ssid.SsidLength = ssid_len; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d " "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid, bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid, cur_network->network.Ssid.SsidLength)); - if (!_rtw_memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || + if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) { if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */ DBG_88E("%s(), SSID is not match return FAIL\n", __func__); @@ -1056,7 +1050,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) { - DBG_88E("%s(): enctyp is not match , return FAIL\n", __func__); + DBG_88E("%s(): encryption protocol is not match , return FAIL\n", __func__); goto _mismatch; } @@ -1096,12 +1090,10 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } kfree(bssid); - _func_exit_; return _SUCCESS; _mismatch: kfree(bssid); - _func_exit_; return _FAIL; } @@ -1147,11 +1139,11 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if ((_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) && (_rtw_memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) + if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) return true; break; case _RSN_IE_2_: - if (_rtw_memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) + if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) return true; default: break; @@ -1178,15 +1170,15 @@ unsigned int should_forbid_n_rate(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4) && - ((_rtw_memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) || - (_rtw_memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4)))) + 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 ((_rtw_memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || - (_rtw_memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) - return false; + if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || + (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) + return false; default: break; } @@ -1214,7 +1206,7 @@ unsigned int is_ap_in_wep(struct adapter *padapter) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) + if (!memcmp(pIE->data, RTW_WPA_OUI, 4)) return false; break; case _RSN_IE_2_: @@ -1230,7 +1222,7 @@ unsigned int is_ap_in_wep(struct adapter *padapter) } } -int wifirate2_ratetbl_inx(unsigned char rate) +static int wifirate2_ratetbl_inx(unsigned char rate) { int inx = 0; rate = rate & 0x7f; @@ -1365,16 +1357,7 @@ 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 */ - /* In the P2P mode, the driver should not support the b mode. */ - /* So, the Tx packet shouldn't use the CCK rate */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; -#endif /* CONFIG_88EU_P2P */ - _rtw_memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); + memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B)) memcpy(supported_rates, rtw_basic_rate_cck, 4); @@ -1406,36 +1389,35 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) switch (pIE->ElementID) { case _VENDOR_SPECIFIC_IE_: - if ((_rtw_memcmp(pIE->data, ARTHEROS_OUI1, 3)) || - (_rtw_memcmp(pIE->data, ARTHEROS_OUI2, 3))) { + if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || + (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { DBG_88E("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; - } else if ((_rtw_memcmp(pIE->data, BROADCOM_OUI1, 3)) || - (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3)) || - (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3))) { + } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || + (!memcmp(pIE->data, BROADCOM_OUI2, 3))) { DBG_88E("link to Broadcom AP\n"); return HT_IOT_PEER_BROADCOM; - } else if (_rtw_memcmp(pIE->data, MARVELL_OUI, 3)) { + } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) { DBG_88E("link to Marvell AP\n"); return HT_IOT_PEER_MARVELL; - } else if (_rtw_memcmp(pIE->data, RALINK_OUI, 3)) { + } else if (!memcmp(pIE->data, RALINK_OUI, 3)) { if (!ralink_vendor_flag) { ralink_vendor_flag = 1; } else { DBG_88E("link to Ralink AP\n"); return HT_IOT_PEER_RALINK; } - } else if (_rtw_memcmp(pIE->data, CISCO_OUI, 3)) { + } else if (!memcmp(pIE->data, CISCO_OUI, 3)) { DBG_88E("link to Cisco AP\n"); return HT_IOT_PEER_CISCO; - } else if (_rtw_memcmp(pIE->data, REALTEK_OUI, 3)) { + } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) { DBG_88E("link to Realtek 96B\n"); return HT_IOT_PEER_REALTEK; - } else if (_rtw_memcmp(pIE->data, AIRGOCAP_OUI, 3)) { + } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { DBG_88E("link to Airgo Cap\n"); return HT_IOT_PEER_AIRGO; - } else if (_rtw_memcmp(pIE->data, EPIGRAM_OUI, 3)) { - epigram_vendor_flag = 1; + } else if (!memcmp(pIE->data, EPIGRAM_OUI, 3)) { + epigram_vendor_flag = 1; if (ralink_vendor_flag) { DBG_88E("link to Tenda W311R AP\n"); return HT_IOT_PEER_TENDA; @@ -1607,13 +1589,18 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); if (pIE == NULL) return _FAIL; + if (ie_len > NDIS_802_11_LENGTH_RATES_EX) + return _FAIL; memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); supportRateNum = ie_len; pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); - if (pIE) + if (pIE) { + if (supportRateNum + ie_len > NDIS_802_11_LENGTH_RATES_EX) + return _FAIL; memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); + } return _SUCCESS; } @@ -1664,26 +1651,3 @@ void beacon_timing_control(struct adapter *padapter) { rtw_hal_bcn_related_reg_setting(padapter); } - -static struct adapter *pbuddy_padapter; - -int rtw_handle_dualmac(struct adapter *adapter, bool init) -{ - int status = _SUCCESS; - - if (init) { - if (pbuddy_padapter == NULL) { - pbuddy_padapter = adapter; - DBG_88E("%s(): pbuddy_padapter == NULL, Set pbuddy_padapter\n", __func__); - } else { - adapter->pbuddy_adapter = pbuddy_padapter; - pbuddy_padapter->pbuddy_adapter = adapter; - /* clear global value */ - pbuddy_padapter = NULL; - DBG_88E("%s(): pbuddy_padapter exist, Exchange Information\n", __func__); - } - } else { - pbuddy_padapter = NULL; - } - return status; -} diff --git a/core/rtw_xmit.c b/core/rtw_xmit.c index 2cfc9ce..7a71df1 100644 --- a/core/rtw_xmit.c +++ b/core/rtw_xmit.c @@ -23,35 +23,29 @@ #include #include #include -#include -#include -#include +#include static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; static void _init_txservq(struct tx_servq *ptxservq) { -_func_enter_; - _rtw_init_listhead(&ptxservq->tx_pending); + INIT_LIST_HEAD(&ptxservq->tx_pending); _rtw_init_queue(&ptxservq->sta_pending); ptxservq->qcnt = 0; -_func_exit_; } void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) { -_func_enter_; - _rtw_memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv)); - _rtw_spinlock_init(&psta_xmitpriv->lock); + memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv)); + spin_lock_init(&psta_xmitpriv->lock); _init_txservq(&psta_xmitpriv->be_q); _init_txservq(&psta_xmitpriv->bk_q); _init_txservq(&psta_xmitpriv->vi_q); _init_txservq(&psta_xmitpriv->vo_q); - _rtw_init_listhead(&psta_xmitpriv->legacy_dz); - _rtw_init_listhead(&psta_xmitpriv->apsd); + INIT_LIST_HEAD(&psta_xmitpriv->legacy_dz); + INIT_LIST_HEAD(&psta_xmitpriv->apsd); -_func_exit_; } s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) @@ -63,13 +57,12 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; -_func_enter_; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - _rtw_spinlock_init(&pxmitpriv->lock); - _rtw_init_sema(&pxmitpriv->xmit_sema, 0); - _rtw_init_sema(&pxmitpriv->terminate_xmitthread_sema, 0); + 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 @@ -91,7 +84,7 @@ _func_enter_; Please also apply free_txobj to link_up all the xmit_frames... */ - pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); if (pxmitpriv->pallocated_frame_buf == NULL) { pxmitpriv->pxmit_frame_buf = NULL; @@ -106,7 +99,7 @@ _func_enter_; pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; for (i = 0; i < NR_XMITFRAME; i++) { - _rtw_init_listhead(&(pxframe->list)); + INIT_LIST_HEAD(&(pxframe->list)); pxframe->padapter = padapter; pxframe->frame_tag = NULL_FRAMETAG; @@ -116,7 +109,7 @@ _func_enter_; pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; - rtw_list_insert_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); + list_add_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); pxframe++; } @@ -129,7 +122,7 @@ _func_enter_; _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); - pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmitbuf == NULL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); @@ -144,7 +137,7 @@ _func_enter_; pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; for (i = 0; i < NR_XMITBUFF; i++) { - _rtw_init_listhead(&pxmitbuf->list); + INIT_LIST_HEAD(&pxmitbuf->list); pxmitbuf->priv_data = NULL; pxmitbuf->padapter = padapter; @@ -153,7 +146,7 @@ _func_enter_; /* Tx buf allocation may fail sometimes, so sleep and retry. */ res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) { - rtw_msleep_os(10); + msleep(10); res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) { goto exit; @@ -162,7 +155,7 @@ _func_enter_; pxmitbuf->flags = XMIT_VO_QUEUE; - rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); pxmitbuf++; } @@ -171,7 +164,7 @@ _func_enter_; /* Init xmit extension buff */ _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (pxmitpriv->pallocated_xmit_extbuf == NULL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); @@ -184,7 +177,7 @@ _func_enter_; pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; for (i = 0; i < num_xmit_extbuf; i++) { - _rtw_init_listhead(&pxmitbuf->list); + INIT_LIST_HEAD(&pxmitbuf->list); pxmitbuf->priv_data = NULL; pxmitbuf->padapter = padapter; @@ -196,7 +189,7 @@ _func_enter_; goto exit; } - rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); pxmitbuf++; } @@ -210,7 +203,7 @@ _func_enter_; pxmitpriv->txirp_cnt = 1; - _rtw_init_sema(&(pxmitpriv->tx_retevt), 0); + sema_init(&(pxmitpriv->tx_retevt), 0); /* per AC pending irp */ pxmitpriv->beq_cnt = 0; @@ -219,36 +212,18 @@ _func_enter_; 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); exit: -_func_exit_; return res; } -static void rtw_mfree_xmit_priv_lock (struct xmit_priv *pxmitpriv) -{ - _rtw_spinlock_free(&pxmitpriv->lock); - _rtw_free_sema(&pxmitpriv->xmit_sema); - _rtw_free_sema(&pxmitpriv->terminate_xmitthread_sema); - - _rtw_spinlock_free(&pxmitpriv->be_pending.lock); - _rtw_spinlock_free(&pxmitpriv->bk_pending.lock); - _rtw_spinlock_free(&pxmitpriv->vi_pending.lock); - _rtw_spinlock_free(&pxmitpriv->vo_pending.lock); - _rtw_spinlock_free(&pxmitpriv->bm_pending.lock); - - _rtw_spinlock_free(&pxmitpriv->free_xmit_queue.lock); - _rtw_spinlock_free(&pxmitpriv->free_xmitbuf_queue.lock); - _rtw_spinlock_free(&pxmitpriv->pending_xmitbuf_queue.lock); -} - -void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) +void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) { int i; struct adapter *padapter = pxmitpriv->adapter; @@ -257,14 +232,8 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - _func_enter_; - - rtw_hal_free_xmit_priv(padapter); - - rtw_mfree_xmit_priv_lock(pxmitpriv); - if (pxmitpriv->pxmit_frame_buf == NULL) - goto out; + return; for (i = 0; i < NR_XMITFRAME; i++) { rtw_os_xmit_complete(padapter, pxmitframe); @@ -278,14 +247,12 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) } if (pxmitpriv->pallocated_frame_buf) - rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + vfree(pxmitpriv->pallocated_frame_buf); if (pxmitpriv->pallocated_xmitbuf) - rtw_vmfree(pxmitpriv->pallocated_xmitbuf, NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmitbuf); /* free xmit extension buff */ - _rtw_spinlock_free(&pxmitpriv->free_xmit_extbuf_queue.lock); - 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)); @@ -293,16 +260,12 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) } if (pxmitpriv->pallocated_xmit_extbuf) { - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmit_extbuf); } rtw_free_hwxmits(padapter); - _rtw_mutex_free(&pxmitpriv->ack_tx_mutex); - -out: - -_func_exit_; + mutex_destroy(&pxmitpriv->ack_tx_mutex); } static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe) @@ -476,7 +439,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p struct qos_priv *pqospriv = &pmlmepriv->qospriv; int res = _SUCCESS; - _func_enter_; _rtw_open_pktfile(pkt, &pktfile); _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); @@ -654,13 +616,10 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: bswenc = false\n")); } - rtw_set_tx_chksum_offload(pkt, pattrib); - update_attrib_phy_info(pattrib, psta); exit: -_func_exit_; return res; } @@ -683,9 +642,8 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr else stainfo = rtw_get_stainfo(&padapter->stapriv , &pattrib->ra[0]); -_func_enter_; - hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);; + hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ /* encode mic code */ @@ -697,14 +655,14 @@ _func_enter_; pframe = pxmitframe->buf_addr + hw_hdr_offset; if (bmcst) { - if (_rtw_memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) + if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) return _FAIL; /* start to calculate the mic code */ rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); } else { - if (_rtw_memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16) == true) { + if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) { /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ - /* rtw_msleep_os(10); */ + /* msleep(10); */ return _FAIL; } /* start to calculate the mic code */ @@ -733,7 +691,7 @@ _func_enter_; payload = pframe; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - payload = (u8 *)RND4((size_t)(payload)); + payload = (u8 *)round_up((size_t)(payload), 4); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("=== curfragnum=%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n", curfragnum, *payload, *(payload+1), @@ -781,7 +739,6 @@ _func_enter_; } } -_func_exit_; return _SUCCESS; } @@ -790,7 +747,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi { struct pkt_attrib *pattrib = &pxmitframe->attrib; -_func_enter_; if (pattrib->bswenc) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); @@ -812,12 +768,11 @@ _func_enter_; RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); } -_func_exit_; return _SUCCESS; } -s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib) +s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) { u16 *qc; @@ -833,7 +788,6 @@ s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pat int bmcst = IS_MCAST(pattrib->ra); -_func_enter_; if (pattrib->psta) { psta = pattrib->psta; @@ -845,7 +799,7 @@ _func_enter_; } } - _rtw_memset(hdr, 0, WLANHDR_OFFSET); + memset(hdr, 0, WLANHDR_OFFSET); SetFrameSubType(fctrl, pattrib->subtype); @@ -939,7 +893,6 @@ _func_enter_; } exit: -_func_exit_; return res; } @@ -947,10 +900,10 @@ s32 rtw_txframes_pending(struct adapter *padapter) { struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - return ((_rtw_queue_empty(&pxmitpriv->be_pending) == false) || - (_rtw_queue_empty(&pxmitpriv->bk_pending) == false) || - (_rtw_queue_empty(&pxmitpriv->vi_pending) == false) || - (_rtw_queue_empty(&pxmitpriv->vo_pending) == false)); + return (!list_empty(&pxmitpriv->be_pending.queue) || + !list_empty(&pxmitpriv->bk_pending.queue) || + !list_empty(&pxmitpriv->vi_pending.queue) || + !list_empty(&pxmitpriv->vo_pending.queue)); } s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib) @@ -1028,7 +981,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct s32 bmcst = IS_MCAST(pattrib->ra); s32 res = _SUCCESS; -_func_enter_; psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); @@ -1073,8 +1025,7 @@ _func_enter_; /* adding icv, if necessary... */ if (pattrib->iv_len) { - if (psta != NULL) { - switch (pattrib->encrypt) { + switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); @@ -1091,7 +1042,6 @@ _func_enter_; else AES_IV(pattrib->iv, psta->dot11txpn, 0); break; - } } memcpy(pframe, pattrib->iv, pattrib->iv_len); @@ -1146,7 +1096,7 @@ _func_enter_; addr = (size_t)(pframe); - mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset; + mem_start = (unsigned char *)round_up(addr, 4) + hw_hdr_offset; memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); } @@ -1166,7 +1116,6 @@ _func_enter_; exit: -_func_exit_; return res; } @@ -1183,7 +1132,6 @@ s32 rtw_put_snap(u8 *data, u16 h_proto) struct ieee80211_snap_hdr *snap; u8 *oui; -_func_enter_; snap = (struct ieee80211_snap_hdr *)data; snap->dsap = 0xaa; @@ -1201,7 +1149,6 @@ _func_enter_; *(__be16 *)(data + SNAP_SIZE) = htons(h_proto); -_func_exit_; return SNAP_SIZE + sizeof(u16); } @@ -1214,7 +1161,6 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; -_func_enter_; switch (pxmitpriv->vcs_setting) { case DISABLE_VCS: @@ -1241,7 +1187,6 @@ _func_enter_; break; } -_func_exit_; } void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz) @@ -1271,20 +1216,19 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) struct list_head *plist, *phead; struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; -_func_enter_; - _enter_critical(&pfree_queue->lock, &irql); + spin_lock_irqsave(&pfree_queue->lock, irql); - if (_rtw_queue_empty(pfree_queue) == true) { + if (list_empty(&pfree_queue->queue)) { pxmitbuf = NULL; } else { phead = get_list_head(pfree_queue); - plist = get_next(phead); + plist = phead->next; - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); - rtw_list_delete(&(pxmitbuf->list)); + list_del_init(&(pxmitbuf->list)); } if (pxmitbuf != NULL) { @@ -1299,9 +1243,8 @@ _func_enter_; } } - _exit_critical(&pfree_queue->lock, &irql); + spin_unlock_irqrestore(&pfree_queue->lock, irql); -_func_exit_; return pxmitbuf; } @@ -1311,21 +1254,19 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) unsigned long irql; struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; -_func_enter_; if (pxmitbuf == NULL) return _FAIL; - _enter_critical(&pfree_queue->lock, &irql); + spin_lock_irqsave(&pfree_queue->lock, irql); - rtw_list_delete(&pxmitbuf->list); + list_del_init(&pxmitbuf->list); - rtw_list_insert_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); + list_add_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); pxmitpriv->free_xmit_extbuf_cnt++; - _exit_critical(&pfree_queue->lock, &irql); + spin_unlock_irqrestore(&pfree_queue->lock, irql); -_func_exit_; return _SUCCESS; } @@ -1337,22 +1278,21 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) struct list_head *plist, *phead; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; -_func_enter_; /* DBG_88E("+rtw_alloc_xmitbuf\n"); */ - _enter_critical(&pfree_xmitbuf_queue->lock, &irql); + spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irql); - if (_rtw_queue_empty(pfree_xmitbuf_queue) == true) { + if (list_empty(&pfree_xmitbuf_queue->queue)) { pxmitbuf = NULL; } else { phead = get_list_head(pfree_xmitbuf_queue); - plist = get_next(phead); + plist = phead->next; - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); - rtw_list_delete(&(pxmitbuf->list)); + list_del_init(&(pxmitbuf->list)); } if (pxmitbuf != NULL) { @@ -1363,9 +1303,8 @@ _func_enter_; rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); } } - _exit_critical(&pfree_xmitbuf_queue->lock, &irql); + spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); -_func_exit_; return pxmitbuf; } @@ -1375,7 +1314,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) unsigned long irql; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; -_func_enter_; if (pxmitbuf == NULL) return _FAIL; @@ -1387,17 +1325,16 @@ _func_enter_; if (pxmitbuf->ext_tag) { rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf); } else { - _enter_critical(&pfree_xmitbuf_queue->lock, &irql); + spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irql); - rtw_list_delete(&pxmitbuf->list); + list_del_init(&pxmitbuf->list); - rtw_list_insert_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); + list_add_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); pxmitpriv->free_xmitbuf_cnt++; - _exit_critical(&pfree_xmitbuf_queue->lock, &irql); + spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); } -_func_exit_; return _SUCCESS; } @@ -1422,26 +1359,24 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf pfree_xmit_queue */ - unsigned long irql; struct xmit_frame *pxframe = NULL; struct list_head *plist, *phead; struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; -_func_enter_; - _enter_critical_bh(&pfree_xmit_queue->lock, &irql); + spin_lock_bh(&pfree_xmit_queue->lock); - if (_rtw_queue_empty(pfree_xmit_queue) == true) { + if (list_empty(&pfree_xmit_queue->queue)) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt)); pxframe = NULL; } else { phead = get_list_head(pfree_xmit_queue); - plist = get_next(phead); + plist = phead->next; - pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxframe = container_of(plist, struct xmit_frame, list); - rtw_list_delete(&(pxframe->list)); + list_del_init(&(pxframe->list)); } if (pxframe != NULL) { /* default value setting */ @@ -1452,7 +1387,7 @@ _func_enter_; pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; - _rtw_memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); + memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); /* pxframe->attrib.psta = NULL; */ pxframe->frame_tag = DATA_FRAMETAG; @@ -1464,76 +1399,69 @@ _func_enter_; pxframe->ack_report = 0; } - _exit_critical_bh(&pfree_xmit_queue->lock, &irql); + spin_unlock_bh(&pfree_xmit_queue->lock); -_func_exit_; return pxframe; } s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe) { - unsigned long irql; struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; struct adapter *padapter = pxmitpriv->adapter; struct sk_buff *pndis_pkt = NULL; -_func_enter_; if (pxmitframe == NULL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n")); goto exit; } - _enter_critical_bh(&pfree_xmit_queue->lock, &irql); + spin_lock_bh(&pfree_xmit_queue->lock); - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); if (pxmitframe->pkt) { pndis_pkt = pxmitframe->pkt; pxmitframe->pkt = NULL; } - rtw_list_insert_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue)); + list_add_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue)); pxmitpriv->free_xmitframe_cnt++; RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); - _exit_critical_bh(&pfree_xmit_queue->lock, &irql); + spin_unlock_bh(&pfree_xmit_queue->lock); if (pndis_pkt) rtw_os_pkt_complete(padapter, pndis_pkt); exit: -_func_exit_; return _SUCCESS; } void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue) { - unsigned long irql; struct list_head *plist, *phead; struct xmit_frame *pxmitframe; -_func_enter_; - _enter_critical_bh(&(pframequeue->lock), &irql); + spin_lock_bh(&(pframequeue->lock)); phead = get_list_head(pframequeue); - plist = get_next(phead); + plist = phead->next; - while (!rtw_end_of_queue_search(phead, plist)) { - pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + while (phead != plist) { + pxmitframe = container_of(plist, struct xmit_frame, list); - plist = get_next(plist); + plist = plist->next; rtw_free_xmitframe(pxmitpriv, pxmitframe); } - _exit_critical_bh(&(pframequeue->lock), &irql); + spin_unlock_bh(&(pframequeue->lock)); -_func_exit_; } s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) @@ -1554,14 +1482,14 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str struct xmit_frame *pxmitframe = NULL; xmitframe_phead = get_list_head(pframe_queue); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; - if (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + if (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); ptxservq->qcnt--; } @@ -1570,7 +1498,6 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry) { - unsigned long irql0; struct list_head *sta_plist, *sta_phead; struct hw_xmit *phwxmit; struct tx_servq *ptxservq = NULL; @@ -1580,7 +1507,6 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi struct registry_priv *pregpriv = &padapter->registrypriv; int i, inx[4]; -_func_enter_; inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; @@ -1591,16 +1517,16 @@ _func_enter_; inx[j] = pxmitpriv->wmm_para_seq[j]; } - _enter_critical_bh(&pxmitpriv->lock, &irql0); + spin_lock_bh(&pxmitpriv->lock); for (i = 0; i < entry; i++) { phwxmit = phwxmit_i + inx[i]; sta_phead = get_list_head(phwxmit->sta_queue); - sta_plist = get_next(sta_phead); + sta_plist = sta_phead->next; - while (!rtw_end_of_queue_search(sta_phead, sta_plist)) { - ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending); + while (sta_phead != sta_plist) { + ptxservq = container_of(sta_plist, struct tx_servq, tx_pending); pframe_queue = &ptxservq->sta_pending; @@ -1610,17 +1536,16 @@ _func_enter_; phwxmit->accnt--; /* Remove sta node when there are no pending packets. */ - if (_rtw_queue_empty(pframe_queue)) /* must be done after get_next and before break */ - rtw_list_delete(&ptxservq->tx_pending); + if (list_empty(&pframe_queue->queue)) /* must be done after get_next and before break */ + list_del_init(&ptxservq->tx_pending); goto exit; } - sta_plist = get_next(sta_plist); + sta_plist = sta_plist->next; } } exit: - _exit_critical_bh(&pxmitpriv->lock, &irql0); -_func_exit_; + spin_unlock_bh(&pxmitpriv->lock); return pxmitframe; } @@ -1628,7 +1553,6 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * { struct tx_servq *ptxservq; -_func_enter_; switch (up) { case 1: case 2: @@ -1657,7 +1581,6 @@ _func_enter_; break; } -_func_exit_; return ptxservq; } @@ -1668,7 +1591,6 @@ _func_exit_; */ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) { - /* unsigned long irql0; */ u8 ac_index; struct sta_info *psta; struct tx_servq *ptxservq; @@ -1677,7 +1599,6 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; int res = _SUCCESS; -_func_enter_; if (pattrib->psta) { psta = pattrib->psta; @@ -1694,15 +1615,14 @@ _func_enter_; ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); - if (rtw_is_list_empty(&ptxservq->tx_pending)) - rtw_list_insert_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); + if (list_empty(&ptxservq->tx_pending)) + list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); - rtw_list_insert_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); + list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); ptxservq->qcnt++; phwxmits[ac_index].accnt++; exit: -_func_exit_; return res; } @@ -1714,7 +1634,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter) pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; - pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); + pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL); hwxmits = pxmitpriv->hwxmits; @@ -1745,136 +1665,8 @@ void rtw_free_hwxmits(struct adapter *padapter) void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry) { int i; -_func_enter_; for (i = 0; i < entry; i++, phwxmit++) phwxmit->accnt = 0; -_func_exit_; -} - -static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - unsigned long irql; - int res, is_vlan_tag = 0, i, do_nat25 = 1; - unsigned short vlan_hdr = 0; - void *br_port = NULL; - - rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) - br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); -#else - br_port = rcu_dereference(padapter->pnetdev->br_port); -#endif - rcu_read_unlock(); - _enter_critical_bh(&padapter->br_ext_lock, &irql); - 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); - padapter->scdb_entry->ageing_timer = jiffies; - _exit_critical_bh(&padapter->br_ext_lock, &irql); - } else { - if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_8021Q)) { - is_vlan_tag = 1; - vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*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)); - skb_pull(skb, 4); - } - if (!memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) && - (*((__be16 *)(skb->data+MACADDRLEN*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)) { - padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter, - skb->data+MACADDRLEN, skb->data+WLAN_ETHHDR_LEN+12); - if (padapter->scdb_entry) { - memcpy(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN); - memcpy(padapter->scdb_ip, skb->data+WLAN_ETHHDR_LEN+12, 4); - padapter->scdb_entry->ageing_timer = jiffies; - do_nat25 = 0; - } - } else { - if (padapter->scdb_entry) { - padapter->scdb_entry->ageing_timer = jiffies; - do_nat25 = 0; - } else { - memset(padapter->scdb_mac, 0, MACADDRLEN); - memset(padapter->scdb_ip, 0, 4); - } - } - } - _exit_critical_bh(&padapter->br_ext_lock, &irql); - if (do_nat25) { - if (nat25_db_handle(padapter, skb, NAT25_CHECK) == 0) { - struct sk_buff *newskb; - - if (is_vlan_tag) { - 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; - } - - newskb = skb_copy(skb, GFP_ATOMIC); - if (newskb == NULL) { - DEBUG_ERR("TX DROP: skb_copy fail!\n"); - return -1; - } - dev_kfree_skb_any(skb); - - *pskb = skb = newskb; - if (is_vlan_tag) { - vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*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)); - skb_pull(skb, 4); - } - } - - if (skb_is_nonlinear(skb)) - DEBUG_ERR("%s(): skb_is_nonlinear!!\n", __func__); - - res = skb_linearize(skb); - if (res < 0) { - DEBUG_ERR("TX DROP: skb_linearize fail!\n"); - return -1; - } - - res = nat25_db_handle(padapter, skb, NAT25_INSERT); - if (res < 0) { - if (res == -2) { - DEBUG_ERR("TX DROP: nat25_db_handle fail!\n"); - return -1; - } - return 0; - } - } - - memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); - - dhcp_flag_bcast(padapter, skb); - - if (is_vlan_tag) { - 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; - } - } - - /* check if SA is equal to our MAC */ - if (memcmp(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) { - 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; - } - return 0; } u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe) @@ -1934,13 +1726,8 @@ static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib */ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) { -#ifdef CONFIG_88EU_AP_MODE - unsigned long irql0; -#endif struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_frame *pxmitframe = NULL; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - void *br_port = NULL; s32 res; pxmitframe = rtw_alloc_xmitframe(pxmitpriv); @@ -1950,22 +1737,6 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) return -1; } - rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) - br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); -#else - br_port = rcu_dereference(padapter->pnetdev->br_port); -#endif - rcu_read_unlock(); - - if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { - res = rtw_br_client_tx(padapter, ppkt); - if (res == -1) { - rtw_free_xmitframe(pxmitpriv, pxmitframe); - return -1; - } - } - res = update_attrib(padapter, *ppkt, &pxmitframe->attrib); if (res == _FAIL) { @@ -1980,12 +1751,12 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) do_queue_select(padapter, &pxmitframe->attrib); #ifdef CONFIG_88EU_AP_MODE - _enter_critical_bh(&pxmitpriv->lock, &irql0); + spin_lock_bh(&pxmitpriv->lock); if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) { - _exit_critical_bh(&pxmitpriv->lock, &irql0); + spin_unlock_bh(&pxmitpriv->lock); return 1; } - _exit_critical_bh(&pxmitpriv->lock, &irql0); + spin_unlock_bh(&pxmitpriv->lock); #endif if (rtw_hal_xmit(padapter, pxmitframe) == false) @@ -1998,7 +1769,6 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe) { - unsigned long irql; int ret = false; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -2024,37 +1794,37 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra } if (bmcst) { - _enter_critical_bh(&psta->sleep_q.lock, &irql); + spin_lock_bh(&psta->sleep_q.lock); if (pstapriv->sta_dz_bitmap) {/* if any one sta is in ps mode */ - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); - rtw_list_insert_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); + list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); psta->sleepq_len++; pstapriv->tim_bitmap |= BIT(0);/* */ pstapriv->sta_dz_bitmap |= BIT(0); - update_beacon(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */ + update_beacon(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after update bcn */ ret = true; } - _exit_critical_bh(&psta->sleep_q.lock, &irql); + spin_unlock_bh(&psta->sleep_q.lock); return ret; } - _enter_critical_bh(&psta->sleep_q.lock, &irql); + spin_lock_bh(&psta->sleep_q.lock); if (psta->state&WIFI_SLEEP_STATE) { u8 wmmps_ac = 0; if (pstapriv->sta_dz_bitmap&BIT(psta->aid)) { - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); - rtw_list_insert_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); + list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); psta->sleepq_len++; @@ -2086,7 +1856,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra pstapriv->tim_bitmap |= BIT(psta->aid); if (psta->sleepq_len == 1) { - /* upate BCN for TIM IE */ + /* update BCN for TIM IE */ update_beacon(padapter, _TIM_IE_, NULL, false); } } @@ -2094,7 +1864,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra } } - _exit_critical_bh(&psta->sleep_q.lock, &irql); + spin_unlock_bh(&psta->sleep_q.lock); return ret; } @@ -2109,12 +1879,12 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; phead = get_list_head(pframequeue); - plist = get_next(phead); + plist = phead->next; - while (!rtw_end_of_queue_search(phead, plist)) { - pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + while (phead != plist) { + pxmitframe = container_of(plist, struct xmit_frame, list); - plist = get_next(plist); + plist = plist->next; xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe); @@ -2129,7 +1899,6 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) { - unsigned long irql0; struct sta_info *psta_bmc; struct sta_xmit_priv *pstaxmitpriv; struct sta_priv *pstapriv = &padapter->stapriv; @@ -2140,52 +1909,51 @@ void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) /* for BC/MC Frames */ psta_bmc = rtw_get_bcmc_stainfo(padapter); - _enter_critical_bh(&pxmitpriv->lock, &irql0); + spin_lock_bh(&pxmitpriv->lock); psta->state |= WIFI_SLEEP_STATE; pstapriv->sta_dz_bitmap |= BIT(psta->aid); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->vo_q.tx_pending)); + list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->vi_q.tx_pending)); + list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&(pstaxmitpriv->be_q.tx_pending)); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->bk_q.tx_pending)); + list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); /* for BC/MC Frames */ pstaxmitpriv = &psta_bmc->sta_xmitpriv; dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending); - rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&(pstaxmitpriv->be_q.tx_pending)); - _exit_critical_bh(&pxmitpriv->lock, &irql0); + spin_unlock_bh(&pxmitpriv->lock); } void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) { - unsigned long irql; u8 update_mask = 0, wmmps_ac = 0; struct sta_info *psta_bmc; struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - _enter_critical_bh(&psta->sleep_q.lock, &irql); + spin_lock_bh(&psta->sleep_q.lock); xmitframe_phead = get_list_head(&psta->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; - while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); switch (pxmitframe->attrib.priority) { case 1: @@ -2226,10 +1994,10 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; - _exit_critical_bh(&psta->sleep_q.lock, &irql); + spin_unlock_bh(&psta->sleep_q.lock); if (rtw_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); - _enter_critical_bh(&psta->sleep_q.lock, &irql); + spin_lock_bh(&psta->sleep_q.lock); } if (psta->sleepq_len == 0) { @@ -2248,7 +2016,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); } - _exit_critical_bh(&psta->sleep_q.lock, &irql); + spin_unlock_bh(&psta->sleep_q.lock); /* for BC/MC Frames */ psta_bmc = rtw_get_bcmc_stainfo(padapter); @@ -2256,17 +2024,17 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) return; if ((pstapriv->sta_dz_bitmap&0xfffe) == 0x0) { /* no any sta in ps mode */ - _enter_critical_bh(&psta_bmc->sleep_q.lock, &irql); + spin_lock_bh(&psta_bmc->sleep_q.lock); xmitframe_phead = get_list_head(&psta_bmc->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; - while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); psta_bmc->sleepq_len--; if (psta_bmc->sleepq_len > 0) @@ -2276,10 +2044,10 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; - _exit_critical_bh(&psta_bmc->sleep_q.lock, &irql); + spin_unlock_bh(&psta_bmc->sleep_q.lock); if (rtw_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); - _enter_critical_bh(&psta_bmc->sleep_q.lock, &irql); + spin_lock_bh(&psta_bmc->sleep_q.lock); } if (psta_bmc->sleepq_len == 0) { @@ -2289,7 +2057,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) update_mask |= BIT(1); } - _exit_critical_bh(&psta_bmc->sleep_q.lock, &irql); + spin_unlock_bh(&psta_bmc->sleep_q.lock); } if (update_mask) @@ -2298,21 +2066,20 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta) { - unsigned long irql; u8 wmmps_ac = 0; struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - _enter_critical_bh(&psta->sleep_q.lock, &irql); + spin_lock_bh(&psta->sleep_q.lock); xmitframe_phead = get_list_head(&psta->sleep_q); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; - while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + xmitframe_plist = xmitframe_plist->next; switch (pxmitframe->attrib.priority) { case 1: @@ -2337,7 +2104,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst if (!wmmps_ac) continue; - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); psta->sleepq_len--; psta->sleepq_ac_len--; @@ -2358,12 +2125,12 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { pstapriv->tim_bitmap &= ~BIT(psta->aid); - /* upate BCN for TIM IE */ + /* update BCN for TIM IE */ update_beacon(padapter, _TIM_IE_, NULL, false); } } - _exit_critical_bh(&psta->sleep_q.lock, &irql); + spin_unlock_bh(&psta->sleep_q.lock); } #endif @@ -2371,7 +2138,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms) { sctx->timeout_ms = timeout_ms; - sctx->submit_time = rtw_get_current_time(); + sctx->submit_time = jiffies; init_completion(&sctx->done); sctx->status = RTW_SCTX_SUBMITTED; } @@ -2432,7 +2199,7 @@ int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms) { struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; - pack_tx_ops->submit_time = rtw_get_current_time(); + pack_tx_ops->submit_time = jiffies; pack_tx_ops->timeout_ms = timeout_ms; pack_tx_ops->status = RTW_SCTX_SUBMITTED; diff --git a/hal/Hal8188ERateAdaptive.c b/hal/Hal8188ERateAdaptive.c index aaa2617..3c651d5 100644 --- a/hal/Hal8188ERateAdaptive.c +++ b/hal/Hal8188ERateAdaptive.c @@ -331,6 +331,7 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) { /* Wilson 2011/10/26 */ + struct adapter *adapt = dm_odm->Adapter; u32 MaskFromReg; s8 i; @@ -357,19 +358,19 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0000000d; break; case 12: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR0); + MaskFromReg = usb_read32(adapt, REG_ARFR0); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; case 13: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR1); + MaskFromReg = usb_read32(adapt, REG_ARFR1); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; case 14: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR2); + MaskFromReg = usb_read32(adapt, REG_ARFR2); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; case 15: - MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR3); + MaskFromReg = usb_read32(adapt, REG_ARFR3); pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; break; default: @@ -529,9 +530,7 @@ ODM_RASupport_Init( { ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n")); - /* 2012/02/14 MH Be noticed, the init must be after IC type is recognized!!!!! */ - if (dm_odm->SupportICType == ODM_RTL8188E) - dm_odm->RaSupport88E = true; + dm_odm->RaSupport88E = true; } int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) @@ -669,7 +668,9 @@ void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime) { - ODM_Write2Byte(dm_odm, REG_TX_RPT_TIME, minRptTime); + struct adapter *adapt = dm_odm->Adapter; + + usb_write16(adapt, REG_TX_RPT_TIME, minRptTime); } void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 TxRPT_Len, u32 macid_entry0, u32 macid_entry1) diff --git a/hal/HalHWImg8188E_MAC.c b/hal/HalHWImg8188E_MAC.c deleted file mode 100644 index b49b5ab..0000000 --- a/hal/HalHWImg8188E_MAC.c +++ /dev/null @@ -1,231 +0,0 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ - -#include "odm_precomp.h" -#include - -static bool Checkcondition(const u32 condition, const u32 hex) -{ - u32 _board = (hex & 0x000000FF); - u32 _interface = (hex & 0x0000FF00) >> 8; - u32 _platform = (hex & 0x00FF0000) >> 16; - u32 cond = condition; - - if (condition == 0xCDCDCDCD) - return true; - - cond = condition & 0x000000FF; - if ((_board == cond) && cond != 0x00) - return false; - - cond = condition & 0x0000FF00; - cond = cond >> 8; - if ((_interface & cond) == 0 && cond != 0x07) - return false; - - cond = condition & 0x00FF0000; - cond = cond >> 16; - if ((_platform & cond) == 0 && cond != 0x0F) - return false; - return true; -} - - -/****************************************************************************** -* MAC_REG.TXT -******************************************************************************/ - -static u32 array_MAC_REG_8188E[] = { - 0x026, 0x00000041, - 0x027, 0x00000035, - 0x428, 0x0000000A, - 0x429, 0x00000010, - 0x430, 0x00000000, - 0x431, 0x00000001, - 0x432, 0x00000002, - 0x433, 0x00000004, - 0x434, 0x00000005, - 0x435, 0x00000006, - 0x436, 0x00000007, - 0x437, 0x00000008, - 0x438, 0x00000000, - 0x439, 0x00000000, - 0x43A, 0x00000001, - 0x43B, 0x00000002, - 0x43C, 0x00000004, - 0x43D, 0x00000005, - 0x43E, 0x00000006, - 0x43F, 0x00000007, - 0x440, 0x0000005D, - 0x441, 0x00000001, - 0x442, 0x00000000, - 0x444, 0x00000015, - 0x445, 0x000000F0, - 0x446, 0x0000000F, - 0x447, 0x00000000, - 0x458, 0x00000041, - 0x459, 0x000000A8, - 0x45A, 0x00000072, - 0x45B, 0x000000B9, - 0x460, 0x00000066, - 0x461, 0x00000066, - 0x480, 0x00000008, - 0x4C8, 0x000000FF, - 0x4C9, 0x00000008, - 0x4CC, 0x000000FF, - 0x4CD, 0x000000FF, - 0x4CE, 0x00000001, - 0x4D3, 0x00000001, - 0x500, 0x00000026, - 0x501, 0x000000A2, - 0x502, 0x0000002F, - 0x503, 0x00000000, - 0x504, 0x00000028, - 0x505, 0x000000A3, - 0x506, 0x0000005E, - 0x507, 0x00000000, - 0x508, 0x0000002B, - 0x509, 0x000000A4, - 0x50A, 0x0000005E, - 0x50B, 0x00000000, - 0x50C, 0x0000004F, - 0x50D, 0x000000A4, - 0x50E, 0x00000000, - 0x50F, 0x00000000, - 0x512, 0x0000001C, - 0x514, 0x0000000A, - 0x516, 0x0000000A, - 0x525, 0x0000004F, - 0x550, 0x00000010, - 0x551, 0x00000010, - 0x559, 0x00000002, - 0x55D, 0x000000FF, - 0x605, 0x00000030, - 0x608, 0x0000000E, - 0x609, 0x0000002A, - 0x620, 0x000000FF, - 0x621, 0x000000FF, - 0x622, 0x000000FF, - 0x623, 0x000000FF, - 0x624, 0x000000FF, - 0x625, 0x000000FF, - 0x626, 0x000000FF, - 0x627, 0x000000FF, - 0x652, 0x00000020, - 0x63C, 0x0000000A, - 0x63D, 0x0000000A, - 0x63E, 0x0000000E, - 0x63F, 0x0000000E, - 0x640, 0x00000040, - 0x66E, 0x00000005, - 0x700, 0x00000021, - 0x701, 0x00000043, - 0x702, 0x00000065, - 0x703, 0x00000087, - 0x708, 0x00000021, - 0x709, 0x00000043, - 0x70A, 0x00000065, - 0x70B, 0x00000087, -}; - -enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) -{ - #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i+1]; } while (0) - - u32 hex = 0; - u32 i; - u8 platform = dm_odm->SupportPlatform; - u8 interface_val = dm_odm->SupportInterface; - u8 board = dm_odm->BoardType; - u32 array_len = sizeof(array_MAC_REG_8188E)/sizeof(u32); - u32 *array = array_MAC_REG_8188E; - bool biol = false; - - struct adapter *adapt = dm_odm->Adapter; - struct xmit_frame *pxmit_frame = NULL; - u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; - hex += board; - hex += interface_val << 8; - hex += platform << 16; - hex += 0xFF000000; - - biol = rtw_IOL_applied(adapt); - - if (biol) { - pxmit_frame = rtw_IOL_accquire_xmit_frame(adapt); - if (pxmit_frame == NULL) { - pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; - } - } - - for (i = 0; i < array_len; i += 2) { - u32 v1 = array[i]; - u32 v2 = array[i+1]; - - /* This (offset, data) pair meets the condition. */ - if (v1 < 0xCDCDCDCD) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF); - } else { - odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2); - } - continue; - } else { /* This line is the start line of branch. */ - if (!Checkcondition(array[i], hex)) { - /* Discard the following (offset, data) pairs. */ - READ_NEXT_PAIR(v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < array_len - 2) { - READ_NEXT_PAIR(v1, v2, i); - } - i -= 2; /* prevent from for-loop += 2 */ - } else { /* Configure matched pairs and skip to end of if-else. */ - READ_NEXT_PAIR(v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < array_len - 2) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF); - } else { - odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2); - } - - READ_NEXT_PAIR(v1, v2, i); - } - while (v2 != 0xDEAD && i < array_len - 2) - READ_NEXT_PAIR(v1, v2, i); - } - } - } - if (biol) { - if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { - pr_info("~~~ MAC IOL_exec_cmds Failed !!!\n"); - rst = HAL_STATUS_FAILURE; - } - } - return rst; -} diff --git a/hal/HalHWImg8188E_RF.c b/hal/HalHWImg8188E_RF.c deleted file mode 100644 index 480c810..0000000 --- a/hal/HalHWImg8188E_RF.c +++ /dev/null @@ -1,269 +0,0 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ - -#include "odm_precomp.h" - -#include - -static bool CheckCondition(const u32 Condition, const u32 Hex) -{ - u32 _board = (Hex & 0x000000FF); - u32 _interface = (Hex & 0x0000FF00) >> 8; - u32 _platform = (Hex & 0x00FF0000) >> 16; - u32 cond = Condition; - - if (Condition == 0xCDCDCDCD) - return true; - - cond = Condition & 0x000000FF; - if ((_board == cond) && cond != 0x00) - return false; - - cond = Condition & 0x0000FF00; - cond = cond >> 8; - if ((_interface & cond) == 0 && cond != 0x07) - return false; - - cond = Condition & 0x00FF0000; - cond = cond >> 16; - if ((_platform & cond) == 0 && cond != 0x0F) - return false; - return true; -} - - -/****************************************************************************** -* RadioA_1T.TXT -******************************************************************************/ - -static u32 Array_RadioA_1T_8188E[] = { - 0x000, 0x00030000, - 0x008, 0x00084000, - 0x018, 0x00000407, - 0x019, 0x00000012, - 0x01E, 0x00080009, - 0x01F, 0x00000880, - 0x02F, 0x0001A060, - 0x03F, 0x00000000, - 0x042, 0x000060C0, - 0x057, 0x000D0000, - 0x058, 0x000BE180, - 0x067, 0x00001552, - 0x083, 0x00000000, - 0x0B0, 0x000FF8FC, - 0x0B1, 0x00054400, - 0x0B2, 0x000CCC19, - 0x0B4, 0x00043003, - 0x0B6, 0x0004953E, - 0x0B7, 0x0001C718, - 0x0B8, 0x000060FF, - 0x0B9, 0x00080001, - 0x0BA, 0x00040000, - 0x0BB, 0x00000400, - 0x0BF, 0x000C0000, - 0x0C2, 0x00002400, - 0x0C3, 0x00000009, - 0x0C4, 0x00040C91, - 0x0C5, 0x00099999, - 0x0C6, 0x000000A3, - 0x0C7, 0x00088820, - 0x0C8, 0x00076C06, - 0x0C9, 0x00000000, - 0x0CA, 0x00080000, - 0x0DF, 0x00000180, - 0x0EF, 0x000001A0, - 0x051, 0x0006B27D, - 0xFF0F041F, 0xABCD, - 0x052, 0x0007E4DD, - 0xCDCDCDCD, 0xCDCD, - 0x052, 0x0007E49D, - 0xFF0F041F, 0xDEAD, - 0x053, 0x00000073, - 0x056, 0x00051FF3, - 0x035, 0x00000086, - 0x035, 0x00000186, - 0x035, 0x00000286, - 0x036, 0x00001C25, - 0x036, 0x00009C25, - 0x036, 0x00011C25, - 0x036, 0x00019C25, - 0x0B6, 0x00048538, - 0x018, 0x00000C07, - 0x05A, 0x0004BD00, - 0x019, 0x000739D0, - 0x034, 0x0000ADF3, - 0x034, 0x00009DF0, - 0x034, 0x00008DED, - 0x034, 0x00007DEA, - 0x034, 0x00006DE7, - 0x034, 0x000054EE, - 0x034, 0x000044EB, - 0x034, 0x000034E8, - 0x034, 0x0000246B, - 0x034, 0x00001468, - 0x034, 0x0000006D, - 0x000, 0x00030159, - 0x084, 0x00068200, - 0x086, 0x000000CE, - 0x087, 0x00048A00, - 0x08E, 0x00065540, - 0x08F, 0x00088000, - 0x0EF, 0x000020A0, - 0x03B, 0x000F02B0, - 0x03B, 0x000EF7B0, - 0x03B, 0x000D4FB0, - 0x03B, 0x000CF060, - 0x03B, 0x000B0090, - 0x03B, 0x000A0080, - 0x03B, 0x00090080, - 0x03B, 0x0008F780, - 0x03B, 0x000722B0, - 0x03B, 0x0006F7B0, - 0x03B, 0x00054FB0, - 0x03B, 0x0004F060, - 0x03B, 0x00030090, - 0x03B, 0x00020080, - 0x03B, 0x00010080, - 0x03B, 0x0000F780, - 0x0EF, 0x000000A0, - 0x000, 0x00010159, - 0x018, 0x0000F407, - 0xFFE, 0x00000000, - 0xFFE, 0x00000000, - 0x01F, 0x00080003, - 0xFFE, 0x00000000, - 0xFFE, 0x00000000, - 0x01E, 0x00000001, - 0x01F, 0x00080000, - 0x000, 0x00033E60, -}; - -enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) -{ - #define READ_NEXT_PAIR(v1, v2, i) do \ - { i += 2; v1 = Array[i]; \ - v2 = Array[i+1]; } while (0) - - u32 hex = 0; - u32 i = 0; - u8 platform = pDM_Odm->SupportPlatform; - u8 interfaceValue = pDM_Odm->SupportInterface; - u8 board = pDM_Odm->BoardType; - u32 ArrayLen = sizeof(Array_RadioA_1T_8188E)/sizeof(u32); - u32 *Array = Array_RadioA_1T_8188E; - bool biol = false; - struct adapter *Adapter = pDM_Odm->Adapter; - struct xmit_frame *pxmit_frame = NULL; - u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; - - hex += board; - hex += interfaceValue << 8; - hex += platform << 16; - hex += 0xFF000000; - biol = rtw_IOL_applied(Adapter); - - if (biol) { - pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter); - if (pxmit_frame == NULL) { - pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; - } - } - - for (i = 0; i < ArrayLen; i += 2) { - u32 v1 = Array[i]; - u32 v2 = Array[i+1]; - - /* This (offset, data) pair meets the condition. */ - if (v1 < 0xCDCDCDCD) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - - if (v1 == 0xffe) - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); - else if (v1 == 0xfd) - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); - else if (v1 == 0xfc) - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); - else if (v1 == 0xfb) - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); - else if (v1 == 0xfa) - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); - else if (v1 == 0xf9) - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); - else - rtw_IOL_append_WRF_cmd(pxmit_frame, ODM_RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask); - } else { - odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2); - } - continue; - } else { /* This line is the start line of branch. */ - if (!CheckCondition(Array[i], hex)) { - /* Discard the following (offset, data) pairs. */ - READ_NEXT_PAIR(v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < ArrayLen - 2) - READ_NEXT_PAIR(v1, v2, i); - i -= 2; /* prevent from for-loop += 2 */ - } else { /* Configure matched pairs and skip to end of if-else. */ - READ_NEXT_PAIR(v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < ArrayLen - 2) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - - if (v1 == 0xffe) - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); - else if (v1 == 0xfd) - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); - else if (v1 == 0xfc) - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); - else if (v1 == 0xfb) - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); - else if (v1 == 0xfa) - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); - else if (v1 == 0xf9) - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); - else - rtw_IOL_append_WRF_cmd(pxmit_frame, ODM_RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask); - } else { - odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2); - } - READ_NEXT_PAIR(v1, v2, i); - } - - while (v2 != 0xDEAD && i < ArrayLen - 2) - READ_NEXT_PAIR(v1, v2, i); - } - } - } - if (biol) { - if (!rtw_IOL_exec_cmds_sync(pDM_Odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { - rst = HAL_STATUS_FAILURE; - pr_info("~~~ IOL Config %s Failed !!!\n", __func__); - } - } - return rst; -} diff --git a/hal/HalPhyRf.c b/hal/HalPhyRf.c deleted file mode 100644 index 980f7da..0000000 --- a/hal/HalPhyRf.c +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - - #include "odm_precomp.h" - -/* 3============================================================ */ -/* 3 IQ Calibration */ -/* 3============================================================ */ - -void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm) -{ -} - -u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) -{ - u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, - 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, - 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, - 155, 157, 159, 161, 163, 165 - }; - u8 place = chnl; - - if (chnl > 14) { - for (place = 14; place < sizeof(channel_all); place++) { - if (channel_all[place] == chnl) - return place-13; - } - } - return 0; -} diff --git a/hal/HalPhyRf_8188e.c b/hal/HalPhyRf_8188e.c deleted file mode 100644 index 8a7947d..0000000 --- a/hal/HalPhyRf_8188e.c +++ /dev/null @@ -1,1505 +0,0 @@ - -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -#include "odm_precomp.h" - -/*---------------------------Define Local Constant---------------------------*/ -/* 2010/04/25 MH Define the max tx power tracking tx agc power. */ -#define ODM_TXPWRTRACK_MAX_IDX_88E 6 - -/*---------------------------Define Local Constant---------------------------*/ - -/* 3============================================================ */ -/* 3 Tx Power Tracking */ -/* 3============================================================ */ -/*----------------------------------------------------------------------------- - * Function: ODM_TxPwrTrackAdjust88E() - * - * Overview: 88E we can not write 0xc80/c94/c4c/ 0xa2x. Instead of write TX agc. - * No matter OFDM & CCK use the same method. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 04/23/2012 MHC Create Version 0. - * 04/23/2012 MHC Adjust TX agc directly not throughput BB digital. - * - *---------------------------------------------------------------------------*/ -void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, 1 = CCK */ - u8 *pDirection, /* 1 = +(increase) 2 = -(decrease) */ - u32 *pOutWriteVal /* Tx tracking CCK/OFDM BB swing index adjust */ - ) -{ - u8 pwr_value = 0; - /* Tx power tracking BB swing table. */ - /* The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ - if (Type == 0) { /* For OFDM afjust */ - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", - dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); - - if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) { - *pDirection = 1; - pwr_value = (dm_odm->BbSwingIdxOfdmBase - dm_odm->BbSwingIdxOfdm); - } else { - *pDirection = 2; - pwr_value = (dm_odm->BbSwingIdxOfdm - dm_odm->BbSwingIdxOfdmBase); - } - - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", - dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); - } else if (Type == 1) { /* For CCK adjust. */ - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("dm_odm->BbSwingIdxCck = %d dm_odm->BbSwingIdxCckBase = %d\n", - dm_odm->BbSwingIdxCck, dm_odm->BbSwingIdxCckBase)); - - if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) { - *pDirection = 1; - pwr_value = (dm_odm->BbSwingIdxCckBase - dm_odm->BbSwingIdxCck); - } else { - *pDirection = 2; - pwr_value = (dm_odm->BbSwingIdxCck - dm_odm->BbSwingIdxCckBase); - } - } - - /* */ - /* 2012/04/25 MH According to Ed/Luke.Lees estimate for EVM the max tx power tracking */ - /* need to be less than 6 power index for 88E. */ - /* */ - if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *pDirection == 1) - pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E; - - *pOutWriteVal = pwr_value | (pwr_value<<8) | (pwr_value<<16) | (pwr_value<<24); -} /* ODM_TxPwrTrackAdjust88E */ - -/*----------------------------------------------------------------------------- - * Function: odm_TxPwrTrackSetPwr88E() - * - * Overview: 88E change all channel tx power accordign to flag. - * OFDM & CCK are all different. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 04/23/2012 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ -static void odm_TxPwrTrackSetPwr88E(struct odm_dm_struct *dm_odm) -{ - if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) { - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("odm_TxPwrTrackSetPwr88E CH=%d\n", *(dm_odm->pChannel))); - PHY_SetTxPowerLevel8188E(dm_odm->Adapter, *(dm_odm->pChannel)); - dm_odm->BbSwingFlagOfdm = false; - dm_odm->BbSwingFlagCck = false; - } -} /* odm_TxPwrTrackSetPwr88E */ - -/* 091212 chiyokolin */ -void -odm_TXPowerTrackingCallback_ThermalMeter_8188E( - struct adapter *Adapter - ) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, offset; - u8 ThermalValue_AVG_count = 0; - u32 ThermalValue_AVG = 0; - s32 ele_A = 0, ele_D, TempCCk, X, value32; - s32 Y, ele_C = 0; - s8 OFDM_index[2], CCK_index = 0; - s8 OFDM_index_old[2] = {0, 0}, CCK_index_old = 0; - u32 i = 0, j = 0; - bool is2t = false; - - u8 OFDM_min_index = 6, rf; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */ - u8 Indexforchannel = 0/*GetRightChnlPlaceforIQK(pHalData->CurrentChannel)*/; - s8 OFDM_index_mapping[2][index_mapping_NUM_88E] = { - {0, 0, 2, 3, 4, 4, /* 2.4G, decrease power */ - 5, 6, 7, 7, 8, 9, - 10, 10, 11}, /* For lower temperature, 20120220 updated on 20120220. */ - {0, 0, -1, -2, -3, -4, /* 2.4G, increase power */ - -4, -4, -4, -5, -7, -8, - -9, -9, -10}, - }; - u8 Thermal_mapping[2][index_mapping_NUM_88E] = { - {0, 2, 4, 6, 8, 10, /* 2.4G, decrease power */ - 12, 14, 16, 18, 20, 22, - 24, 26, 27}, - {0, 2, 4, 6, 8, 10, /* 2.4G,, increase power */ - 12, 14, 16, 18, 20, 22, - 25, 25, 25}, - }; - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - /* 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. */ - odm_TxPwrTrackSetPwr88E(dm_odm); - - dm_odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; /* cosa add for debug */ - dm_odm->RFCalibrateInfo.bTXPowerTrackingInit = true; - - /* RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. */ - dm_odm->RFCalibrateInfo.RegA24 = 0x090e1317; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("===>dm_TXPowerTrackingCallback_ThermalMeter_8188E txpowercontrol %d\n", - dm_odm->RFCalibrateInfo.TxPowerTrackControl)); - - ThermalValue = (u8)ODM_GetRFReg(dm_odm, RF_PATH_A, RF_T_METER_88E, 0xfc00); /* 0x42: RF Reg[15:10] 88E */ - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", - ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, pHalData->EEPROMThermalMeter)); - - if (is2t) - rf = 2; - else - rf = 1; - - if (ThermalValue) { - /* Query OFDM path A default setting */ - ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord)&bMaskOFDM_D; - for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ - if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { - OFDM_index_old[0] = (u8)i; - dm_odm->BbSwingIdxOfdmBase = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial pathA ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", - rOFDM0_XATxIQImbalance, ele_D, OFDM_index_old[0])); - break; - } - } - - /* Query OFDM path B default setting */ - if (is2t) { - ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord)&bMaskOFDM_D; - for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ - if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { - OFDM_index_old[1] = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial pathB ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", - rOFDM0_XBTxIQImbalance, ele_D, OFDM_index_old[1])); - break; - } - } - } - - /* Query CCK default setting From 0xa24 */ - TempCCk = dm_odm->RFCalibrateInfo.RegA24; - - for (i = 0; i < CCK_TABLE_SIZE; i++) { - if (dm_odm->RFCalibrateInfo.bCCKinCH14) { - if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4) == 0) { - CCK_index_old = (u8)i; - dm_odm->BbSwingIdxCckBase = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch 14 %d\n", - rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); - break; - } - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("RegA24: 0x%X, CCKSwingTable_Ch1_Ch13[%d][2]: CCKSwingTable_Ch1_Ch13[i][2]: 0x%X\n", - TempCCk, i, CCKSwingTable_Ch1_Ch13[i][2])); - if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4) == 0) { - CCK_index_old = (u8)i; - dm_odm->BbSwingIdxCckBase = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch14 %d\n", - rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); - break; - } - } - } - - if (!dm_odm->RFCalibrateInfo.ThermalValue) { - dm_odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter; - dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; - dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; - - for (i = 0; i < rf; i++) - dm_odm->RFCalibrateInfo.OFDM_index[i] = OFDM_index_old[i]; - dm_odm->RFCalibrateInfo.CCK_index = CCK_index_old; - } - - if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("reload ofdm index for band switch\n")); - - /* calculate average thermal meter */ - dm_odm->RFCalibrateInfo.ThermalValue_AVG[dm_odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue; - dm_odm->RFCalibrateInfo.ThermalValue_AVG_index++; - if (dm_odm->RFCalibrateInfo.ThermalValue_AVG_index == AVG_THERMAL_NUM_88E) - dm_odm->RFCalibrateInfo.ThermalValue_AVG_index = 0; - - for (i = 0; i < AVG_THERMAL_NUM_88E; i++) { - if (dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]) { - ThermalValue_AVG += dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]; - ThermalValue_AVG_count++; - } - } - - if (ThermalValue_AVG_count) { - ThermalValue = (u8)(ThermalValue_AVG / ThermalValue_AVG_count); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("AVG Thermal Meter = 0x%x\n", ThermalValue)); - } - - if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { - delta = ThermalValue > pHalData->EEPROMThermalMeter ? - (ThermalValue - pHalData->EEPROMThermalMeter) : - (pHalData->EEPROMThermalMeter - ThermalValue); - dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false; - dm_odm->RFCalibrateInfo.bDoneTxpower = false; - } else if (dm_odm->RFCalibrateInfo.bDoneTxpower) { - delta = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue) ? - (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue) : - (dm_odm->RFCalibrateInfo.ThermalValue - ThermalValue); - } else { - delta = ThermalValue > pHalData->EEPROMThermalMeter ? - (ThermalValue - pHalData->EEPROMThermalMeter) : - (pHalData->EEPROMThermalMeter - ThermalValue); - } - delta_LCK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_LCK) ? - (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_LCK) : - (dm_odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue); - delta_IQK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_IQK) ? - (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_IQK) : - (dm_odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x delta 0x%x delta_LCK 0x%x delta_IQK 0x%x\n", - ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, - pHalData->EEPROMThermalMeter, delta, delta_LCK, delta_IQK)); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("pre thermal meter LCK 0x%x pre thermal meter IQK 0x%x delta_LCK_bound 0x%x delta_IQK_bound 0x%x\n", - dm_odm->RFCalibrateInfo.ThermalValue_LCK, - dm_odm->RFCalibrateInfo.ThermalValue_IQK, - dm_odm->RFCalibrateInfo.Delta_LCK, - dm_odm->RFCalibrateInfo.Delta_IQK)); - - if ((delta_LCK >= 8)) { /* Delta temperature is equal to or larger than 20 centigrade. */ - dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; - PHY_LCCalibrate_8188E(Adapter); - } - - if (delta > 0 && dm_odm->RFCalibrateInfo.TxPowerTrackControl) { - delta = ThermalValue > pHalData->EEPROMThermalMeter ? - (ThermalValue - pHalData->EEPROMThermalMeter) : - (pHalData->EEPROMThermalMeter - ThermalValue); - /* calculate new OFDM / CCK offset */ - if (ThermalValue > pHalData->EEPROMThermalMeter) - j = 1; - else - j = 0; - for (offset = 0; offset < index_mapping_NUM_88E; offset++) { - if (delta < Thermal_mapping[j][offset]) { - if (offset != 0) - offset--; - break; - } - } - if (offset >= index_mapping_NUM_88E) - offset = index_mapping_NUM_88E-1; - for (i = 0; i < rf; i++) - OFDM_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + OFDM_index_mapping[j][offset]; - CCK_index = dm_odm->RFCalibrateInfo.CCK_index + OFDM_index_mapping[j][offset]; - - if (is2t) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("temp OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", - dm_odm->RFCalibrateInfo.OFDM_index[0], - dm_odm->RFCalibrateInfo.OFDM_index[1], - dm_odm->RFCalibrateInfo.CCK_index)); - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("temp OFDM_A_index=0x%x, CCK_index=0x%x\n", - dm_odm->RFCalibrateInfo.OFDM_index[0], - dm_odm->RFCalibrateInfo.CCK_index)); - } - - for (i = 0; i < rf; i++) { - if (OFDM_index[i] > OFDM_TABLE_SIZE_92D-1) - OFDM_index[i] = OFDM_TABLE_SIZE_92D-1; - else if (OFDM_index[i] < OFDM_min_index) - OFDM_index[i] = OFDM_min_index; - } - - if (CCK_index > CCK_TABLE_SIZE-1) - CCK_index = CCK_TABLE_SIZE-1; - else if (CCK_index < 0) - CCK_index = 0; - - if (is2t) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("new OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", - OFDM_index[0], OFDM_index[1], CCK_index)); - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("new OFDM_A_index=0x%x, CCK_index=0x%x\n", - OFDM_index[0], CCK_index)); - } - - /* 2 temporarily remove bNOPG */ - /* Config by SwingTable */ - if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) { - dm_odm->RFCalibrateInfo.bDoneTxpower = true; - - /* Adujst OFDM Ant_A according to IQK result */ - ele_D = (OFDMSwingTable[(u8)OFDM_index[0]] & 0xFFC00000)>>22; - X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][0]; - Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][1]; - - /* Revse TX power table. */ - dm_odm->BbSwingIdxOfdm = (u8)OFDM_index[0]; - dm_odm->BbSwingIdxCck = (u8)CCK_index; - - if (dm_odm->BbSwingIdxOfdmCurrent != dm_odm->BbSwingIdxOfdm) { - dm_odm->BbSwingIdxOfdmCurrent = dm_odm->BbSwingIdxOfdm; - dm_odm->BbSwingFlagOfdm = true; - } - - if (dm_odm->BbSwingIdxCckCurrent != dm_odm->BbSwingIdxCck) { - dm_odm->BbSwingIdxCckCurrent = dm_odm->BbSwingIdxCck; - dm_odm->BbSwingFlagCck = true; - } - - if (X != 0) { - if ((X & 0x00000200) != 0) - X = X | 0xFFFFFC00; - ele_A = ((X * ele_D)>>8)&0x000003FF; - - /* new element C = element D x Y */ - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - ele_C = ((Y * ele_D)>>8)&0x000003FF; - - /* 2012/04/23 MH According to Luke's suggestion, we can not write BB digital */ - /* to increase TX power. Otherwise, EVM will be bad. */ - } - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("TxPwrTracking for path A: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xe94=0x%x 0xe9c=0x%x\n", - (u32)X, (u32)Y, (u32)ele_A, (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); - - if (is2t) { - ele_D = (OFDMSwingTable[(u8)OFDM_index[1]] & 0xFFC00000)>>22; - - /* new element A = element D x X */ - X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][4]; - Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][5]; - - if ((X != 0) && (*(dm_odm->pBandType) == ODM_BAND_2_4G)) { - if ((X & 0x00000200) != 0) /* consider minus */ - X = X | 0xFFFFFC00; - ele_A = ((X * ele_D)>>8)&0x000003FF; - - /* new element C = element D x Y */ - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - ele_C = ((Y * ele_D)>>8)&0x00003FF; - - /* wtite new elements A, C, D to regC88 and regC9C, element B is always 0 */ - value32 = (ele_D<<22) | ((ele_C&0x3F)<<16) | ele_A; - ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, value32); - - value32 = (ele_C&0x000003C0)>>6; - ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, value32); - - value32 = ((X * ele_D)>>7)&0x01; - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, value32); - } else { - ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable[(u8)OFDM_index[1]]); - ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, 0x00); - } - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("TxPwrTracking path B: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xeb4=0x%x 0xebc=0x%x\n", - (u32)X, (u32)Y, (u32)ele_A, - (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); - } - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("TxPwrTracking 0xc80 = 0x%x, 0xc94 = 0x%x RF 0x24 = 0x%x\n", - ODM_GetBBReg(dm_odm, 0xc80, bMaskDWord), ODM_GetBBReg(dm_odm, - 0xc94, bMaskDWord), ODM_GetRFReg(dm_odm, RF_PATH_A, 0x24, bRFRegOffsetMask))); - } - } - - if (delta_IQK >= 8) { /* Delta temperature is equal to or larger than 20 centigrade. */ - ODM_ResetIQKResult(dm_odm); - - dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; - PHY_IQCalibrate_8188E(Adapter, false); - } - /* update thermal meter value */ - if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) - dm_odm->RFCalibrateInfo.ThermalValue = ThermalValue; - } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("<===dm_TXPowerTrackingCallback_ThermalMeter_8188E\n")); - dm_odm->RFCalibrateInfo.TXPowercount = 0; -} - -/* 1 7. IQK */ -#define MAX_TOLERANCE 5 -#define IQK_DELAY_TIME 1 /* ms */ - -static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) -{ - u32 regeac, regE94, regE9C, regEA4; - u8 result = 0x00; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK!\n")); - - /* 1 Tx IQK */ - /* path-A IQK setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A IQK setting!\n")); - ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); - ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); - ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x8214032a); - ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); - - /* LO calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); - ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x00462911); - - /* One shot, path A LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); - ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); - ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - - /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); - /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ - ODM_delay_ms(IQK_DELAY_TIME_88E); - - /* Check failed */ - regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); - regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); - regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); - regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); - - if (!(regeac & BIT28) && - (((regE94 & 0x03FF0000)>>16) != 0x142) && - (((regE9C & 0x03FF0000)>>16) != 0x42)) - result |= 0x01; - return result; -} - -static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) -{ - u32 regeac, regE94, regE9C, regEA4, u4tmp; - u8 result = 0x00; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK!\n")); - - /* 1 Get TXIMR setting */ - /* modify RXIQK mode table */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table!\n")); - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf117B); - - /* PA,PAD off */ - ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x980); - ODM_SetRFReg(dm_odm, RF_PATH_A, 0x56, bRFRegOffsetMask, 0x51000); - - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); - - /* IQK setting */ - ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, 0x01007c00); - ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x81004800); - - /* path-A IQK setting */ - ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); - ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); - ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x82160c1f); - ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); - - /* LO calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); - ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); - - /* One shot, path A LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); - ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); - ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - - /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Delay %d ms for One shot, path A LOK & IQK.\n", - IQK_DELAY_TIME_88E)); - ODM_delay_ms(IQK_DELAY_TIME_88E); - - /* Check failed */ - regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xeac = 0x%x\n", regeac)); - regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xe94 = 0x%x\n", regE94)); - regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xe9c = 0x%x\n", regE9C)); - - if (!(regeac & BIT28) && - (((regE94 & 0x03FF0000)>>16) != 0x142) && - (((regE9C & 0x03FF0000)>>16) != 0x42)) - result |= 0x01; - else /* if Tx not OK, ignore Rx */ - return result; - - u4tmp = 0x80007C00 | (regE94&0x3FF0000) | ((regE9C&0x3FF0000) >> 16); - ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, u4tmp); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe40 = 0x%x u4tmp = 0x%x\n", ODM_GetBBReg(dm_odm, rTx_IQK, bMaskDWord), u4tmp)); - - /* 1 RX IQK */ - /* modify RXIQK mode table */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table 2!\n")); - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7ffa); - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); - - /* IQK setting */ - ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x01004800); - - /* path-A IQK setting */ - ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x38008c1c); - ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x18008c1c); - ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x82160c05); - ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160c1f); - - /* LO calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); - ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); - - /* One shot, path A LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); - ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); - ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - - /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); - /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ - ODM_delay_ms(IQK_DELAY_TIME_88E); - - /* Check failed */ - regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); - regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); - regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); - regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); - - /* reload RF 0xdf */ - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); - ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x180); - - if (!(regeac & BIT27) && /* if Tx is OK, check whether Rx is OK */ - (((regEA4 & 0x03FF0000)>>16) != 0x132) && - (((regeac & 0x03FF0000)>>16) != 0x36)) - result |= 0x02; - else - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK fail!!\n")); - - return result; -} - -static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -phy_PathB_IQK_8188E(struct adapter *adapt) -{ - u32 regeac, regeb4, regebc, regec4, regecc; - u8 result = 0x00; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK!\n")); - - /* One shot, path B LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); - ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000002); - ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000000); - - /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Delay %d ms for One shot, path B LOK & IQK.\n", - IQK_DELAY_TIME_88E)); - ODM_delay_ms(IQK_DELAY_TIME_88E); - - /* Check failed */ - regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xeac = 0x%x\n", regeac)); - regeb4 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xeb4 = 0x%x\n", regeb4)); - regebc = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xebc = 0x%x\n", regebc)); - regec4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xec4 = 0x%x\n", regec4)); - regecc = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xecc = 0x%x\n", regecc)); - - if (!(regeac & BIT31) && - (((regeb4 & 0x03FF0000)>>16) != 0x142) && - (((regebc & 0x03FF0000)>>16) != 0x42)) - result |= 0x01; - else - return result; - - if (!(regeac & BIT30) && - (((regec4 & 0x03FF0000)>>16) != 0x132) && - (((regecc & 0x03FF0000)>>16) != 0x36)) - result |= 0x02; - else - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK fail!!\n")); - return result; -} - -static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly) -{ - u32 Oldval_0, X, TX0_A, reg; - s32 Y, TX0_C; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Path A IQ Calibration %s !\n", - (iqkok) ? "Success" : "Failed")); - - if (final_candidate == 0xFF) { - return; - } else if (iqkok) { - Oldval_0 = (ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF; - - X = result[final_candidate][0]; - if ((X & 0x00000200) != 0) - X = X | 0xFFFFFC00; - TX0_A = (X * Oldval_0) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("X = 0x%x, TX0_A = 0x%x, Oldval_0 0x%x\n", - X, TX0_A, Oldval_0)); - ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A); - - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0>>7) & 0x1)); - - Y = result[final_candidate][1]; - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - - TX0_C = (Y * Oldval_0) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX = 0x%x\n", Y, TX0_C)); - ODM_SetBBReg(dm_odm, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C&0x3C0)>>6)); - ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C&0x3F)); - - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0>>7) & 0x1)); - - if (txonly) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("patha_fill_iqk only Tx OK\n")); - return; - } - - reg = result[final_candidate][2]; - ODM_SetBBReg(dm_odm, rOFDM0_XARxIQImbalance, 0x3FF, reg); - - reg = result[final_candidate][3] & 0x3F; - ODM_SetBBReg(dm_odm, rOFDM0_XARxIQImbalance, 0xFC00, reg); - - reg = (result[final_candidate][3] >> 6) & 0xF; - ODM_SetBBReg(dm_odm, rOFDM0_RxIQExtAnta, 0xF0000000, reg); - } -} - -static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly) -{ - u32 Oldval_1, X, TX1_A, reg; - s32 Y, TX1_C; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Path B IQ Calibration %s !\n", - (iqkok) ? "Success" : "Failed")); - - if (final_candidate == 0xFF) { - return; - } else if (iqkok) { - Oldval_1 = (ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF; - - X = result[final_candidate][4]; - if ((X & 0x00000200) != 0) - X = X | 0xFFFFFC00; - TX1_A = (X * Oldval_1) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("X = 0x%x, TX1_A = 0x%x\n", X, TX1_A)); - ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A); - - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1>>7) & 0x1)); - - Y = result[final_candidate][5]; - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - - TX1_C = (Y * Oldval_1) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX1_C = 0x%x\n", Y, TX1_C)); - ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C&0x3C0)>>6)); - ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C&0x3F)); - - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(25), ((Y * Oldval_1>>7) & 0x1)); - - if (txonly) - return; - - reg = result[final_candidate][6]; - ODM_SetBBReg(dm_odm, rOFDM0_XBRxIQImbalance, 0x3FF, reg); - - reg = result[final_candidate][7] & 0x3F; - ODM_SetBBReg(dm_odm, rOFDM0_XBRxIQImbalance, 0xFC00, reg); - - reg = (result[final_candidate][7] >> 6) & 0xF; - ODM_SetBBReg(dm_odm, rOFDM0_AGCRSSITable, 0x0000F000, reg); - } -} - -/* */ -/* 2011/07/26 MH Add an API for testing IQK fail case. */ -/* */ -/* MP Already declare in odm.c */ -static bool ODM_CheckPowerStatus(struct adapter *Adapter) -{ - return true; -} - -void _PHY_SaveADDARegisters(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegisterNum) -{ - u32 i; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - if (!ODM_CheckPowerStatus(adapt)) - return; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save ADDA parameters.\n")); - for (i = 0; i < RegisterNum; i++) { - ADDABackup[i] = ODM_GetBBReg(dm_odm, ADDAReg[i], bMaskDWord); - } -} - -static void _PHY_SaveMACRegisters( - struct adapter *adapt, - u32 *MACReg, - u32 *MACBackup - ) -{ - u32 i; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save MAC parameters.\n")); - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { - MACBackup[i] = ODM_Read1Byte(dm_odm, MACReg[i]); - } - MACBackup[i] = ODM_Read4Byte(dm_odm, MACReg[i]); -} - -static void reload_adda_reg(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegiesterNum) -{ - u32 i; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload ADDA power saving parameters !\n")); - for (i = 0; i < RegiesterNum; i++) - ODM_SetBBReg(dm_odm, ADDAReg[i], bMaskDWord, ADDABackup[i]); -} - -static void -_PHY_ReloadMACRegisters( - struct adapter *adapt, - u32 *MACReg, - u32 *MACBackup - ) -{ - u32 i; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload MAC parameters !\n")); - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { - ODM_Write1Byte(dm_odm, MACReg[i], (u8)MACBackup[i]); - } - ODM_Write4Byte(dm_odm, MACReg[i], MACBackup[i]); -} - -void -_PHY_PathADDAOn( - struct adapter *adapt, - u32 *ADDAReg, - bool isPathAOn, - bool is2t - ) -{ - u32 pathOn; - u32 i; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n")); - - pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4; - if (!is2t) { - pathOn = 0x0bdb25a0; - ODM_SetBBReg(dm_odm, ADDAReg[0], bMaskDWord, 0x0b1b25a0); - } else { - ODM_SetBBReg(dm_odm, ADDAReg[0], bMaskDWord, pathOn); - } - - for (i = 1; i < IQK_ADDA_REG_NUM; i++) - ODM_SetBBReg(dm_odm, ADDAReg[i], bMaskDWord, pathOn); -} - -void -_PHY_MACSettingCalibration( - struct adapter *adapt, - u32 *MACReg, - u32 *MACBackup - ) -{ - u32 i = 0; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n")); - - ODM_Write1Byte(dm_odm, MACReg[i], 0x3F); - - for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT3))); - } - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT5))); -} - -void -_PHY_PathAStandBy( - struct adapter *adapt - ) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A standby mode!\n")); - - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x0); - ODM_SetBBReg(dm_odm, 0x840, bMaskDWord, 0x00010000); - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); -} - -static void _PHY_PIModeSwitch( - struct adapter *adapt, - bool PIMode - ) -{ - u32 mode; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("BB Switch to %s mode!\n", (PIMode ? "PI" : "SI"))); - - mode = PIMode ? 0x01000100 : 0x01000000; - ODM_SetBBReg(dm_odm, rFPGA0_XA_HSSIParameter1, bMaskDWord, mode); - ODM_SetBBReg(dm_odm, rFPGA0_XB_HSSIParameter1, bMaskDWord, mode); -} - -static bool phy_SimularityCompare_8188E( - struct adapter *adapt, - s32 resulta[][8], - u8 c1, - u8 c2 - ) -{ - u32 i, j, diff, sim_bitmap, bound = 0; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ - bool result = true; - bool is2t; - s32 tmp1 = 0, tmp2 = 0; - - if ((dm_odm->RFType == ODM_2T2R) || (dm_odm->RFType == ODM_2T3R) || (dm_odm->RFType == ODM_2T4R)) - is2t = true; - else - is2t = false; - - if (is2t) - bound = 8; - else - bound = 4; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("===> IQK:phy_SimularityCompare_8188E c1 %d c2 %d!!!\n", c1, c2)); - - sim_bitmap = 0; - - for (i = 0; i < bound; i++) { - if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) { - if ((resulta[c1][i] & 0x00000200) != 0) - tmp1 = resulta[c1][i] | 0xFFFFFC00; - else - tmp1 = resulta[c1][i]; - - if ((resulta[c2][i] & 0x00000200) != 0) - tmp2 = resulta[c2][i] | 0xFFFFFC00; - else - tmp2 = resulta[c2][i]; - } else { - tmp1 = resulta[c1][i]; - tmp2 = resulta[c2][i]; - } - - diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); - - if (diff > MAX_TOLERANCE) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK:phy_SimularityCompare_8188E differnece overflow index %d compare1 0x%x compare2 0x%x!!!\n", - i, resulta[c1][i], resulta[c2][i])); - - if ((i == 2 || i == 6) && !sim_bitmap) { - if (resulta[c1][i] + resulta[c1][i+1] == 0) - final_candidate[(i/4)] = c2; - else if (resulta[c2][i] + resulta[c2][i+1] == 0) - final_candidate[(i/4)] = c1; - else - sim_bitmap = sim_bitmap | (1<odmpriv; - u32 i; - u8 PathAOK, PathBOK; - u32 ADDA_REG[IQK_ADDA_REG_NUM] = { - rFPGA0_XCD_SwitchControl, rBlue_Tooth, - rRx_Wait_CCA, rTx_CCK_RFON, - rTx_CCK_BBON, rTx_OFDM_RFON, - rTx_OFDM_BBON, rTx_To_Rx, - rTx_To_Tx, rRx_CCK, - rRx_OFDM, rRx_Wait_RIFS, - rRx_TO_Rx, rStandby, - rSleep, rPMPD_ANAEN }; - u32 IQK_MAC_REG[IQK_MAC_REG_NUM] = { - REG_TXPAUSE, REG_BCN_CTRL, - REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; - - /* since 92C & 92D have the different define in IQK_BB_REG */ - u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { - rOFDM0_TRxPathEnable, rOFDM0_TRMuxPar, - rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB, - rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, - rFPGA0_XB_RFInterfaceOE, rFPGA0_RFMOD - }; - - u32 retryCount = 9; - if (*(dm_odm->mp_mode) == 1) - retryCount = 9; - else - retryCount = 2; - /* Note: IQ calibration must be performed after loading */ - /* PHY_REG.txt , and radio_a, radio_b.txt */ - - if (t == 0) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); - - /* Save ADDA parameters, turn Path A ADDA on */ - _PHY_SaveADDARegisters(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); - _PHY_SaveMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); - _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); - } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); - - _PHY_PathADDAOn(adapt, ADDA_REG, true, is2t); - if (t == 0) - dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)ODM_GetBBReg(dm_odm, rFPGA0_XA_HSSIParameter1, BIT(8)); - - if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { - /* Switch BB to PI mode to do IQ Calibration. */ - _PHY_PIModeSwitch(adapt, true); - } - - /* BB setting */ - ODM_SetBBReg(dm_odm, rFPGA0_RFMOD, BIT24, 0x00); - ODM_SetBBReg(dm_odm, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); - ODM_SetBBReg(dm_odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); - ODM_SetBBReg(dm_odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); - - ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT10, 0x01); - ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT26, 0x01); - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT10, 0x00); - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT10, 0x00); - - if (is2t) { - ODM_SetBBReg(dm_odm, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00010000); - ODM_SetBBReg(dm_odm, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00010000); - } - - /* MAC settings */ - _PHY_MACSettingCalibration(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); - - /* Page B init */ - /* AP or IQK */ - ODM_SetBBReg(dm_odm, rConfig_AntA, bMaskDWord, 0x0f600000); - - if (is2t) - ODM_SetBBReg(dm_odm, rConfig_AntB, bMaskDWord, 0x0f600000); - - /* IQ calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK setting!\n")); - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); - ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, 0x01007c00); - ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x81004800); - - for (i = 0; i < retryCount; i++) { - PathAOK = phy_PathA_IQK_8188E(adapt, is2t); - if (PathAOK == 0x01) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Tx IQK Success!!\n")); - result[t][0] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; - result[t][1] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; - break; - } - } - - for (i = 0; i < retryCount; i++) { - PathAOK = phy_PathA_RxIQK(adapt, is2t); - if (PathAOK == 0x03) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Success!!\n")); - result[t][2] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; - result[t][3] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; - break; - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Fail!!\n")); - } - } - - if (0x00 == PathAOK) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK failed!!\n")); - } - - if (is2t) { - _PHY_PathAStandBy(adapt); - - /* Turn Path B ADDA on */ - _PHY_PathADDAOn(adapt, ADDA_REG, false, is2t); - - for (i = 0; i < retryCount; i++) { - PathBOK = phy_PathB_IQK_8188E(adapt); - if (PathBOK == 0x03) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK Success!!\n")); - result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][6] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; - result[t][7] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; - break; - } else if (i == (retryCount - 1) && PathBOK == 0x01) { /* Tx IQK OK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Only Tx IQK Success!!\n")); - result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; - } - } - - if (0x00 == PathBOK) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK failed!!\n")); - } - } - - /* Back to BB mode, load original value */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Back to BB mode, load original value!\n")); - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0); - - if (t != 0) { - if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { - /* Switch back BB to SI mode after finish IQ Calibration. */ - _PHY_PIModeSwitch(adapt, false); - } - - /* Reload ADDA power saving parameters */ - reload_adda_reg(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); - - /* Reload MAC parameters */ - _PHY_ReloadMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); - - reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); - - /* Restore RX initial gain */ - ODM_SetBBReg(dm_odm, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00032ed3); - if (is2t) - ODM_SetBBReg(dm_odm, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00032ed3); - - /* load 0xe30 IQC default value */ - ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); - ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); - } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_IQCalibrate_8188E() <==\n")); -} - -static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) -{ - u8 tmpreg; - u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - /* Check continuous TX and Packet TX */ - tmpreg = ODM_Read1Byte(dm_odm, 0xd03); - - if ((tmpreg&0x70) != 0) /* Deal with contisuous TX case */ - ODM_Write1Byte(dm_odm, 0xd03, tmpreg&0x8F); /* disable all continuous TX */ - else /* Deal with Packet TX case */ - ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0xFF); /* block all queues */ - - if ((tmpreg&0x70) != 0) { - /* 1. Read original RF mode */ - /* Path-A */ - RF_Amode = PHY_QueryRFReg(adapt, RF_PATH_A, RF_AC, bMask12Bits); - - /* Path-B */ - if (is2t) - RF_Bmode = PHY_QueryRFReg(adapt, RF_PATH_B, RF_AC, bMask12Bits); - - /* 2. Set RF mode = standby mode */ - /* Path-A */ - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode&0x8FFFF)|0x10000); - - /* Path-B */ - if (is2t) - ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode&0x8FFFF)|0x10000); - } - - /* 3. Read RF reg18 */ - LC_Cal = PHY_QueryRFReg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits); - - /* 4. Set LC calibration begin bit15 */ - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal|0x08000); - - ODM_sleep_ms(100); - - /* Restore original situation */ - if ((tmpreg&0x70) != 0) { - /* Deal with continuous TX case */ - /* Path-A */ - ODM_Write1Byte(dm_odm, 0xd03, tmpreg); - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); - - /* Path-B */ - if (is2t) - ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); - } else { - /* Deal with Packet TX case */ - ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0x00); - } -} - -void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); - s32 result[4][8]; /* last is final result */ - u8 i, final_candidate, Indexforchannel; - bool pathaok, pathbok; - s32 RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC; - bool is12simular, is13simular, is23simular; - bool singletone = false, carrier_sup = false; - u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { - rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, - rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, - rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, - rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, - rOFDM0_RxIQExtAnta}; - bool is2t; - - is2t = (dm_odm->RFType == ODM_2T2R) ? true : false; - if (!ODM_CheckPowerStatus(adapt)) - return; - - if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) - return; - - if (*(dm_odm->mp_mode) == 1) { - singletone = pMptCtx->bSingleTone; - carrier_sup = pMptCtx->bCarrierSuppression; - } - - /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ - if (singletone || carrier_sup) - return; - - if (recovery) { - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("PHY_IQCalibrate_8188E: Return due to recovery!\n")); - reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); - return; - } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Start!!!\n")); - - for (i = 0; i < 8; i++) { - result[0][i] = 0; - result[1][i] = 0; - result[2][i] = 0; - if ((i == 0) || (i == 2) || (i == 4) || (i == 6)) - result[3][i] = 0x100; - else - result[3][i] = 0; - } - final_candidate = 0xff; - pathaok = false; - pathbok = false; - is12simular = false; - is23simular = false; - is13simular = false; - - for (i = 0; i < 3; i++) { - phy_IQCalibrate_8188E(adapt, result, i, is2t); - - if (i == 1) { - is12simular = phy_SimularityCompare_8188E(adapt, result, 0, 1); - if (is12simular) { - final_candidate = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is12simular final_candidate is %x\n", final_candidate)); - break; - } - } - - if (i == 2) { - is13simular = phy_SimularityCompare_8188E(adapt, result, 0, 2); - if (is13simular) { - final_candidate = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is13simular final_candidate is %x\n", final_candidate)); - - break; - } - is23simular = phy_SimularityCompare_8188E(adapt, result, 1, 2); - if (is23simular) { - final_candidate = 1; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is23simular final_candidate is %x\n", final_candidate)); - } else { - final_candidate = 3; - } - } - } - - for (i = 0; i < 4; i++) { - RegE94 = result[i][0]; - RegE9C = result[i][1]; - RegEA4 = result[i][2]; - RegEAC = result[i][3]; - RegEB4 = result[i][4]; - RegEBC = result[i][5]; - RegEC4 = result[i][6]; - RegECC = result[i][7]; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", - RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); - } - - if (final_candidate != 0xff) { - RegE94 = result[final_candidate][0]; - RegE9C = result[final_candidate][1]; - RegEA4 = result[final_candidate][2]; - RegEAC = result[final_candidate][3]; - RegEB4 = result[final_candidate][4]; - RegEBC = result[final_candidate][5]; - dm_odm->RFCalibrateInfo.RegE94 = RegE94; - dm_odm->RFCalibrateInfo.RegE9C = RegE9C; - dm_odm->RFCalibrateInfo.RegEB4 = RegEB4; - dm_odm->RFCalibrateInfo.RegEBC = RegEBC; - RegEC4 = result[final_candidate][6]; - RegECC = result[final_candidate][7]; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK: final_candidate is %x\n", final_candidate)); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", - RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); - pathaok = true; - pathbok = true; - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: FAIL use default value\n")); - dm_odm->RFCalibrateInfo.RegE94 = 0x100; - dm_odm->RFCalibrateInfo.RegEB4 = 0x100; /* X default value */ - dm_odm->RFCalibrateInfo.RegE9C = 0x0; - dm_odm->RFCalibrateInfo.RegEBC = 0x0; /* Y default value */ - } - if (RegE94 != 0) - patha_fill_iqk(adapt, pathaok, result, final_candidate, (RegEA4 == 0)); - if (is2t) { - if (RegEB4 != 0) - pathb_fill_iqk(adapt, pathbok, result, final_candidate, (RegEC4 == 0)); - } - - Indexforchannel = ODM_GetRightChnlPlaceforIQK(pHalData->CurrentChannel); - -/* To Fix BSOD when final_candidate is 0xff */ -/* by sherry 20120321 */ - if (final_candidate < 4) { - for (i = 0; i < IQK_Matrix_REG_NUM; i++) - dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][i] = result[final_candidate][i]; - dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].bIQKDone = true; - } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("\nIQK OK Indexforchannel %d.\n", Indexforchannel)); - - _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK finished\n")); -} - -void PHY_LCCalibrate_8188E(struct adapter *adapt) -{ - bool singletone = false, carrier_sup = false; - u32 timeout = 2000, timecount = 0; - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); - - if (*(dm_odm->mp_mode) == 1) { - singletone = pMptCtx->bSingleTone; - carrier_sup = pMptCtx->bCarrierSuppression; - } - if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) - return; - /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ - if (singletone || carrier_sup) - return; - - while (*(dm_odm->pbScanInProcess) && timecount < timeout) { - ODM_delay_ms(50); - timecount += 50; - } - - dm_odm->RFCalibrateInfo.bLCKInProgress = true; - - if (dm_odm->RFType == ODM_2T2R) { - phy_LCCalibrate_8188E(adapt, true); - } else { - /* For 88C 1T1R */ - phy_LCCalibrate_8188E(adapt, false); - } - - dm_odm->RFCalibrateInfo.bLCKInProgress = false; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("LCK:Finish!!!interface %d\n", dm_odm->InterfaceIndex)); -} - -static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2t) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - if (!adapt->hw_init_completed) { - u8 u1btmp; - u1btmp = ODM_Read1Byte(dm_odm, REG_LEDCFG2) | BIT7; - ODM_Write1Byte(dm_odm, REG_LEDCFG2, u1btmp); - ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFParameter, BIT13, 0x01); - } - - if (is2t) { /* 92C */ - if (main) - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x1); /* 92C_Path_A */ - else - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x2); /* BT */ - } else { /* 88C */ - if (main) - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x2); /* Main */ - else - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x1); /* Aux */ - } -} - -void PHY_SetRFPathSwitch_8188E(struct adapter *adapt, bool main) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); - struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - - if (dm_odm->RFType == ODM_2T2R) { - phy_setrfpathswitch_8188e(adapt, main, true); - } else { - /* For 88C 1T1R */ - phy_setrfpathswitch_8188e(adapt, main, false); - } -} diff --git a/hal/HalHWImg8188E_BB.c b/hal/bb_cfg.c similarity index 54% rename from hal/HalHWImg8188E_BB.c rename to hal/bb_cfg.c index 787e8f1..1e963bf 100644 --- a/hal/HalHWImg8188E_BB.c +++ b/hal/bb_cfg.c @@ -20,7 +20,7 @@ #include "odm_precomp.h" -#include +#include #define read_next_pair(array, v1, v2, i) \ do { \ @@ -29,36 +29,8 @@ v2 = array[i+1]; \ } while (0) -static bool CheckCondition(const u32 condition, const u32 hex) -{ - u32 _board = (hex & 0x000000FF); - u32 _interface = (hex & 0x0000FF00) >> 8; - u32 _platform = (hex & 0x00FF0000) >> 16; - u32 cond = condition; - if (condition == 0xCDCDCDCD) - return true; - - cond = condition & 0x000000FF; - if ((_board == cond) && cond != 0x00) - return false; - - cond = condition & 0x0000FF00; - cond = cond >> 8; - if ((_interface & cond) == 0 && cond != 0x07) - return false; - - cond = condition & 0x00FF0000; - cond = cond >> 16; - if ((_platform & cond) == 0 && cond != 0x0F) - return false; - return true; -} - - -/****************************************************************************** -* AGC_TAB_1T.TXT -******************************************************************************/ +/* AGC_TAB_1T.TXT */ static u32 array_agc_tab_1t_8188e[] = { 0xC78, 0xFB000001, @@ -191,91 +163,25 @@ static u32 array_agc_tab_1t_8188e[] = { 0xC78, 0x407F0001, }; -enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) +static bool set_baseband_agc_config(struct adapter *adapt) { - u32 hex = 0; - u32 i = 0; - u8 platform = dm_odm->SupportPlatform; - u8 interfaceValue = dm_odm->SupportInterface; - u8 board = dm_odm->BoardType; - u32 arraylen = sizeof(array_agc_tab_1t_8188e)/sizeof(u32); - u32 *array = array_agc_tab_1t_8188e; - bool biol = false; - struct adapter *adapter = dm_odm->Adapter; - struct xmit_frame *pxmit_frame = NULL; - u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; - - hex += board; - hex += interfaceValue << 8; - hex += platform << 16; - hex += 0xFF000000; - biol = rtw_IOL_applied(adapter); - - if (biol) { - pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); - if (pxmit_frame == NULL) { - pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; - } - } + u32 i; + u32 arraylen = sizeof(array_agc_tab_1t_8188e)/sizeof(u32); + u32 *array = array_agc_tab_1t_8188e; for (i = 0; i < arraylen; i += 2) { u32 v1 = array[i]; u32 v2 = array[i+1]; - /* This (offset, data) pair meets the condition. */ if (v1 < 0xCDCDCDCD) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); - } else { - odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2); - } - continue; - } else { - /* This line is the start line of branch. */ - if (!CheckCondition(array[i], hex)) { - /* Discard the following (offset, data) pairs. */ - read_next_pair(array, v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < arraylen - 2) - read_next_pair(array, v1, v2, i); - i -= 2; /* prevent from for-loop += 2 */ - } else { /* Configure matched pairs and skip to end of if-else. */ - read_next_pair(array, v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < arraylen - 2) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); - } else { - odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2); - } - read_next_pair(array, v1, v2, i); - } - - while (v2 != 0xDEAD && i < arraylen - 2) - read_next_pair(array, v1, v2, i); - } + phy_set_bb_reg(adapt, v1, bMaskDWord, v2); + udelay(1); } } - if (biol) { - if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { - printk("~~~ %s IOL_exec_cmds Failed !!!\n", __func__); - rst = HAL_STATUS_FAILURE; - } - } - return rst; + return true; } -/****************************************************************************** -* PHY_REG_1T.TXT -******************************************************************************/ +/* PHY_REG_1T.TXT */ static u32 array_phy_reg_1t_8188e[] = { 0x800, 0x80040000, @@ -471,122 +377,44 @@ static u32 array_phy_reg_1t_8188e[] = { 0xF00, 0x00000300, }; -enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) +static void rtl_bb_delay(struct adapter *adapt, u32 addr, u32 data) { - u32 hex = 0; - u32 i = 0; - u8 platform = dm_odm->SupportPlatform; - u8 interfaceValue = dm_odm->SupportInterface; - u8 board = dm_odm->BoardType; - u32 arraylen = sizeof(array_phy_reg_1t_8188e)/sizeof(u32); - u32 *array = array_phy_reg_1t_8188e; - bool biol = false; - struct adapter *adapter = dm_odm->Adapter; - struct xmit_frame *pxmit_frame = NULL; - u8 bndy_cnt = 1; - enum HAL_STATUS rst = HAL_STATUS_SUCCESS; - hex += board; - hex += interfaceValue << 8; - hex += platform << 16; - hex += 0xFF000000; - biol = rtw_IOL_applied(adapter); - - if (biol) { - pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); - if (pxmit_frame == NULL) { - pr_info("rtw_IOL_accquire_xmit_frame failed\n"); - return HAL_STATUS_FAILURE; - } + if (addr == 0xfe) { + msleep(50); + } else if (addr == 0xfd) { + mdelay(5); + } else if (addr == 0xfc) { + mdelay(1); + } else if (addr == 0xfb) { + udelay(50); + } else if (addr == 0xfa) { + udelay(5); + } else if (addr == 0xf9) { + udelay(1); + } else { + phy_set_bb_reg(adapt, addr, bMaskDWord, data); + /* Add 1us delay between BB/RF register setting. */ + udelay(1); } +} + +static bool set_baseband_phy_config(struct adapter *adapt) +{ + u32 i; + u32 arraylen = sizeof(array_phy_reg_1t_8188e)/sizeof(u32); + u32 *array = array_phy_reg_1t_8188e; for (i = 0; i < arraylen; i += 2) { u32 v1 = array[i]; u32 v2 = array[i+1]; - /* This (offset, data) pair meets the condition. */ - if (v1 < 0xCDCDCDCD) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - if (v1 == 0xfe) { - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); - } else if (v1 == 0xfd) { - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); - } else if (v1 == 0xfc) { - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); - } else if (v1 == 0xfb) { - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); - } else if (v1 == 0xfa) { - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); - } else if (v1 == 0xf9) { - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); - } else { - if (v1 == 0xa24) - dm_odm->RFCalibrateInfo.RegA24 = v2; - rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); - } - } else { - odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2); - } - continue; - } else { /* This line is the start line of branch. */ - if (!CheckCondition(array[i], hex)) { - /* Discard the following (offset, data) pairs. */ - read_next_pair(array, v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < arraylen - 2) - read_next_pair(array, v1, v2, i); - i -= 2; /* prevent from for-loop += 2 */ - } else { /* Configure matched pairs and skip to end of if-else. */ - read_next_pair(array, v1, v2, i); - while (v2 != 0xDEAD && - v2 != 0xCDEF && - v2 != 0xCDCD && i < arraylen - 2) { - if (biol) { - if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) - bndy_cnt++; - if (v1 == 0xfe) { - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); - } else if (v1 == 0xfd) { - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); - } else if (v1 == 0xfc) { - rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); - } else if (v1 == 0xfb) { - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); - } else if (v1 == 0xfa) { - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); - } else if (v1 == 0xf9) { - rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); - } else{ - if (v1 == 0xa24) - dm_odm->RFCalibrateInfo.RegA24 = v2; - - rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); - } - } else { - odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2); - } - read_next_pair(array, v1, v2, i); - } - - while (v2 != 0xDEAD && i < arraylen - 2) - read_next_pair(array, v1, v2, i); - } - } + if (v1 < 0xCDCDCDCD) + rtl_bb_delay(adapt, v1, v2); } - if (biol) { - if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { - rst = HAL_STATUS_FAILURE; - pr_info("~~~ IOL Config %s Failed !!!\n", __func__); - } - } - return rst; + return true; } -/****************************************************************************** -* PHY_REG_PG.TXT -******************************************************************************/ +/* PHY_REG_PG.TXT */ static u32 array_phy_reg_pg_8188e[] = { 0xE00, 0xFFFFFFFF, 0x06070809, @@ -680,42 +508,208 @@ static u32 array_phy_reg_pg_8188e[] = { }; -void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm) +static void store_pwrindex_offset(struct adapter *Adapter, u32 regaddr, u32 bitmask, u32 data) { - u32 hex; - u32 i = 0; - u8 platform = dm_odm->SupportPlatform; - u8 interfaceValue = dm_odm->SupportInterface; - u8 board = dm_odm->BoardType; - u32 arraylen = sizeof(array_phy_reg_pg_8188e) / sizeof(u32); - u32 *array = array_phy_reg_pg_8188e; + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); - hex = board + (interfaceValue << 8); - hex += (platform << 16) + 0xFF000000; + if (regaddr == rTxAGC_A_Rate18_06) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][0] = data; + if (regaddr == rTxAGC_A_Rate54_24) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][1] = data; + if (regaddr == rTxAGC_A_CCK1_Mcs32) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][6] = data; + if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][7] = data; + if (regaddr == rTxAGC_A_Mcs03_Mcs00) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][2] = data; + if (regaddr == rTxAGC_A_Mcs07_Mcs04) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][3] = data; + if (regaddr == rTxAGC_A_Mcs11_Mcs08) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][4] = data; + if (regaddr == rTxAGC_A_Mcs15_Mcs12) { + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][5] = data; + if (hal_data->rf_type == RF_1T1R) + hal_data->pwrGroupCnt++; + } + if (regaddr == rTxAGC_B_Rate18_06) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][8] = data; + if (regaddr == rTxAGC_B_Rate54_24) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][9] = data; + if (regaddr == rTxAGC_B_CCK1_55_Mcs32) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][14] = data; + if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][15] = data; + if (regaddr == rTxAGC_B_Mcs03_Mcs00) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][10] = data; + if (regaddr == rTxAGC_B_Mcs07_Mcs04) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][11] = data; + if (regaddr == rTxAGC_B_Mcs11_Mcs08) + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][12] = data; + if (regaddr == rTxAGC_B_Mcs15_Mcs12) { + hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][13] = data; + if (hal_data->rf_type != RF_1T1R) + hal_data->pwrGroupCnt++; + } +} + +static void rtl_addr_delay(struct adapter *adapt, u32 addr, u32 bit_mask, u32 data) +{ + if (addr == 0xfe) { + msleep(50); + } else if (addr == 0xfd) { + mdelay(5); + } else if (addr == 0xfc) { + mdelay(1); + } else if (addr == 0xfb) { + udelay(50); + } else if (addr == 0xfa) { + udelay(5); + } else if (addr == 0xf9) { + udelay(1); + } else{ + store_pwrindex_offset(adapt, addr, bit_mask, data); + } +} + +static bool config_bb_with_pgheader(struct adapter *adapt) +{ + u32 i = 0; + u32 arraylen = sizeof(array_phy_reg_pg_8188e) / sizeof(u32); + u32 *array = array_phy_reg_pg_8188e; for (i = 0; i < arraylen; i += 3) { u32 v1 = array[i]; u32 v2 = array[i+1]; u32 v3 = array[i+2]; - /* this line is a line of pure_body */ - if (v1 < 0xCDCDCDCD) { - odm_ConfigBB_PHY_REG_PG_8188E(dm_odm, v1, v2, v3); - continue; - } else { /* this line is the start of branch */ - if (!CheckCondition(array[i], hex)) { - /* don't need the hw_body */ - i += 2; /* skip the pair of expression */ - v1 = array[i]; - v2 = array[i+1]; - v3 = array[i+2]; - while (v2 != 0xDEAD) { - i += 3; - v1 = array[i]; - v2 = array[i+1]; - v3 = array[i+1]; - } - } - } + if (v1 < 0xCDCDCDCD) + rtl_addr_delay(adapt, v1, v2, v3); } + return true; +} + +static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + + hal_data->PHYRegDef[RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; + hal_data->PHYRegDef[RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; + hal_data->PHYRegDef[RF_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW; + hal_data->PHYRegDef[RF_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW; + + hal_data->PHYRegDef[RF_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; + hal_data->PHYRegDef[RF_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB; + hal_data->PHYRegDef[RF_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB; + hal_data->PHYRegDef[RF_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB; + + hal_data->PHYRegDef[RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; + hal_data->PHYRegDef[RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; + + hal_data->PHYRegDef[RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; + hal_data->PHYRegDef[RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; + + hal_data->PHYRegDef[RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; + hal_data->PHYRegDef[RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; + + hal_data->PHYRegDef[RF_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; + hal_data->PHYRegDef[RF_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; + hal_data->PHYRegDef[RF_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; + hal_data->PHYRegDef[RF_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; + + hal_data->PHYRegDef[RF_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; + hal_data->PHYRegDef[RF_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; + hal_data->PHYRegDef[RF_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; + hal_data->PHYRegDef[RF_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; + + hal_data->PHYRegDef[RF_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; + hal_data->PHYRegDef[RF_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; + + hal_data->PHYRegDef[RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; + hal_data->PHYRegDef[RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; + + hal_data->PHYRegDef[RF_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; + hal_data->PHYRegDef[RF_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; + hal_data->PHYRegDef[RF_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; + hal_data->PHYRegDef[RF_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; + + hal_data->PHYRegDef[RF_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; + hal_data->PHYRegDef[RF_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; + hal_data->PHYRegDef[RF_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; + hal_data->PHYRegDef[RF_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; + + hal_data->PHYRegDef[RF_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; + hal_data->PHYRegDef[RF_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; + hal_data->PHYRegDef[RF_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; + hal_data->PHYRegDef[RF_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; + + hal_data->PHYRegDef[RF_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; + hal_data->PHYRegDef[RF_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; + hal_data->PHYRegDef[RF_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; + hal_data->PHYRegDef[RF_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; + + hal_data->PHYRegDef[RF_PATH_A].rfRxAFE = rOFDM0_XARxAFE; + hal_data->PHYRegDef[RF_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; + hal_data->PHYRegDef[RF_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; + hal_data->PHYRegDef[RF_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; + + hal_data->PHYRegDef[RF_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; + hal_data->PHYRegDef[RF_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; + hal_data->PHYRegDef[RF_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; + hal_data->PHYRegDef[RF_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; + + hal_data->PHYRegDef[RF_PATH_A].rfTxAFE = rOFDM0_XATxAFE; + hal_data->PHYRegDef[RF_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; + hal_data->PHYRegDef[RF_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; + hal_data->PHYRegDef[RF_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; + + hal_data->PHYRegDef[RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; + hal_data->PHYRegDef[RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; + hal_data->PHYRegDef[RF_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; + hal_data->PHYRegDef[RF_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; + + hal_data->PHYRegDef[RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; + hal_data->PHYRegDef[RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback; +} + +static bool config_parafile(struct adapter *adapt) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(adapt); + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + + set_baseband_phy_config(adapt); + + /* If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ + if (!pEEPROM->bautoload_fail_flag) { + hal_data->pwrGroupCnt = 0; + config_bb_with_pgheader(adapt); + } + set_baseband_agc_config(adapt); + return true; +} + +bool rtl88eu_phy_bb_config(struct adapter *adapt) +{ + int rtstatus = true; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u32 regval; + u8 crystal_cap; + + rtl88e_phy_init_bb_rf_register_definition(adapt); + + /* Enable BB and RF */ + regval = usb_read16(adapt, REG_SYS_FUNC_EN); + usb_write16(adapt, REG_SYS_FUNC_EN, (u16)(regval|BIT13|BIT0|BIT1)); + + usb_write8(adapt, REG_RF_CTRL, RF_EN|RF_RSTB|RF_SDMRSTB); + + usb_write8(adapt, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB); + + /* Config BB and AGC */ + rtstatus = config_parafile(adapt); + + /* write 0x24[16:11] = 0x24[22:17] = crystal_cap */ + crystal_cap = hal_data->CrystalCap & 0x3F; + phy_set_bb_reg(adapt, REG_AFE_XTAL_CTRL, 0x7ff800, (crystal_cap | (crystal_cap << 6))); + + return rtstatus; } diff --git a/hal/fw.c b/hal/fw.c new file mode 100644 index 0000000..3b28754 --- /dev/null +++ b/hal/fw.c @@ -0,0 +1,236 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2013 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "fw.h" +#include "drv_types.h" +#include "usb_ops_linux.h" +#include "rtl8188e_spec.h" +#include "rtl8188e_hal.h" + +#include +#include + +static void _rtl88e_enable_fw_download(struct adapter *adapt, bool enable) +{ + u8 tmp; + + if (enable) { + tmp = usb_read8(adapt, REG_MCUFWDL); + usb_write8(adapt, REG_MCUFWDL, tmp | 0x01); + + tmp = usb_read8(adapt, REG_MCUFWDL + 2); + usb_write8(adapt, REG_MCUFWDL + 2, tmp & 0xf7); + } else { + tmp = usb_read8(adapt, REG_MCUFWDL); + usb_write8(adapt, REG_MCUFWDL, tmp & 0xfe); + + usb_write8(adapt, REG_MCUFWDL + 1, 0x00); + } +} + +static void _rtl88e_fw_block_write(struct adapter *adapt, + const u8 *buffer, u32 size) +{ + u32 blk_sz = sizeof(u32); + u8 *buf_ptr = (u8 *)buffer; + u32 *pu4BytePtr = (u32 *)buffer; + u32 i, offset, blk_cnt, remain; + + blk_cnt = size / blk_sz; + remain = size % blk_sz; + + for (i = 0; i < blk_cnt; i++) { + offset = i * blk_sz; + usb_write32(adapt, (FW_8192C_START_ADDRESS + offset), + *(pu4BytePtr + i)); + } + + if (remain) { + offset = blk_cnt * blk_sz; + buf_ptr += offset; + for (i = 0; i < remain; i++) { + usb_write8(adapt, (FW_8192C_START_ADDRESS + + offset + i), *(buf_ptr + i)); + } + } +} + +static void _rtl88e_fill_dummy(u8 *pfwbuf, u32 *pfwlen) +{ + u32 fwlen = *pfwlen; + u8 remain = (u8)(fwlen % 4); + + remain = (remain == 0) ? 0 : (4 - remain); + + while (remain > 0) { + pfwbuf[fwlen] = 0; + fwlen++; + remain--; + } + + *pfwlen = fwlen; +} + +static void _rtl88e_fw_page_write(struct adapter *adapt, + u32 page, const u8 *buffer, u32 size) +{ + u8 value8; + u8 u8page = (u8)(page & 0x07); + + value8 = (usb_read8(adapt, REG_MCUFWDL + 2) & 0xF8) | u8page; + + usb_write8(adapt, (REG_MCUFWDL + 2), value8); + _rtl88e_fw_block_write(adapt, buffer, size); +} + +static void _rtl88e_write_fw(struct adapter *adapt, u8 *buffer, u32 size) +{ + u8 *buf_ptr = buffer; + u32 page_no, remain; + u32 page, offset; + + _rtl88e_fill_dummy(buf_ptr, &size); + + page_no = size / FW_8192C_PAGE_SIZE; + remain = size % FW_8192C_PAGE_SIZE; + + for (page = 0; page < page_no; page++) { + offset = page * FW_8192C_PAGE_SIZE; + _rtl88e_fw_page_write(adapt, page, (buf_ptr + offset), + FW_8192C_PAGE_SIZE); + } + + if (remain) { + offset = page_no * FW_8192C_PAGE_SIZE; + page = page_no; + _rtl88e_fw_page_write(adapt, page, (buf_ptr + offset), remain); + } +} + +static void rtl88e_firmware_selfreset(struct adapter *adapt) +{ + u8 u1b_tmp; + + u1b_tmp = usb_read8(adapt, REG_SYS_FUNC_EN+1); + usb_write8(adapt, REG_SYS_FUNC_EN+1, (u1b_tmp & (~BIT(2)))); + usb_write8(adapt, REG_SYS_FUNC_EN+1, (u1b_tmp | BIT(2))); +} + +static int _rtl88e_fw_free_to_go(struct adapter *adapt) +{ + int err = -EIO; + u32 counter = 0; + u32 value32; + + do { + value32 = usb_read32(adapt, REG_MCUFWDL); + if (value32 & FWDL_ChkSum_rpt) + break; + } while (counter++ < POLLING_READY_TIMEOUT_COUNT); + + if (counter >= POLLING_READY_TIMEOUT_COUNT) { + goto exit; + } + + value32 = usb_read32(adapt, REG_MCUFWDL); + value32 |= MCUFWDL_RDY; + value32 &= ~WINTINI_RDY; + usb_write32(adapt, REG_MCUFWDL, value32); + + rtl88e_firmware_selfreset(adapt); + counter = 0; + + do { + value32 = usb_read32(adapt, REG_MCUFWDL); + if (value32 & WINTINI_RDY) { + err = 0; + goto exit; + } + + udelay(FW_8192C_POLLING_DELAY); + + } while (counter++ < POLLING_READY_TIMEOUT_COUNT); + +exit: + return err; +} + +int rtl88eu_download_fw(struct adapter *adapt) +{ + struct hal_data_8188e *rtlhal = GET_HAL_DATA(adapt); + struct dvobj_priv *dvobj = adapter_to_dvobj(adapt); + struct device *device = dvobj_to_dev(dvobj); + const struct firmware *fw; + const char fw_name[] = "rtlwifi/rtl8188eufw.bin"; + struct rtl92c_firmware_header *pfwheader = NULL; + u8 *pfwdata; + u32 fwsize; + int err; + + if (request_firmware(&fw, fw_name, device)) { + dev_err(device, "Firmware %s not available\n", fw_name); + return -ENOENT; + } + + if (fw->size > FW_8188E_SIZE) { + dev_err(device, "Firmware size exceed 0x%X. Check it.\n", + FW_8188E_SIZE); + return -1; + } + + pfwdata = kzalloc(FW_8188E_SIZE, GFP_KERNEL); + if (!pfwdata) + return -ENOMEM; + + rtlhal->pfirmware = pfwdata; + memcpy(rtlhal->pfirmware, fw->data, fw->size); + rtlhal->fwsize = fw->size; + release_firmware(fw); + + fwsize = rtlhal->fwsize; + pfwheader = (struct rtl92c_firmware_header *)pfwdata; + + if (IS_FW_HEADER_EXIST(pfwheader)) { + pfwdata = pfwdata + 32; + fwsize = fwsize - 32; + } + + if (usb_read8(adapt, REG_MCUFWDL) & RAM_DL_SEL) { + usb_write8(adapt, REG_MCUFWDL, 0); + rtl88e_firmware_selfreset(adapt); + } + _rtl88e_enable_fw_download(adapt, true); + usb_write8(adapt, REG_MCUFWDL, usb_read8(adapt, REG_MCUFWDL) | FWDL_ChkSum_rpt); + _rtl88e_write_fw(adapt, pfwdata, fwsize); + _rtl88e_enable_fw_download(adapt, false); + + err = _rtl88e_fw_free_to_go(adapt); + + return err; +} diff --git a/hal/hal_com.c b/hal/hal_com.c index 829b900..170e3de 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -319,63 +319,3 @@ void hal_init_macaddr(struct adapter *adapter) rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR, adapter->eeprompriv.mac_addr); } - -/* -* C2H event format: -* Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID -* BITS [127:120] [119:16] [15:8] [7:4] [3:0] -*/ - -void c2h_evt_clear(struct adapter *adapter) -{ - rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); -} - -s32 c2h_evt_read(struct adapter *adapter, u8 *buf) -{ - s32 ret = _FAIL; - struct c2h_evt_hdr *c2h_evt; - int i; - u8 trigger; - - if (buf == NULL) - goto exit; - - trigger = rtw_read8(adapter, REG_C2HEVT_CLEAR); - - if (trigger == C2H_EVT_HOST_CLOSE) - goto exit; /* Not ready */ - else if (trigger != C2H_EVT_FW_CLOSE) - goto clear_evt; /* Not a valid value */ - - c2h_evt = (struct c2h_evt_hdr *)buf; - - _rtw_memset(c2h_evt, 0, 16); - - *buf = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL); - *(buf+1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); - - RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read(): ", - &c2h_evt , sizeof(c2h_evt)); - - /* Read the content */ - for (i = 0; i < c2h_evt->plen; i++) - c2h_evt->payload[i] = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + - sizeof(*c2h_evt) + i); - - RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, - "c2h_evt_read(): Command Content:\n", - c2h_evt->payload, c2h_evt->plen); - - ret = _SUCCESS; - -clear_evt: - /* - * Clear event to notify FW we have read the command. - * If this field isn't clear, the FW won't update the next - * command message. - */ - c2h_evt_clear(adapter); -exit: - return ret; -} diff --git a/hal/hal_intf.c b/hal/hal_intf.c index 5981404..538a0f6 100644 --- a/hal/hal_intf.c +++ b/hal/hal_intf.c @@ -60,13 +60,6 @@ void rtw_hal_dm_init(struct adapter *adapt) adapt->HalFunc.dm_init(adapt); } -void rtw_hal_dm_deinit(struct adapter *adapt) -{ - /* cancel dm timer */ - if (adapt->HalFunc.dm_deinit) - adapt->HalFunc.dm_deinit(adapt); -} - void rtw_hal_sw_led_init(struct adapter *adapt) { if (adapt->HalFunc.InitSwLeds) @@ -116,8 +109,6 @@ uint rtw_hal_deinit(struct adapter *adapt) { uint status = _SUCCESS; -_func_enter_; - status = adapt->HalFunc.hal_deinit(adapt); if (status == _SUCCESS) @@ -125,8 +116,6 @@ _func_enter_; else DBG_88E("\n rtw_hal_deinit: hal_init fail\n"); -_func_exit_; - return status; } @@ -167,15 +156,6 @@ void rtw_hal_set_odm_var(struct adapter *adapt, val1, set); } -void rtw_hal_get_odm_var(struct adapter *adapt, - enum hal_odm_variable var, void *val1, - bool set) -{ - if (adapt->HalFunc.GetHalODMVarHandler) - adapt->HalFunc.GetHalODMVarHandler(adapt, var, - val1, set); -} - void rtw_hal_enable_interrupt(struct adapter *adapt) { if (adapt->HalFunc.enable_interrupt) @@ -211,15 +191,6 @@ u32 rtw_hal_inirp_deinit(struct adapter *adapt) return _FAIL; } -u8 rtw_hal_intf_ps_func(struct adapter *adapt, - enum hal_intf_ps_func efunc_id, u8 *val) -{ - if (adapt->HalFunc.interface_ps_func) - return adapt->HalFunc.interface_ps_func(adapt, efunc_id, - val); - return _FAIL; -} - s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) { if (adapt->HalFunc.hal_xmit) @@ -243,12 +214,6 @@ s32 rtw_hal_init_xmit_priv(struct adapter *adapt) return _FAIL; } -void rtw_hal_free_xmit_priv(struct adapter *adapt) -{ - if (adapt->HalFunc.free_xmit_priv != NULL) - adapt->HalFunc.free_xmit_priv(adapt); -} - s32 rtw_hal_init_recv_priv(struct adapter *adapt) { if (adapt->HalFunc.init_recv_priv) @@ -291,36 +256,6 @@ void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, rssi_level); } -/* Start specifical interface thread */ -void rtw_hal_start_thread(struct adapter *adapt) -{ - if (adapt->HalFunc.run_thread) - adapt->HalFunc.run_thread(adapt); -} - -/* Start specifical interface thread */ -void rtw_hal_stop_thread(struct adapter *adapt) -{ - if (adapt->HalFunc.cancel_thread) - adapt->HalFunc.cancel_thread(adapt); -} - -u32 rtw_hal_read_bbreg(struct adapter *adapt, u32 regaddr, u32 bitmask) -{ - u32 data = 0; - - if (adapt->HalFunc.read_bbreg) - data = adapt->HalFunc.read_bbreg(adapt, regaddr, bitmask); - return data; -} - -void rtw_hal_write_bbreg(struct adapter *adapt, u32 regaddr, u32 bitmask, - u32 data) -{ - if (adapt->HalFunc.write_bbreg) - adapt->HalFunc.write_bbreg(adapt, regaddr, bitmask, data); -} - u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rfpath, u32 regaddr, u32 bitmask) { @@ -394,30 +329,6 @@ void rtw_hal_sreset_init(struct adapter *adapt) adapt->HalFunc.sreset_init_value(adapt); } -void rtw_hal_sreset_reset(struct adapter *adapt) -{ - if (adapt->HalFunc.silentreset) - adapt->HalFunc.silentreset(adapt); -} - -void rtw_hal_sreset_reset_value(struct adapter *adapt) -{ - if (adapt->HalFunc.sreset_reset_value) - adapt->HalFunc.sreset_reset_value(adapt); -} - -void rtw_hal_sreset_xmit_status_check(struct adapter *adapt) -{ - if (adapt->HalFunc.sreset_xmit_status_check) - adapt->HalFunc.sreset_xmit_status_check(adapt); -} - -void rtw_hal_sreset_linked_status_check(struct adapter *adapt) -{ - if (adapt->HalFunc.sreset_linked_status_check) - adapt->HalFunc.sreset_linked_status_check(adapt); -} - u8 rtw_hal_sreset_get_wifi_status(struct adapter *adapt) { u8 status = 0; @@ -427,16 +338,6 @@ u8 rtw_hal_sreset_get_wifi_status(struct adapter *adapt) return status; } -int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame, - u32 max_wating_ms, u32 bndy_cnt) -{ - if (adapter->HalFunc.IOL_exec_cmds_sync) - return adapter->HalFunc.IOL_exec_cmds_sync(adapter, xmit_frame, - max_wating_ms, - bndy_cnt); - return _FAIL; -} - void rtw_hal_notch_filter(struct adapter *adapter, bool enable) { if (adapter->HalFunc.hal_notch_filter) @@ -448,17 +349,3 @@ void rtw_hal_reset_security_engine(struct adapter *adapter) if (adapter->HalFunc.hal_reset_security_engine) adapter->HalFunc.hal_reset_security_engine(adapter); } - -s32 rtw_hal_c2h_handler(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt) -{ - s32 ret = _FAIL; - - if (adapter->HalFunc.c2h_handler) - ret = adapter->HalFunc.c2h_handler(adapter, c2h_evt); - return ret; -} - -c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter) -{ - return adapter->HalFunc.c2h_id_filter_ccx; -} diff --git a/hal/mac_cfg.c b/hal/mac_cfg.c new file mode 100644 index 0000000..febc83a --- /dev/null +++ b/hal/mac_cfg.c @@ -0,0 +1,134 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" +#include "phy.h" +#include + +/* MAC_REG.TXT */ + +static u32 array_MAC_REG_8188E[] = { + 0x026, 0x00000041, + 0x027, 0x00000035, + 0x428, 0x0000000A, + 0x429, 0x00000010, + 0x430, 0x00000000, + 0x431, 0x00000001, + 0x432, 0x00000002, + 0x433, 0x00000004, + 0x434, 0x00000005, + 0x435, 0x00000006, + 0x436, 0x00000007, + 0x437, 0x00000008, + 0x438, 0x00000000, + 0x439, 0x00000000, + 0x43A, 0x00000001, + 0x43B, 0x00000002, + 0x43C, 0x00000004, + 0x43D, 0x00000005, + 0x43E, 0x00000006, + 0x43F, 0x00000007, + 0x440, 0x0000005D, + 0x441, 0x00000001, + 0x442, 0x00000000, + 0x444, 0x00000015, + 0x445, 0x000000F0, + 0x446, 0x0000000F, + 0x447, 0x00000000, + 0x458, 0x00000041, + 0x459, 0x000000A8, + 0x45A, 0x00000072, + 0x45B, 0x000000B9, + 0x460, 0x00000066, + 0x461, 0x00000066, + 0x480, 0x00000008, + 0x4C8, 0x000000FF, + 0x4C9, 0x00000008, + 0x4CC, 0x000000FF, + 0x4CD, 0x000000FF, + 0x4CE, 0x00000001, + 0x4D3, 0x00000001, + 0x500, 0x00000026, + 0x501, 0x000000A2, + 0x502, 0x0000002F, + 0x503, 0x00000000, + 0x504, 0x00000028, + 0x505, 0x000000A3, + 0x506, 0x0000005E, + 0x507, 0x00000000, + 0x508, 0x0000002B, + 0x509, 0x000000A4, + 0x50A, 0x0000005E, + 0x50B, 0x00000000, + 0x50C, 0x0000004F, + 0x50D, 0x000000A4, + 0x50E, 0x00000000, + 0x50F, 0x00000000, + 0x512, 0x0000001C, + 0x514, 0x0000000A, + 0x516, 0x0000000A, + 0x525, 0x0000004F, + 0x550, 0x00000010, + 0x551, 0x00000010, + 0x559, 0x00000002, + 0x55D, 0x000000FF, + 0x605, 0x00000030, + 0x608, 0x0000000E, + 0x609, 0x0000002A, + 0x620, 0x000000FF, + 0x621, 0x000000FF, + 0x622, 0x000000FF, + 0x623, 0x000000FF, + 0x624, 0x000000FF, + 0x625, 0x000000FF, + 0x626, 0x000000FF, + 0x627, 0x000000FF, + 0x652, 0x00000020, + 0x63C, 0x0000000A, + 0x63D, 0x0000000A, + 0x63E, 0x0000000E, + 0x63F, 0x0000000E, + 0x640, 0x00000040, + 0x66E, 0x00000005, + 0x700, 0x00000021, + 0x701, 0x00000043, + 0x702, 0x00000065, + 0x703, 0x00000087, + 0x708, 0x00000021, + 0x709, 0x00000043, + 0x70A, 0x00000065, + 0x70B, 0x00000087, +}; + +bool rtl88eu_phy_mac_config(struct adapter *adapt) +{ + u32 i; + u32 arraylength; + u32 *ptrarray; + + arraylength = sizeof(array_MAC_REG_8188E)/sizeof(u32); + ptrarray = array_MAC_REG_8188E; + + for (i = 0; i < arraylength; i = i + 2) + usb_write8(adapt, ptrarray[i], (u8)ptrarray[i + 1]); + + usb_write8(adapt, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); + return true; +} diff --git a/hal/odm.c b/hal/odm.c index 285475f..9873998 100644 --- a/hal/odm.c +++ b/hal/odm.c @@ -21,7 +21,9 @@ /* include files */ #include "odm_precomp.h" +#include "phy.h" +u32 GlobalDebugLevel; static const u16 dB_Invert_Table[8][12] = { {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4}, {4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16}, @@ -171,6 +173,13 @@ u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = { #define RxDefaultAnt1 0x65a9 #define RxDefaultAnt2 0x569a +void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm) +{ + pDM_Odm->DebugLevel = ODM_DBG_TRACE; + + pDM_Odm->DebugComponents = 0; +} + /* 3 Export Interface */ /* 2011/09/21 MH Add to describe different team necessary resource allocate?? */ @@ -182,22 +191,14 @@ void ODM_DMInit(struct odm_dm_struct *pDM_Odm) odm_DIGInit(pDM_Odm); odm_RateAdaptiveMaskInit(pDM_Odm); - if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { - ; - } else if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { - odm_PrimaryCCA_Init(pDM_Odm); /* Gary */ - odm_DynamicBBPowerSavingInit(pDM_Odm); - odm_DynamicTxPowerInit(pDM_Odm); - odm_TXPowerTrackingInit(pDM_Odm); - ODM_EdcaTurboInit(pDM_Odm); - ODM_RAInfo_Init_all(pDM_Odm); - if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || - (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || - (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) - odm_InitHybridAntDiv(pDM_Odm); - else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV) - odm_SwAntDivInit(pDM_Odm); - } + odm_DynamicTxPowerInit(pDM_Odm); + odm_TXPowerTrackingInit(pDM_Odm); + ODM_EdcaTurboInit(pDM_Odm); + ODM_RAInfo_Init_all(pDM_Odm); + if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) + odm_InitHybridAntDiv(pDM_Odm); } /* 2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */ @@ -206,27 +207,14 @@ void ODM_DMInit(struct odm_dm_struct *pDM_Odm) void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) { /* 2012.05.03 Luke: For all IC series */ - odm_GlobalAdapterCheck(); odm_CmnInfoHook_Debug(pDM_Odm); odm_CmnInfoUpdate_Debug(pDM_Odm); odm_CommonInfoSelfUpdate(pDM_Odm); odm_FalseAlarmCounterStatistics(pDM_Odm); odm_RSSIMonitorCheck(pDM_Odm); - /* For CE Platform(SPRD or Tablet) */ - /* 8723A or 8189ES platform */ - /* NeilChen--2012--08--24-- */ /* Fix Leave LPS issue */ - if ((pDM_Odm->Adapter->pwrctrlpriv.pwr_mode != PS_MODE_ACTIVE) &&/* in LPS mode */ - ((pDM_Odm->SupportICType & (ODM_RTL8723A)) || - (pDM_Odm->SupportICType & (ODM_RTL8188E) && - ((pDM_Odm->SupportInterface == ODM_ITRF_SDIO))))) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n")); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n")); - odm_DIGbyRSSI_LPS(pDM_Odm); - } else { - odm_DIG(pDM_Odm); - } + odm_DIG(pDM_Odm); odm_CCKPacketDetectionThresh(pDM_Odm); if (*(pDM_Odm->pbPowerSaving)) @@ -234,23 +222,13 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) odm_RefreshRateAdaptiveMask(pDM_Odm); - odm_DynamicBBPowerSaving(pDM_Odm); - odm_DynamicPrimaryCCA(pDM_Odm); if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) odm_HwAntDiv(pDM_Odm); - else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV) - odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_PEAK); - if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { - ; - } else if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { - ODM_TXPowerTrackingCheck(pDM_Odm); - odm_EdcaTurboCheck(pDM_Odm); - odm_DynamicTxPower(pDM_Odm); - } - odm_dtc(pDM_Odm); + ODM_TXPowerTrackingCheck(pDM_Odm); + odm_EdcaTurboCheck(pDM_Odm); } /* Init /.. Fixed HW value. Only init time. */ @@ -457,12 +435,10 @@ void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value) void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) { - pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT9); - pDM_Odm->RFPathRxEnable = (u8) ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F); - if (pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D)) - pDM_Odm->AntDivType = CG_TRX_HW_ANTDIV; - if (pDM_Odm->SupportICType & (ODM_RTL8723A)) - pDM_Odm->AntDivType = CGCS_RX_SW_ANTDIV; + struct adapter *adapter = pDM_Odm->Adapter; + + pDM_Odm->bCckHighPower = (bool)phy_query_bb_reg(adapter, 0x824, BIT9); + pDM_Odm->RFPathRxEnable = (u8)phy_query_bb_reg(adapter, 0xc04, 0x0F); ODM_InitDebugSetting(pDM_Odm); } @@ -526,9 +502,6 @@ void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm) ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbScanInProcess=%d\n", *(pDM_Odm->pbScanInProcess))); ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbPowerSaving=%d\n", *(pDM_Odm->pbPowerSaving))); - - if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pOnePathCCA=%d\n", *(pDM_Odm->pOnePathCCA))); } void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm) @@ -540,115 +513,23 @@ void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm) ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RSSI_Min=%d\n", pDM_Odm->RSSI_Min)); } -static int getIGIForDiff(int value_IGI) -{ - #define ONERCCA_LOW_TH 0x30 - #define ONERCCA_LOW_DIFF 8 - - if (value_IGI < ONERCCA_LOW_TH) { - if ((ONERCCA_LOW_TH - value_IGI) < ONERCCA_LOW_DIFF) - return ONERCCA_LOW_TH; - else - return value_IGI + ONERCCA_LOW_DIFF; - } else { - return value_IGI; - } -} - void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) { struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("ODM_REG(IGI_A,pDM_Odm)=0x%x, ODM_BIT(IGI,pDM_Odm)=0x%x\n", - ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm))); + struct adapter *adapter = pDM_Odm->Adapter; if (pDM_DigTable->CurIGValue != CurrentIGI) { - if (pDM_Odm->SupportPlatform & (ODM_CE|ODM_MP)) { - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - if (pDM_Odm->SupportICType != ODM_RTL8188E) - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - } else if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { - switch (*(pDM_Odm->pOnePathCCA)) { - case ODM_CCA_2R: - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - if (pDM_Odm->SupportICType != ODM_RTL8188E) - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - break; - case ODM_CCA_1R_A: - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - if (pDM_Odm->SupportICType != ODM_RTL8188E) - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); - break; - case ODM_CCA_1R_B: - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); - if (pDM_Odm->SupportICType != ODM_RTL8188E) - ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - break; - } - } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("CurrentIGI(0x%02x).\n", CurrentIGI)); - /* pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue; */ + phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N, CurrentIGI); pDM_DigTable->CurIGValue = CurrentIGI; } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_Write_DIG():CurrentIGI=0x%x\n", CurrentIGI)); - -/* Add by Neil Chen to enable edcca to MP Platform */ -} - -/* Need LPS mode for CE platform --2012--08--24--- */ -/* 8723AS/8189ES */ -void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *pAdapter = pDM_Odm->Adapter; - struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; - - u8 RSSI_Lower = DM_DIG_MIN_NIC; /* 0x1E or 0x1C */ - u8 bFwCurrentInPSMode = false; - u8 CurrentIGI = pDM_Odm->RSSI_Min; - - if (!(pDM_Odm->SupportICType & (ODM_RTL8723A | ODM_RTL8188E))) - return; - - CurrentIGI = CurrentIGI + RSSI_OFFSET_DIG; - bFwCurrentInPSMode = pAdapter->pwrctrlpriv.bFwCurrentInPSMode; - - /* Using FW PS mode to make IGI */ - if (bFwCurrentInPSMode) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Neil---odm_DIG is in LPS mode\n")); - /* Adjust by FA in LPS MODE */ - if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) - CurrentIGI = CurrentIGI+2; - else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS) - CurrentIGI = CurrentIGI+1; - else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_LPS) - CurrentIGI = CurrentIGI-1; - } else { - CurrentIGI = RSSI_Lower; - } - - /* Lower bound checking */ - - /* RSSI Lower bound check */ - if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) - RSSI_Lower = (pDM_Odm->RSSI_Min-10); - else - RSSI_Lower = DM_DIG_MIN_NIC; - - /* Upper and Lower Bound checking */ - if (CurrentIGI > DM_DIG_MAX_NIC) - CurrentIGI = DM_DIG_MAX_NIC; - else if (CurrentIGI < RSSI_Lower) - CurrentIGI = RSSI_Lower; - - ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ } void odm_DIGInit(struct odm_dm_struct *pDM_Odm) { + struct adapter *adapter = pDM_Odm->Adapter; struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - pDM_DigTable->CurIGValue = (u8) ODM_GetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm)); + pDM_DigTable->CurIGValue = (u8)phy_query_bb_reg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N); pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; pDM_DigTable->FALowThresh = DM_false_ALARM_THRESH_LOW; @@ -705,102 +586,47 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) return; } - if (pDM_Odm->SupportICType == ODM_RTL8192D) { - if (*(pDM_Odm->pMacPhyMode) == ODM_DMSP) { - if (*(pDM_Odm->pbMasterOfDMSP)) { - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); - } else { - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); - } - } else { - if (*(pDM_Odm->pBandType) == ODM_BAND_5G) { - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); - } else { - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); - } - } - } else { - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); - } + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); /* 1 Boundary Decision */ - if ((pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8723A)) && - ((pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) || pDM_Odm->ExtLNA)) { - if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { - dm_dig_max = DM_DIG_MAX_AP_HP; - dm_dig_min = DM_DIG_MIN_AP_HP; - } else { - dm_dig_max = DM_DIG_MAX_NIC_HP; - dm_dig_min = DM_DIG_MIN_NIC_HP; - } - DIG_MaxOfMin = DM_DIG_MAX_AP_HP; - } else { - if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { - dm_dig_max = DM_DIG_MAX_AP; - dm_dig_min = DM_DIG_MIN_AP; - DIG_MaxOfMin = dm_dig_max; - } else { - dm_dig_max = DM_DIG_MAX_NIC; - dm_dig_min = DM_DIG_MIN_NIC; - DIG_MaxOfMin = DM_DIG_MAX_AP; - } - } + dm_dig_max = DM_DIG_MAX_NIC; + dm_dig_min = DM_DIG_MIN_NIC; + DIG_MaxOfMin = DM_DIG_MAX_AP; + if (pDM_Odm->bLinked) { - /* 2 8723A Series, offset need to be 10 */ - if (pDM_Odm->SupportICType == (ODM_RTL8723A)) { - /* 2 Upper Bound */ - if ((pDM_Odm->RSSI_Min + 10) > DM_DIG_MAX_NIC) - pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; - else if ((pDM_Odm->RSSI_Min + 10) < DM_DIG_MIN_NIC) - pDM_DigTable->rx_gain_range_max = DM_DIG_MIN_NIC; - else - pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 10; - /* 2 If BT is Concurrent, need to set Lower Bound */ - DIG_Dynamic_MIN = DM_DIG_MIN_NIC; - } else { - /* 2 Modify DIG upper bound */ - if ((pDM_Odm->RSSI_Min + 20) > dm_dig_max) - pDM_DigTable->rx_gain_range_max = dm_dig_max; - else if ((pDM_Odm->RSSI_Min + 20) < dm_dig_min) - pDM_DigTable->rx_gain_range_max = dm_dig_min; - else - pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20; - /* 2 Modify DIG lower bound */ - if (pDM_Odm->bOneEntryOnly) { - if (pDM_Odm->RSSI_Min < dm_dig_min) - DIG_Dynamic_MIN = dm_dig_min; - else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin) - DIG_Dynamic_MIN = DIG_MaxOfMin; - else - DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("odm_DIG() : bOneEntryOnly=true, DIG_Dynamic_MIN=0x%x\n", - DIG_Dynamic_MIN)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("odm_DIG() : pDM_Odm->RSSI_Min=%d\n", - pDM_Odm->RSSI_Min)); - } else if ((pDM_Odm->SupportICType == ODM_RTL8188E) && - (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { - /* 1 Lower Bound for 88E AntDiv */ - if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) { - DIG_Dynamic_MIN = (u8) pDM_DigTable->AntDiv_RSSI_max; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("odm_DIG(): pDM_DigTable->AntDiv_RSSI_max=%d\n", - pDM_DigTable->AntDiv_RSSI_max)); - } - } else { + /* 2 Modify DIG upper bound */ + if ((pDM_Odm->RSSI_Min + 20) > dm_dig_max) + pDM_DigTable->rx_gain_range_max = dm_dig_max; + else if ((pDM_Odm->RSSI_Min + 20) < dm_dig_min) + pDM_DigTable->rx_gain_range_max = dm_dig_min; + else + pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20; + /* 2 Modify DIG lower bound */ + if (pDM_Odm->bOneEntryOnly) { + if (pDM_Odm->RSSI_Min < dm_dig_min) DIG_Dynamic_MIN = dm_dig_min; + else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin) + DIG_Dynamic_MIN = DIG_MaxOfMin; + else + DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() : bOneEntryOnly=true, DIG_Dynamic_MIN=0x%x\n", + DIG_Dynamic_MIN)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() : pDM_Odm->RSSI_Min=%d\n", + pDM_Odm->RSSI_Min)); + } else if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) { + /* 1 Lower Bound for 88E AntDiv */ + if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) { + DIG_Dynamic_MIN = (u8)pDM_DigTable->AntDiv_RSSI_max; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("odm_DIG(): pDM_DigTable->AntDiv_RSSI_max=%d\n", + pDM_DigTable->AntDiv_RSSI_max)); } + } else { + DIG_Dynamic_MIN = dm_dig_min; } } else { pDM_DigTable->rx_gain_range_max = dm_dig_max; @@ -858,21 +684,12 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) CurrentIGI = pDM_Odm->RSSI_Min; ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("DIG: First Connect\n")); } else { - if (pDM_Odm->SupportICType == ODM_RTL8192D) { - if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_92D) - CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ - else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_92D) - CurrentIGI = CurrentIGI + 1; /* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ - else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_92D) - CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ - } else { - if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2) - CurrentIGI = CurrentIGI + 4;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ - else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1) - CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ - else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0) - CurrentIGI = CurrentIGI - 2;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ - } + if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2) + CurrentIGI = CurrentIGI + 4;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1) + CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ + else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0) + CurrentIGI = CurrentIGI - 2;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ } } else { ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG BeforeLink\n")); @@ -916,102 +733,69 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) { + struct adapter *adapter = pDM_Odm->Adapter; u32 ret_value; struct false_alarm_stats *FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) return; - if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { - /* hold ofdm counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); /* hold page C counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); /* hold page D counter */ + /* hold ofdm counter */ + phy_set_bb_reg(adapter, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); /* hold page C counter */ + phy_set_bb_reg(adapter, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); /* hold page D counter */ - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); - FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); - FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16); - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); - FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); - FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); + ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); + FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); + FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16); + ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); + FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); + FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); + ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); - FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + - FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; + FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + + FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; - if (pDM_Odm->SupportICType == ODM_RTL8188E) { - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_SC_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_BW_LSC = (ret_value&0xffff); - FalseAlmCnt->Cnt_BW_USC = ((ret_value&0xffff0000)>>16); - } + ret_value = phy_query_bb_reg(adapter, ODM_REG_SC_CNT_11N, bMaskDWord); + FalseAlmCnt->Cnt_BW_LSC = (ret_value&0xffff); + FalseAlmCnt->Cnt_BW_USC = ((ret_value&0xffff0000)>>16); - /* hold cck counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT12, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT14, 1); + /* hold cck counter */ + phy_set_bb_reg(adapter, ODM_REG_CCK_FA_RST_11N, BIT12, 1); + phy_set_bb_reg(adapter, ODM_REG_CCK_FA_RST_11N, BIT14, 1); - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); - FalseAlmCnt->Cnt_Cck_fail = ret_value; - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_MSB_11N, bMaskByte3); - FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff)<<8; + ret_value = phy_query_bb_reg(adapter, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); + FalseAlmCnt->Cnt_Cck_fail = ret_value; + ret_value = phy_query_bb_reg(adapter, ODM_REG_CCK_FA_MSB_11N, bMaskByte3); + FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff)<<8; - ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8); + ret_value = phy_query_bb_reg(adapter, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord); + FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8); - FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + - FalseAlmCnt->Cnt_SB_Search_fail + - FalseAlmCnt->Cnt_Parity_Fail + - FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + - FalseAlmCnt->Cnt_Mcs_fail + - FalseAlmCnt->Cnt_Cck_fail); + FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + + FalseAlmCnt->Cnt_SB_Search_fail + + FalseAlmCnt->Cnt_Parity_Fail + + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + + FalseAlmCnt->Cnt_Mcs_fail + + FalseAlmCnt->Cnt_Cck_fail); - FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; + FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; - if (pDM_Odm->SupportICType >= ODM_RTL8723A) { - /* reset false alarm counter registers */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 0); - /* update ofdm counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 0); /* update page C counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 0); /* update page D counter */ - - /* reset CCK CCA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 2); - /* reset CCK FA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 2); - } - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics\n")); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, - ("Cnt_Fast_Fsync=%d, Cnt_SB_Search_fail=%d\n", - FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, - ("Cnt_Parity_Fail=%d, Cnt_Rate_Illegal=%d\n", - FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, - ("Cnt_Crc8_fail=%d, Cnt_Mcs_fail=%d\n", - FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail)); - } else { /* FOR ODM_IC_11AC_SERIES */ - /* read OFDM FA counter */ - FalseAlmCnt->Cnt_Ofdm_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_11AC, bMaskLWord); - FalseAlmCnt->Cnt_Cck_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_11AC, bMaskLWord); - FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail + FalseAlmCnt->Cnt_Cck_fail; - - /* reset OFDM FA coutner */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 0); - /* reset CCK FA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 1); - } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Fast_Fsync=%d, Cnt_SB_Search_fail=%d\n", + FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Parity_Fail=%d, Cnt_Rate_Illegal=%d\n", + FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Crc8_fail=%d, Cnt_Mcs_fail=%d\n", + FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail)); ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail=%d\n", FalseAlmCnt->Cnt_Cck_fail)); ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail=%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm=%d\n", FalseAlmCnt->Cnt_all)); @@ -1053,83 +837,17 @@ void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm) void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) { struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + struct adapter *adapt = pDM_Odm->Adapter; if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) /* modify by Guo.Mingzhi 2012-01-03 */ - ODM_Write1Byte(pDM_Odm, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres); + usb_write8(adapt, ODM_REG_CCK_CCA_11N, CurCCK_CCAThres); pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; } -/* 3============================================================ */ -/* 3 BB Power Save */ -/* 3============================================================ */ -void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm) -{ - struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; - - pDM_PSTable->PreCCAState = CCA_MAX; - pDM_PSTable->CurCCAState = CCA_MAX; - pDM_PSTable->PreRFState = RF_MAX; - pDM_PSTable->CurRFState = RF_MAX; - pDM_PSTable->Rssi_val_min = 0; - pDM_PSTable->initialize = 0; -} - -void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm) -{ - if ((pDM_Odm->SupportICType != ODM_RTL8192C) && (pDM_Odm->SupportICType != ODM_RTL8723A)) - return; - if (!(pDM_Odm->SupportAbility & ODM_BB_PWR_SAVE)) - return; - if (!(pDM_Odm->SupportPlatform & (ODM_MP|ODM_CE))) - return; - - /* 1 2.Power Saving for 92C */ - if ((pDM_Odm->SupportICType == ODM_RTL8192C) && (pDM_Odm->RFType == ODM_2T2R)) { - odm_1R_CCA(pDM_Odm); - } else { - /* 20100628 Joseph: Turn off BB power save for 88CE because it makesthroughput unstable. */ - /* 20100831 Joseph: Turn ON BB power save again after modifying AGC delay from 900ns ot 600ns. */ - /* 1 3.Power Saving for 88C */ - ODM_RF_Saving(pDM_Odm, false); - } -} - -void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) -{ - struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; - - if (pDM_Odm->RSSI_Min != 0xFF) { - if (pDM_PSTable->PreCCAState == CCA_2R) { - if (pDM_Odm->RSSI_Min >= 35) - pDM_PSTable->CurCCAState = CCA_1R; - else - pDM_PSTable->CurCCAState = CCA_2R; - } else { - if (pDM_Odm->RSSI_Min <= 30) - pDM_PSTable->CurCCAState = CCA_2R; - else - pDM_PSTable->CurCCAState = CCA_1R; - } - } else { - pDM_PSTable->CurCCAState = CCA_MAX; - } - - if (pDM_PSTable->PreCCAState != pDM_PSTable->CurCCAState) { - if (pDM_PSTable->CurCCAState == CCA_1R) { - if (pDM_Odm->RFType == ODM_2T2R) - ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x13); - else - ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x23); - } else { - ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x33); - } - pDM_PSTable->PreCCAState = pDM_PSTable->CurCCAState; - } -} - void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) { + struct adapter *adapter = pDM_Odm->Adapter; struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; u8 Rssi_Up_bound = 30; u8 Rssi_Low_bound = 25; @@ -1139,10 +857,10 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) Rssi_Low_bound = 45; } if (pDM_PSTable->initialize == 0) { - pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14; - pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT3)>>3; - pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24; - pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12; + pDM_PSTable->Reg874 = (phy_query_bb_reg(adapter, 0x874, bMaskDWord)&0x1CC000)>>14; + pDM_PSTable->RegC70 = (phy_query_bb_reg(adapter, 0xc70, bMaskDWord)&BIT3)>>3; + pDM_PSTable->Reg85C = (phy_query_bb_reg(adapter, 0x85c, bMaskDWord)&0xFF000000)>>24; + pDM_PSTable->RegA74 = (phy_query_bb_reg(adapter, 0xa74, bMaskDWord)&0xF000)>>12; pDM_PSTable->initialize = 1; } @@ -1168,26 +886,19 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) { if (pDM_PSTable->CurRFState == RF_Save) { - /* 8723 RSSI report will be wrong. Set 0x874[5]=1 when enter BB power saving mode. */ - /* Suggested by SD3 Yu-Nan. 2011.01.20. */ - if (pDM_Odm->SupportICType == ODM_RTL8723A) - ODM_SetBBReg(pDM_Odm, 0x874 , BIT5, 0x1); /* Reg874[5]=1b'1 */ - ODM_SetBBReg(pDM_Odm, 0x874 , 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ - ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, 0); /* RegC70[3]=1'b0 */ - ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */ - ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ - ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */ - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); /* Reg818[28]=1'b0 */ - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x1); /* Reg818[28]=1'b1 */ + phy_set_bb_reg(adapter, 0x874 , 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ + phy_set_bb_reg(adapter, 0xc70, BIT3, 0); /* RegC70[3]=1'b0 */ + phy_set_bb_reg(adapter, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */ + phy_set_bb_reg(adapter, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ + phy_set_bb_reg(adapter, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */ + phy_set_bb_reg(adapter, 0x818, BIT28, 0x0); /* Reg818[28]=1'b0 */ + phy_set_bb_reg(adapter, 0x818, BIT28, 0x1); /* Reg818[28]=1'b1 */ } else { - ODM_SetBBReg(pDM_Odm, 0x874 , 0x1CC000, pDM_PSTable->Reg874); - ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, pDM_PSTable->RegC70); - ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); - ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74); - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); - - if (pDM_Odm->SupportICType == ODM_RTL8723A) - ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x0); /* Reg874[5]=1b'0 */ + phy_set_bb_reg(adapter, 0x874 , 0x1CC000, pDM_PSTable->Reg874); + phy_set_bb_reg(adapter, 0xc70, BIT3, pDM_PSTable->RegC70); + phy_set_bb_reg(adapter, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); + phy_set_bb_reg(adapter, 0xa74, 0xF000, pDM_PSTable->RegA74); + phy_set_bb_reg(adapter, 0x818, BIT28, 0x0); } pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; } @@ -1316,22 +1027,7 @@ void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm) /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ /* HW dynamic mechanism. */ /* */ - switch (pDM_Odm->SupportPlatform) { - case ODM_MP: - odm_RefreshRateAdaptiveMaskMP(pDM_Odm); - break; - case ODM_CE: - odm_RefreshRateAdaptiveMaskCE(pDM_Odm); - break; - case ODM_AP: - case ODM_ADSL: - odm_RefreshRateAdaptiveMaskAPADSL(pDM_Odm); - break; - } -} - -void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm) -{ + odm_RefreshRateAdaptiveMaskCE(pDM_Odm); } void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) @@ -1362,10 +1058,6 @@ void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) } } -void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm) -{ -} - /* Return Value: bool */ /* - true: RATRState is changed. */ bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate, u8 *pRATRState) @@ -1425,49 +1117,6 @@ void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm) pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; } -void odm_DynamicTxPower(struct odm_dm_struct *pDM_Odm) -{ - /* For AP/ADSL use struct rtl8192cd_priv * */ - /* For CE/NIC use struct adapter * */ - - if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR)) - return; - - /* 2012/01/12 MH According to Luke's suggestion, only high power will support the feature. */ - if (!pDM_Odm->ExtPA) - return; - - /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ - /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ - /* HW dynamic mechanism. */ - switch (pDM_Odm->SupportPlatform) { - case ODM_MP: - case ODM_CE: - odm_DynamicTxPowerNIC(pDM_Odm); - break; - case ODM_AP: - odm_DynamicTxPowerAP(pDM_Odm); - break; - case ODM_ADSL: - break; - } -} - -void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm) -{ - if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR)) - return; - - if (pDM_Odm->SupportICType == ODM_RTL8188E) { - /* ??? */ - /* This part need to be redefined. */ - } -} - -void odm_DynamicTxPowerAP(struct odm_dm_struct *pDM_Odm) -{ -} - /* 3============================================================ */ /* 3 RSSI Monitor */ /* 3============================================================ */ @@ -1482,27 +1131,9 @@ void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm) /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ /* HW dynamic mechanism. */ /* */ - switch (pDM_Odm->SupportPlatform) { - case ODM_MP: - odm_RSSIMonitorCheckMP(pDM_Odm); - break; - case ODM_CE: - odm_RSSIMonitorCheckCE(pDM_Odm); - break; - case ODM_AP: - odm_RSSIMonitorCheckAP(pDM_Odm); - break; - case ODM_ADSL: - /* odm_DIGAP(pDM_Odm); */ - break; - } - + odm_RSSIMonitorCheckCE(pDM_Odm); } /* odm_RSSIMonitorCheck */ -void odm_RSSIMonitorCheckMP(struct odm_dm_struct *pDM_Odm) -{ -} - static void FindMinimumRSSI(struct adapter *pAdapter) { struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); @@ -1538,8 +1169,8 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) psta = pDM_Odm->pODM_StaInfo[i]; if (IS_STA_VALID(psta) && (psta->state & WIFI_ASOC_STATE) && - !_rtw_memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) && - !_rtw_memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) { + memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) && + memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) { if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; @@ -1575,28 +1206,6 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); } -void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm) -{ -} - -void ODM_InitAllTimers(struct odm_dm_struct *pDM_Odm) -{ - ODM_InitializeTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer, - (void *)odm_SwAntDivChkAntSwitchCallback, NULL, "SwAntennaSwitchTimer"); -} - -void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm) -{ - ODM_CancelTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); -} - -void ODM_ReleaseAllTimers(struct odm_dm_struct *pDM_Odm) -{ - ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); - - ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->FastAntTrainingTimer); -} - /* 3============================================================ */ /* 3 Tx Power Tracking */ /* 3============================================================ */ @@ -1623,19 +1232,7 @@ void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm) /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ /* HW dynamic mechanism. */ - switch (pDM_Odm->SupportPlatform) { - case ODM_MP: - odm_TXPowerTrackingCheckMP(pDM_Odm); - break; - case ODM_CE: - odm_TXPowerTrackingCheckCE(pDM_Odm); - break; - case ODM_AP: - odm_TXPowerTrackingCheckAP(pDM_Odm); - break; - case ODM_ADSL: - break; - } + odm_TXPowerTrackingCheckCE(pDM_Odm); } void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm) @@ -1646,55 +1243,16 @@ void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm) return; if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */ - PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03); + phy_set_rf_reg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03); pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; return; } else { - odm_TXPowerTrackingCallback_ThermalMeter_8188E(Adapter); + rtl88eu_dm_txpower_tracking_callback_thermalmeter(Adapter); pDM_Odm->RFCalibrateInfo.TM_Trigger = 0; } } -void odm_TXPowerTrackingCheckMP(struct odm_dm_struct *pDM_Odm) -{ -} - -void odm_TXPowerTrackingCheckAP(struct odm_dm_struct *pDM_Odm) -{ -} - -/* antenna mapping info */ -/* 1: right-side antenna */ -/* 2/0: left-side antenna */ -/* PDM_SWAT_Table->CCK_Ant1_Cnt /OFDM_Ant1_Cnt: for right-side antenna: Ant:1 RxDefaultAnt1 */ -/* PDM_SWAT_Table->CCK_Ant2_Cnt /OFDM_Ant2_Cnt: for left-side antenna: Ant:0 RxDefaultAnt2 */ -/* We select left antenna as default antenna in initial process, modify it as needed */ -/* */ - -/* 3============================================================ */ -/* 3 SW Antenna Diversity */ -/* 3============================================================ */ -void odm_SwAntDivInit(struct odm_dm_struct *pDM_Odm) -{ -} - -void ODM_SwAntDivChkPerPktRssi(struct odm_dm_struct *pDM_Odm, u8 StationID, struct odm_phy_status_info *pPhyInfo) -{ -} - -void odm_SwAntDivChkAntSwitch(struct odm_dm_struct *pDM_Odm, u8 Step) -{ -} - -void ODM_SwAntDivRestAfterLink(struct odm_dm_struct *pDM_Odm) -{ -} - -void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext) -{ -} - /* 3============================================================ */ /* 3 SW Antenna Diversity */ /* 3============================================================ */ @@ -1706,31 +1264,7 @@ void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm) return; } - if (pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8192D)) - ; - else if (pDM_Odm->SupportICType == ODM_RTL8188E) - ODM_AntennaDiversityInit_88E(pDM_Odm); -} - -void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, u32 PWDBAll, bool isCCKrate) -{ - struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; - - if (pDM_SWAT_Table->antsel == 1) { - if (isCCKrate) { - pDM_SWAT_Table->CCK_Ant1_Cnt[MacId]++; - } else { - pDM_SWAT_Table->OFDM_Ant1_Cnt[MacId]++; - pDM_SWAT_Table->RSSI_Ant1_Sum[MacId] += PWDBAll; - } - } else { - if (isCCKrate) { - pDM_SWAT_Table->CCK_Ant2_Cnt[MacId]++; - } else { - pDM_SWAT_Table->OFDM_Ant2_Cnt[MacId]++; - pDM_SWAT_Table->RSSI_Ant2_Sum[MacId] += PWDBAll; - } - } + rtl88eu_dm_antenna_div_init(pDM_Odm); } void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm) @@ -1740,8 +1274,7 @@ void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm) return; } - if (pDM_Odm->SupportICType == ODM_RTL8188E) - ODM_AntennaDiversity_88E(pDM_Odm); + rtl88eu_dm_antenna_diversity(pDM_Odm); } /* EDCA Turbo */ @@ -1752,10 +1285,10 @@ void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm) pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false; Adapter->recvpriv.bIsAnyNonBEPkts = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VO_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VI_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BE_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BK_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_VO_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_VI_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_BE_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_BK_PARAM))); } /* ODM_InitEdcaTurbo */ void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) @@ -1768,16 +1301,7 @@ void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO)) return; - switch (pDM_Odm->SupportPlatform) { - case ODM_MP: - break; - case ODM_CE: - odm_EdcaTurboCheckCE(pDM_Odm); - break; - case ODM_AP: - case ODM_ADSL: - break; - } + odm_EdcaTurboCheckCE(pDM_Odm); ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("<========================odm_EdcaTurboCheck\n")); } /* odm_CheckEdcaTurbo */ @@ -1833,7 +1357,7 @@ void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) else edca_param = EDCAParam[HT_IOT_PEER_UNKNOWN][trafficIndex]; - rtw_write32(Adapter, REG_EDCA_BE_PARAM, edca_param); + usb_write32(Adapter, REG_EDCA_BE_PARAM, edca_param); pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex; } @@ -1843,7 +1367,7 @@ void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) /* Turn Off EDCA turbo here. */ /* Restore original EDCA according to the declaration of AP. */ if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) { - rtw_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE); + usb_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE); pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; } } @@ -1854,318 +1378,3 @@ dm_CheckEdcaTurbo_EXIT: pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes; precvpriv->last_rx_bytes = precvpriv->rx_bytes; } - -/* need to ODM CE Platform */ -/* move to here for ANT detection mechanism using */ - -u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, u8 initial_gain_psd) -{ - u32 psd_report; - - /* Set DCO frequency index, offset=(40MHz/SamplePts)*point */ - ODM_SetBBReg(pDM_Odm, 0x808, 0x3FF, point); - - /* Start PSD calculation, Reg808[22]=0->1 */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 1); - /* Need to wait for HW PSD report */ - ODM_StallExecution(30); - ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 0); - /* Read PSD report, Reg8B4[15:0] */ - psd_report = ODM_GetBBReg(pDM_Odm, 0x8B4, bMaskDWord) & 0x0000FFFF; - - psd_report = (u32) (ConvertTo_dB(psd_report))+(u32)(initial_gain_psd-0x1c); - - return psd_report; -} - -u32 ConvertTo_dB(u32 Value) -{ - u8 i; - u8 j; - u32 dB; - - Value = Value & 0xFFFF; - for (i = 0; i < 8; i++) { - if (Value <= dB_Invert_Table[i][11]) - break; - } - - if (i >= 8) - return 96; /* maximum 96 dB */ - - for (j = 0; j < 12; j++) { - if (Value <= dB_Invert_Table[i][j]) - break; - } - - dB = i*12 + j + 1; - - return dB; -} - -/* 2011/09/22 MH Add for 92D global spin lock utilization. */ -void odm_GlobalAdapterCheck(void) -{ -} /* odm_GlobalAdapterCheck */ - -/* Description: */ -/* Set Single/Dual Antenna default setting for products that do not do detection in advance. */ -/* Added by Joseph, 2012.03.22 */ -void ODM_SingleDualAntennaDefaultSetting(struct odm_dm_struct *pDM_Odm) -{ - struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; - - pDM_SWAT_Table->ANTA_ON = true; - pDM_SWAT_Table->ANTB_ON = true; -} - - -/* 2 8723A ANT DETECT */ - -static void odm_PHY_SaveAFERegisters(struct odm_dm_struct *pDM_Odm, u32 *AFEReg, u32 *AFEBackup, u32 RegisterNum) -{ - u32 i; - - /* RTPRINT(FINIT, INIT_IQK, ("Save ADDA parameters.\n")); */ - for (i = 0; i < RegisterNum; i++) - AFEBackup[i] = ODM_GetBBReg(pDM_Odm, AFEReg[i], bMaskDWord); -} - -static void odm_PHY_ReloadAFERegisters(struct odm_dm_struct *pDM_Odm, u32 *AFEReg, u32 *AFEBackup, u32 RegiesterNum) -{ - u32 i; - - for (i = 0; i < RegiesterNum; i++) - ODM_SetBBReg(pDM_Odm, AFEReg[i], bMaskDWord, AFEBackup[i]); -} - -/* 2 8723A ANT DETECT */ -/* Description: */ -/* Implement IQK single tone for RF DPK loopback and BB PSD scanning. */ -/* This function is cooperated with BB team Neil. */ -bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) -{ - struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; - u32 CurrentChannel, RfLoopReg; - u8 n; - u32 Reg88c, Regc08, Reg874, Regc50; - u8 initial_gain = 0x5a; - u32 PSD_report_tmp; - u32 AntA_report = 0x0, AntB_report = 0x0, AntO_report = 0x0; - bool bResult = true; - u32 AFE_Backup[16]; - u32 AFE_REG_8723A[16] = { - rRx_Wait_CCA, rTx_CCK_RFON, - rTx_CCK_BBON, rTx_OFDM_RFON, - rTx_OFDM_BBON, rTx_To_Rx, - rTx_To_Tx, rRx_CCK, - rRx_OFDM, rRx_Wait_RIFS, - rRx_TO_Rx, rStandby, - rSleep, rPMPD_ANAEN, - rFPGA0_XCD_SwitchControl, rBlue_Tooth}; - - if (!(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8192C))) - return bResult; - - if (!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV)) - return bResult; - - if (pDM_Odm->SupportICType == ODM_RTL8192C) { - /* Which path in ADC/DAC is turnned on for PSD: both I/Q */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT10|BIT11, 0x3); - /* Ageraged number: 8 */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT12|BIT13, 0x1); - /* pts = 128; */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x0); - } - - /* 1 Backup Current RF/BB Settings */ - - CurrentChannel = ODM_GetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask); - RfLoopReg = ODM_GetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask); - ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, ODM_DPDT, Antenna_A); /* change to Antenna A */ - /* Step 1: USE IQK to transmitter single tone */ - - ODM_StallExecution(10); - - /* Store A Path Register 88c, c08, 874, c50 */ - Reg88c = ODM_GetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord); - Regc08 = ODM_GetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord); - Reg874 = ODM_GetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord); - Regc50 = ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord); - - /* Store AFE Registers */ - odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); - - /* Set PSD 128 pts */ - ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT14|BIT15, 0x0); /* 128 pts */ - - /* To SET CH1 to do */ - ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01); /* Channel 1 */ - - /* AFE all on step */ - ODM_SetBBReg(pDM_Odm, rRx_Wait_CCA, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rTx_CCK_RFON, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rTx_CCK_BBON, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rTx_OFDM_RFON, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rTx_OFDM_BBON, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rTx_To_Rx, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rTx_To_Tx, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rRx_CCK, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rRx_OFDM, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rRx_Wait_RIFS, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rRx_TO_Rx, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rStandby, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rSleep, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rPMPD_ANAEN, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_SwitchControl, bMaskDWord, 0x6FDB25A4); - ODM_SetBBReg(pDM_Odm, rBlue_Tooth, bMaskDWord, 0x6FDB25A4); - - /* 3 wire Disable */ - ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, 0xCCF000C0); - - /* BB IQK Setting */ - ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800E4); - ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22208000); - - /* IQK setting tone@ 4.34Mhz */ - ODM_SetBBReg(pDM_Odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008C1C); - ODM_SetBBReg(pDM_Odm, rTx_IQK, bMaskDWord, 0x01007c00); - - - /* Page B init */ - ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x00080000); - ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x0f600000); - ODM_SetBBReg(pDM_Odm, rRx_IQK, bMaskDWord, 0x01004800); - ODM_SetBBReg(pDM_Odm, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f); - ODM_SetBBReg(pDM_Odm, rTx_IQK_PI_A, bMaskDWord, 0x82150008); - ODM_SetBBReg(pDM_Odm, rRx_IQK_PI_A, bMaskDWord, 0x28150008); - ODM_SetBBReg(pDM_Odm, rIQK_AGC_Rsp, bMaskDWord, 0x001028d0); - - /* RF loop Setting */ - ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x0, 0xFFFFF, 0x50008); - - /* IQK Single tone start */ - ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x80800000); - ODM_SetBBReg(pDM_Odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - ODM_StallExecution(1000); - PSD_report_tmp = 0x0; - - for (n = 0; n < 2; n++) { - PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); - if (PSD_report_tmp > AntA_report) - AntA_report = PSD_report_tmp; - } - - PSD_report_tmp = 0x0; - - ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); /* change to Antenna B */ - ODM_StallExecution(10); - - - for (n = 0; n < 2; n++) { - PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); - if (PSD_report_tmp > AntB_report) - AntB_report = PSD_report_tmp; - } - - /* change to open case */ - ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, 0); /* change to Ant A and B all open case */ - ODM_StallExecution(10); - - for (n = 0; n < 2; n++) { - PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); - if (PSD_report_tmp > AntO_report) - AntO_report = PSD_report_tmp; - } - - /* Close IQK Single Tone function */ - ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x00000000); - PSD_report_tmp = 0x0; - - /* 1 Return to antanna A */ - ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); - ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, Reg88c); - ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, Regc08); - ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, Reg874); - ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, 0x7F, 0x40); - ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord, Regc50); - ODM_SetRFReg(pDM_Odm, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, CurrentChannel); - ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask, RfLoopReg); - - /* Reload AFE Registers */ - odm_PHY_ReloadAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_A[%d]= %d\n", 2416, AntA_report)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_B[%d]= %d\n", 2416, AntB_report)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_O[%d]= %d\n", 2416, AntO_report)); - - - if (pDM_Odm->SupportICType == ODM_RTL8723A) { - /* 2 Test Ant B based on Ant A is ON */ - if (mode == ANTTESTB) { - if (AntA_report >= 100) { - if (AntB_report > (AntA_report+1)) { - pDM_SWAT_Table->ANTB_ON = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); - } else { - pDM_SWAT_Table->ANTB_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Dual Antenna is A and B\n")); - } - } else { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); - pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ - bResult = false; - } - } else if (mode == ANTTESTALL) { - /* 2 Test Ant A and B based on DPDT Open */ - if ((AntO_report >= 100)&(AntO_report < 118)) { - if (AntA_report > (AntO_report+1)) { - pDM_SWAT_Table->ANTA_ON = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is OFF")); - } else { - pDM_SWAT_Table->ANTA_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is ON")); - } - - if (AntB_report > (AntO_report+2)) { - pDM_SWAT_Table->ANTB_ON = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is OFF")); - } else { - pDM_SWAT_Table->ANTB_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is ON")); - } - } - } - } else if (pDM_Odm->SupportICType == ODM_RTL8192C) { - if (AntA_report >= 100) { - if (AntB_report > (AntA_report+2)) { - pDM_SWAT_Table->ANTA_ON = false; - pDM_SWAT_Table->ANTB_ON = true; - ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna B\n")); - } else if (AntA_report > (AntB_report+2)) { - pDM_SWAT_Table->ANTA_ON = true; - pDM_SWAT_Table->ANTB_ON = false; - ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); - } else { - pDM_SWAT_Table->ANTA_ON = true; - pDM_SWAT_Table->ANTB_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("ODM_SingleDualAntennaDetection(): Dual Antenna\n")); - } - } else { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); - pDM_SWAT_Table->ANTA_ON = true; /* Set Antenna A on as default */ - pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ - bResult = false; - } - } - return bResult; -} - -/* Justin: According to the current RRSI to adjust Response Frame TX power, 2012/11/05 */ -void odm_dtc(struct odm_dm_struct *pDM_Odm) -{ -} diff --git a/hal/odm_HWConfig.c b/hal/odm_HWConfig.c index 4c6b6c2..29f87df 100644 --- a/hal/odm_HWConfig.c +++ b/hal/odm_HWConfig.c @@ -39,61 +39,32 @@ static u8 odm_QueryRxPwrPercentage(s8 AntPower) /* 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer. */ /* IF other SW team do not support the feature, remove this section.?? */ -static s32 odm_sig_patch_lenove(struct odm_dm_struct *dm_odm, s32 CurrSig) -{ - return 0; -} - -static s32 odm_sig_patch_netcore(struct odm_dm_struct *dm_odm, s32 CurrSig) -{ - return 0; -} - static s32 odm_SignalScaleMapping_92CSeries(struct odm_dm_struct *dm_odm, s32 CurrSig) { s32 RetSig = 0; - if ((dm_odm->SupportInterface == ODM_ITRF_USB) || - (dm_odm->SupportInterface == ODM_ITRF_SDIO)) { - if (CurrSig >= 51 && CurrSig <= 100) - RetSig = 100; - else if (CurrSig >= 41 && CurrSig <= 50) - RetSig = 80 + ((CurrSig - 40)*2); - else if (CurrSig >= 31 && CurrSig <= 40) - RetSig = 66 + (CurrSig - 30); - else if (CurrSig >= 21 && CurrSig <= 30) - RetSig = 54 + (CurrSig - 20); - else if (CurrSig >= 10 && CurrSig <= 20) - RetSig = 42 + (((CurrSig - 10) * 2) / 3); - else if (CurrSig >= 5 && CurrSig <= 9) - RetSig = 22 + (((CurrSig - 5) * 3) / 2); - else if (CurrSig >= 1 && CurrSig <= 4) - RetSig = 6 + (((CurrSig - 1) * 3) / 2); - else - RetSig = CurrSig; - } + if (CurrSig >= 51 && CurrSig <= 100) + RetSig = 100; + else if (CurrSig >= 41 && CurrSig <= 50) + RetSig = 80 + ((CurrSig - 40)*2); + else if (CurrSig >= 31 && CurrSig <= 40) + RetSig = 66 + (CurrSig - 30); + else if (CurrSig >= 21 && CurrSig <= 30) + RetSig = 54 + (CurrSig - 20); + else if (CurrSig >= 10 && CurrSig <= 20) + RetSig = 42 + (((CurrSig - 10) * 2) / 3); + else if (CurrSig >= 5 && CurrSig <= 9) + RetSig = 22 + (((CurrSig - 5) * 3) / 2); + else if (CurrSig >= 1 && CurrSig <= 4) + RetSig = 6 + (((CurrSig - 1) * 3) / 2); + else + RetSig = CurrSig; return RetSig; } static s32 odm_SignalScaleMapping(struct odm_dm_struct *dm_odm, s32 CurrSig) { - if ((dm_odm->SupportPlatform == ODM_MP) && - (dm_odm->SupportInterface != ODM_ITRF_PCIE) && /* USB & SDIO */ - (dm_odm->PatchID == 10)) - return odm_sig_patch_netcore(dm_odm, CurrSig); - else if ((dm_odm->SupportPlatform == ODM_MP) && - (dm_odm->SupportInterface == ODM_ITRF_PCIE) && - (dm_odm->PatchID == 19)) - return odm_sig_patch_lenove(dm_odm, CurrSig); - else - return odm_SignalScaleMapping_92CSeries(dm_odm, CurrSig); -} - -/* pMgntInfo->CustomerID == RT_CID_819x_Lenovo */ -static u8 odm_SQ_process_patch_RT_CID_819x_Lenovo(struct odm_dm_struct *dm_odm, - u8 isCCKrate, u8 PWDB_ALL, u8 path, u8 RSSI) -{ - return 0; + return odm_SignalScaleMapping_92CSeries(dm_odm, CurrSig); } static u8 odm_EVMdbToPercentage(s8 Value) @@ -119,8 +90,7 @@ static u8 odm_EVMdbToPercentage(s8 Value) static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo, - struct adapter *adapt) + struct odm_per_pkt_info *pPktinfo) { struct sw_ant_switch *pDM_SWAT_Table = &dm_odm->DM_SWAT_Table; u8 i, Max_spatial_stream; @@ -136,11 +106,10 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; - pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = -1; - pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1; + pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = -1; + pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; if (isCCKrate) { - u8 report; u8 cck_agc_rpt; dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; @@ -149,118 +118,56 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, cck_highpwr = dm_odm->bCckHighPower; - cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ; + cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a; /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ /* The RSSI formula should be modified according to the gain table */ /* In 88E, cck_highpwr is always set to 1 */ - if (dm_odm->SupportICType & (ODM_RTL8188E|ODM_RTL8812)) { - LNA_idx = ((cck_agc_rpt & 0xE0) >> 5); - VGA_idx = (cck_agc_rpt & 0x1F); - switch (LNA_idx) { - case 7: - if (VGA_idx <= 27) - rx_pwr_all = -100 + 2*(27-VGA_idx); /* VGA_idx = 27~2 */ - else - rx_pwr_all = -100; - break; - case 6: - rx_pwr_all = -48 + 2*(2-VGA_idx); /* VGA_idx = 2~0 */ - break; - case 5: - rx_pwr_all = -42 + 2*(7-VGA_idx); /* VGA_idx = 7~5 */ - break; - case 4: - rx_pwr_all = -36 + 2*(7-VGA_idx); /* VGA_idx = 7~4 */ - break; - case 3: - rx_pwr_all = -24 + 2*(7-VGA_idx); /* VGA_idx = 7~0 */ - break; - case 2: - if (cck_highpwr) - rx_pwr_all = -12 + 2*(5-VGA_idx); /* VGA_idx = 5~0 */ - else - rx_pwr_all = -6 + 2*(5-VGA_idx); - break; - case 1: - rx_pwr_all = 8-2*VGA_idx; - break; - case 0: - rx_pwr_all = 14-2*VGA_idx; - break; - default: - break; - } - rx_pwr_all += 6; - PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); - if (!cck_highpwr) { - if (PWDB_ALL >= 80) - PWDB_ALL = ((PWDB_ALL-80)<<1)+((PWDB_ALL-80)>>1)+80; - else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) - PWDB_ALL += 3; - if (PWDB_ALL > 100) - PWDB_ALL = 100; - } - } else { - if (!cck_highpwr) { - report = (cck_agc_rpt & 0xc0)>>6; - switch (report) { - /* 03312009 modified by cosa */ - /* Modify the RF RNA gain value to -40, -20, -2, 14 by Jenyu's suggestion */ - /* Note: different RF with the different RNA gain. */ - case 0x3: - rx_pwr_all = -46 - (cck_agc_rpt & 0x3e); - break; - case 0x2: - rx_pwr_all = -26 - (cck_agc_rpt & 0x3e); - break; - case 0x1: - rx_pwr_all = -12 - (cck_agc_rpt & 0x3e); - break; - case 0x0: - rx_pwr_all = 16 - (cck_agc_rpt & 0x3e); - break; - } - } else { - report = (cck_agc_rpt & 0x60)>>5; - switch (report) { - case 0x3: - rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f)<<1) ; - break; - case 0x2: - rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f)<<1); - break; - case 0x1: - rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f)<<1); - break; - case 0x0: - rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f)<<1); - break; - } - } - - PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); - - /* Modification for ext-LNA board */ - if (dm_odm->BoardType == ODM_BOARD_HIGHPWR) { - if ((cck_agc_rpt>>7) == 0) { - PWDB_ALL = (PWDB_ALL > 94) ? 100 : (PWDB_ALL+6); - } else { - if (PWDB_ALL > 38) - PWDB_ALL -= 16; - else - PWDB_ALL = (PWDB_ALL <= 16) ? (PWDB_ALL>>2) : (PWDB_ALL-12); - } - - /* CCK modification */ - if (PWDB_ALL > 25 && PWDB_ALL <= 60) - PWDB_ALL += 6; - } else {/* Modification for int-LNA board */ - if (PWDB_ALL > 99) - PWDB_ALL -= 8; - else if (PWDB_ALL > 50 && PWDB_ALL <= 68) - PWDB_ALL += 4; - } + LNA_idx = ((cck_agc_rpt & 0xE0) >> 5); + VGA_idx = (cck_agc_rpt & 0x1F); + switch (LNA_idx) { + case 7: + if (VGA_idx <= 27) + rx_pwr_all = -100 + 2*(27-VGA_idx); /* VGA_idx = 27~2 */ + else + rx_pwr_all = -100; + break; + case 6: + rx_pwr_all = -48 + 2*(2-VGA_idx); /* VGA_idx = 2~0 */ + break; + case 5: + rx_pwr_all = -42 + 2*(7-VGA_idx); /* VGA_idx = 7~5 */ + break; + case 4: + rx_pwr_all = -36 + 2*(7-VGA_idx); /* VGA_idx = 7~4 */ + break; + case 3: + rx_pwr_all = -24 + 2*(7-VGA_idx); /* VGA_idx = 7~0 */ + break; + case 2: + if (cck_highpwr) + rx_pwr_all = -12 + 2*(5-VGA_idx); /* VGA_idx = 5~0 */ + else + rx_pwr_all = -6 + 2*(5-VGA_idx); + break; + case 1: + rx_pwr_all = 8-2*VGA_idx; + break; + case 0: + rx_pwr_all = 14-2*VGA_idx; + break; + default: + break; + } + rx_pwr_all += 6; + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + if (!cck_highpwr) { + if (PWDB_ALL >= 80) + PWDB_ALL = ((PWDB_ALL-80)<<1)+((PWDB_ALL-80)>>1)+80; + else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) + PWDB_ALL += 3; + if (PWDB_ALL > 100) + PWDB_ALL = 100; } pPhyInfo->RxPWDBAll = PWDB_ALL; @@ -270,9 +177,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, if (pPktinfo->bPacketMatchBSSID) { u8 SQ, SQ_rpt; - if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { - SQ = odm_SQ_process_patch_RT_CID_819x_Lenovo(dm_odm, isCCKrate, PWDB_ALL, 0, 0); - } else if (pPhyInfo->RxPWDBAll > 40 && !dm_odm->bInHctTest) { + if (pPhyInfo->RxPWDBAll > 40 && !dm_odm->bInHctTest) { SQ = 100; } else { SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all; @@ -285,22 +190,20 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, SQ = ((64-SQ_rpt) * 100) / 44; } pPhyInfo->SignalQuality = SQ; - pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = SQ; - pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1; + pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = SQ; + pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; } } else { /* is OFDM rate */ dm_odm->PhyDbgInfo.NumQryPhyStatusOFDM++; /* (1)Get RSSI for HT rate */ - for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++) { + for (i = RF_PATH_A; i < RF_PATH_MAX; i++) { /* 2008/01/30 MH we will judge RF RX path now. */ if (dm_odm->RFPathRxEnable & BIT(i)) rf_rx_num++; rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F)*2) - 110; - if (i == RF_PATH_A) - adapt->signal_strength = rx_pwr[i]; pPhyInfo->RxPwr[i] = rx_pwr[i]; @@ -324,14 +227,6 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, /* Get Rx snr value in DB */ pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); - - /* Record Signal Strength for next packet */ - if (pPktinfo->bPacketMatchBSSID) { - if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { - if (i == ODM_RF_PATH_A) - pPhyInfo->SignalQuality = odm_SQ_process_patch_RT_CID_819x_Lenovo(dm_odm, isCCKrate, PWDB_ALL, i, RSSI); - } - } } /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110; @@ -344,26 +239,22 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, pPhyInfo->RxPower = rx_pwr_all; pPhyInfo->RecvSignalPower = rx_pwr_all; - if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { - /* do nothing */ - } else { - /* (3)EVM of HT rate */ - if (pPktinfo->Rate >= DESC92C_RATEMCS8 && pPktinfo->Rate <= DESC92C_RATEMCS15) - Max_spatial_stream = 2; /* both spatial stream make sense */ - else - Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ + /* (3)EVM of HT rate */ + if (pPktinfo->Rate >= DESC92C_RATEMCS8 && pPktinfo->Rate <= DESC92C_RATEMCS15) + Max_spatial_stream = 2; /* both spatial stream make sense */ + else + Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ - for (i = 0; i < Max_spatial_stream; i++) { - /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ - /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ - /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ - EVM = odm_EVMdbToPercentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ + for (i = 0; i < Max_spatial_stream; i++) { + /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ + /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ + /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ + EVM = odm_EVMdbToPercentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ - if (pPktinfo->bPacketMatchBSSID) { - if (i == ODM_RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ - pPhyInfo->SignalQuality = (u8)(EVM & 0xff); - pPhyInfo->RxMIMOSignalQuality[i] = (u8)(EVM & 0xff); - } + if (pPktinfo->bPacketMatchBSSID) { + if (i == RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ + pPhyInfo->SignalQuality = (u8)(EVM & 0xff); + pPhyInfo->RxMIMOSignalQuality[i] = (u8)(EVM & 0xff); } } } @@ -384,10 +275,6 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, dm_odm->DM_FatTable.antsel_rx_keep_2 = pPhyStaRpt->antsel_rx_keep_2; } -void odm_Init_RSSIForDM(struct odm_dm_struct *dm_odm) -{ -} - static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, struct odm_per_pkt_info *pPktinfo) @@ -399,6 +286,8 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, u32 OFDM_pkt = 0; u32 Weighting = 0; struct sta_info *pEntry; + u8 antsel_tr_mux; + struct fast_ant_train *pDM_FatTable = &dm_odm->DM_FatTable; if (pPktinfo->StationID == 0xFF) return; @@ -411,27 +300,23 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; /* Smart Antenna Debug Message------------------ */ - if (dm_odm->SupportICType == ODM_RTL8188E) { - u8 antsel_tr_mux; - struct fast_ant_train *pDM_FatTable = &dm_odm->DM_FatTable; - if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) { - if (pDM_FatTable->FAT_State == FAT_TRAINING_STATE) { - if (pPktinfo->bPacketToSelf) { - antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | - (pDM_FatTable->antsel_rx_keep_1<<1) | - pDM_FatTable->antsel_rx_keep_0; - pDM_FatTable->antSumRSSI[antsel_tr_mux] += pPhyInfo->RxPWDBAll; - pDM_FatTable->antRSSIcnt[antsel_tr_mux]++; - } - } - } else if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) { - if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { + if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) { + if (pDM_FatTable->FAT_State == FAT_TRAINING_STATE) { + if (pPktinfo->bPacketToSelf) { antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | - (pDM_FatTable->antsel_rx_keep_1<<1) | pDM_FatTable->antsel_rx_keep_0; - ODM_AntselStatistics_88E(dm_odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll); + (pDM_FatTable->antsel_rx_keep_1<<1) | + pDM_FatTable->antsel_rx_keep_0; + pDM_FatTable->antSumRSSI[antsel_tr_mux] += pPhyInfo->RxPWDBAll; + pDM_FatTable->antRSSIcnt[antsel_tr_mux]++; } } + } else if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) { + if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { + antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | + (pDM_FatTable->antsel_rx_keep_1<<1) | pDM_FatTable->antsel_rx_keep_0; + rtl88eu_dm_ant_sel_statistics(dm_odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll); + } } /* Smart Antenna Debug Message------------------ */ @@ -441,15 +326,15 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { if (!isCCKrate) { /* ofdm rate */ - if (pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B] == 0) { - RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_B] == 0) { + RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; } else { - if (pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]) { - RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; - RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]; + if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]) { + RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]; } else { - RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]; - RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; } if ((RSSI_max - RSSI_min) < 3) RSSI_Ave = RSSI_max; @@ -529,15 +414,12 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo, - struct adapter *adapt) + struct odm_per_pkt_info *pPktinfo) { odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus, - pPktinfo, adapt); + pPktinfo); if (dm_odm->RSSI_test) { - /* Select the packets to do RSSI checking for antenna switching. */ - if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) - ODM_SwAntDivChkPerPktRssi(dm_odm, pPktinfo->StationID, pPhyInfo); + ;/* Select the packets to do RSSI checking for antenna switching. */ } else { odm_Process_RSSIForDM(dm_odm, pPhyInfo, pPktinfo); } @@ -545,57 +427,7 @@ static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, - u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo, - struct adapter *adapt) + u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo) { - ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo, adapt); -} - -/* For future use. */ -void ODM_MacStatusQuery(struct odm_dm_struct *dm_odm, u8 *mac_stat, - u8 macid, bool pkt_match_bssid, - bool pkttoself, bool pkt_beacon) -{ - /* 2011/10/19 Driver team will handle in the future. */ -} - -enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *dm_odm, - enum ODM_RF_RADIO_PATH content, - enum ODM_RF_RADIO_PATH rfpath) -{ - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===>ODM_ConfigRFWithHeaderFile\n")); - if (dm_odm->SupportICType == ODM_RTL8188E) { - if (rfpath == ODM_RF_PATH_A) - READ_AND_CONFIG(8188E, _RadioA_1T_); - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_A:Rtl8188ERadioA_1TArray\n")); - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_B:Rtl8188ERadioB_1TArray\n")); - } - - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("ODM_ConfigRFWithHeaderFile: Radio No %x\n", rfpath)); - return HAL_STATUS_SUCCESS; -} - -enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *dm_odm, - enum odm_bb_config_type config_tp) -{ - if (dm_odm->SupportICType == ODM_RTL8188E) { - if (config_tp == CONFIG_BB_PHY_REG) { - READ_AND_CONFIG(8188E, _PHY_REG_1T_); - } else if (config_tp == CONFIG_BB_AGC_TAB) { - READ_AND_CONFIG(8188E, _AGC_TAB_1T_); - } else if (config_tp == CONFIG_BB_PHY_REG_PG) { - READ_AND_CONFIG(8188E, _PHY_REG_PG_); - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, - (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8188EPHY_REG_PGArray\n")); - } - } - return HAL_STATUS_SUCCESS; -} - -enum HAL_STATUS ODM_ConfigMACWithHeaderFile(struct odm_dm_struct *dm_odm) -{ - u8 result = HAL_STATUS_SUCCESS; - if (dm_odm->SupportICType == ODM_RTL8188E) - result = READ_AND_CONFIG(8188E, _MAC_REG_); - return result; + ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo); } diff --git a/hal/odm_RTL8188E.c b/hal/odm_RTL8188E.c index 58410f3..d3c6873 100644 --- a/hal/odm_RTL8188E.c +++ b/hal/odm_RTL8188E.c @@ -19,96 +19,91 @@ ******************************************************************************/ #include "odm_precomp.h" +#include "phy.h" -void ODM_DIG_LowerBound_88E(struct odm_dm_struct *dm_odm) +static void dm_rx_hw_antena_div_init(struct odm_dm_struct *dm_odm) { - struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; + struct adapter *adapter = dm_odm->Adapter; + u32 value32; - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { - pDM_DigTable->rx_gain_range_min = (u8) pDM_DigTable->AntDiv_RSSI_max; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("ODM_DIG_LowerBound_88E(): pDM_DigTable->AntDiv_RSSI_max=%d\n", pDM_DigTable->AntDiv_RSSI_max)); + if (*(dm_odm->mp_mode) == 1) { + dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; + phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT7, 0); + phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT31, 1); + return; } - /* If only one Entry connected */ + + /* MAC Setting */ + value32 = phy_query_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); + phy_set_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, + value32|(BIT23|BIT25)); + /* Pin Settings */ + phy_set_bb_reg(adapter, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0); + phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); + phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT22, 1); + phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT31, 1); + /* OFDM Settings */ + phy_set_bb_reg(adapter, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, + 0x000000a0); + /* CCK Settings */ + phy_set_bb_reg(adapter, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); + phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); + rtl88eu_dm_update_rx_idle_ant(dm_odm, MAIN_ANT); + phy_set_bb_reg(adapter, ODM_REG_ANT_MAPPING1_11N, 0xFFFF, 0x0201); } -static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) +static void dm_trx_hw_antenna_div_init(struct odm_dm_struct *dm_odm) { + struct adapter *adapter = dm_odm->Adapter; u32 value32; if (*(dm_odm->mp_mode) == 1) { dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* 1:CG, 0:CS */ + phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT7, 0); + phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, + BIT5|BIT4|BIT3, 0); return; } - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_RX_HWAntDivInit()\n")); /* MAC Setting */ - value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + value32 = phy_query_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); + phy_set_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, + value32|(BIT23|BIT25)); /* Pin Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 1); /* Regb2c[22]=1'b0 disable CS/CG switch */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + phy_set_bb_reg(adapter, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0); + phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); + phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT22, 0); + phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* OFDM Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); + phy_set_bb_reg(adapter, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, + 0x000000a0); /* CCK Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ - ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); - ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, 0xFFFF, 0x0201); /* antenna mapping table */ -} - -static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) -{ - u32 value32; - - if (*(dm_odm->mp_mode) == 1) { - dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, 0); /* Default RX (0/1) */ - return; - } - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_TRX_HWAntDivInit()\n")); - - /* MAC Setting */ - value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ - /* Pin Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ - /* OFDM Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); - /* CCK Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ + phy_set_bb_reg(adapter, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); + phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* Tx Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ - ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); + phy_set_bb_reg(adapter, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); + rtl88eu_dm_update_rx_idle_ant(dm_odm, MAIN_ANT); /* antenna mapping table */ if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + phy_set_bb_reg(adapter, ODM_REG_RX_DEFUALT_A_11N, + BIT10|BIT9|BIT8, 1); + phy_set_bb_reg(adapter, ODM_REG_RX_DEFUALT_A_11N, + BIT13|BIT12|BIT11, 2); } else { /* MPchip */ - ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, 0x0201); /* Reg914=3'b010, Reg915=3'b001 */ + phy_set_bb_reg(adapter, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, + 0x0201); } } -static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) +static void dm_fast_training_init(struct odm_dm_struct *dm_odm) { - u32 value32, i; + struct adapter *adapter = dm_odm->Adapter; + u32 value32, i; struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - u32 AntCombination = 2; - - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_FastAntTrainingInit()\n")); + u32 AntCombination = 2; if (*(dm_odm->mp_mode) == 1) { - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("dm_odm->AntDivType: %d\n", dm_odm->AntDivType)); return; } @@ -122,210 +117,206 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) dm_fat_tbl->FAT_State = FAT_NORMAL_STATE; /* MAC Setting */ - value32 = ODM_GetMACReg(dm_odm, 0x4c, bMaskDWord); - ODM_SetMACReg(dm_odm, 0x4c, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ - value32 = ODM_GetMACReg(dm_odm, 0x7B4, bMaskDWord); - ODM_SetMACReg(dm_odm, 0x7b4, bMaskDWord, value32|(BIT16|BIT17)); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */ + value32 = phy_query_bb_reg(adapter, 0x4c, bMaskDWord); + phy_set_bb_reg(adapter, 0x4c, bMaskDWord, value32|(BIT23|BIT25)); + value32 = phy_query_bb_reg(adapter, 0x7B4, bMaskDWord); + phy_set_bb_reg(adapter, 0x7b4, bMaskDWord, value32|(BIT16|BIT17)); /* Match MAC ADDR */ - ODM_SetMACReg(dm_odm, 0x7b4, 0xFFFF, 0); - ODM_SetMACReg(dm_odm, 0x7b0, bMaskDWord, 0); + phy_set_bb_reg(adapter, 0x7b4, 0xFFFF, 0); + phy_set_bb_reg(adapter, 0x7b0, bMaskDWord, 0); - ODM_SetBBReg(dm_odm, 0x870, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ - ODM_SetBBReg(dm_odm, 0x864, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ - ODM_SetBBReg(dm_odm, 0xb2c, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ - ODM_SetBBReg(dm_odm, 0xb2c, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ - ODM_SetBBReg(dm_odm, 0xca4, bMaskDWord, 0x000000a0); + phy_set_bb_reg(adapter, 0x870, BIT9|BIT8, 0); + phy_set_bb_reg(adapter, 0x864, BIT10, 0); + phy_set_bb_reg(adapter, 0xb2c, BIT22, 0); + phy_set_bb_reg(adapter, 0xb2c, BIT31, 1); + phy_set_bb_reg(adapter, 0xca4, bMaskDWord, 0x000000a0); /* antenna mapping table */ if (AntCombination == 2) { if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ - ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + phy_set_bb_reg(adapter, 0x858, BIT10|BIT9|BIT8, 1); + phy_set_bb_reg(adapter, 0x858, BIT13|BIT12|BIT11, 2); } else { /* MPchip */ - ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 1); - ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 2); + phy_set_bb_reg(adapter, 0x914, bMaskByte0, 1); + phy_set_bb_reg(adapter, 0x914, bMaskByte1, 2); } } else if (AntCombination == 7) { if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 0); /* Reg858[10:8]=3'b000 */ - ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 1); /* Reg858[13:11]=3'b001 */ - ODM_SetBBReg(dm_odm, 0x878, BIT16, 0); - ODM_SetBBReg(dm_odm, 0x858, BIT15|BIT14, 2); /* Reg878[0],Reg858[14:15])=3'b010 */ - ODM_SetBBReg(dm_odm, 0x878, BIT19|BIT18|BIT17, 3);/* Reg878[3:1]=3b'011 */ - ODM_SetBBReg(dm_odm, 0x878, BIT22|BIT21|BIT20, 4);/* Reg878[6:4]=3b'100 */ - ODM_SetBBReg(dm_odm, 0x878, BIT25|BIT24|BIT23, 5);/* Reg878[9:7]=3b'101 */ - ODM_SetBBReg(dm_odm, 0x878, BIT28|BIT27|BIT26, 6);/* Reg878[12:10]=3b'110 */ - ODM_SetBBReg(dm_odm, 0x878, BIT31|BIT30|BIT29, 7);/* Reg878[15:13]=3b'111 */ + phy_set_bb_reg(adapter, 0x858, BIT10|BIT9|BIT8, 0); + phy_set_bb_reg(adapter, 0x858, BIT13|BIT12|BIT11, 1); + phy_set_bb_reg(adapter, 0x878, BIT16, 0); + phy_set_bb_reg(adapter, 0x858, BIT15|BIT14, 2); + phy_set_bb_reg(adapter, 0x878, BIT19|BIT18|BIT17, 3); + phy_set_bb_reg(adapter, 0x878, BIT22|BIT21|BIT20, 4); + phy_set_bb_reg(adapter, 0x878, BIT25|BIT24|BIT23, 5); + phy_set_bb_reg(adapter, 0x878, BIT28|BIT27|BIT26, 6); + phy_set_bb_reg(adapter, 0x878, BIT31|BIT30|BIT29, 7); } else { /* MPchip */ - ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 0); - ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 1); - ODM_SetBBReg(dm_odm, 0x914, bMaskByte2, 2); - ODM_SetBBReg(dm_odm, 0x914, bMaskByte3, 3); - ODM_SetBBReg(dm_odm, 0x918, bMaskByte0, 4); - ODM_SetBBReg(dm_odm, 0x918, bMaskByte1, 5); - ODM_SetBBReg(dm_odm, 0x918, bMaskByte2, 6); - ODM_SetBBReg(dm_odm, 0x918, bMaskByte3, 7); + phy_set_bb_reg(adapter, 0x914, bMaskByte0, 0); + phy_set_bb_reg(adapter, 0x914, bMaskByte1, 1); + phy_set_bb_reg(adapter, 0x914, bMaskByte2, 2); + phy_set_bb_reg(adapter, 0x914, bMaskByte3, 3); + phy_set_bb_reg(adapter, 0x918, bMaskByte0, 4); + phy_set_bb_reg(adapter, 0x918, bMaskByte1, 5); + phy_set_bb_reg(adapter, 0x918, bMaskByte2, 6); + phy_set_bb_reg(adapter, 0x918, bMaskByte3, 7); } } /* Default Ant Setting when no fast training */ - ODM_SetBBReg(dm_odm, 0x80c, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ - ODM_SetBBReg(dm_odm, 0x864, BIT5|BIT4|BIT3, 0); /* Default RX */ - ODM_SetBBReg(dm_odm, 0x864, BIT8|BIT7|BIT6, 1); /* Optional RX */ + phy_set_bb_reg(adapter, 0x80c, BIT21, 1); + phy_set_bb_reg(adapter, 0x864, BIT5|BIT4|BIT3, 0); + phy_set_bb_reg(adapter, 0x864, BIT8|BIT7|BIT6, 1); /* Enter Traing state */ - ODM_SetBBReg(dm_odm, 0x864, BIT2|BIT1|BIT0, (AntCombination-1)); /* Reg864[2:0]=3'd6 ant combination=reg864[2:0]+1 */ - ODM_SetBBReg(dm_odm, 0xc50, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ + phy_set_bb_reg(adapter, 0x864, BIT2|BIT1|BIT0, (AntCombination-1)); + phy_set_bb_reg(adapter, 0xc50, BIT7, 1); } -void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *dm_odm) +void rtl88eu_dm_antenna_div_init(struct odm_dm_struct *dm_odm) { - if (dm_odm->SupportICType != ODM_RTL8188E) - return; - - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->AntDivType=%d\n", dm_odm->AntDivType)); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->bIsMPChip=%s\n", (dm_odm->bIsMPChip ? "true" : "false"))); - if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) - odm_RX_HWAntDivInit(dm_odm); + dm_rx_hw_antena_div_init(dm_odm); else if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - odm_TRX_HWAntDivInit(dm_odm); + dm_trx_hw_antenna_div_init(dm_odm); else if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) - odm_FastAntTrainingInit(dm_odm); + dm_fast_training_init(dm_odm); } -void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant) +void rtl88eu_dm_update_rx_idle_ant(struct odm_dm_struct *dm_odm, u8 ant) { struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - u32 DefaultAnt, OptionalAnt; + struct adapter *adapter = dm_odm->Adapter; + u32 default_ant, optional_ant; - if (dm_fat_tbl->RxIdleAnt != Ant) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Update Rx Idle Ant\n")); - if (Ant == MAIN_ANT) { - DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; - OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; + if (dm_fat_tbl->RxIdleAnt != ant) { + if (ant == MAIN_ANT) { + default_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? + MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; + optional_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? + AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; } else { - DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; - OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; + default_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? + AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; + optional_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? + MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; } if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ - ODM_SetBBReg(dm_odm, ODM_REG_ANTSEL_CTRL_11N, BIT14|BIT13|BIT12, DefaultAnt); /* Default TX */ - ODM_SetMACReg(dm_odm, ODM_REG_RESP_TX_11N, BIT6|BIT7, DefaultAnt); /* Resp Tx */ + phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, + BIT5|BIT4|BIT3, default_ant); + phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, + BIT8|BIT7|BIT6, optional_ant); + phy_set_bb_reg(adapter, ODM_REG_ANTSEL_CTRL_11N, + BIT14|BIT13|BIT12, default_ant); + phy_set_bb_reg(adapter, ODM_REG_RESP_TX_11N, + BIT6|BIT7, default_ant); } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ + phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, + BIT5|BIT4|BIT3, default_ant); + phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, + BIT8|BIT7|BIT6, optional_ant); } } - dm_fat_tbl->RxIdleAnt = Ant; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("RxIdleAnt=%s\n", (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); - pr_info("RxIdleAnt=%s\n", (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT"); + dm_fat_tbl->RxIdleAnt = ant; } -static void odm_UpdateTxAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant, u32 MacId) +static void update_tx_ant_88eu(struct odm_dm_struct *dm_odm, u8 ant, u32 mac_id) { struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - u8 TargetAnt; + u8 target_ant; - if (Ant == MAIN_ANT) - TargetAnt = MAIN_ANT_CG_TRX; + if (ant == MAIN_ANT) + target_ant = MAIN_ANT_CG_TRX; else - TargetAnt = AUX_ANT_CG_TRX; - dm_fat_tbl->antsel_a[MacId] = TargetAnt&BIT0; - dm_fat_tbl->antsel_b[MacId] = (TargetAnt&BIT1)>>1; - dm_fat_tbl->antsel_c[MacId] = (TargetAnt&BIT2)>>2; - - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("Tx from TxInfo, TargetAnt=%s\n", - (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("antsel_tr_mux=3'b%d%d%d\n", - dm_fat_tbl->antsel_c[MacId], dm_fat_tbl->antsel_b[MacId], dm_fat_tbl->antsel_a[MacId])); + target_ant = AUX_ANT_CG_TRX; + dm_fat_tbl->antsel_a[mac_id] = target_ant&BIT0; + dm_fat_tbl->antsel_b[mac_id] = (target_ant&BIT1)>>1; + dm_fat_tbl->antsel_c[mac_id] = (target_ant&BIT2)>>2; } -void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *dm_odm, u8 *pDesc, u8 macId) +void rtl88eu_dm_set_tx_ant_by_tx_info(struct odm_dm_struct *dm_odm, + u8 *desc, u8 mac_id) { struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV)) { - SET_TX_DESC_ANTSEL_A_88E(pDesc, dm_fat_tbl->antsel_a[macId]); - SET_TX_DESC_ANTSEL_B_88E(pDesc, dm_fat_tbl->antsel_b[macId]); - SET_TX_DESC_ANTSEL_C_88E(pDesc, dm_fat_tbl->antsel_c[macId]); + if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || + (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV)) { + SET_TX_DESC_ANTSEL_A_88E(desc, dm_fat_tbl->antsel_a[mac_id]); + SET_TX_DESC_ANTSEL_B_88E(desc, dm_fat_tbl->antsel_b[mac_id]); + SET_TX_DESC_ANTSEL_C_88E(desc, dm_fat_tbl->antsel_c[mac_id]); } } -void ODM_AntselStatistics_88E(struct odm_dm_struct *dm_odm, u8 antsel_tr_mux, u32 MacId, u8 RxPWDBAll) +void rtl88eu_dm_ant_sel_statistics(struct odm_dm_struct *dm_odm, + u8 antsel_tr_mux, u32 mac_id, u8 rx_pwdb_all) { struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { if (antsel_tr_mux == MAIN_ANT_CG_TRX) { - dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll; - dm_fat_tbl->MainAnt_Cnt[MacId]++; + dm_fat_tbl->MainAnt_Sum[mac_id] += rx_pwdb_all; + dm_fat_tbl->MainAnt_Cnt[mac_id]++; } else { - dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll; - dm_fat_tbl->AuxAnt_Cnt[MacId]++; + dm_fat_tbl->AuxAnt_Sum[mac_id] += rx_pwdb_all; + dm_fat_tbl->AuxAnt_Cnt[mac_id]++; } } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { if (antsel_tr_mux == MAIN_ANT_CGCS_RX) { - dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll; - dm_fat_tbl->MainAnt_Cnt[MacId]++; + dm_fat_tbl->MainAnt_Sum[mac_id] += rx_pwdb_all; + dm_fat_tbl->MainAnt_Cnt[mac_id]++; } else { - dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll; - dm_fat_tbl->AuxAnt_Cnt[MacId]++; + dm_fat_tbl->AuxAnt_Sum[mac_id] += rx_pwdb_all; + dm_fat_tbl->AuxAnt_Cnt[mac_id]++; } } } -static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) +static void rtl88eu_dm_hw_ant_div(struct odm_dm_struct *dm_odm) { - u32 i, MinRSSI = 0xFF, AntDivMaxRSSI = 0, MaxRSSI = 0, LocalMinRSSI, LocalMaxRSSI; - u32 Main_RSSI, Aux_RSSI; - u8 RxIdleAnt = 0, TargetAnt = 7; struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; - struct sta_info *pEntry; + struct rtw_dig *dig_table = &dm_odm->DM_DigTable; + struct sta_info *entry; + u32 i, min_rssi = 0xFF, ant_div_max_rssi = 0, max_rssi = 0; + u32 local_min_rssi, local_max_rssi; + u32 main_rssi, aux_rssi; + u8 RxIdleAnt = 0, target_ant = 7; for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { - pEntry = dm_odm->pODM_StaInfo[i]; - if (IS_STA_VALID(pEntry)) { + entry = dm_odm->pODM_StaInfo[i]; + if (IS_STA_VALID(entry)) { /* 2 Caculate RSSI per Antenna */ - Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; - Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; - TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("MacID=%d, MainAnt_Sum=%d, MainAnt_Cnt=%d\n", - i, dm_fat_tbl->MainAnt_Sum[i], - dm_fat_tbl->MainAnt_Cnt[i])); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("MacID=%d, AuxAnt_Sum=%d, AuxAnt_Cnt=%d\n", - i, dm_fat_tbl->AuxAnt_Sum[i], dm_fat_tbl->AuxAnt_Cnt[i])); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("MacID=%d, Main_RSSI= %d, Aux_RSSI= %d\n", - i, Main_RSSI, Aux_RSSI)); - /* 2 Select MaxRSSI for DIG */ - LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI; - if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40)) - AntDivMaxRSSI = LocalMaxRSSI; - if (LocalMaxRSSI > MaxRSSI) - MaxRSSI = LocalMaxRSSI; + main_rssi = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? + (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; + aux_rssi = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? + (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; + target_ant = (main_rssi >= aux_rssi) ? MAIN_ANT : AUX_ANT; + /* 2 Select max_rssi for DIG */ + local_max_rssi = (main_rssi > aux_rssi) ? + main_rssi : aux_rssi; + if ((local_max_rssi > ant_div_max_rssi) && + (local_max_rssi < 40)) + ant_div_max_rssi = local_max_rssi; + if (local_max_rssi > max_rssi) + max_rssi = local_max_rssi; /* 2 Select RX Idle Antenna */ - if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && (Main_RSSI == 0)) - Main_RSSI = Aux_RSSI; - else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0)) - Aux_RSSI = Main_RSSI; + if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && + (main_rssi == 0)) + main_rssi = aux_rssi; + else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && + (aux_rssi == 0)) + aux_rssi = main_rssi; - LocalMinRSSI = (Main_RSSI > Aux_RSSI) ? Aux_RSSI : Main_RSSI; - if (LocalMinRSSI < MinRSSI) { - MinRSSI = LocalMinRSSI; - RxIdleAnt = TargetAnt; + local_min_rssi = (main_rssi > aux_rssi) ? + aux_rssi : main_rssi; + if (local_min_rssi < min_rssi) { + min_rssi = local_min_rssi; + RxIdleAnt = target_ant; } /* 2 Select TRX Antenna */ if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - odm_UpdateTxAnt_88E(dm_odm, TargetAnt, i); + update_tx_ant_88eu(dm_odm, target_ant, i); } dm_fat_tbl->MainAnt_Sum[i] = 0; dm_fat_tbl->AuxAnt_Sum[i] = 0; @@ -334,66 +325,48 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) } /* 2 Set RX Idle Antenna */ - ODM_UpdateRxIdleAnt_88E(dm_odm, RxIdleAnt); + rtl88eu_dm_update_rx_idle_ant(dm_odm, RxIdleAnt); - pDM_DigTable->AntDiv_RSSI_max = AntDivMaxRSSI; - pDM_DigTable->RSSI_max = MaxRSSI; + dig_table->AntDiv_RSSI_max = ant_div_max_rssi; + dig_table->RSSI_max = max_rssi; } -void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm) +void rtl88eu_dm_antenna_diversity(struct odm_dm_struct *dm_odm) { struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - if ((dm_odm->SupportICType != ODM_RTL8188E) || (!(dm_odm->SupportAbility & ODM_BB_ANT_DIV))) + struct adapter *adapter = dm_odm->Adapter; + + if (!(dm_odm->SupportAbility & ODM_BB_ANT_DIV)) return; if (!dm_odm->bLinked) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_AntennaDiversity_88E(): No Link.\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("ODM_AntennaDiversity_88E(): No Link.\n")); if (dm_fat_tbl->bBecomeLinked) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn off HW AntDiv\n")); - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* RegC50[7]=1'b1 enable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 0); /* Enable CCK AntDiv */ + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("Need to Turn off HW AntDiv\n")); + phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT7, 0); + phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA1_11N, + BIT15, 0); if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ + phy_set_bb_reg(adapter, ODM_REG_TX_ANT_CTRL_11N, + BIT21, 0); dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; } return; } else { if (!dm_fat_tbl->bBecomeLinked) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn on HW AntDiv\n")); - /* Because HW AntDiv is disabled before Link, we enable HW AntDiv after link */ - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 1); /* Enable CCK AntDiv */ + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("Need to Turn on HW AntDiv\n")); + phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT7, 1); + phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA1_11N, + BIT15, 1); if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ + phy_set_bb_reg(adapter, ODM_REG_TX_ANT_CTRL_11N, + BIT21, 1); dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; } } - if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) - odm_HWAntDiv(dm_odm); -} - -/* 3============================================================ */ -/* 3 Dynamic Primary CCA */ -/* 3============================================================ */ - -void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) -{ - struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); - - PrimaryCCA->DupRTS_flag = 0; - PrimaryCCA->intf_flag = 0; - PrimaryCCA->intf_type = 0; - PrimaryCCA->Monitor_flag = 0; - PrimaryCCA->PriCCA_flag = 0; -} - -bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) -{ - struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); - - return PrimaryCCA->DupRTS_flag; -} - -void odm_DynamicPrimaryCCA(struct odm_dm_struct *dm_odm) -{ - return; + if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || + (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) + rtl88eu_dm_hw_ant_div(dm_odm); } diff --git a/hal/odm_RegConfig8188E.c b/hal/odm_RegConfig8188E.c deleted file mode 100644 index 18c0533..0000000 --- a/hal/odm_RegConfig8188E.c +++ /dev/null @@ -1,130 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -#include "odm_precomp.h" - -void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, - u32 Data, enum ODM_RF_RADIO_PATH RF_PATH, - u32 RegAddr) -{ - if (Addr == 0xffe) { - ODM_sleep_ms(50); - } else if (Addr == 0xfd) { - ODM_delay_ms(5); - } else if (Addr == 0xfc) { - ODM_delay_ms(1); - } else if (Addr == 0xfb) { - ODM_delay_us(50); - } else if (Addr == 0xfa) { - ODM_delay_us(5); - } else if (Addr == 0xf9) { - ODM_delay_us(1); - } else { - ODM_SetRFReg(pDM_Odm, RF_PATH, RegAddr, bRFRegOffsetMask, Data); - /* Add 1us delay between BB/RF register setting. */ - ODM_delay_us(1); - } -} - -void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) -{ - u32 content = 0x1000; /* RF_Content: radioa_txt */ - u32 maskforPhySet = (u32)(content&0xE000); - - odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, ODM_RF_PATH_A, Addr|maskforPhySet); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioA] %08X %08X\n", Addr, Data)); -} - -void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) -{ - u32 content = 0x1001; /* RF_Content: radiob_txt */ - u32 maskforPhySet = (u32)(content&0xE000); - - odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, ODM_RF_PATH_B, Addr|maskforPhySet); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioB] %08X %08X\n", Addr, Data)); -} - -void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) -{ - ODM_Write1Byte(pDM_Odm, Addr, Data); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigMACWithHeaderFile: [MAC_REG] %08X %08X\n", Addr, Data)); -} - -void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) -{ - ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data); - /* Add 1us delay between BB/RF register setting. */ - ODM_delay_us(1); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, - ("===> ODM_ConfigBBWithHeaderFile: [AGC_TAB] %08X %08X\n", - Addr, Data)); -} - -void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, - u32 Bitmask, u32 Data) -{ - if (Addr == 0xfe) { - ODM_sleep_ms(50); - } else if (Addr == 0xfd) { - ODM_delay_ms(5); - } else if (Addr == 0xfc) { - ODM_delay_ms(1); - } else if (Addr == 0xfb) { - ODM_delay_us(50); - } else if (Addr == 0xfa) { - ODM_delay_us(5); - } else if (Addr == 0xf9) { - ODM_delay_us(1); - } else{ - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, - ("===> @@@@@@@ ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X %08X\n", - Addr, Bitmask, Data)); - storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data); - } -} - -void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) -{ - if (Addr == 0xfe) { - ODM_sleep_ms(50); - } else if (Addr == 0xfd) { - ODM_delay_ms(5); - } else if (Addr == 0xfc) { - ODM_delay_ms(1); - } else if (Addr == 0xfb) { - ODM_delay_us(50); - } else if (Addr == 0xfa) { - ODM_delay_us(5); - } else if (Addr == 0xf9) { - ODM_delay_us(1); - } else { - if (Addr == 0xa24) - pDM_Odm->RFCalibrateInfo.RegA24 = Data; - ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data); - - /* Add 1us delay between BB/RF register setting. */ - ODM_delay_us(1); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, - ("===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X\n", - Addr, Data)); - } -} diff --git a/hal/odm_debug.c b/hal/odm_debug.c deleted file mode 100644 index 84caadd..0000000 --- a/hal/odm_debug.c +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -/* include files */ - -#include "odm_precomp.h" - -void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm) -{ - pDM_Odm->DebugLevel = ODM_DBG_TRACE; - - pDM_Odm->DebugComponents = 0; -} - -u32 GlobalDebugLevel; diff --git a/hal/odm_interface.c b/hal/odm_interface.c deleted file mode 100644 index 59ad5bf..0000000 --- a/hal/odm_interface.c +++ /dev/null @@ -1,203 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -#include "odm_precomp.h" -/* ODM IO Relative API. */ - -u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return rtw_read8(Adapter, RegAddr); -} - -u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return rtw_read16(Adapter, RegAddr); -} - -u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return rtw_read32(Adapter, RegAddr); -} - -void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - rtw_write8(Adapter, RegAddr, Data); -} - -void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - rtw_write16(Adapter, RegAddr, Data); -} - -void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - rtw_write32(Adapter, RegAddr, Data); -} - -void ODM_SetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - PHY_SetBBReg(Adapter, RegAddr, BitMask, Data); -} - -u32 ODM_GetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return PHY_QueryBBReg(Adapter, RegAddr, BitMask); -} - -void ODM_SetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - PHY_SetBBReg(Adapter, RegAddr, BitMask, Data); -} - -u32 ODM_GetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return PHY_QueryBBReg(Adapter, RegAddr, BitMask); -} - -void ODM_SetRFReg(struct odm_dm_struct *pDM_Odm, enum ODM_RF_RADIO_PATH eRFPath, u32 RegAddr, u32 BitMask, u32 Data) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - PHY_SetRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask, Data); -} - -u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum ODM_RF_RADIO_PATH eRFPath, u32 RegAddr, u32 BitMask) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - return PHY_QueryRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask); -} - -/* ODM Memory relative API. */ -void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) -{ - *pPtr = rtw_zvmalloc(length); -} - -/* length could be ignored, used to detect memory leakage. */ -void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length) -{ - rtw_vmfree(pPtr, length); -} - -s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length) -{ - return _rtw_memcmp(pBuf1, pBuf2, length); -} - -/* ODM MISC relative API. */ -void ODM_AcquireSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type) -{ -} - -void ODM_ReleaseSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type) -{ -} - -/* Work item relative API. FOr MP driver only~! */ -void ODM_InitializeWorkItem(struct odm_dm_struct *pDM_Odm, void *pRtWorkItem, - RT_WORKITEM_CALL_BACK RtWorkItemCallback, - void *pContext, const char *szID) -{ -} - -void ODM_StartWorkItem(void *pRtWorkItem) -{ -} - -void ODM_StopWorkItem(void *pRtWorkItem) -{ -} - -void ODM_FreeWorkItem(void *pRtWorkItem) -{ -} - -void ODM_ScheduleWorkItem(void *pRtWorkItem) -{ -} - -void ODM_IsWorkItemScheduled(void *pRtWorkItem) -{ -} - -/* ODM Timer relative API. */ -void ODM_StallExecution(u32 usDelay) -{ - rtw_udelay_os(usDelay); -} - -void ODM_delay_ms(u32 ms) -{ - rtw_mdelay_os(ms); -} - -void ODM_delay_us(u32 us) -{ - rtw_udelay_os(us); -} - -void ODM_sleep_ms(u32 ms) -{ - rtw_msleep_os(ms); -} - -void ODM_sleep_us(u32 us) -{ - rtw_usleep_os(us); -} - -void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 msDelay) -{ - _set_timer(pTimer, msDelay); /* ms */ -} - -void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, - void *CallBackFunc, void *pContext, - const char *szID) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - _init_timer(pTimer, Adapter->pnetdev, CallBackFunc, pDM_Odm); -} - -void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) -{ - _cancel_timer_ex(pTimer); -} - -void ODM_ReleaseTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) -{ -} - -/* ODM FW relative API. */ -u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, - u32 *pElementID, u32 *pCmdLen, - u8 **pCmbBuffer, u8 *CmdStartSeq) -{ - return true; -} diff --git a/hal/phy.c b/hal/phy.c new file mode 100644 index 0000000..3f663fe --- /dev/null +++ b/hal/phy.c @@ -0,0 +1,1570 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_PHYCFG_C_ + +#include +#include +#include +#include +#include +#include + +#define MAX_PRECMD_CNT 16 +#define MAX_RFDEPENDCMD_CNT 16 +#define MAX_POSTCMD_CNT 16 + +#define MAX_DOZE_WAITING_TIMES_9x 64 + +static u32 cal_bit_shift(u32 bitmask) +{ + u32 i; + + for (i = 0; i <= 31; i++) { + if (((bitmask >> i) & 0x1) == 1) + break; + } + return i; +} + +u32 phy_query_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask) +{ + u32 return_value = 0, original_value, bit_shift; + + original_value = usb_read32(adapt, regaddr); + bit_shift = cal_bit_shift(bitmask); + return_value = (original_value & bitmask) >> bit_shift; + return return_value; +} + +void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data) +{ + u32 original_value, bit_shift; + + if (bitmask != bMaskDWord) { /* if not "double word" write */ + original_value = usb_read32(adapt, regaddr); + bit_shift = cal_bit_shift(bitmask); + data = ((original_value & (~bitmask)) | (data << bit_shift)); + } + + usb_write32(adapt, regaddr, data); +} + +static u32 rf_serial_read(struct adapter *adapt, + enum rf_radio_path rfpath, u32 offset) +{ + u32 ret = 0; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct bb_reg_def *phyreg = &hal_data->PHYRegDef[rfpath]; + u32 newoffset; + u32 tmplong, tmplong2; + u8 rfpi_enable = 0; + + offset &= 0xff; + newoffset = offset; + + tmplong = phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord); + if (rfpath == RF_PATH_A) + tmplong2 = tmplong; + else + tmplong2 = phy_query_bb_reg(adapt, phyreg->rfHSSIPara2, + bMaskDWord); + + tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | + (newoffset<<23) | bLSSIReadEdge; + + phy_set_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord, + tmplong&(~bLSSIReadEdge)); + udelay(10); + + phy_set_bb_reg(adapt, phyreg->rfHSSIPara2, bMaskDWord, tmplong2); + udelay(100); + + udelay(10); + + if (rfpath == RF_PATH_A) + rfpi_enable = (u8)phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, BIT8); + else if (rfpath == RF_PATH_B) + rfpi_enable = (u8)phy_query_bb_reg(adapt, rFPGA0_XB_HSSIParameter1, BIT8); + + if (rfpi_enable) + ret = phy_query_bb_reg(adapt, phyreg->rfLSSIReadBackPi, + bLSSIReadBackData); + else + ret = phy_query_bb_reg(adapt, phyreg->rfLSSIReadBack, + bLSSIReadBackData); + return ret; +} + +static void rf_serial_write(struct adapter *adapt, + enum rf_radio_path rfpath, u32 offset, + u32 data) +{ + u32 data_and_addr = 0; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct bb_reg_def *phyreg = &hal_data->PHYRegDef[rfpath]; + u32 newoffset; + + newoffset = offset & 0xff; + data_and_addr = ((newoffset<<20) | (data&0x000fffff)) & 0x0fffffff; + phy_set_bb_reg(adapt, phyreg->rf3wireOffset, bMaskDWord, data_and_addr); +} + +u32 phy_query_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path, + u32 reg_addr, u32 bit_mask) +{ + u32 original_value, readback_value, bit_shift; + + original_value = rf_serial_read(adapt, rf_path, reg_addr); + bit_shift = cal_bit_shift(bit_mask); + readback_value = (original_value & bit_mask) >> bit_shift; + return readback_value; +} + +void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path, + u32 reg_addr, u32 bit_mask, u32 data) +{ + u32 original_value, bit_shift; + + /* RF data is 12 bits only */ + if (bit_mask != bRFRegOffsetMask) { + original_value = rf_serial_read(adapt, rf_path, reg_addr); + bit_shift = cal_bit_shift(bit_mask); + data = ((original_value & (~bit_mask)) | (data << bit_shift)); + } + + rf_serial_write(adapt, rf_path, reg_addr, data); +} + +static void get_tx_power_index(struct adapter *adapt, u8 channel, u8 *cck_pwr, + u8 *ofdm_pwr, u8 *bw20_pwr, u8 *bw40_pwr) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u8 index = (channel - 1); + u8 TxCount = 0, path_nums; + + if ((RF_1T2R == hal_data->rf_type) || (RF_1T1R == hal_data->rf_type)) + path_nums = 1; + else + path_nums = 2; + + for (TxCount = 0; TxCount < path_nums; TxCount++) { + if (TxCount == RF_PATH_A) { + cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->OFDM_24G_Diff[TxCount][RF_PATH_A]; + + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]; + bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_B) { + cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[TxCount][index]; + + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]+ + hal_data->BW20_24G_Diff[TxCount][index]; + bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_C) { + cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_B][index]+ + hal_data->BW20_24G_Diff[TxCount][index]; + + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_B][index]+ + hal_data->BW20_24G_Diff[TxCount][index]; + bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_D) { + cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_B][index]+ + hal_data->BW20_24G_Diff[RF_PATH_C][index]+ + hal_data->BW20_24G_Diff[TxCount][index]; + + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_A][index]+ + hal_data->BW20_24G_Diff[RF_PATH_B][index]+ + hal_data->BW20_24G_Diff[RF_PATH_C][index]+ + hal_data->BW20_24G_Diff[TxCount][index]; + bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; + } + } +} + +static void phy_power_index_check(struct adapter *adapt, u8 channel, + u8 *cck_pwr, u8 *ofdm_pwr, u8 *bw20_pwr, + u8 *bw40_pwr) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + + hal_data->CurrentCckTxPwrIdx = cck_pwr[0]; + hal_data->CurrentOfdm24GTxPwrIdx = ofdm_pwr[0]; + hal_data->CurrentBW2024GTxPwrIdx = bw20_pwr[0]; + hal_data->CurrentBW4024GTxPwrIdx = bw40_pwr[0]; +} + +void phy_set_tx_power_level(struct adapter *adapt, u8 channel) +{ + u8 cck_pwr[MAX_TX_COUNT] = {0}; + u8 ofdm_pwr[MAX_TX_COUNT] = {0};/* [0]:RF-A, [1]:RF-B */ + u8 bw20_pwr[MAX_TX_COUNT] = {0}; + u8 bw40_pwr[MAX_TX_COUNT] = {0}; + + get_tx_power_index(adapt, channel, &cck_pwr[0], &ofdm_pwr[0], + &bw20_pwr[0], &bw40_pwr[0]); + + phy_power_index_check(adapt, channel, &cck_pwr[0], &ofdm_pwr[0], + &bw20_pwr[0], &bw40_pwr[0]); + + rtl88eu_phy_rf6052_set_cck_txpower(adapt, &cck_pwr[0]); + rtl88eu_phy_rf6052_set_ofdm_txpower(adapt, &ofdm_pwr[0], &bw20_pwr[0], + &bw40_pwr[0], channel); +} + +static void phy_set_bw_mode_callback(struct adapter *adapt) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u8 reg_bw_opmode; + u8 reg_prsr_rsc; + + if (hal_data->rf_chip == RF_PSEUDO_11N) + return; + + /* There is no 40MHz mode in RF_8225. */ + if (hal_data->rf_chip == RF_8225) + return; + + if (adapt->bDriverStopped) + return; + + /* Set MAC register */ + + reg_bw_opmode = usb_read8(adapt, REG_BWOPMODE); + reg_prsr_rsc = usb_read8(adapt, REG_RRSR+2); + + switch (hal_data->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + reg_bw_opmode |= BW_OPMODE_20MHZ; + usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode); + break; + case HT_CHANNEL_WIDTH_40: + reg_bw_opmode &= ~BW_OPMODE_20MHZ; + usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode); + reg_prsr_rsc = (reg_prsr_rsc&0x90) | + (hal_data->nCur40MhzPrimeSC<<5); + usb_write8(adapt, REG_RRSR+2, reg_prsr_rsc); + break; + default: + break; + } + + /* Set PHY related register */ + switch (hal_data->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + phy_set_bb_reg(adapt, rFPGA0_RFMOD, bRFMOD, 0x0); + phy_set_bb_reg(adapt, rFPGA1_RFMOD, bRFMOD, 0x0); + break; + case HT_CHANNEL_WIDTH_40: + phy_set_bb_reg(adapt, rFPGA0_RFMOD, bRFMOD, 0x1); + phy_set_bb_reg(adapt, rFPGA1_RFMOD, bRFMOD, 0x1); + /* Set Control channel to upper or lower. + * These settings are required only for 40MHz + */ + phy_set_bb_reg(adapt, rCCK0_System, bCCKSideBand, + (hal_data->nCur40MhzPrimeSC>>1)); + phy_set_bb_reg(adapt, rOFDM1_LSTF, 0xC00, + hal_data->nCur40MhzPrimeSC); + phy_set_bb_reg(adapt, 0x818, (BIT26 | BIT27), + (hal_data->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); + break; + default: + break; + } + + /* Set RF related register */ + switch (hal_data->rf_chip) { + case RF_8225: + break; + case RF_8256: + break; + case RF_8258: + break; + case RF_PSEUDO_11N: + break; + case RF_6052: + rtl88eu_phy_rf6052_set_bandwidth(adapt, hal_data->CurrentChannelBW); + break; + default: + break; + } +} + +void phy_set_bw_mode(struct adapter *adapt, enum ht_channel_width bandwidth, + unsigned char offset) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + enum ht_channel_width tmp_bw = hal_data->CurrentChannelBW; + + hal_data->CurrentChannelBW = bandwidth; + hal_data->nCur40MhzPrimeSC = offset; + + if ((!adapt->bDriverStopped) && (!adapt->bSurpriseRemoved)) + phy_set_bw_mode_callback(adapt); + else + hal_data->CurrentChannelBW = tmp_bw; +} + +static void phy_sw_chnl_callback(struct adapter *adapt, u8 channel) +{ + u8 rf_path; + u32 param1, param2; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + + if (adapt->bNotifyChannelChange) + DBG_88E("[%s] ch = %d\n", __func__, channel); + + phy_set_tx_power_level(adapt, channel); + + param1 = RF_CHNLBW; + param2 = channel; + for (rf_path = 0; rf_path < hal_data->NumTotalRFPath; rf_path++) { + hal_data->RfRegChnlVal[rf_path] = (hal_data->RfRegChnlVal[rf_path] & + 0xfffffc00) | param2; + phy_set_rf_reg(adapt, (enum rf_radio_path)rf_path, param1, + bRFRegOffsetMask, hal_data->RfRegChnlVal[rf_path]); + } +} + +void phy_sw_chnl(struct adapter *adapt, u8 channel) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u8 tmpchannel = hal_data->CurrentChannel; + bool result = true; + + if (hal_data->rf_chip == RF_PSEUDO_11N) + return; + + if (channel == 0) + channel = 1; + + hal_data->CurrentChannel = channel; + + if ((!adapt->bDriverStopped) && (!adapt->bSurpriseRemoved)) { + phy_sw_chnl_callback(adapt, channel); + + if (!result) + hal_data->CurrentChannel = tmpchannel; + + } else { + hal_data->CurrentChannel = tmpchannel; + } +} + +#define ODM_TXPWRTRACK_MAX_IDX_88E 6 + +static u8 get_right_chnl_for_iqk(u8 chnl) +{ + u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, + 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, + 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, + 155, 157, 159, 161, 163, 165 + }; + u8 place = chnl; + + if (chnl > 14) { + for (place = 14; place < sizeof(channel_all); place++) { + if (channel_all[place] == chnl) + return place-13; + } + } + return 0; +} + +void rtl88eu_dm_txpower_track_adjust(struct odm_dm_struct *dm_odm, u8 type, + u8 *direction, u32 *out_write_val) +{ + u8 pwr_value = 0; + /* Tx power tracking BB swing table. */ + if (type == 0) { /* For OFDM adjust */ + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", + dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); + + if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) { + *direction = 1; + pwr_value = (dm_odm->BbSwingIdxOfdmBase - + dm_odm->BbSwingIdxOfdm); + } else { + *direction = 2; + pwr_value = (dm_odm->BbSwingIdxOfdm - + dm_odm->BbSwingIdxOfdmBase); + } + + } else if (type == 1) { /* For CCK adjust. */ + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("dm_odm->BbSwingIdxCck = %d dm_odm->BbSwingIdxCckBase = %d\n", + dm_odm->BbSwingIdxCck, dm_odm->BbSwingIdxCckBase)); + + if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) { + *direction = 1; + pwr_value = (dm_odm->BbSwingIdxCckBase - + dm_odm->BbSwingIdxCck); + } else { + *direction = 2; + pwr_value = (dm_odm->BbSwingIdxCck - + dm_odm->BbSwingIdxCckBase); + } + + } + + if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *direction == 1) + pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E; + + *out_write_val = pwr_value | (pwr_value<<8) | (pwr_value<<16) | + (pwr_value<<24); +} + +static void dm_txpwr_track_setpwr(struct odm_dm_struct *dm_odm) +{ + if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) { + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("dm_txpwr_track_setpwr CH=%d\n", *(dm_odm->pChannel))); + phy_set_tx_power_level(dm_odm->Adapter, *(dm_odm->pChannel)); + dm_odm->BbSwingFlagOfdm = false; + dm_odm->BbSwingFlagCck = false; + } +} + +void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u8 thermal_val = 0, delta, delta_lck, delta_iqk, offset; + u8 thermal_avg_count = 0; + u32 thermal_avg = 0; + s32 ele_a = 0, ele_d, temp_cck, x, value32; + s32 y, ele_c = 0; + s8 ofdm_index[2], cck_index = 0; + s8 ofdm_index_old[2] = {0, 0}, cck_index_old = 0; + u32 i = 0, j = 0; + bool is2t = false; + + u8 ofdm_min_index = 6, rf; /* OFDM BB Swing should be less than +3.0dB */ + u8 indexforchannel = 0; + s8 ofdm_index_mapping[2][index_mapping_NUM_88E] = { + /* 2.4G, decrease power */ + {0, 0, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11}, + /* 2.4G, increase power */ + {0, 0, -1, -2, -3, -4, -4, -4, -4, -5, -7, -8, -9, -9, -10}, + }; + u8 thermal_mapping[2][index_mapping_NUM_88E] = { + /* 2.4G, decrease power */ + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27}, + /* 2.4G, increase power */ + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 25, 25}, + }; + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + + dm_txpwr_track_setpwr(dm_odm); + + dm_odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; + dm_odm->RFCalibrateInfo.bTXPowerTrackingInit = true; + + dm_odm->RFCalibrateInfo.RegA24 = 0x090e1317; + + thermal_val = (u8)phy_query_rf_reg(adapt, RF_PATH_A, + RF_T_METER_88E, 0xfc00); + + if (is2t) + rf = 2; + else + rf = 1; + + if (thermal_val) { + /* Query OFDM path A default setting */ + ele_d = phy_query_bb_reg(adapt, rOFDM0_XATxIQImbalance, bMaskDWord)&bMaskOFDM_D; + for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { + if (ele_d == (OFDMSwingTable[i]&bMaskOFDM_D)) { + ofdm_index_old[0] = (u8)i; + dm_odm->BbSwingIdxOfdmBase = (u8)i; + break; + } + } + + /* Query OFDM path B default setting */ + if (is2t) { + ele_d = phy_query_bb_reg(adapt, rOFDM0_XBTxIQImbalance, bMaskDWord)&bMaskOFDM_D; + for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { + if (ele_d == (OFDMSwingTable[i]&bMaskOFDM_D)) { + ofdm_index_old[1] = (u8)i; + break; + } + } + } + + /* Query CCK default setting From 0xa24 */ + temp_cck = dm_odm->RFCalibrateInfo.RegA24; + + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (dm_odm->RFCalibrateInfo.bCCKinCH14) { + if (memcmp(&temp_cck, &CCKSwingTable_Ch14[i][2], 4)) { + cck_index_old = (u8)i; + dm_odm->BbSwingIdxCckBase = (u8)i; + break; + } + } else { + if (memcmp(&temp_cck, &CCKSwingTable_Ch1_Ch13[i][2], 4)) { + cck_index_old = (u8)i; + dm_odm->BbSwingIdxCckBase = (u8)i; + break; + } + } + } + + if (!dm_odm->RFCalibrateInfo.ThermalValue) { + dm_odm->RFCalibrateInfo.ThermalValue = hal_data->EEPROMThermalMeter; + dm_odm->RFCalibrateInfo.ThermalValue_LCK = thermal_val; + dm_odm->RFCalibrateInfo.ThermalValue_IQK = thermal_val; + + for (i = 0; i < rf; i++) + dm_odm->RFCalibrateInfo.OFDM_index[i] = ofdm_index_old[i]; + dm_odm->RFCalibrateInfo.CCK_index = cck_index_old; + } + + /* calculate average thermal meter */ + dm_odm->RFCalibrateInfo.ThermalValue_AVG[dm_odm->RFCalibrateInfo.ThermalValue_AVG_index] = thermal_val; + dm_odm->RFCalibrateInfo.ThermalValue_AVG_index++; + if (dm_odm->RFCalibrateInfo.ThermalValue_AVG_index == AVG_THERMAL_NUM_88E) + dm_odm->RFCalibrateInfo.ThermalValue_AVG_index = 0; + + for (i = 0; i < AVG_THERMAL_NUM_88E; i++) { + if (dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]) { + thermal_avg += dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]; + thermal_avg_count++; + } + } + + if (thermal_avg_count) + thermal_val = (u8)(thermal_avg / thermal_avg_count); + + if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { + delta = thermal_val > hal_data->EEPROMThermalMeter ? + (thermal_val - hal_data->EEPROMThermalMeter) : + (hal_data->EEPROMThermalMeter - thermal_val); + dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false; + dm_odm->RFCalibrateInfo.bDoneTxpower = false; + } else if (dm_odm->RFCalibrateInfo.bDoneTxpower) { + delta = (thermal_val > dm_odm->RFCalibrateInfo.ThermalValue) ? + (thermal_val - dm_odm->RFCalibrateInfo.ThermalValue) : + (dm_odm->RFCalibrateInfo.ThermalValue - thermal_val); + } else { + delta = thermal_val > hal_data->EEPROMThermalMeter ? + (thermal_val - hal_data->EEPROMThermalMeter) : + (hal_data->EEPROMThermalMeter - thermal_val); + } + delta_lck = (thermal_val > dm_odm->RFCalibrateInfo.ThermalValue_LCK) ? + (thermal_val - dm_odm->RFCalibrateInfo.ThermalValue_LCK) : + (dm_odm->RFCalibrateInfo.ThermalValue_LCK - thermal_val); + delta_iqk = (thermal_val > dm_odm->RFCalibrateInfo.ThermalValue_IQK) ? + (thermal_val - dm_odm->RFCalibrateInfo.ThermalValue_IQK) : + (dm_odm->RFCalibrateInfo.ThermalValue_IQK - thermal_val); + + /* Delta temperature is equal to or larger than 20 centigrade.*/ + if ((delta_lck >= 8)) { + dm_odm->RFCalibrateInfo.ThermalValue_LCK = thermal_val; + rtl88eu_phy_lc_calibrate(adapt); + } + + if (delta > 0 && dm_odm->RFCalibrateInfo.TxPowerTrackControl) { + delta = thermal_val > hal_data->EEPROMThermalMeter ? + (thermal_val - hal_data->EEPROMThermalMeter) : + (hal_data->EEPROMThermalMeter - thermal_val); + /* calculate new OFDM / CCK offset */ + if (thermal_val > hal_data->EEPROMThermalMeter) + j = 1; + else + j = 0; + for (offset = 0; offset < index_mapping_NUM_88E; offset++) { + if (delta < thermal_mapping[j][offset]) { + if (offset != 0) + offset--; + break; + } + } + if (offset >= index_mapping_NUM_88E) + offset = index_mapping_NUM_88E-1; + for (i = 0; i < rf; i++) + ofdm_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + ofdm_index_mapping[j][offset]; + cck_index = dm_odm->RFCalibrateInfo.CCK_index + ofdm_index_mapping[j][offset]; + + for (i = 0; i < rf; i++) { + if (ofdm_index[i] > OFDM_TABLE_SIZE_92D-1) + ofdm_index[i] = OFDM_TABLE_SIZE_92D-1; + else if (ofdm_index[i] < ofdm_min_index) + ofdm_index[i] = ofdm_min_index; + } + + if (cck_index > CCK_TABLE_SIZE-1) + cck_index = CCK_TABLE_SIZE-1; + else if (cck_index < 0) + cck_index = 0; + + /* 2 temporarily remove bNOPG */ + /* Config by SwingTable */ + if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) { + dm_odm->RFCalibrateInfo.bDoneTxpower = true; + + /* Adujst OFDM Ant_A according to IQK result */ + ele_d = (OFDMSwingTable[(u8)ofdm_index[0]] & 0xFFC00000)>>22; + x = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][0]; + y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][1]; + + /* Revse TX power table. */ + dm_odm->BbSwingIdxOfdm = (u8)ofdm_index[0]; + dm_odm->BbSwingIdxCck = (u8)cck_index; + + if (dm_odm->BbSwingIdxOfdmCurrent != dm_odm->BbSwingIdxOfdm) { + dm_odm->BbSwingIdxOfdmCurrent = dm_odm->BbSwingIdxOfdm; + dm_odm->BbSwingFlagOfdm = true; + } + + if (dm_odm->BbSwingIdxCckCurrent != dm_odm->BbSwingIdxCck) { + dm_odm->BbSwingIdxCckCurrent = dm_odm->BbSwingIdxCck; + dm_odm->BbSwingFlagCck = true; + } + + if (x != 0) { + if ((x & 0x00000200) != 0) + x = x | 0xFFFFFC00; + ele_a = ((x * ele_d)>>8)&0x000003FF; + + /* new element C = element D x Y */ + if ((y & 0x00000200) != 0) + y = y | 0xFFFFFC00; + ele_c = ((y * ele_d)>>8)&0x000003FF; + + } + + if (is2t) { + ele_d = (OFDMSwingTable[(u8)ofdm_index[1]] & 0xFFC00000)>>22; + + /* new element A = element D x X */ + x = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][4]; + y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][5]; + + if ((x != 0) && (*(dm_odm->pBandType) == ODM_BAND_2_4G)) { + if ((x & 0x00000200) != 0) /* consider minus */ + x = x | 0xFFFFFC00; + ele_a = ((x * ele_d)>>8)&0x000003FF; + + /* new element C = element D x Y */ + if ((y & 0x00000200) != 0) + y = y | 0xFFFFFC00; + ele_c = ((y * ele_d)>>8)&0x00003FF; + + /* wtite new elements A, C, D to regC88 and regC9C, element B is always 0 */ + value32 = (ele_d<<22) | ((ele_c&0x3F)<<16) | ele_a; + phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, bMaskDWord, value32); + + value32 = (ele_c&0x000003C0)>>6; + phy_set_bb_reg(adapt, rOFDM0_XDTxAFE, bMaskH4Bits, value32); + + value32 = ((x * ele_d)>>7)&0x01; + phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT28, value32); + } else { + phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable[(u8)ofdm_index[1]]); + phy_set_bb_reg(adapt, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); + phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT28, 0x00); + } + + } + + } + } + + /* Delta temperature is equal to or larger than 20 centigrade.*/ + if (delta_iqk >= 8) { + dm_odm->RFCalibrateInfo.ThermalValue_IQK = thermal_val; + rtl88eu_phy_iq_calibrate(adapt, false); + } + /* update thermal meter value */ + if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) + dm_odm->RFCalibrateInfo.ThermalValue = thermal_val; + } + dm_odm->RFCalibrateInfo.TXPowercount = 0; +} + +#define MAX_TOLERANCE 5 + +static u8 phy_path_a_iqk(struct adapter *adapt, bool config_pathb) +{ + u32 reg_eac, reg_e94, reg_e9c, reg_ea4; + u8 result = 0x00; + + /* 1 Tx IQK */ + /* path-A IQK setting */ + phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); + phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); + phy_set_bb_reg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x8214032a); + phy_set_bb_reg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160000); + + /* LO calibration setting */ + phy_set_bb_reg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x00462911); + + /* One shot, path A LOK & IQK */ + phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + mdelay(IQK_DELAY_TIME_88E); + + reg_eac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); + reg_e94 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord); + reg_e9c = phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, bMaskDWord); + reg_ea4 = phy_query_bb_reg(adapt, rRx_Power_Before_IQK_A_2, bMaskDWord); + + if (!(reg_eac & BIT28) && + (((reg_e94 & 0x03FF0000)>>16) != 0x142) && + (((reg_e9c & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + return result; +} + +static u8 phy_path_a_rx_iqk(struct adapter *adapt, bool configPathB) +{ + u32 reg_eac, reg_e94, reg_e9c, reg_ea4, u4tmp; + u8 result = 0x00; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + + /* 1 Get TXIMR setting */ + /* modify RXIQK mode table */ + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000); + phy_set_rf_reg(adapt, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); + phy_set_rf_reg(adapt, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); + phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); + phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf117B); + + /* PA,PAD off */ + phy_set_rf_reg(adapt, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x980); + phy_set_rf_reg(adapt, RF_PATH_A, 0x56, bRFRegOffsetMask, 0x51000); + + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); + + /* IQK setting */ + phy_set_bb_reg(adapt, rTx_IQK, bMaskDWord, 0x01007c00); + phy_set_bb_reg(adapt, rRx_IQK, bMaskDWord, 0x81004800); + + /* path-A IQK setting */ + phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); + phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); + phy_set_bb_reg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x82160c1f); + phy_set_bb_reg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160000); + + /* LO calibration setting */ + phy_set_bb_reg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); + + /* One shot, path A LOK & IQK */ + phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + /* delay x ms */ + mdelay(IQK_DELAY_TIME_88E); + + /* Check failed */ + reg_eac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); + reg_e94 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord); + reg_e9c = phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, bMaskDWord); + + if (!(reg_eac & BIT28) && + (((reg_e94 & 0x03FF0000)>>16) != 0x142) && + (((reg_e9c & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + else /* if Tx not OK, ignore Rx */ + return result; + + u4tmp = 0x80007C00 | (reg_e94&0x3FF0000) | ((reg_e9c&0x3FF0000) >> 16); + phy_set_bb_reg(adapt, rTx_IQK, bMaskDWord, u4tmp); + + /* 1 RX IQK */ + /* modify RXIQK mode table */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path-A Rx IQK modify RXIQK mode table 2!\n")); + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000); + phy_set_rf_reg(adapt, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); + phy_set_rf_reg(adapt, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); + phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); + phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7ffa); + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); + + /* IQK setting */ + phy_set_bb_reg(adapt, rRx_IQK, bMaskDWord, 0x01004800); + + /* path-A IQK setting */ + phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x38008c1c); + phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x18008c1c); + phy_set_bb_reg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x82160c05); + phy_set_bb_reg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160c1f); + + /* LO calibration setting */ + phy_set_bb_reg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); + + phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + mdelay(IQK_DELAY_TIME_88E); + + /* Check failed */ + reg_eac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); + reg_e94 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord); + reg_e9c = phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, bMaskDWord); + reg_ea4 = phy_query_bb_reg(adapt, rRx_Power_Before_IQK_A_2, bMaskDWord); + + /* reload RF 0xdf */ + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000); + phy_set_rf_reg(adapt, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x180); + + if (!(reg_eac & BIT27) && /* if Tx is OK, check whether Rx is OK */ + (((reg_ea4 & 0x03FF0000)>>16) != 0x132) && + (((reg_eac & 0x03FF0000)>>16) != 0x36)) + result |= 0x02; + else + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path A Rx IQK fail!!\n")); + + return result; +} + +static u8 phy_path_b_iqk(struct adapter *adapt) +{ + u32 regeac, regeb4, regebc, regec4, regecc; + u8 result = 0x00; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + + /* One shot, path B LOK & IQK */ + phy_set_bb_reg(adapt, rIQK_AGC_Cont, bMaskDWord, 0x00000002); + phy_set_bb_reg(adapt, rIQK_AGC_Cont, bMaskDWord, 0x00000000); + + mdelay(IQK_DELAY_TIME_88E); + + regeac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); + regeb4 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_B, bMaskDWord); + regebc = phy_query_bb_reg(adapt, rTx_Power_After_IQK_B, bMaskDWord); + regec4 = phy_query_bb_reg(adapt, rRx_Power_Before_IQK_B_2, bMaskDWord); + regecc = phy_query_bb_reg(adapt, rRx_Power_After_IQK_B_2, bMaskDWord); + + if (!(regeac & BIT31) && + (((regeb4 & 0x03FF0000)>>16) != 0x142) && + (((regebc & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + else + return result; + + if (!(regeac & BIT30) && + (((regec4 & 0x03FF0000)>>16) != 0x132) && + (((regecc & 0x03FF0000)>>16) != 0x36)) + result |= 0x02; + else + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, + ODM_DBG_LOUD, ("Path B Rx IQK fail!!\n")); + return result; +} + +static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], + u8 final_candidate, bool txonly) +{ + u32 oldval_0, x, tx0_a, reg; + s32 y, tx0_c; + + if (final_candidate == 0xFF) { + return; + } else if (iqkok) { + oldval_0 = (phy_query_bb_reg(adapt, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + x = result[final_candidate][0]; + if ((x & 0x00000200) != 0) + x = x | 0xFFFFFC00; + + tx0_a = (x * oldval_0) >> 8; + phy_set_bb_reg(adapt, rOFDM0_XATxIQImbalance, 0x3FF, tx0_a); + phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(31), + ((x * oldval_0>>7) & 0x1)); + + y = result[final_candidate][1]; + if ((y & 0x00000200) != 0) + y = y | 0xFFFFFC00; + + tx0_c = (y * oldval_0) >> 8; + phy_set_bb_reg(adapt, rOFDM0_XCTxAFE, 0xF0000000, + ((tx0_c&0x3C0)>>6)); + phy_set_bb_reg(adapt, rOFDM0_XATxIQImbalance, 0x003F0000, + (tx0_c&0x3F)); + phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(29), + ((y * oldval_0>>7) & 0x1)); + + if (txonly) + return; + + reg = result[final_candidate][2]; + phy_set_bb_reg(adapt, rOFDM0_XARxIQImbalance, 0x3FF, reg); + + reg = result[final_candidate][3] & 0x3F; + phy_set_bb_reg(adapt, rOFDM0_XARxIQImbalance, 0xFC00, reg); + + reg = (result[final_candidate][3] >> 6) & 0xF; + phy_set_bb_reg(adapt, rOFDM0_RxIQExtAnta, 0xF0000000, reg); + } +} + +static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], + u8 final_candidate, bool txonly) +{ + u32 oldval_1, x, tx1_a, reg; + s32 y, tx1_c; + + if (final_candidate == 0xFF) { + return; + } else if (iqkok) { + oldval_1 = (phy_query_bb_reg(adapt, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + x = result[final_candidate][4]; + if ((x & 0x00000200) != 0) + x = x | 0xFFFFFC00; + tx1_a = (x * oldval_1) >> 8; + phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, 0x3FF, tx1_a); + + phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(27), + ((x * oldval_1>>7) & 0x1)); + + y = result[final_candidate][5]; + if ((y & 0x00000200) != 0) + y = y | 0xFFFFFC00; + + tx1_c = (y * oldval_1) >> 8; + + phy_set_bb_reg(adapt, rOFDM0_XDTxAFE, 0xF0000000, + ((tx1_c&0x3C0)>>6)); + phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, 0x003F0000, + (tx1_c&0x3F)); + phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(25), + ((y * oldval_1>>7) & 0x1)); + + if (txonly) + return; + + reg = result[final_candidate][6]; + phy_set_bb_reg(adapt, rOFDM0_XBRxIQImbalance, 0x3FF, reg); + + reg = result[final_candidate][7] & 0x3F; + phy_set_bb_reg(adapt, rOFDM0_XBRxIQImbalance, 0xFC00, reg); + + reg = (result[final_candidate][7] >> 6) & 0xF; + phy_set_bb_reg(adapt, rOFDM0_AGCRSSITable, 0x0000F000, reg); + } +} + +static void save_adda_registers(struct adapter *adapt, u32 *addareg, + u32 *backup, u32 register_num) +{ + u32 i; + + for (i = 0; i < register_num; i++) { + backup[i] = phy_query_bb_reg(adapt, addareg[i], bMaskDWord); + } +} + +static void save_mac_registers(struct adapter *adapt, u32 *mac_reg, + u32 *backup) +{ + u32 i; + + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + backup[i] = usb_read8(adapt, mac_reg[i]); + } + backup[i] = usb_read32(adapt, mac_reg[i]); +} + +static void reload_adda_reg(struct adapter *adapt, u32 *adda_reg, + u32 *backup, u32 regiester_num) +{ + u32 i; + + for (i = 0; i < regiester_num; i++) + phy_set_bb_reg(adapt, adda_reg[i], bMaskDWord, backup[i]); +} + +static void reload_mac_registers(struct adapter *adapt, + u32 *mac_reg, u32 *backup) +{ + u32 i; + + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + usb_write8(adapt, mac_reg[i], (u8)backup[i]); + } + usb_write32(adapt, mac_reg[i], backup[i]); +} + +static void path_adda_on(struct adapter *adapt, u32 *adda_reg, + bool is_path_a_on, bool is2t) +{ + u32 path_on; + u32 i; + + path_on = is_path_a_on ? 0x04db25a4 : 0x0b1b25a4; + if (!is2t) { + path_on = 0x0bdb25a0; + phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, 0x0b1b25a0); + } else { + phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, path_on); + } + + for (i = 1; i < IQK_ADDA_REG_NUM; i++) + phy_set_bb_reg(adapt, adda_reg[i], bMaskDWord, path_on); +} + +static void mac_setting_calibration(struct adapter *adapt, u32 *mac_reg, u32 *backup) +{ + u32 i = 0; + + usb_write8(adapt, mac_reg[i], 0x3F); + + for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { + usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT3))); + } + usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT5))); +} + +static void path_a_standby(struct adapter *adapt) +{ + + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x0); + phy_set_bb_reg(adapt, 0x840, bMaskDWord, 0x00010000); + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); +} + +static void pi_mode_switch(struct adapter *adapt, bool pi_mode) +{ + u32 mode; + + mode = pi_mode ? 0x01000100 : 0x01000000; + phy_set_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, bMaskDWord, mode); + phy_set_bb_reg(adapt, rFPGA0_XB_HSSIParameter1, bMaskDWord, mode); +} + +static bool simularity_compare(struct adapter *adapt, s32 resulta[][8], + u8 c1, u8 c2) +{ + u32 i, j, diff, sim_bitmap, bound = 0; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ + bool result = true; + bool is2t; + s32 tmp1 = 0, tmp2 = 0; + + if ((dm_odm->RFType == ODM_2T2R) || (dm_odm->RFType == ODM_2T3R) || + (dm_odm->RFType == ODM_2T4R)) + is2t = true; + else + is2t = false; + + if (is2t) + bound = 8; + else + bound = 4; + + sim_bitmap = 0; + + for (i = 0; i < bound; i++) { + if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) { + if ((resulta[c1][i] & 0x00000200) != 0) + tmp1 = resulta[c1][i] | 0xFFFFFC00; + else + tmp1 = resulta[c1][i]; + + if ((resulta[c2][i] & 0x00000200) != 0) + tmp2 = resulta[c2][i] | 0xFFFFFC00; + else + tmp2 = resulta[c2][i]; + } else { + tmp1 = resulta[c1][i]; + tmp2 = resulta[c2][i]; + } + + diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); + + if (diff > MAX_TOLERANCE) { + if ((i == 2 || i == 6) && !sim_bitmap) { + if (resulta[c1][i] + resulta[c1][i+1] == 0) + final_candidate[(i/4)] = c2; + else if (resulta[c2][i] + resulta[c2][i+1] == 0) + final_candidate[(i/4)] = c1; + else + sim_bitmap = sim_bitmap | (1<odmpriv; + u32 i; + u8 path_a_ok, path_b_ok; + u32 adda_reg[IQK_ADDA_REG_NUM] = { + rFPGA0_XCD_SwitchControl, rBlue_Tooth, + rRx_Wait_CCA, rTx_CCK_RFON, + rTx_CCK_BBON, rTx_OFDM_RFON, + rTx_OFDM_BBON, rTx_To_Rx, + rTx_To_Tx, rRx_CCK, + rRx_OFDM, rRx_Wait_RIFS, + rRx_TO_Rx, rStandby, + rSleep, rPMPD_ANAEN}; + + u32 iqk_mac_reg[IQK_MAC_REG_NUM] = { + REG_TXPAUSE, REG_BCN_CTRL, + REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; + + /* since 92C & 92D have the different define in IQK_BB_REG */ + u32 iqk_bb_reg_92c[IQK_BB_REG_NUM] = { + rOFDM0_TRxPathEnable, rOFDM0_TRMuxPar, + rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB, + rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, + rFPGA0_XB_RFInterfaceOE, rFPGA0_RFMOD}; + + u32 retry_count = 9; + if (*(dm_odm->mp_mode) == 1) + retry_count = 9; + else + retry_count = 2; + + if (t == 0) { + + /* Save ADDA parameters, turn Path A ADDA on */ + save_adda_registers(adapt, adda_reg, dm_odm->RFCalibrateInfo.ADDA_backup, + IQK_ADDA_REG_NUM); + save_mac_registers(adapt, iqk_mac_reg, + dm_odm->RFCalibrateInfo.IQK_MAC_backup); + save_adda_registers(adapt, iqk_bb_reg_92c, + dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); + } + + path_adda_on(adapt, adda_reg, true, is2t); + if (t == 0) + dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, + BIT(8)); + + if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { + /* Switch BB to PI mode to do IQ Calibration. */ + pi_mode_switch(adapt, true); + } + + /* BB setting */ + phy_set_bb_reg(adapt, rFPGA0_RFMOD, BIT24, 0x00); + phy_set_bb_reg(adapt, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); + phy_set_bb_reg(adapt, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); + phy_set_bb_reg(adapt, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); + + phy_set_bb_reg(adapt, rFPGA0_XAB_RFInterfaceSW, BIT10, 0x01); + phy_set_bb_reg(adapt, rFPGA0_XAB_RFInterfaceSW, BIT26, 0x01); + phy_set_bb_reg(adapt, rFPGA0_XA_RFInterfaceOE, BIT10, 0x00); + phy_set_bb_reg(adapt, rFPGA0_XB_RFInterfaceOE, BIT10, 0x00); + + if (is2t) { + phy_set_bb_reg(adapt, rFPGA0_XA_LSSIParameter, bMaskDWord, + 0x00010000); + phy_set_bb_reg(adapt, rFPGA0_XB_LSSIParameter, bMaskDWord, + 0x00010000); + } + + /* MAC settings */ + mac_setting_calibration(adapt, iqk_mac_reg, + dm_odm->RFCalibrateInfo.IQK_MAC_backup); + + /* Page B init */ + /* AP or IQK */ + phy_set_bb_reg(adapt, rConfig_AntA, bMaskDWord, 0x0f600000); + + if (is2t) + phy_set_bb_reg(adapt, rConfig_AntB, bMaskDWord, 0x0f600000); + + /* IQ calibration setting */ + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); + phy_set_bb_reg(adapt, rTx_IQK, bMaskDWord, 0x01007c00); + phy_set_bb_reg(adapt, rRx_IQK, bMaskDWord, 0x81004800); + + for (i = 0; i < retry_count; i++) { + path_a_ok = phy_path_a_iqk(adapt, is2t); + if (path_a_ok == 0x01) { + result[t][0] = (phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, + bMaskDWord)&0x3FF0000)>>16; + result[t][1] = (phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, + bMaskDWord)&0x3FF0000)>>16; + break; + } + } + + for (i = 0; i < retry_count; i++) { + path_a_ok = phy_path_a_rx_iqk(adapt, is2t); + if (path_a_ok == 0x03) { + result[t][2] = (phy_query_bb_reg(adapt, rRx_Power_Before_IQK_A_2, + bMaskDWord)&0x3FF0000)>>16; + result[t][3] = (phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, + bMaskDWord)&0x3FF0000)>>16; + break; + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path A Rx IQK Fail!!\n")); + } + } + + if (0x00 == path_a_ok) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path A IQK failed!!\n")); + } + + if (is2t) { + path_a_standby(adapt); + + /* Turn Path B ADDA on */ + path_adda_on(adapt, adda_reg, false, is2t); + + for (i = 0; i < retry_count; i++) { + path_b_ok = phy_path_b_iqk(adapt); + if (path_b_ok == 0x03) { + result[t][4] = (phy_query_bb_reg(adapt, rTx_Power_Before_IQK_B, + bMaskDWord)&0x3FF0000)>>16; + result[t][5] = (phy_query_bb_reg(adapt, rTx_Power_After_IQK_B, + bMaskDWord)&0x3FF0000)>>16; + result[t][6] = (phy_query_bb_reg(adapt, rRx_Power_Before_IQK_B_2, + bMaskDWord)&0x3FF0000)>>16; + result[t][7] = (phy_query_bb_reg(adapt, rRx_Power_After_IQK_B_2, + bMaskDWord)&0x3FF0000)>>16; + break; + } else if (i == (retry_count - 1) && path_b_ok == 0x01) { /* Tx IQK OK */ + result[t][4] = (phy_query_bb_reg(adapt, rTx_Power_Before_IQK_B, + bMaskDWord)&0x3FF0000)>>16; + result[t][5] = (phy_query_bb_reg(adapt, rTx_Power_After_IQK_B, + bMaskDWord)&0x3FF0000)>>16; + } + } + + if (0x00 == path_b_ok) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path B IQK failed!!\n")); + } + } + + /* Back to BB mode, load original value */ + phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0); + + if (t != 0) { + if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { + /* Switch back BB to SI mode after + * finish IQ Calibration. + */ + pi_mode_switch(adapt, false); + } + + /* Reload ADDA power saving parameters */ + reload_adda_reg(adapt, adda_reg, dm_odm->RFCalibrateInfo.ADDA_backup, + IQK_ADDA_REG_NUM); + + /* Reload MAC parameters */ + reload_mac_registers(adapt, iqk_mac_reg, + dm_odm->RFCalibrateInfo.IQK_MAC_backup); + + reload_adda_reg(adapt, iqk_bb_reg_92c, dm_odm->RFCalibrateInfo.IQK_BB_backup, + IQK_BB_REG_NUM); + + /* Restore RX initial gain */ + phy_set_bb_reg(adapt, rFPGA0_XA_LSSIParameter, + bMaskDWord, 0x00032ed3); + if (is2t) + phy_set_bb_reg(adapt, rFPGA0_XB_LSSIParameter, + bMaskDWord, 0x00032ed3); + + /* load 0xe30 IQC default value */ + phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); + phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); + } +} + +static void phy_lc_calibrate(struct adapter *adapt, bool is2t) +{ + u8 tmpreg; + u32 rf_a_mode = 0, rf_b_mode = 0, lc_cal; + + /* Check continuous TX and Packet TX */ + tmpreg = usb_read8(adapt, 0xd03); + + if ((tmpreg&0x70) != 0) + usb_write8(adapt, 0xd03, tmpreg&0x8F); + else + usb_write8(adapt, REG_TXPAUSE, 0xFF); + + if ((tmpreg&0x70) != 0) { + /* 1. Read original RF mode */ + /* Path-A */ + rf_a_mode = phy_query_rf_reg(adapt, RF_PATH_A, RF_AC, + bMask12Bits); + + /* Path-B */ + if (is2t) + rf_b_mode = phy_query_rf_reg(adapt, RF_PATH_B, RF_AC, + bMask12Bits); + + /* 2. Set RF mode = standby mode */ + /* Path-A */ + phy_set_rf_reg(adapt, RF_PATH_A, RF_AC, bMask12Bits, + (rf_a_mode&0x8FFFF)|0x10000); + + /* Path-B */ + if (is2t) + phy_set_rf_reg(adapt, RF_PATH_B, RF_AC, bMask12Bits, + (rf_b_mode&0x8FFFF)|0x10000); + } + + /* 3. Read RF reg18 */ + lc_cal = phy_query_rf_reg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits); + + /* 4. Set LC calibration begin bit15 */ + phy_set_rf_reg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits, + lc_cal|0x08000); + + msleep(100); + + /* Restore original situation */ + if ((tmpreg&0x70) != 0) { + /* Deal with continuous TX case */ + /* Path-A */ + usb_write8(adapt, 0xd03, tmpreg); + phy_set_rf_reg(adapt, RF_PATH_A, RF_AC, bMask12Bits, rf_a_mode); + + /* Path-B */ + if (is2t) + phy_set_rf_reg(adapt, RF_PATH_B, RF_AC, bMask12Bits, + rf_b_mode); + } else { + /* Deal with Packet TX case */ + usb_write8(adapt, REG_TXPAUSE, 0x00); + } +} + +void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + s32 result[4][8]; + u8 i, final, chn_index; + bool pathaok, pathbok; + s32 reg_e94, reg_e9c, reg_ea4, reg_eac, reg_eb4, reg_ebc, reg_ec4, + reg_ecc; + bool is12simular, is13simular, is23simular; + bool singletone = false, carrier_sup = false; + u32 iqk_bb_reg_92c[IQK_BB_REG_NUM] = { + rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, + rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, + rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, + rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, + rOFDM0_RxIQExtAnta}; + bool is2t; + + is2t = (dm_odm->RFType == ODM_2T2R) ? true : false; + + if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) + return; + + if (singletone || carrier_sup) + return; + + if (recovery) { + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("phy_iq_calibrate: Return due to recovery!\n")); + reload_adda_reg(adapt, iqk_bb_reg_92c, + dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); + return; + } + + for (i = 0; i < 8; i++) { + result[0][i] = 0; + result[1][i] = 0; + result[2][i] = 0; + if ((i == 0) || (i == 2) || (i == 4) || (i == 6)) + result[3][i] = 0x100; + else + result[3][i] = 0; + } + final = 0xff; + pathaok = false; + pathbok = false; + is12simular = false; + is23simular = false; + is13simular = false; + + for (i = 0; i < 3; i++) { + phy_iq_calibrate(adapt, result, i, is2t); + + if (i == 1) { + is12simular = simularity_compare(adapt, result, 0, 1); + if (is12simular) { + final = 0; + break; + } + } + + if (i == 2) { + is13simular = simularity_compare(adapt, result, 0, 2); + if (is13simular) { + final = 0; + break; + } + is23simular = simularity_compare(adapt, result, 1, 2); + if (is23simular) + final = 1; + else + final = 3; + } + } + + for (i = 0; i < 4; i++) { + reg_e94 = result[i][0]; + reg_e9c = result[i][1]; + reg_ea4 = result[i][2]; + reg_eac = result[i][3]; + reg_eb4 = result[i][4]; + reg_ebc = result[i][5]; + reg_ec4 = result[i][6]; + reg_ecc = result[i][7]; + } + + if (final != 0xff) { + reg_e94 = result[final][0]; + reg_e9c = result[final][1]; + reg_ea4 = result[final][2]; + reg_eac = result[final][3]; + reg_eb4 = result[final][4]; + reg_ebc = result[final][5]; + dm_odm->RFCalibrateInfo.RegE94 = reg_e94; + dm_odm->RFCalibrateInfo.RegE9C = reg_e9c; + dm_odm->RFCalibrateInfo.RegEB4 = reg_eb4; + dm_odm->RFCalibrateInfo.RegEBC = reg_ebc; + reg_ec4 = result[final][6]; + reg_ecc = result[final][7]; + pathaok = true; + pathbok = true; + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK: FAIL use default value\n")); + dm_odm->RFCalibrateInfo.RegE94 = 0x100; + dm_odm->RFCalibrateInfo.RegEB4 = 0x100; + dm_odm->RFCalibrateInfo.RegE9C = 0x0; + dm_odm->RFCalibrateInfo.RegEBC = 0x0; + } + if (reg_e94 != 0) + patha_fill_iqk(adapt, pathaok, result, final, + (reg_ea4 == 0)); + if (is2t) { + if (reg_eb4 != 0) + pathb_fill_iqk(adapt, pathbok, result, final, + (reg_ec4 == 0)); + } + + chn_index = get_right_chnl_for_iqk(hal_data->CurrentChannel); + + if (final < 4) { + for (i = 0; i < IQK_Matrix_REG_NUM; i++) + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[chn_index].Value[0][i] = result[final][i]; + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[chn_index].bIQKDone = true; + } + + save_adda_registers(adapt, iqk_bb_reg_92c, + dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); +} + +void rtl88eu_phy_lc_calibrate(struct adapter *adapt) +{ + bool singletone = false, carrier_sup = false; + u32 timeout = 2000, timecount = 0; + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + + if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) + return; + if (singletone || carrier_sup) + return; + + while (*(dm_odm->pbScanInProcess) && timecount < timeout) { + mdelay(50); + timecount += 50; + } + + dm_odm->RFCalibrateInfo.bLCKInProgress = true; + + if (dm_odm->RFType == ODM_2T2R) { + phy_lc_calibrate(adapt, true); + } else { + /* For 88C 1T1R */ + phy_lc_calibrate(adapt, false); + } + + dm_odm->RFCalibrateInfo.bLCKInProgress = false; +} diff --git a/hal/Hal8188EPwrSeq.c b/hal/pwrseq.c similarity index 68% rename from hal/Hal8188EPwrSeq.c rename to hal/pwrseq.c index fc23bf1..20dce42 100644 --- a/hal/Hal8188EPwrSeq.c +++ b/hal/pwrseq.c @@ -18,68 +18,84 @@ * ******************************************************************************/ -#include "Hal8188EPwrSeq.h" +#include "pwrseq.h" #include /* drivers should parse below arrays and do the corresponding actions */ /* 3 Power on Array */ -struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS] = { +struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + + RTL8188E_TRANS_END_STEPS] = { RTL8188E_TRANS_CARDEMU_TO_ACT RTL8188E_TRANS_END }; /* 3Radio off Array */ -struct wl_pwr_cfg rtl8188E_radio_off_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_END_STEPS] = { +struct wl_pwr_cfg rtl8188E_radio_off_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_END_STEPS] = { RTL8188E_TRANS_ACT_TO_CARDEMU RTL8188E_TRANS_END }; /* 3Card Disable Array */ -struct wl_pwr_cfg rtl8188E_card_disable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_ACT_TO_CARDEMU - RTL8188E_TRANS_CARDEMU_TO_CARDDIS - RTL8188E_TRANS_END +struct wl_pwr_cfg rtl8188E_card_disable_flow + [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_CARDDIS + RTL8188E_TRANS_END }; /* 3 Card Enable Array */ -struct wl_pwr_cfg rtl8188E_card_enable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_CARDDIS_TO_CARDEMU - RTL8188E_TRANS_CARDEMU_TO_ACT - RTL8188E_TRANS_END +struct wl_pwr_cfg rtl8188E_card_enable_flow + [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_CARDDIS_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_ACT + RTL8188E_TRANS_END }; /* 3Suspend Array */ -struct wl_pwr_cfg rtl8188E_suspend_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + RTL8188E_TRANS_END_STEPS] = { +struct wl_pwr_cfg rtl8188E_suspend_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8188E_TRANS_END_STEPS] = { RTL8188E_TRANS_ACT_TO_CARDEMU RTL8188E_TRANS_CARDEMU_TO_SUS RTL8188E_TRANS_END }; /* 3 Resume Array */ -struct wl_pwr_cfg rtl8188E_resume_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + RTL8188E_TRANS_END_STEPS] = { +struct wl_pwr_cfg rtl8188E_resume_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8188E_TRANS_END_STEPS] = { RTL8188E_TRANS_SUS_TO_CARDEMU RTL8188E_TRANS_CARDEMU_TO_ACT RTL8188E_TRANS_END }; /* 3HWPDN Array */ -struct wl_pwr_cfg rtl8188E_hwpdn_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { +struct wl_pwr_cfg rtl8188E_hwpdn_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8188E_TRANS_END_STEPS] = { RTL8188E_TRANS_ACT_TO_CARDEMU RTL8188E_TRANS_CARDEMU_TO_PDN RTL8188E_TRANS_END }; /* 3 Enter LPS */ -struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_END_STEPS] = { +struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS + + RTL8188E_TRANS_END_STEPS] = { /* FW behavior */ RTL8188E_TRANS_ACT_TO_LPS RTL8188E_TRANS_END }; /* 3 Leave LPS */ -struct wl_pwr_cfg rtl8188E_leave_lps_flow[RTL8188E_TRANS_LPS_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS] = { +struct wl_pwr_cfg rtl8188E_leave_lps_flow[RTL8188E_TRANS_LPS_TO_ACT_STEPS + + RTL8188E_TRANS_END_STEPS] = { /* FW behavior */ RTL8188E_TRANS_LPS_TO_ACT RTL8188E_TRANS_END diff --git a/hal/HalPwrSeqCmd.c b/hal/pwrseqcmd.c similarity index 55% rename from hal/HalPwrSeqCmd.c rename to hal/pwrseqcmd.c index 5700dbc..be0663e 100644 --- a/hal/HalPwrSeqCmd.c +++ b/hal/pwrseqcmd.c @@ -15,35 +15,16 @@ * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * - * ******************************************************************************/ -/*++ -Copyright (c) Realtek Semiconductor Corp. All rights reserved. -Module Name: - HalPwrSeqCmd.c +#include +#include -Abstract: - Implement HW Power sequence configuration CMD handling routine for Realtek devices. - -Major Change History: - When Who What - ---------- --------------- ------------------------------- - 2011-10-26 Lucas Modify to be compatible with SD4-CE driver. - 2011-07-07 Roger Create. - ---*/ - -#include - -/* Description: */ -/* This routine deals with the Power Configuration CMDs parsing - * for RTL8723/RTL8188E Series IC. - * Assumption: - * We should follow specific format which was released from HW SD. +/* This routine deals with the Power Configuration CMDs parsing + * for RTL8723/RTL8188E Series IC. */ -u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, - u8 ifacetype, struct wl_pwr_cfg pwrseqcmd[]) +u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, + u8 ifacetype, struct wl_pwr_cfg pwrseqcmd[]) { struct wl_pwr_cfg pwrcfgcmd = {0}; u8 poll_bit = false; @@ -57,7 +38,9 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, pwrcfgcmd = pwrseqcmd[aryidx]; RT_TRACE(_module_hal_init_c_ , _drv_info_, - ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", + ("rtl88eu_pwrseqcmdparsing: offset(%#x) cut_msk(%#x)" + "fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x)" + "msk(%#x) value(%#x)\n", GET_PWR_CFG_OFFSET(pwrcfgcmd), GET_PWR_CFG_CUT_MASK(pwrcfgcmd), GET_PWR_CFG_FAB_MASK(pwrcfgcmd), @@ -67,40 +50,45 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, GET_PWR_CFG_MASK(pwrcfgcmd), GET_PWR_CFG_VALUE(pwrcfgcmd))); - /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ + /* Only Handle the command whose FAB, CUT, and Interface are matched */ if ((GET_PWR_CFG_FAB_MASK(pwrcfgcmd) & fab_vers) && (GET_PWR_CFG_CUT_MASK(pwrcfgcmd) & cut_vers) && (GET_PWR_CFG_INTF_MASK(pwrcfgcmd) & ifacetype)) { switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { case PWR_CMD_READ: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, + ("rtl88eu_pwrseqcmdparsing: PWR_CMD_READ\n")); break; case PWR_CMD_WRITE: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, + ("rtl88eu_pwrseqcmdparsing: PWR_CMD_WRITE\n")); offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); /* Read the value from system register */ - value = rtw_read8(padapter, offset); + value = usb_read8(padapter, offset); value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); - value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)); + value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & + GET_PWR_CFG_MASK(pwrcfgcmd)); /* Write the value back to system register */ - rtw_write8(padapter, offset, value); + usb_write8(padapter, offset, value); break; case PWR_CMD_POLLING: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, + ("rtl88eu_pwrseqcmdparsing: PWR_CMD_POLLING\n")); poll_bit = false; offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); do { - value = rtw_read8(padapter, offset); - + value = usb_read8(padapter, offset); value &= GET_PWR_CFG_MASK(pwrcfgcmd); - if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) + + if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & + GET_PWR_CFG_MASK(pwrcfgcmd))) poll_bit = true; else - rtw_udelay_os(10); + udelay(10); if (poll_count++ > max_poll_count) { DBG_88E("Fail to polling Offset[%#x]\n", offset); @@ -109,19 +97,22 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, } while (!poll_bit); break; case PWR_CMD_DELAY: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, + ("rtl88eu_pwrseqcmdparsing: PWR_CMD_DELAY\n")); if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) - rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)); + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else - rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); break; case PWR_CMD_END: - /* When this command is parsed, end the process */ - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); + /* When this command is parsed, end the process */ + RT_TRACE(_module_hal_init_c_, _drv_info_, + ("rtl88eu_pwrseqcmdparsing: PWR_CMD_END\n")); return true; break; default: - RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); + RT_TRACE(_module_hal_init_c_, _drv_err_, + ("rtl88eu_pwrseqcmdparsing: Unknown CMD!!\n")); break; } } diff --git a/hal/rf.c b/hal/rf.c new file mode 100644 index 0000000..eea4c8a --- /dev/null +++ b/hal/rf.c @@ -0,0 +1,318 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + ******************************************************************************/ + +#include +#include +#include +#include +#include + +void rtl88eu_phy_rf6052_set_bandwidth(struct adapter *adapt, + enum ht_channel_width bandwidth) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + + switch (bandwidth) { + case HT_CHANNEL_WIDTH_20: + hal_data->RfRegChnlVal[0] = ((hal_data->RfRegChnlVal[0] & + 0xfffff3ff) | BIT(10) | BIT(11)); + phy_set_rf_reg(adapt, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, + hal_data->RfRegChnlVal[0]); + break; + case HT_CHANNEL_WIDTH_40: + hal_data->RfRegChnlVal[0] = ((hal_data->RfRegChnlVal[0] & + 0xfffff3ff) | BIT(10)); + phy_set_rf_reg(adapt, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, + hal_data->RfRegChnlVal[0]); + break; + default: + break; + } +} + +void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + u32 tx_agc[2] = {0, 0}, tmpval = 0, pwrtrac_value; + u8 idx1, idx2; + u8 *ptr; + u8 direction; + + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + tx_agc[RF_PATH_A] = 0x3f3f3f3f; + tx_agc[RF_PATH_B] = 0x3f3f3f3f; + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + tx_agc[idx1] = powerlevel[idx1] | + (powerlevel[idx1]<<8) | + (powerlevel[idx1]<<16) | + (powerlevel[idx1]<<24); + if (tx_agc[idx1] > 0x20 && hal_data->ExternalPA) + tx_agc[idx1] = 0x20; + } + } else { + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { + tx_agc[RF_PATH_A] = 0x10101010; + tx_agc[RF_PATH_B] = 0x10101010; + } else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) { + tx_agc[RF_PATH_A] = 0x00000000; + tx_agc[RF_PATH_B] = 0x00000000; + } else { + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + tx_agc[idx1] = powerlevel[idx1] | + (powerlevel[idx1]<<8) | + (powerlevel[idx1]<<16) | + (powerlevel[idx1]<<24); + } + if (hal_data->EEPROMRegulatory == 0) { + tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][6] + + (hal_data->MCSTxPowerLevelOriginalOffset[0][7]<<8); + tx_agc[RF_PATH_A] += tmpval; + + tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][14] + + (hal_data->MCSTxPowerLevelOriginalOffset[0][15]<<24); + tx_agc[RF_PATH_B] += tmpval; + } + } + } + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + ptr = (u8 *)(&(tx_agc[idx1])); + for (idx2 = 0; idx2 < 4; idx2++) { + if (*ptr > RF6052_MAX_TX_PWR) + *ptr = RF6052_MAX_TX_PWR; + ptr++; + } + } + rtl88eu_dm_txpower_track_adjust(&hal_data->odmpriv, 1, &direction, + &pwrtrac_value); + + if (direction == 1) { + /* Increase TX power */ + tx_agc[0] += pwrtrac_value; + tx_agc[1] += pwrtrac_value; + } else if (direction == 2) { + /* Decrease TX power */ + tx_agc[0] -= pwrtrac_value; + tx_agc[1] -= pwrtrac_value; + } + + /* rf-A cck tx power */ + tmpval = tx_agc[RF_PATH_A]&0xff; + phy_set_bb_reg(adapt, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); + tmpval = tx_agc[RF_PATH_A]>>8; + phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); + + /* rf-B cck tx power */ + tmpval = tx_agc[RF_PATH_B]>>24; + phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); + tmpval = tx_agc[RF_PATH_B]&0x00ffffff; + phy_set_bb_reg(adapt, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); +} + +/* powerbase0 for OFDM rates */ +/* powerbase1 for HT MCS rates */ +static void getpowerbase88e(struct adapter *adapt, u8 *pwr_level_ofdm, + u8 *pwr_level_bw20, u8 *pwr_level_bw40, + u8 channel, u32 *ofdmbase, u32 *mcs_base) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u32 powerbase0, powerbase1; + u8 i, powerlevel[2]; + + for (i = 0; i < 2; i++) { + powerbase0 = pwr_level_ofdm[i]; + + powerbase0 = (powerbase0<<24) | (powerbase0<<16) | + (powerbase0<<8) | powerbase0; + *(ofdmbase+i) = powerbase0; + } + for (i = 0; i < hal_data->NumTotalRFPath; i++) { + /* Check HT20 to HT40 diff */ + if (hal_data->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + powerlevel[i] = pwr_level_bw20[i]; + else + powerlevel[i] = pwr_level_bw40[i]; + powerbase1 = powerlevel[i]; + powerbase1 = (powerbase1<<24) | (powerbase1<<16) | + (powerbase1<<8) | powerbase1; + *(mcs_base+i) = powerbase1; + } +} +static void get_rx_power_val_by_reg(struct adapter *adapt, u8 channel, + u8 index, u32 *powerbase0, u32 *powerbase1, + u32 *out_val) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + u8 i, chnlGroup = 0, pwr_diff_limit[4], customer_pwr_limit; + s8 pwr_diff = 0; + u32 write_val, customer_limit, rf; + u8 regulatory = hal_data->EEPROMRegulatory; + + /* Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate */ + + for (rf = 0; rf < 2; rf++) { + u8 j = index + (rf ? 8 : 0); + + switch (regulatory) { + case 0: + chnlGroup = 0; + write_val = hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); + break; + case 1: /* Realtek regulatory */ + /* increase power diff defined by Realtek for regulatory */ + if (hal_data->pwrGroupCnt == 1) + chnlGroup = 0; + if (hal_data->pwrGroupCnt >= hal_data->PGMaxGroup) { + if (channel < 3) + chnlGroup = 0; + else if (channel < 6) + chnlGroup = 1; + else if (channel < 9) + chnlGroup = 2; + else if (channel < 12) + chnlGroup = 3; + else if (channel < 14) + chnlGroup = 4; + else if (channel == 14) + chnlGroup = 5; + } + write_val = hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); + break; + case 2: /* Better regulatory */ + /* don't increase any power diff */ + write_val = ((index < 2) ? powerbase0[rf] : powerbase1[rf]); + break; + case 3: /* Customer defined power diff. */ + /* increase power diff defined by customer. */ + chnlGroup = 0; + + if (index < 2) + pwr_diff = hal_data->TxPwrLegacyHtDiff[rf][channel-1]; + else if (hal_data->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + pwr_diff = hal_data->TxPwrHt20Diff[rf][channel-1]; + + if (hal_data->CurrentChannelBW == HT_CHANNEL_WIDTH_40) + customer_pwr_limit = hal_data->PwrGroupHT40[rf][channel-1]; + else + customer_pwr_limit = hal_data->PwrGroupHT20[rf][channel-1]; + + if (pwr_diff >= customer_pwr_limit) + pwr_diff = 0; + else + pwr_diff = customer_pwr_limit - pwr_diff; + + for (i = 0; i < 4; i++) { + pwr_diff_limit[i] = (u8)((hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][j] & + (0x7f << (i * 8))) >> (i * 8)); + + if (pwr_diff_limit[i] > pwr_diff) + pwr_diff_limit[i] = pwr_diff; + } + customer_limit = (pwr_diff_limit[3]<<24) | + (pwr_diff_limit[2]<<16) | + (pwr_diff_limit[1]<<8) | + (pwr_diff_limit[0]); + write_val = customer_limit + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); + break; + default: + chnlGroup = 0; + write_val = hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][j] + + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); + break; + } +/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism. */ +/* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ +/* In the future, two mechanism shall be separated from each other and maintained independently. Thanks for Lanhsin's reminder. */ + /* 92d do not need this */ + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) + write_val = 0x14141414; + else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) + write_val = 0x00000000; + + *(out_val+rf) = write_val; + } +} + +static void write_ofdm_pwr_reg(struct adapter *adapt, u8 index, u32 *pvalue) +{ + u16 regoffset_a[6] = { rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24, + rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04, + rTxAGC_A_Mcs11_Mcs08, rTxAGC_A_Mcs15_Mcs12 }; + u16 regoffset_b[6] = { rTxAGC_B_Rate18_06, rTxAGC_B_Rate54_24, + rTxAGC_B_Mcs03_Mcs00, rTxAGC_B_Mcs07_Mcs04, + rTxAGC_B_Mcs11_Mcs08, rTxAGC_B_Mcs15_Mcs12 }; + u8 i, rf, pwr_val[4]; + u32 write_val; + u16 regoffset; + + for (rf = 0; rf < 2; rf++) { + write_val = pvalue[rf]; + for (i = 0; i < 4; i++) { + pwr_val[i] = (u8)((write_val & (0x7f<<(i*8)))>>(i*8)); + if (pwr_val[i] > RF6052_MAX_TX_PWR) + pwr_val[i] = RF6052_MAX_TX_PWR; + } + write_val = (pwr_val[3]<<24) | (pwr_val[2]<<16) | + (pwr_val[1]<<8) | pwr_val[0]; + + if (rf == 0) + regoffset = regoffset_a[index]; + else + regoffset = regoffset_b[index]; + + phy_set_bb_reg(adapt, regoffset, bMaskDWord, write_val); + } +} + +void rtl88eu_phy_rf6052_set_ofdm_txpower(struct adapter *adapt, + u8 *pwr_level_ofdm, + u8 *pwr_level_bw20, + u8 *pwr_level_bw40, u8 channel) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u32 write_val[2], powerbase0[2], powerbase1[2], pwrtrac_value; + u8 direction; + u8 index = 0; + + getpowerbase88e(adapt, pwr_level_ofdm, pwr_level_bw20, pwr_level_bw40, + channel, &powerbase0[0], &powerbase1[0]); + + rtl88eu_dm_txpower_track_adjust(&hal_data->odmpriv, 0, &direction, + &pwrtrac_value); + + for (index = 0; index < 6; index++) { + get_rx_power_val_by_reg(adapt, channel, index, + &powerbase0[0], &powerbase1[0], + &write_val[0]); + + if (direction == 1) { + write_val[0] += pwrtrac_value; + write_val[1] += pwrtrac_value; + } else if (direction == 2) { + write_val[0] -= pwrtrac_value; + write_val[1] -= pwrtrac_value; + } + write_ofdm_pwr_reg(adapt, index, &write_val[0]); + } +} diff --git a/hal/rf_cfg.c b/hal/rf_cfg.c new file mode 100644 index 0000000..5dc11ca --- /dev/null +++ b/hal/rf_cfg.c @@ -0,0 +1,320 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" + +#include + +static bool check_condition(struct adapter *adapt, const u32 condition) +{ + struct odm_dm_struct *odm = &GET_HAL_DATA(adapt)->odmpriv; + u32 _board = odm->BoardType; + u32 _platform = odm->SupportPlatform; + u32 _interface = odm->SupportInterface; + u32 cond = condition; + + if (condition == 0xCDCDCDCD) + return true; + + cond = condition & 0x000000FF; + if ((_board == cond) && cond != 0x00) + return false; + + cond = condition & 0x0000FF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + + cond = condition & 0x00FF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + +/* RadioA_1T.TXT */ + +static u32 Array_RadioA_1T_8188E[] = { + 0x000, 0x00030000, + 0x008, 0x00084000, + 0x018, 0x00000407, + 0x019, 0x00000012, + 0x01E, 0x00080009, + 0x01F, 0x00000880, + 0x02F, 0x0001A060, + 0x03F, 0x00000000, + 0x042, 0x000060C0, + 0x057, 0x000D0000, + 0x058, 0x000BE180, + 0x067, 0x00001552, + 0x083, 0x00000000, + 0x0B0, 0x000FF8FC, + 0x0B1, 0x00054400, + 0x0B2, 0x000CCC19, + 0x0B4, 0x00043003, + 0x0B6, 0x0004953E, + 0x0B7, 0x0001C718, + 0x0B8, 0x000060FF, + 0x0B9, 0x00080001, + 0x0BA, 0x00040000, + 0x0BB, 0x00000400, + 0x0BF, 0x000C0000, + 0x0C2, 0x00002400, + 0x0C3, 0x00000009, + 0x0C4, 0x00040C91, + 0x0C5, 0x00099999, + 0x0C6, 0x000000A3, + 0x0C7, 0x00088820, + 0x0C8, 0x00076C06, + 0x0C9, 0x00000000, + 0x0CA, 0x00080000, + 0x0DF, 0x00000180, + 0x0EF, 0x000001A0, + 0x051, 0x0006B27D, + 0xFF0F041F, 0xABCD, + 0x052, 0x0007E4DD, + 0xCDCDCDCD, 0xCDCD, + 0x052, 0x0007E49D, + 0xFF0F041F, 0xDEAD, + 0x053, 0x00000073, + 0x056, 0x00051FF3, + 0x035, 0x00000086, + 0x035, 0x00000186, + 0x035, 0x00000286, + 0x036, 0x00001C25, + 0x036, 0x00009C25, + 0x036, 0x00011C25, + 0x036, 0x00019C25, + 0x0B6, 0x00048538, + 0x018, 0x00000C07, + 0x05A, 0x0004BD00, + 0x019, 0x000739D0, + 0x034, 0x0000ADF3, + 0x034, 0x00009DF0, + 0x034, 0x00008DED, + 0x034, 0x00007DEA, + 0x034, 0x00006DE7, + 0x034, 0x000054EE, + 0x034, 0x000044EB, + 0x034, 0x000034E8, + 0x034, 0x0000246B, + 0x034, 0x00001468, + 0x034, 0x0000006D, + 0x000, 0x00030159, + 0x084, 0x00068200, + 0x086, 0x000000CE, + 0x087, 0x00048A00, + 0x08E, 0x00065540, + 0x08F, 0x00088000, + 0x0EF, 0x000020A0, + 0x03B, 0x000F02B0, + 0x03B, 0x000EF7B0, + 0x03B, 0x000D4FB0, + 0x03B, 0x000CF060, + 0x03B, 0x000B0090, + 0x03B, 0x000A0080, + 0x03B, 0x00090080, + 0x03B, 0x0008F780, + 0x03B, 0x000722B0, + 0x03B, 0x0006F7B0, + 0x03B, 0x00054FB0, + 0x03B, 0x0004F060, + 0x03B, 0x00030090, + 0x03B, 0x00020080, + 0x03B, 0x00010080, + 0x03B, 0x0000F780, + 0x0EF, 0x000000A0, + 0x000, 0x00010159, + 0x018, 0x0000F407, + 0xFFE, 0x00000000, + 0xFFE, 0x00000000, + 0x01F, 0x00080003, + 0xFFE, 0x00000000, + 0xFFE, 0x00000000, + 0x01E, 0x00000001, + 0x01F, 0x00080000, + 0x000, 0x00033E60, +}; + +#define READ_NEXT_PAIR(v1, v2, i) \ +do { \ + i += 2; v1 = array[i]; \ + v2 = array[i+1]; \ +} while (0) + +#define RFREG_OFFSET_MASK 0xfffff +#define B3WIREADDREAALENGTH 0x400 +#define B3WIREDATALENGTH 0x800 +#define BRFSI_RFENV 0x10 + +static void rtl_rfreg_delay(struct adapter *adapt, enum rf_radio_path rfpath, u32 addr, u32 mask, u32 data) +{ + if (addr == 0xfe) { + mdelay(50); + } else if (addr == 0xfd) { + mdelay(5); + } else if (addr == 0xfc) { + mdelay(1); + } else if (addr == 0xfb) { + udelay(50); + } else if (addr == 0xfa) { + udelay(5); + } else if (addr == 0xf9) { + udelay(1); + } else { + phy_set_rf_reg(adapt, rfpath, addr, mask, data); + udelay(1); + } +} + +static void rtl8188e_config_rf_reg(struct adapter *adapt, + u32 addr, u32 data) +{ + u32 content = 0x1000; /*RF Content: radio_a_txt*/ + u32 maskforphyset = (u32)(content & 0xE000); + + rtl_rfreg_delay(adapt, RF90_PATH_A, addr | maskforphyset, + RFREG_OFFSET_MASK, + data); +} + +static bool rtl88e_phy_config_rf_with_headerfile(struct adapter *adapt) +{ + u32 i; + u32 array_len = sizeof(Array_RadioA_1T_8188E)/sizeof(u32); + u32 *array = Array_RadioA_1T_8188E; + + for (i = 0; i < array_len; i += 2) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + + if (v1 < 0xCDCDCDCD) { + rtl8188e_config_rf_reg(adapt, v1, v2); + continue; + } else { + if (!check_condition(adapt, array[i])) { + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && v2 != 0xCDEF && + v2 != 0xCDCD && i < array_len - 2) + READ_NEXT_PAIR(v1, v2, i); + i -= 2; + } else { + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && v2 != 0xCDEF && + v2 != 0xCDCD && i < array_len - 2) { + rtl8188e_config_rf_reg(adapt, v1, v2); + READ_NEXT_PAIR(v1, v2, i); + } + + while (v2 != 0xDEAD && i < array_len - 2) + READ_NEXT_PAIR(v1, v2, i); + } + } + } + return true; +} + +static bool rf6052_conf_para(struct adapter *adapt) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + u32 u4val = 0; + u8 rfpath; + bool rtstatus = true; + struct bb_reg_def *pphyreg; + + for (rfpath = 0; rfpath < hal_data->NumTotalRFPath; rfpath++) { + pphyreg = &hal_data->PHYRegDef[rfpath]; + + switch (rfpath) { + case RF90_PATH_A: + case RF90_PATH_C: + u4val = phy_query_bb_reg(adapt, pphyreg->rfintfs, + BRFSI_RFENV); + break; + case RF90_PATH_B: + case RF90_PATH_D: + u4val = phy_query_bb_reg(adapt, pphyreg->rfintfs, + BRFSI_RFENV << 16); + break; + } + + phy_set_bb_reg(adapt, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1); + udelay(1); + + phy_set_bb_reg(adapt, pphyreg->rfintfo, BRFSI_RFENV, 0x1); + udelay(1); + + phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, + B3WIREADDREAALENGTH, 0x0); + udelay(1); + + phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, + B3WIREDATALENGTH, 0x0); + udelay(1); + + switch (rfpath) { + case RF90_PATH_A: + rtstatus = rtl88e_phy_config_rf_with_headerfile(adapt); + break; + case RF90_PATH_B: + rtstatus = rtl88e_phy_config_rf_with_headerfile(adapt); + break; + case RF90_PATH_C: + break; + case RF90_PATH_D: + break; + } + + switch (rfpath) { + case RF90_PATH_A: + case RF90_PATH_C: + phy_set_bb_reg(adapt, pphyreg->rfintfs, + BRFSI_RFENV, u4val); + break; + case RF90_PATH_B: + case RF90_PATH_D: + phy_set_bb_reg(adapt, pphyreg->rfintfs, + BRFSI_RFENV << 16, u4val); + break; + } + + if (rtstatus != true) + return false; + } + + return rtstatus; +} + +static bool rtl88e_phy_rf6052_config(struct adapter *adapt) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt); + + if (hal_data->rf_type == RF_1T1R) + hal_data->NumTotalRFPath = 1; + else + hal_data->NumTotalRFPath = 2; + + return rf6052_conf_para(adapt); +} + +bool rtl88eu_phy_rf_config(struct adapter *adapt) +{ + return rtl88e_phy_rf6052_config(adapt); +} diff --git a/hal/rtl8188e_cmd.c b/hal/rtl8188e_cmd.c index 8be2ad7..7f30dea 100644 --- a/hal/rtl8188e_cmd.c +++ b/hal/rtl8188e_cmd.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -41,7 +40,7 @@ static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num) u8 valid; do { - valid = rtw_read8(adapt, REG_HMETFR) & BIT(msgbox_num); + valid = usb_read8(adapt, REG_HMETFR) & BIT(msgbox_num); if (0 == valid) read_down = true; } while ((!read_down) && (retry_cnts--)); @@ -72,7 +71,6 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p u32 h2c_cmd_ex = 0; s32 ret = _FAIL; -_func_enter_; if (!adapt->bFWReady) { DBG_88E("FillH2CCmd_88E(): return H2C cmd because fw is not ready\n"); @@ -107,13 +105,13 @@ _func_enter_; /* Write Ext command */ msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) { - rtw_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx)); + usb_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx)); } } /* Write command */ msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) { - rtw_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx)); + usb_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx)); } bcmd_down = true; @@ -125,7 +123,6 @@ _func_enter_; exit: -_func_exit_; return ret; } @@ -134,7 +131,6 @@ u8 rtl8188e_set_rssi_cmd(struct adapter *adapt, u8 *param) { u8 res = _SUCCESS; struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); -_func_enter_; if (haldata->fw_ractrl) { ; @@ -143,7 +139,6 @@ _func_enter_; res = _FAIL; } -_func_exit_; return res; } @@ -154,13 +149,10 @@ u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask) u8 res = _SUCCESS; struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); -_func_enter_; if (haldata->fw_ractrl) { - __le32 lmask; - _rtw_memset(buf, 0, 3); - lmask = cpu_to_le32(mask); - memcpy(buf, &lmask, 3); + memset(buf, 0, 3); + put_unaligned_le32(mask, buf); FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf); } else { @@ -168,7 +160,6 @@ _func_enter_; res = _FAIL; } -_func_exit_; return res; } @@ -215,7 +206,6 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) struct setpwrmode_parm H2CSetPwrMode; struct pwrctrl_priv *pwrpriv = &adapt->pwrctrlpriv; u8 RLBM = 0; /* 0:Min, 1:Max, 2:User define */ -_func_enter_; DBG_88E("%s: Mode=%d SmartPS=%d UAPSD=%d\n", __func__, Mode, pwrpriv->smart_ps, adapt->registrypriv.uapsd_enable); @@ -256,14 +246,13 @@ _func_enter_; FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode); -_func_exit_; } void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) { u8 opmode, macid; u16 mst_rpt = le16_to_cpu(mstatus_rpt); - opmode = (u8) mst_rpt; + opmode = (u8)mst_rpt; macid = (u8)(mst_rpt >> 8); DBG_88E("### %s: MStatus=%x MACID=%d\n", __func__, opmode, macid); @@ -484,12 +473,6 @@ static void ConstructProbeRsp(struct adapter *adapt, u8 *pframe, u32 *pLength, u *pLength = pktlen; } -/* To check if reserved page content is destroyed by beacon because beacon is too large. */ -/* 2010.06.23. Added by tynli. */ -void CheckFwRsvdPageContent(struct adapter *Adapter) -{ -} - /* */ /* Description: Fill the reserved packets that FW will use to RSVD page. */ /* Now we just send 4 types packet to rsvd page. */ @@ -517,7 +500,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) struct rsvdpage_loc RsvdPageLoc; DBG_88E("%s\n", __func__); - ReservedPagePacket = (u8 *)rtw_zmalloc(1000); + ReservedPagePacket = kzalloc(1000, GFP_KERNEL); if (ReservedPagePacket == NULL) { DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__); return; @@ -617,25 +600,24 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) u8 DLBcnCount = 0; u32 poll = 0; -_func_enter_; DBG_88E("%s mstatus(%x)\n", __func__, mstatus); if (mstatus == 1) { /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */ /* Suggested by filen. Added by tynli. */ - rtw_write16(adapt, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid)); + usb_write16(adapt, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid)); /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */ /* Set REG_CR bit 8. DMA beacon by SW. */ haldata->RegCR_1 |= BIT0; - rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + usb_write8(adapt, REG_CR+1, haldata->RegCR_1); /* Disable Hw protection for a time which revserd for Hw sending beacon. */ /* Fix download reserved page packet fail that access collision with the protection time. */ /* 2010.05.11. Added by tynli. */ - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(3))); - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(4)); + usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)&(~BIT(3))); + usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)|BIT(4)); if (haldata->RegFwHwTxQCtrl&BIT6) { DBG_88E("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n"); @@ -643,7 +625,7 @@ _func_enter_; } /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT6))); + usb_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT6))); haldata->RegFwHwTxQCtrl &= (~BIT6); /* Clear beacon valid check bit. */ @@ -655,8 +637,8 @@ _func_enter_; SetFwRsvdPagePkt(adapt, false); DLBcnCount++; do { - rtw_yield_os(); - /* rtw_mdelay_os(10); */ + yield(); + /* mdelay(10); */ /* check rsvd page download OK. */ rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); poll++; @@ -677,8 +659,8 @@ _func_enter_; /* */ /* Enable Bcn */ - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(3)); - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(4))); + usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)|BIT(3)); + usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL)&(~BIT(4))); /* To make sure that if there exists an adapter which would like to send beacon. */ /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */ @@ -686,7 +668,7 @@ _func_enter_; /* the beacon cannot be sent by HW. */ /* 2010.06.23. Added by tynli. */ if (bSendBeacon) { - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT6)); + usb_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT6)); haldata->RegFwHwTxQCtrl |= BIT6; } @@ -699,81 +681,6 @@ _func_enter_; /* Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */ /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ haldata->RegCR_1 &= (~BIT0); - rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + usb_write8(adapt, REG_CR+1, haldata->RegCR_1); } -_func_exit_; -} - -void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state) -{ -#ifdef CONFIG_88EU_P2P - struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - struct wifidirect_info *pwdinfo = &(adapt->wdinfo); - struct P2P_PS_Offload_t *p2p_ps_offload = &haldata->p2p_ps_offload; - u8 i; - -_func_enter_; - - switch (p2p_ps_state) { - case P2P_PS_DISABLE: - DBG_88E("P2P_PS_DISABLE\n"); - _rtw_memset(p2p_ps_offload, 0, 1); - break; - case P2P_PS_ENABLE: - DBG_88E("P2P_PS_ENABLE\n"); - /* update CTWindow value. */ - if (pwdinfo->ctwindow > 0) { - p2p_ps_offload->CTWindow_En = 1; - rtw_write8(adapt, REG_P2P_CTWIN, pwdinfo->ctwindow); - } - - /* hw only support 2 set of NoA */ - for (i = 0; i < pwdinfo->noa_num; i++) { - /* To control the register setting for which NOA */ - rtw_write8(adapt, REG_NOA_DESC_SEL, (i << 4)); - if (i == 0) - p2p_ps_offload->NoA0_En = 1; - else - p2p_ps_offload->NoA1_En = 1; - - /* config P2P NoA Descriptor Register */ - rtw_write32(adapt, REG_NOA_DESC_DURATION, pwdinfo->noa_duration[i]); - rtw_write32(adapt, REG_NOA_DESC_INTERVAL, pwdinfo->noa_interval[i]); - rtw_write32(adapt, REG_NOA_DESC_START, pwdinfo->noa_start_time[i]); - rtw_write8(adapt, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]); - } - - if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) { - /* rst p2p circuit */ - rtw_write8(adapt, REG_DUAL_TSF_RST, BIT(4)); - - p2p_ps_offload->Offload_En = 1; - - if (pwdinfo->role == P2P_ROLE_GO) { - p2p_ps_offload->role = 1; - p2p_ps_offload->AllStaSleep = 0; - } else { - p2p_ps_offload->role = 0; - } - - p2p_ps_offload->discovery = 0; - } - break; - case P2P_PS_SCAN: - DBG_88E("P2P_PS_SCAN\n"); - p2p_ps_offload->discovery = 1; - break; - case P2P_PS_SCAN_DONE: - DBG_88E("P2P_PS_SCAN_DONE\n"); - p2p_ps_offload->discovery = 0; - pwdinfo->p2p_ps_state = P2P_PS_ENABLE; - break; - default: - break; - } - - FillH2CCmd_88E(adapt, H2C_PS_P2P_OFFLOAD, 1, (u8 *)p2p_ps_offload); -#endif - -_func_exit_; } diff --git a/hal/rtl8188e_dm.c b/hal/rtl8188e_dm.c index ec0028d..0156621 100644 --- a/hal/rtl8188e_dm.c +++ b/hal/rtl8188e_dm.c @@ -31,19 +31,15 @@ #include -static void dm_CheckStatistics(struct adapter *Adapter) -{ -} - /* Initialize GPIO setting registers */ static void dm_InitGPIOSetting(struct adapter *Adapter) { u8 tmp1byte; - tmp1byte = rtw_read8(Adapter, REG_GPIO_MUXCFG); + tmp1byte = usb_read8(Adapter, REG_GPIO_MUXCFG); tmp1byte &= (GPIOSEL_GPIO | ~GPIOSEL_ENBT); - rtw_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte); + usb_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte); } /* */ @@ -57,17 +53,12 @@ static void Init_ODM_ComInfo_88E(struct adapter *Adapter) u8 cut_ver, fab_ver; /* Init Value */ - _rtw_memset(dm_odm, 0, sizeof(*dm_odm)); + memset(dm_odm, 0, sizeof(*dm_odm)); dm_odm->Adapter = Adapter; ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_PLATFORM, ODM_CE); - if (Adapter->interface_type == RTW_GSPI) - ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, ODM_ITRF_SDIO); - else - ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, Adapter->interface_type);/* RTL871X_HCI_TYPE */ - ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_IC_TYPE, ODM_RTL8188E); fab_ver = ODM_TSMC; @@ -164,8 +155,9 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) bool fw_ps_awake = true; u8 hw_init_completed = false; struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct mlme_priv *pmlmepriv = NULL; + u8 bLinked = false; - _func_enter_; hw_init_completed = Adapter->hw_init_completed; if (!hw_init_completed) @@ -179,30 +171,21 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) if (Adapter->wdinfo.p2p_ps_mode) fw_ps_awake = false; - if (hw_init_completed && ((!fw_cur_in_ps) && fw_ps_awake)) { - /* Calculate Tx/Rx statistics. */ - dm_CheckStatistics(Adapter); - - _func_exit_; - } - /* ODM */ - if (hw_init_completed) { - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - u8 bLinked = false; + pmlmepriv = &Adapter->mlmepriv; - if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))) { - if (Adapter->stapriv.asoc_sta_count > 2) - bLinked = true; - } else {/* Station mode */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) - bLinked = true; - } - - ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); - ODM_DMWatchdog(&hal_data->odmpriv); + if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | + WIFI_ADHOC_MASTER_STATE))) { + if (Adapter->stapriv.asoc_sta_count > 2) + bLinked = true; + } else {/* Station mode */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) + bLinked = true; } + + ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); + ODM_DMWatchdog(&hal_data->odmpriv); skip_dm: /* Check GPIO to determine current RF on/off and Pbc status. */ /* Check Hardware Radio ON/OFF or not */ @@ -215,15 +198,11 @@ void rtl8188e_init_dm_priv(struct adapter *Adapter) struct dm_priv *pdmpriv = &hal_data->dmpriv; struct odm_dm_struct *podmpriv = &hal_data->odmpriv; - _rtw_memset(pdmpriv, 0, sizeof(struct dm_priv)); + memset(pdmpriv, 0, sizeof(struct dm_priv)); Init_ODM_ComInfo_88E(Adapter); ODM_InitDebugSetting(podmpriv); } -void rtl8188e_deinit_dm_priv(struct adapter *Adapter) -{ -} - /* Add new function to reset the state of antenna diversity before link. */ /* Compare RSSI for deciding antenna */ void AntDivCompare8188E(struct adapter *Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src) diff --git a/hal/rtl8188e_hal_init.c b/hal/rtl8188e_hal_init.c index d76052a..68db5c9 100644 --- a/hal/rtl8188e_hal_init.c +++ b/hal/rtl8188e_hal_init.c @@ -20,23 +20,22 @@ #define _HAL_INIT_C_ #include +#include #include #include - +#include #include #include -#include - -static void iol_mode_enable(struct adapter *padapter, u8 enable) +void iol_mode_enable(struct adapter *padapter, u8 enable) { u8 reg_0xf0 = 0; if (enable) { /* Enable initial offload */ - reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); - rtw_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); + reg_0xf0 = usb_read8(padapter, REG_SYS_CFG); + usb_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); if (!padapter->bFWReady) { DBG_88E("bFWReady == false call reset 8051...\n"); @@ -45,28 +44,28 @@ static void iol_mode_enable(struct adapter *padapter, u8 enable) } else { /* disable initial offload */ - reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); - rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN); + reg_0xf0 = usb_read8(padapter, REG_SYS_CFG); + usb_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN); } } -static s32 iol_execute(struct adapter *padapter, u8 control) +s32 iol_execute(struct adapter *padapter, u8 control) { s32 status = _FAIL; u8 reg_0x88 = 0; u32 start = 0, passing_time = 0; control = control&0x0f; - reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); - rtw_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); + reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); + usb_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); - start = rtw_get_current_time(); - while ((reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0)) & control && + start = jiffies; + while ((reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0)) & control && (passing_time = rtw_get_passing_time_ms(start)) < 1000) { ; } - reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); + reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); status = (reg_0x88 & control) ? _FAIL : _SUCCESS; if (reg_0x88 & control<<4) status = _FAIL; @@ -77,233 +76,12 @@ static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) { s32 rst = _SUCCESS; iol_mode_enable(padapter, 1); - rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + usb_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); rst = iol_execute(padapter, CMD_INIT_LLT); iol_mode_enable(padapter, 0); return rst; } -static void -efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) -{ - u8 *efuseTbl = NULL; - u8 rtemp8; - u16 eFuse_Addr = 0; - u8 offset, wren; - u16 i, j; - u16 **eFuseWord = NULL; - u16 efuse_utilized = 0; - u8 u1temp = 0; - - efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); - if (efuseTbl == NULL) { - DBG_88E("%s: alloc efuseTbl fail!\n", __func__); - goto exit; - } - - eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); - if (eFuseWord == NULL) { - DBG_88E("%s: alloc eFuseWord fail!\n", __func__); - goto exit; - } - - /* 0. Refresh efuse init map as all oxFF. */ - for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) - for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) - eFuseWord[i][j] = 0xFFFF; - - /* */ - /* 1. Read the first byte to check if efuse is empty!!! */ - /* */ - /* */ - rtemp8 = *(phymap+eFuse_Addr); - if (rtemp8 != 0xFF) { - efuse_utilized++; - eFuse_Addr++; - } else { - DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8); - goto exit; - } - - /* */ - /* 2. Read real efuse content. Filter PG header and every section data. */ - /* */ - while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { - /* Check PG header for section num. */ - if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */ - u1temp = ((rtemp8 & 0xE0) >> 5); - rtemp8 = *(phymap+eFuse_Addr); - if ((rtemp8 & 0x0F) == 0x0F) { - eFuse_Addr++; - rtemp8 = *(phymap+eFuse_Addr); - - if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) - eFuse_Addr++; - continue; - } else { - offset = ((rtemp8 & 0xF0) >> 1) | u1temp; - wren = (rtemp8 & 0x0F); - eFuse_Addr++; - } - } else { - offset = ((rtemp8 >> 4) & 0x0f); - wren = (rtemp8 & 0x0f); - } - - if (offset < EFUSE_MAX_SECTION_88E) { - /* Get word enable value from PG header */ - for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { - /* Check word enable condition in the section */ - if (!(wren & 0x01)) { - rtemp8 = *(phymap+eFuse_Addr); - eFuse_Addr++; - efuse_utilized++; - eFuseWord[offset][i] = (rtemp8 & 0xff); - if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) - break; - rtemp8 = *(phymap+eFuse_Addr); - eFuse_Addr++; - efuse_utilized++; - eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00); - - if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) - break; - } - wren >>= 1; - } - } - /* Read next PG header */ - rtemp8 = *(phymap+eFuse_Addr); - - if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { - efuse_utilized++; - eFuse_Addr++; - } - } - - /* */ - /* 3. Collect 16 sections and 4 word unit into Efuse map. */ - /* */ - for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { - for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { - efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); - efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); - } - } - - /* */ - /* 4. Copy from Efuse map to output pointer memory!!! */ - /* */ - for (i = 0; i < _size_byte; i++) - pbuf[i] = efuseTbl[_offset+i]; - - /* */ - /* 5. Calculate Efuse utilization. */ - /* */ - -exit: - kfree(efuseTbl); - - if (eFuseWord) - rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); -} - -static void efuse_read_phymap_from_txpktbuf( - struct adapter *adapter, - int bcnhead, /* beacon head, where FW store len(2-byte) and efuse physical map. */ - u8 *content, /* buffer to store efuse physical map */ - u16 *size /* for efuse content: the max byte to read. will update to byte read */ - ) -{ - u16 dbg_addr = 0; - u32 start = 0, passing_time = 0; - u8 reg_0x143 = 0; - u32 lo32 = 0, hi32 = 0; - u16 len = 0, count = 0; - int i = 0; - u16 limit = *size; - - u8 *pos = content; - - if (bcnhead < 0) /* if not valid */ - bcnhead = rtw_read8(adapter, REG_TDECTRL+1); - - DBG_88E("%s bcnhead:%d\n", __func__, bcnhead); - - rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); - - dbg_addr = bcnhead*128/8; /* 8-bytes addressing */ - - while (1) { - rtw_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr+i); - - rtw_write8(adapter, REG_TXPKTBUF_DBG, 0); - start = rtw_get_current_time(); - while (!(reg_0x143 = rtw_read8(adapter, REG_TXPKTBUF_DBG)) && - (passing_time = rtw_get_passing_time_ms(start)) < 1000) { - DBG_88E("%s polling reg_0x143:0x%02x, reg_0x106:0x%02x\n", __func__, reg_0x143, rtw_read8(adapter, 0x106)); - rtw_usleep_os(100); - } - - lo32 = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L); - hi32 = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H); - - if (i == 0) { - u8 lenc[2]; - u16 lenbak, aaabak; - u16 aaa; - lenc[0] = rtw_read8(adapter, REG_PKTBUF_DBG_DATA_L); - lenc[1] = rtw_read8(adapter, REG_PKTBUF_DBG_DATA_L+1); - - aaabak = le16_to_cpup((__le16 *)lenc); - lenbak = le16_to_cpu(*((__le16 *)lenc)); - aaa = le16_to_cpup((__le16 *)&lo32); - len = le16_to_cpu(*((__le16 *)&lo32)); - - limit = (len-2 < limit) ? len-2 : limit; - - DBG_88E("%s len:%u, lenbak:%u, aaa:%u, aaabak:%u\n", __func__, len, lenbak, aaa, aaabak); - - memcpy(pos, ((u8 *)&lo32)+2, (limit >= count+2) ? 2 : limit-count); - count += (limit >= count+2) ? 2 : limit-count; - pos = content+count; - - } else { - memcpy(pos, ((u8 *)&lo32), (limit >= count+4) ? 4 : limit-count); - count += (limit >= count+4) ? 4 : limit-count; - pos = content+count; - } - - if (limit > count && len-2 > count) { - memcpy(pos, (u8 *)&hi32, (limit >= count+4) ? 4 : limit-count); - count += (limit >= count+4) ? 4 : limit-count; - pos = content+count; - } - - if (limit <= count || len-2 <= count) - break; - i++; - } - rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, DISABLE_TRXPKT_BUF_ACCESS); - DBG_88E("%s read count:%u\n", __func__, count); - *size = count; -} - -static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset, u16 size_byte, u8 *logical_map) -{ - s32 status = _FAIL; - u8 physical_map[512]; - u16 size = 512; - - rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); - _rtw_memset(physical_map, 0xFF, 512); - rtw_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); - status = iol_execute(padapter, CMD_READ_EFUSE_MAP); - if (status == _SUCCESS) - efuse_read_phymap_from_txpktbuf(padapter, txpktbuf_bndy, physical_map, &size); - efuse_phymap_to_logical(physical_map, offset, size_byte, logical_map); - return status; -} s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) { @@ -321,387 +99,18 @@ s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) return result; } -static s32 iol_ioconfig(struct adapter *padapter, u8 iocfg_bndy) -{ - s32 rst = _SUCCESS; - - rtw_write8(padapter, REG_TDECTRL+1, iocfg_bndy); - rst = iol_execute(padapter, CMD_IOCONFIG); - return rst; -} - -static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt) -{ - struct pkt_attrib *pattrib = &xmit_frame->attrib; - u8 i; - int ret = _FAIL; - - if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) - goto exit; - if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE+pattrib->last_txcmdsz)) { - if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) - goto exit; - } - - dump_mgntframe_and_wait(adapter, xmit_frame, max_wating_ms); - - iol_mode_enable(adapter, 1); - for (i = 0; i < bndy_cnt; i++) { - u8 page_no = 0; - page_no = i*2; - ret = iol_ioconfig(adapter, page_no); - if (ret != _SUCCESS) - break; - } - iol_mode_enable(adapter, 0); -exit: - /* restore BCN_HEAD */ - rtw_write8(adapter, REG_TDECTRL+1, 0); - return ret; -} - -void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) -{ - u32 fifo_data, reg_140; - u32 addr, rstatus, loop = 0; - u16 data_cnts = (data_len/8)+1; - u8 *pbuf = rtw_zvmalloc(data_len+10); - DBG_88E("###### %s ######\n", __func__); - - rtw_write8(Adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); - if (pbuf) { - for (addr = 0; addr < data_cnts; addr++) { - rtw_write32(Adapter, 0x140, addr); - rtw_usleep_os(2); - loop = 0; - do { - rstatus = (reg_140 = rtw_read32(Adapter, REG_PKTBUF_DBG_CTRL)&BIT24); - if (rstatus) { - fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_L); - memcpy(pbuf+(addr*8), &fifo_data, 4); - - fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_H); - memcpy(pbuf+(addr*8+4), &fifo_data, 4); - } - rtw_usleep_os(2); - } while (!rstatus && (loop++ < 10)); - } - rtw_IOL_cmd_buf_dump(Adapter, data_len, pbuf); - rtw_vmfree(pbuf, data_len+10); - } - DBG_88E("###### %s ######\n", __func__); -} - -static void _FWDownloadEnable(struct adapter *padapter, bool enable) -{ - u8 tmp; - - if (enable) { - /* MCU firmware download enable. */ - tmp = rtw_read8(padapter, REG_MCUFWDL); - rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01); - - /* 8051 reset */ - tmp = rtw_read8(padapter, REG_MCUFWDL+2); - rtw_write8(padapter, REG_MCUFWDL+2, tmp&0xf7); - } else { - /* MCU firmware download disable. */ - tmp = rtw_read8(padapter, REG_MCUFWDL); - rtw_write8(padapter, REG_MCUFWDL, tmp&0xfe); - - /* Reserved for fw extension. */ - rtw_write8(padapter, REG_MCUFWDL+1, 0x00); - } -} - #define MAX_REG_BOLCK_SIZE 196 -static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) -{ - int ret = _SUCCESS; - u32 blockSize_p1 = 4; /* (Default) Phase #1 : PCI muse use 4-byte write to download FW */ - u32 blockSize_p2 = 8; /* Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */ - u32 blockSize_p3 = 1; /* Phase #3 : Use 1-byte, the remnant of FW image. */ - u32 blockCount_p1 = 0, blockCount_p2 = 0, blockCount_p3 = 0; - u32 remainSize_p1 = 0, remainSize_p2 = 0; - u8 *bufferPtr = (u8 *)buffer; - u32 i = 0, offset = 0; - - blockSize_p1 = MAX_REG_BOLCK_SIZE; - - /* 3 Phase #1 */ - blockCount_p1 = buffSize / blockSize_p1; - remainSize_p1 = buffSize % blockSize_p1; - - if (blockCount_p1) { - RT_TRACE(_module_hal_init_c_, _drv_notice_, - ("_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) blockCount_p1(%d) remainSize_p1(%d)\n", - buffSize, blockSize_p1, blockCount_p1, remainSize_p1)); - } - - for (i = 0; i < blockCount_p1; i++) { - ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + i * blockSize_p1), blockSize_p1, (bufferPtr + i * blockSize_p1)); - if (ret == _FAIL) - goto exit; - } - - /* 3 Phase #2 */ - if (remainSize_p1) { - offset = blockCount_p1 * blockSize_p1; - - blockCount_p2 = remainSize_p1/blockSize_p2; - remainSize_p2 = remainSize_p1%blockSize_p2; - - if (blockCount_p2) { - RT_TRACE(_module_hal_init_c_, _drv_notice_, - ("_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n", - (buffSize-offset), blockSize_p2 , blockCount_p2, remainSize_p2)); - } - - for (i = 0; i < blockCount_p2; i++) { - ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + offset + i*blockSize_p2), blockSize_p2, (bufferPtr + offset + i*blockSize_p2)); - - if (ret == _FAIL) - goto exit; - } - } - - /* 3 Phase #3 */ - if (remainSize_p2) { - offset = (blockCount_p1 * blockSize_p1) + (blockCount_p2 * blockSize_p2); - - blockCount_p3 = remainSize_p2 / blockSize_p3; - - RT_TRACE(_module_hal_init_c_, _drv_notice_, - ("_BlockWrite: [P3] buffSize_p3(%d) blockSize_p3(%d) blockCount_p3(%d)\n", - (buffSize-offset), blockSize_p3, blockCount_p3)); - - for (i = 0; i < blockCount_p3; i++) { - ret = rtw_write8(padapter, (FW_8188E_START_ADDRESS + offset + i), *(bufferPtr + offset + i)); - - if (ret == _FAIL) - goto exit; - } - } - -exit: - return ret; -} - -static int _PageWrite(struct adapter *padapter, u32 page, void *buffer, u32 size) -{ - u8 value8; - u8 u8Page = (u8)(page & 0x07); - - value8 = (rtw_read8(padapter, REG_MCUFWDL+2) & 0xF8) | u8Page; - rtw_write8(padapter, REG_MCUFWDL+2, value8); - - return _BlockWrite(padapter, buffer, size); -} - -static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) -{ - /* Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */ - /* We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */ - int ret = _SUCCESS; - u32 pageNums, remainSize; - u32 page, offset; - u8 *bufferPtr = (u8 *)buffer; - - pageNums = size / MAX_PAGE_SIZE; - remainSize = size % MAX_PAGE_SIZE; - - for (page = 0; page < pageNums; page++) { - offset = page * MAX_PAGE_SIZE; - ret = _PageWrite(padapter, page, bufferPtr+offset, MAX_PAGE_SIZE); - - if (ret == _FAIL) - goto exit; - } - if (remainSize) { - offset = pageNums * MAX_PAGE_SIZE; - page = pageNums; - ret = _PageWrite(padapter, page, bufferPtr+offset, remainSize); - - if (ret == _FAIL) - goto exit; - } - RT_TRACE(_module_hal_init_c_, _drv_info_, ("_WriteFW Done- for Normal chip.\n")); -exit: - return ret; -} - void _8051Reset88E(struct adapter *padapter) { u8 u1bTmp; - u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT2)); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT2)); + u1bTmp = usb_read8(padapter, REG_SYS_FUNC_EN+1); + usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT2)); + usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT2)); DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n"); } -static s32 _FWFreeToGo(struct adapter *padapter) -{ - u32 counter = 0; - u32 value32; - - /* polling CheckSum report */ - do { - value32 = rtw_read32(padapter, REG_MCUFWDL); - if (value32 & FWDL_ChkSum_rpt) - break; - } while (counter++ < POLLING_READY_TIMEOUT_COUNT); - - if (counter >= POLLING_READY_TIMEOUT_COUNT) { - DBG_88E("%s: chksum report fail! REG_MCUFWDL:0x%08x\n", __func__, value32); - return _FAIL; - } - DBG_88E("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__, value32); - - value32 = rtw_read32(padapter, REG_MCUFWDL); - value32 |= MCUFWDL_RDY; - value32 &= ~WINTINI_RDY; - rtw_write32(padapter, REG_MCUFWDL, value32); - - _8051Reset88E(padapter); - - /* polling for FW ready */ - counter = 0; - do { - value32 = rtw_read32(padapter, REG_MCUFWDL); - if (value32 & WINTINI_RDY) { - DBG_88E("%s: Polling FW ready success!! REG_MCUFWDL:0x%08x\n", __func__, value32); - return _SUCCESS; - } - rtw_udelay_os(5); - } while (counter++ < POLLING_READY_TIMEOUT_COUNT); - - DBG_88E("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32); - return _FAIL; -} - -#define IS_FW_81xxC(padapter) (((GET_HAL_DATA(padapter))->FirmwareSignature & 0xFFF0) == 0x88C0) - -static int load_firmware(struct rt_firmware *pFirmware, struct device *device) -{ - s32 rtStatus = _SUCCESS; - const struct firmware *fw; - const char *fw_name = "rtlwifi/rtl8188eufw.bin"; - int err = request_firmware(&fw, fw_name, device); - - if (err) { - pr_err("Request firmware failed with error 0x%x\n", err); - rtStatus = _FAIL; - goto Exit; - } - if (!fw) { - pr_err("Firmware %s not available\n", fw_name); - rtStatus = _FAIL; - goto Exit; - } - if (fw->size > FW_8188E_SIZE) { - rtStatus = _FAIL; - RT_TRACE(_module_hal_init_c_, _drv_err_, ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE)); - goto Exit; - } - - pFirmware->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL); - if (!pFirmware->szFwBuffer) { - pr_err("Failed to allocate pFirmware->szFwBuffer\n"); - rtStatus = _FAIL; - goto Exit; - } - memcpy(pFirmware->szFwBuffer, fw->data, fw->size); - pFirmware->ulFwLength = fw->size; - release_firmware(fw); - DBG_88E_LEVEL(_drv_info_, "+%s: !bUsedWoWLANFw, FmrmwareLen:%d+\n", __func__, pFirmware->ulFwLength); - -Exit: - return rtStatus; -} - -s32 rtl8188e_FirmwareDownload(struct adapter *padapter) -{ - s32 rtStatus = _SUCCESS; - u8 writeFW_retry = 0; - u32 fwdl_start_time; - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); - struct device *device = dvobj_to_dev(dvobj); - struct rt_firmware_hdr *pFwHdr = NULL; - u8 *pFirmwareBuf; - u32 FirmwareLen; - static int log_version; - - RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__)); - if (!dvobj->firmware.szFwBuffer) - rtStatus = load_firmware(&dvobj->firmware, device); - if (rtStatus == _FAIL) { - dvobj->firmware.szFwBuffer = NULL; - goto Exit; - } - pFirmwareBuf = dvobj->firmware.szFwBuffer; - FirmwareLen = dvobj->firmware.ulFwLength; - - /* To Check Fw header. Added by tynli. 2009.12.04. */ - pFwHdr = (struct rt_firmware_hdr *)dvobj->firmware.szFwBuffer; - - pHalData->FirmwareVersion = le16_to_cpu(pFwHdr->Version); - pHalData->FirmwareSubVersion = pFwHdr->Subversion; - pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->Signature); - - if (!log_version++) - pr_info("%sFirmware Version %d, SubVersion %d, Signature 0x%x\n", - DRIVER_PREFIX, pHalData->FirmwareVersion, - pHalData->FirmwareSubVersion, pHalData->FirmwareSignature); - - if (IS_FW_HEADER_EXIST(pFwHdr)) { - /* Shift 32 bytes for FW header */ - pFirmwareBuf = pFirmwareBuf + 32; - FirmwareLen = FirmwareLen - 32; - } - - /* Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */ - /* or it will cause download Fw fail. 2010.02.01. by tynli. */ - if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */ - rtw_write8(padapter, REG_MCUFWDL, 0x00); - _8051Reset88E(padapter); - } - - _FWDownloadEnable(padapter, true); - fwdl_start_time = rtw_get_current_time(); - while (1) { - /* reset the FWDL chksum */ - rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt); - - rtStatus = _WriteFW(padapter, pFirmwareBuf, FirmwareLen); - - if (rtStatus == _SUCCESS || - (rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3)) - break; - - DBG_88E("%s writeFW_retry:%u, time after fwdl_start_time:%ums\n", - __func__, writeFW_retry, rtw_get_passing_time_ms(fwdl_start_time) - ); - } - _FWDownloadEnable(padapter, false); - if (_SUCCESS != rtStatus) { - DBG_88E("DL Firmware failed!\n"); - goto Exit; - } - - rtStatus = _FWFreeToGo(padapter); - if (_SUCCESS != rtStatus) { - DBG_88E("DL Firmware failed!\n"); - goto Exit; - } - RT_TRACE(_module_hal_init_c_, _drv_info_, ("Firmware is ready to run!\n")); - -Exit: - return rtStatus; -} - void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); @@ -715,1025 +124,8 @@ void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) static void rtl8188e_free_hal_data(struct adapter *padapter) { -_func_enter_; kfree(padapter->HalData); padapter->HalData = NULL; -_func_exit_; -} - -/* */ -/* Efuse related code */ -/* */ -enum{ - VOLTAGE_V25 = 0x03, - LDOE25_SHIFT = 28 , - }; - -static bool -hal_EfusePgPacketWrite2ByteHeader( - struct adapter *pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest); -static bool -hal_EfusePgPacketWrite1ByteHeader( - struct adapter *pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest); -static bool -hal_EfusePgPacketWriteData( - struct adapter *pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest); - -static void -hal_EfusePowerSwitch_RTL8188E( - struct adapter *pAdapter, - u8 bWrite, - u8 PwrState) -{ - u8 tempval; - u16 tmpV16; - - if (PwrState) { - rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); - - /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ - tmpV16 = rtw_read16(pAdapter, REG_SYS_ISO_CTRL); - if (!(tmpV16 & PWC_EV12V)) { - tmpV16 |= PWC_EV12V; - rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); - } - /* Reset: 0x0000h[28], default valid */ - tmpV16 = rtw_read16(pAdapter, REG_SYS_FUNC_EN); - if (!(tmpV16 & FEN_ELDR)) { - tmpV16 |= FEN_ELDR; - rtw_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16); - } - - /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ - tmpV16 = rtw_read16(pAdapter, REG_SYS_CLKR); - if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { - tmpV16 |= (LOADER_CLK_EN | ANA8M); - rtw_write16(pAdapter, REG_SYS_CLKR, tmpV16); - } - - if (bWrite) { - /* Enable LDO 2.5V before read/write action */ - tempval = rtw_read8(pAdapter, EFUSE_TEST+3); - tempval &= 0x0F; - tempval |= (VOLTAGE_V25 << 4); - rtw_write8(pAdapter, EFUSE_TEST+3, (tempval | 0x80)); - } - } else { - rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); - - if (bWrite) { - /* Disable LDO 2.5V after read/write action */ - tempval = rtw_read8(pAdapter, EFUSE_TEST+3); - rtw_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); - } - } -} - -static void -rtl8188e_EfusePowerSwitch( - struct adapter *pAdapter, - u8 bWrite, - u8 PwrState) -{ - hal_EfusePowerSwitch_RTL8188E(pAdapter, bWrite, PwrState); -} - - -static void Hal_EfuseReadEFuse88E(struct adapter *Adapter, - u16 _offset, - u16 _size_byte, - u8 *pbuf, - bool bPseudoTest - ) -{ - u8 *efuseTbl = NULL; - u8 rtemp8[1]; - u16 eFuse_Addr = 0; - u8 offset, wren; - u16 i, j; - u16 **eFuseWord = NULL; - u16 efuse_utilized = 0; - u8 u1temp = 0; - - /* */ - /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ - /* */ - if ((_offset + _size_byte) > EFUSE_MAP_LEN_88E) {/* total E-Fuse table is 512bytes */ - DBG_88E("Hal_EfuseReadEFuse88E(): Invalid offset(%#x) with read bytes(%#x)!!\n", _offset, _size_byte); - goto exit; - } - - efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); - if (efuseTbl == NULL) { - DBG_88E("%s: alloc efuseTbl fail!\n", __func__); - goto exit; - } - - eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); - if (eFuseWord == NULL) { - DBG_88E("%s: alloc eFuseWord fail!\n", __func__); - goto exit; - } - - /* 0. Refresh efuse init map as all oxFF. */ - for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) - for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) - eFuseWord[i][j] = 0xFFFF; - - /* */ - /* 1. Read the first byte to check if efuse is empty!!! */ - /* */ - /* */ - ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - if (*rtemp8 != 0xFF) { - efuse_utilized++; - eFuse_Addr++; - } else { - DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, *rtemp8); - goto exit; - } - - /* */ - /* 2. Read real efuse content. Filter PG header and every section data. */ - /* */ - while ((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { - /* Check PG header for section num. */ - if ((*rtemp8 & 0x1F) == 0x0F) { /* extended header */ - u1temp = ((*rtemp8 & 0xE0) >> 5); - - ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - - if ((*rtemp8 & 0x0F) == 0x0F) { - eFuse_Addr++; - ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - - if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) - eFuse_Addr++; - continue; - } else { - offset = ((*rtemp8 & 0xF0) >> 1) | u1temp; - wren = (*rtemp8 & 0x0F); - eFuse_Addr++; - } - } else { - offset = ((*rtemp8 >> 4) & 0x0f); - wren = (*rtemp8 & 0x0f); - } - - if (offset < EFUSE_MAX_SECTION_88E) { - /* Get word enable value from PG header */ - - for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { - /* Check word enable condition in the section */ - if (!(wren & 0x01)) { - ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - eFuse_Addr++; - efuse_utilized++; - eFuseWord[offset][i] = (*rtemp8 & 0xff); - if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) - break; - ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - eFuse_Addr++; - efuse_utilized++; - eFuseWord[offset][i] |= (((u16)*rtemp8 << 8) & 0xff00); - if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) - break; - } - wren >>= 1; - } - } - - /* Read next PG header */ - ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); - - if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { - efuse_utilized++; - eFuse_Addr++; - } - } - - /* 3. Collect 16 sections and 4 word unit into Efuse map. */ - for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { - for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { - efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); - efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); - } - } - - /* 4. Copy from Efuse map to output pointer memory!!! */ - for (i = 0; i < _size_byte; i++) - pbuf[i] = efuseTbl[_offset+i]; - - /* 5. Calculate Efuse utilization. */ - rtw_hal_set_hwreg(Adapter, HW_VAR_EFUSE_BYTES, (u8 *)&eFuse_Addr); - -exit: - kfree(efuseTbl); - - if (eFuseWord) - rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); -} - -static void ReadEFuseByIC(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) -{ - if (!bPseudoTest) { - int ret = _FAIL; - if (rtw_IOL_applied(Adapter)) { - rtw_hal_power_on(Adapter); - - iol_mode_enable(Adapter, 1); - ret = iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf); - iol_mode_enable(Adapter, 0); - - if (_SUCCESS == ret) - goto exit; - } - } - Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf, bPseudoTest); - -exit: - return; -} - -static void ReadEFuse_Pseudo(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) -{ - Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf, bPseudoTest); -} - -static void rtl8188e_ReadEFuse(struct adapter *Adapter, u8 efuseType, - u16 _offset, u16 _size_byte, u8 *pbuf, - bool bPseudoTest) -{ - if (bPseudoTest) - ReadEFuse_Pseudo (Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); - else - ReadEFuseByIC(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); -} - -/* Do not support BT */ -static void Hal_EFUSEGetEfuseDefinition88E(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) -{ - switch (type) { - case TYPE_EFUSE_MAX_SECTION: - { - u8 *pMax_section; - pMax_section = (u8 *)pOut; - *pMax_section = EFUSE_MAX_SECTION_88E; - } - break; - case TYPE_EFUSE_REAL_CONTENT_LEN: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_EFUSE_CONTENT_LEN_BANK: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_BANK: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_EFUSE_MAP_LEN: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; - } - break; - case TYPE_EFUSE_PROTECT_BYTES_BANK: - { - u8 *pu1Tmp; - pu1Tmp = (u8 *)pOut; - *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - default: - { - u8 *pu1Tmp; - pu1Tmp = (u8 *)pOut; - *pu1Tmp = 0; - } - break; - } -} - -static void Hal_EFUSEGetEfuseDefinition_Pseudo88E(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) -{ - switch (type) { - case TYPE_EFUSE_MAX_SECTION: - { - u8 *pMax_section; - pMax_section = (u8 *)pOut; - *pMax_section = EFUSE_MAX_SECTION_88E; - } - break; - case TYPE_EFUSE_REAL_CONTENT_LEN: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_EFUSE_CONTENT_LEN_BANK: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_BANK: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - case TYPE_EFUSE_MAP_LEN: - { - u16 *pu2Tmp; - pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; - } - break; - case TYPE_EFUSE_PROTECT_BYTES_BANK: - { - u8 *pu1Tmp; - pu1Tmp = (u8 *)pOut; - *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); - } - break; - default: - { - u8 *pu1Tmp; - pu1Tmp = (u8 *)pOut; - *pu1Tmp = 0; - } - break; - } -} - -static void rtl8188e_EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut, bool bPseudoTest) -{ - if (bPseudoTest) - Hal_EFUSEGetEfuseDefinition_Pseudo88E(pAdapter, efuseType, type, pOut); - else - Hal_EFUSEGetEfuseDefinition88E(pAdapter, efuseType, type, pOut); -} - -static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) -{ - u16 tmpaddr = 0; - u16 start_addr = efuse_addr; - u8 badworden = 0x0F; - u8 tmpdata[8]; - - _rtw_memset((void *)tmpdata, 0xff, PGPKT_DATA_SIZE); - - if (!(word_en&BIT0)) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[0], bPseudoTest); - efuse_OneByteWrite(pAdapter, start_addr++, data[1], bPseudoTest); - - efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[1], bPseudoTest); - if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) - badworden &= (~BIT0); - } - if (!(word_en&BIT1)) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[2], bPseudoTest); - efuse_OneByteWrite(pAdapter, start_addr++, data[3], bPseudoTest); - - efuse_OneByteRead(pAdapter, tmpaddr , &tmpdata[2], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3], bPseudoTest); - if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) - badworden &= (~BIT1); - } - if (!(word_en&BIT2)) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[4], bPseudoTest); - efuse_OneByteWrite(pAdapter, start_addr++, data[5], bPseudoTest); - - efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[5], bPseudoTest); - if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) - badworden &= (~BIT2); - } - if (!(word_en&BIT3)) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[6], bPseudoTest); - efuse_OneByteWrite(pAdapter, start_addr++, data[7], bPseudoTest); - - efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[7], bPseudoTest); - if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) - badworden &= (~BIT3); - } - return badworden; -} - -static u8 Hal_EfuseWordEnableDataWrite_Pseudo(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) -{ - u8 ret; - - ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); - return ret; -} - -static u8 rtl8188e_Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) -{ - u8 ret = 0; - - if (bPseudoTest) - ret = Hal_EfuseWordEnableDataWrite_Pseudo (pAdapter, efuse_addr, word_en, data, bPseudoTest); - else - ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); - return ret; -} - -static u16 hal_EfuseGetCurrentSize_8188e(struct adapter *pAdapter, bool bPseudoTest) -{ - int bContinual = true; - u16 efuse_addr = 0; - u8 hoffset = 0, hworden = 0; - u8 efuse_data, word_cnts = 0; - - if (bPseudoTest) - efuse_addr = (u16)(fakeEfuseUsedBytes); - else - rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); - - while (bContinual && - efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && - AVAILABLE_EFUSE_ADDR(efuse_addr)) { - if (efuse_data != 0xFF) { - if ((efuse_data&0x1F) == 0x0F) { /* extended header */ - hoffset = efuse_data; - efuse_addr++; - efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); - if ((efuse_data & 0x0F) == 0x0F) { - efuse_addr++; - continue; - } else { - hoffset = ((hoffset & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); - hworden = efuse_data & 0x0F; - } - } else { - hoffset = (efuse_data>>4) & 0x0F; - hworden = efuse_data & 0x0F; - } - word_cnts = Efuse_CalculateWordCnts(hworden); - /* read next header */ - efuse_addr = efuse_addr + (word_cnts*2)+1; - } else { - bContinual = false; - } - } - - if (bPseudoTest) - fakeEfuseUsedBytes = efuse_addr; - else - rtw_hal_set_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); - - return efuse_addr; -} - -static u16 Hal_EfuseGetCurrentSize_Pseudo(struct adapter *pAdapter, bool bPseudoTest) -{ - u16 ret = 0; - - ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); - return ret; -} - -static u16 rtl8188e_EfuseGetCurrentSize(struct adapter *pAdapter, u8 efuseType, bool bPseudoTest) -{ - u16 ret = 0; - - if (bPseudoTest) - ret = Hal_EfuseGetCurrentSize_Pseudo(pAdapter, bPseudoTest); - else - ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); - return ret; -} - -static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) -{ - u8 ReadState = PG_STATE_HEADER; - int bContinual = true; - int bDataEmpty = true; - u8 efuse_data, word_cnts = 0; - u16 efuse_addr = 0; - u8 hoffset = 0, hworden = 0; - u8 tmpidx = 0; - u8 tmpdata[8]; - u8 max_section = 0; - u8 tmp_header = 0; - - EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, (void *)&max_section, bPseudoTest); - - if (data == NULL) - return false; - if (offset > max_section) - return false; - - _rtw_memset((void *)data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); - _rtw_memset((void *)tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); - - /* Efuse has been pre-programmed dummy 5Bytes at the end of Efuse by CP. */ - /* Skip dummy parts to prevent unexpected data read from Efuse. */ - /* By pass right now. 2009.02.19. */ - while (bContinual && AVAILABLE_EFUSE_ADDR(efuse_addr)) { - /* Header Read ------------- */ - if (ReadState & PG_STATE_HEADER) { - if (efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { - if (EXT_HEADER(efuse_data)) { - tmp_header = efuse_data; - efuse_addr++; - efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); - if (!ALL_WORDS_DISABLED(efuse_data)) { - hoffset = ((tmp_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); - hworden = efuse_data & 0x0F; - } else { - DBG_88E("Error, All words disabled\n"); - efuse_addr++; - continue; - } - } else { - hoffset = (efuse_data>>4) & 0x0F; - hworden = efuse_data & 0x0F; - } - word_cnts = Efuse_CalculateWordCnts(hworden); - bDataEmpty = true; - - if (hoffset == offset) { - for (tmpidx = 0; tmpidx < word_cnts*2; tmpidx++) { - if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx, &efuse_data, bPseudoTest)) { - tmpdata[tmpidx] = efuse_data; - if (efuse_data != 0xff) - bDataEmpty = false; - } - } - if (bDataEmpty == false) { - ReadState = PG_STATE_DATA; - } else {/* read next header */ - efuse_addr = efuse_addr + (word_cnts*2)+1; - ReadState = PG_STATE_HEADER; - } - } else {/* read next header */ - efuse_addr = efuse_addr + (word_cnts*2)+1; - ReadState = PG_STATE_HEADER; - } - } else { - bContinual = false; - } - } else if (ReadState & PG_STATE_DATA) { - /* Data section Read ------------- */ - efuse_WordEnableDataRead(hworden, tmpdata, data); - efuse_addr = efuse_addr + (word_cnts*2)+1; - ReadState = PG_STATE_HEADER; - } - - } - - if ((data[0] == 0xff) && (data[1] == 0xff) && (data[2] == 0xff) && (data[3] == 0xff) && - (data[4] == 0xff) && (data[5] == 0xff) && (data[6] == 0xff) && (data[7] == 0xff)) - return false; - else - return true; -} - -static int Hal_EfusePgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) -{ - int ret; - - ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); - return ret; -} - -static int Hal_EfusePgPacketRead_Pseudo(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) -{ - int ret; - - ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); - return ret; -} - -static int rtl8188e_Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) -{ - int ret; - - if (bPseudoTest) - ret = Hal_EfusePgPacketRead_Pseudo (pAdapter, offset, data, bPseudoTest); - else - ret = Hal_EfusePgPacketRead(pAdapter, offset, data, bPseudoTest); - return ret; -} - -static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, u8 efuseType, struct pgpkt *pFixPkt, u16 *pAddr, bool bPseudoTest) -{ - u8 originaldata[8], badworden = 0; - u16 efuse_addr = *pAddr; - u32 PgWriteSuccess = 0; - - _rtw_memset((void *)originaldata, 0xff, 8); - - if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata, bPseudoTest)) { - /* check if data exist */ - badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pFixPkt->word_en, originaldata, bPseudoTest); - - if (badworden != 0xf) { /* write fail */ - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata, bPseudoTest); - - if (!PgWriteSuccess) - return false; - else - efuse_addr = Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest); - } else { - efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; - } - } else { - efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; - } - *pAddr = efuse_addr; - return true; -} - -static bool hal_EfusePgPacketWrite2ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) -{ - bool bRet = false; - u16 efuse_addr = *pAddr, efuse_max_available_len = 0; - u8 pg_header = 0, tmp_header = 0, pg_header_temp = 0; - u8 repeatcnt = 0; - - EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); - - while (efuse_addr < efuse_max_available_len) { - pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - - while (tmp_header == 0xFF) { - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - return false; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - } - - /* to write ext_header */ - if (tmp_header == pg_header) { - efuse_addr++; - pg_header_temp = pg_header; - pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - - while (tmp_header == 0xFF) { - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - return false; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - } - - if ((tmp_header & 0x0F) == 0x0F) { /* word_en PG fail */ - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { - return false; - } else { - efuse_addr++; - continue; - } - } else if (pg_header != tmp_header) { /* offset PG fail */ - struct pgpkt fixPkt; - fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); - fixPkt.word_en = tmp_header & 0x0F; - fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); - if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) - return false; - } else { - bRet = true; - break; - } - } else if ((tmp_header & 0x1F) == 0x0F) { /* wrong extended header */ - efuse_addr += 2; - continue; - } - } - - *pAddr = efuse_addr; - return bRet; -} - -static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) -{ - bool bRet = false; - u8 pg_header = 0, tmp_header = 0; - u16 efuse_addr = *pAddr; - u8 repeatcnt = 0; - - pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - - while (tmp_header == 0xFF) { - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - return false; - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); - } - - if (pg_header == tmp_header) { - bRet = true; - } else { - struct pgpkt fixPkt; - fixPkt.offset = (tmp_header>>4) & 0x0F; - fixPkt.word_en = tmp_header & 0x0F; - fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); - if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) - return false; - } - - *pAddr = efuse_addr; - return bRet; -} - -static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) -{ - u16 efuse_addr = *pAddr; - u8 badworden = 0; - u32 PgWriteSuccess = 0; - - badworden = 0x0f; - badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); - if (badworden == 0x0F) { - /* write ok */ - return true; - } else { - /* reorganize other pg packet */ - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); - if (!PgWriteSuccess) - return false; - else - return true; - } -} - -static bool -hal_EfusePgPacketWriteHeader( - struct adapter *pAdapter, - u8 efuseType, - u16 *pAddr, - struct pgpkt *pTargetPkt, - bool bPseudoTest) -{ - bool bRet = false; - - if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) - bRet = hal_EfusePgPacketWrite2ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); - else - bRet = hal_EfusePgPacketWrite1ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); - - return bRet; -} - -static bool wordEnMatched(struct pgpkt *pTargetPkt, struct pgpkt *pCurPkt, - u8 *pWden) -{ - u8 match_word_en = 0x0F; /* default all words are disabled */ - - /* check if the same words are enabled both target and current PG packet */ - if (((pTargetPkt->word_en & BIT0) == 0) && - ((pCurPkt->word_en & BIT0) == 0)) - match_word_en &= ~BIT0; /* enable word 0 */ - if (((pTargetPkt->word_en & BIT1) == 0) && - ((pCurPkt->word_en & BIT1) == 0)) - match_word_en &= ~BIT1; /* enable word 1 */ - if (((pTargetPkt->word_en & BIT2) == 0) && - ((pCurPkt->word_en & BIT2) == 0)) - match_word_en &= ~BIT2; /* enable word 2 */ - if (((pTargetPkt->word_en & BIT3) == 0) && - ((pCurPkt->word_en & BIT3) == 0)) - match_word_en &= ~BIT3; /* enable word 3 */ - - *pWden = match_word_en; - - if (match_word_en != 0xf) - return true; - else - return false; -} - -static bool hal_EfuseCheckIfDatafollowed(struct adapter *pAdapter, u8 word_cnts, u16 startAddr, bool bPseudoTest) -{ - bool bRet = false; - u8 i, efuse_data; - - for (i = 0; i < (word_cnts*2); i++) { - if (efuse_OneByteRead(pAdapter, (startAddr+i), &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) - bRet = true; - } - return bRet; -} - -static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) -{ - bool bRet = false; - u8 i, efuse_data = 0, cur_header = 0; - u8 matched_wden = 0, badworden = 0; - u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; - struct pgpkt curPkt; - - EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); - EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&efuse_max, bPseudoTest); - - if (efuseType == EFUSE_WIFI) { - if (bPseudoTest) { - startAddr = (u16)(fakeEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); - } else { - rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); - startAddr %= EFUSE_REAL_CONTENT_LEN; - } - } else { - if (bPseudoTest) - startAddr = (u16)(fakeBTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); - else - startAddr = (u16)(BTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); - } - - while (1) { - if (startAddr >= efuse_max_available_len) { - bRet = false; - break; - } - - if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { - if (EXT_HEADER(efuse_data)) { - cur_header = efuse_data; - startAddr++; - efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest); - if (ALL_WORDS_DISABLED(efuse_data)) { - bRet = false; - break; - } else { - curPkt.offset = ((cur_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); - curPkt.word_en = efuse_data & 0x0F; - } - } else { - cur_header = efuse_data; - curPkt.offset = (cur_header>>4) & 0x0F; - curPkt.word_en = cur_header & 0x0F; - } - - curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); - /* if same header is found but no data followed */ - /* write some part of data followed by the header. */ - if ((curPkt.offset == pTargetPkt->offset) && - (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1, bPseudoTest)) && - wordEnMatched(pTargetPkt, &curPkt, &matched_wden)) { - /* Here to write partial data */ - badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest); - if (badworden != 0x0F) { - u32 PgWriteSuccess = 0; - /* if write fail on some words, write these bad words again */ - - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); - - if (!PgWriteSuccess) { - bRet = false; /* write fail, return */ - break; - } - } - /* partial write ok, update the target packet for later use */ - for (i = 0; i < 4; i++) { - if ((matched_wden & (0x1<word_en |= (0x1<word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); - } - /* read from next header */ - startAddr = startAddr + (curPkt.word_cnts*2) + 1; - } else { - /* not used header, 0xff */ - *pAddr = startAddr; - bRet = true; - break; - } - } - return bRet; -} - -static bool -hal_EfusePgCheckAvailableAddr( - struct adapter *pAdapter, - u8 efuseType, - bool bPseudoTest - ) -{ - u16 efuse_max_available_len = 0; - - /* Change to check TYPE_EFUSE_MAP_LEN , because 8188E raw 256, logic map over 256. */ - EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&efuse_max_available_len, false); - - if (Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest) >= efuse_max_available_len) - return false; - return true; -} - -static void hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, struct pgpkt *pTargetPkt) -{ - _rtw_memset((void *)pTargetPkt->data, 0xFF, sizeof(u8)*8); - pTargetPkt->offset = offset; - pTargetPkt->word_en = word_en; - efuse_WordEnableDataRead(word_en, pData, pTargetPkt->data); - pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); -} - -static bool hal_EfusePgPacketWrite_8188e(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *pData, bool bPseudoTest) -{ - struct pgpkt targetPkt; - u16 startAddr = 0; - u8 efuseType = EFUSE_WIFI; - - if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType, bPseudoTest)) - return false; - - hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); - - if (!hal_EfusePartialWriteCheck(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) - return false; - - if (!hal_EfusePgPacketWriteHeader(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) - return false; - - if (!hal_EfusePgPacketWriteData(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) - return false; - - return true; -} - -static int Hal_EfusePgPacketWrite_Pseudo(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) -{ - int ret; - - ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); - return ret; -} - -static int Hal_EfusePgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) -{ - int ret = 0; - ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); - - return ret; -} - -static int rtl8188e_Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) -{ - int ret; - - if (bPseudoTest) - ret = Hal_EfusePgPacketWrite_Pseudo (pAdapter, offset, word_en, data, bPseudoTest); - else - ret = Hal_EfusePgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest); - return ret; } static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) @@ -1744,7 +136,7 @@ static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) pHalData = GET_HAL_DATA(padapter); - value32 = rtw_read32(padapter, REG_SYS_CFG); + value32 = usb_read32(padapter, REG_SYS_CFG); ChipVersion.ICType = CHIP_8188E; ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); @@ -1756,7 +148,6 @@ static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) pHalData->RegulatorMode = ((value32 & TRP_BT_EN) ? RT_LDO_REGULATOR : RT_SWITCHING_REGULATOR); ChipVersion.ROMVer = 0; /* ROM code version. */ - pHalData->MultiFunc = RT_MULTI_FUNC_NONE; dump_chip_info(ChipVersion); @@ -1783,10 +174,6 @@ static void rtl8188e_read_chip_version(struct adapter *padapter) ReadChipVersion8188E(padapter); } -static void rtl8188e_GetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) -{ -} - static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) { struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); @@ -1794,7 +181,7 @@ static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable switch (eVariable) { case HAL_ODM_STA_INFO: { - struct sta_info *psta = (struct sta_info *)pValue1; + struct sta_info *psta = pValue1; if (bSet) { DBG_88E("### Set STA_(%d) info\n", psta->mac_id); ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); @@ -1816,27 +203,14 @@ static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable } } -void rtl8188e_clone_haldata(struct adapter *dst_adapter, struct adapter *src_adapter) -{ - memcpy(dst_adapter->HalData, src_adapter->HalData, dst_adapter->hal_data_sz); -} - -void rtl8188e_start_thread(struct adapter *padapter) -{ -} - -void rtl8188e_stop_thread(struct adapter *padapter) -{ -} - static void hal_notch_filter_8188e(struct adapter *adapter, bool enable) { if (enable) { DBG_88E("Enable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) | BIT1); + usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) | BIT1); } else { DBG_88E("Disable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) & ~BIT1); + usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) & ~BIT1); } } void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) @@ -1844,47 +218,26 @@ void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->free_hal_data = &rtl8188e_free_hal_data; pHalFunc->dm_init = &rtl8188e_init_dm_priv; - pHalFunc->dm_deinit = &rtl8188e_deinit_dm_priv; pHalFunc->read_chip_version = &rtl8188e_read_chip_version; - pHalFunc->set_bwmode_handler = &PHY_SetBWMode8188E; - pHalFunc->set_channel_handler = &PHY_SwChnl8188E; + pHalFunc->set_bwmode_handler = &phy_set_bw_mode; + pHalFunc->set_channel_handler = &phy_sw_chnl; pHalFunc->hal_dm_watchdog = &rtl8188e_HalDmWatchDog; pHalFunc->Add_RateATid = &rtl8188e_Add_RateATid; - pHalFunc->run_thread = &rtl8188e_start_thread; - pHalFunc->cancel_thread = &rtl8188e_stop_thread; pHalFunc->AntDivBeforeLinkHandler = &AntDivBeforeLink8188E; pHalFunc->AntDivCompareHandler = &AntDivCompare8188E; - pHalFunc->read_bbreg = &rtl8188e_PHY_QueryBBReg; - pHalFunc->write_bbreg = &rtl8188e_PHY_SetBBReg; - pHalFunc->read_rfreg = &rtl8188e_PHY_QueryRFReg; - pHalFunc->write_rfreg = &rtl8188e_PHY_SetRFReg; - - /* Efuse related function */ - pHalFunc->EfusePowerSwitch = &rtl8188e_EfusePowerSwitch; - pHalFunc->ReadEFuse = &rtl8188e_ReadEFuse; - pHalFunc->EFUSEGetEfuseDefinition = &rtl8188e_EFUSE_GetEfuseDefinition; - pHalFunc->EfuseGetCurrentSize = &rtl8188e_EfuseGetCurrentSize; - pHalFunc->Efuse_PgPacketRead = &rtl8188e_Efuse_PgPacketRead; - pHalFunc->Efuse_PgPacketWrite = &rtl8188e_Efuse_PgPacketWrite; - pHalFunc->Efuse_WordEnableDataWrite = &rtl8188e_Efuse_WordEnableDataWrite; + pHalFunc->read_rfreg = &phy_query_rf_reg; + pHalFunc->write_rfreg = &phy_set_rf_reg; pHalFunc->sreset_init_value = &sreset_init_value; - pHalFunc->sreset_reset_value = &sreset_reset_value; - pHalFunc->silentreset = &rtl8188e_silentreset_for_specific_platform; - pHalFunc->sreset_xmit_status_check = &rtl8188e_sreset_xmit_status_check; - pHalFunc->sreset_linked_status_check = &rtl8188e_sreset_linked_status_check; pHalFunc->sreset_get_wifi_status = &sreset_get_wifi_status; - pHalFunc->GetHalODMVarHandler = &rtl8188e_GetHalODMVar; pHalFunc->SetHalODMVarHandler = &rtl8188e_SetHalODMVar; - pHalFunc->IOL_exec_cmds_sync = &rtl8188e_IOL_exec_cmds_sync; - pHalFunc->hal_notch_filter = &hal_notch_filter_8188e; } @@ -1893,7 +246,7 @@ u8 GetEEPROMSize8188E(struct adapter *padapter) u8 size = 0; u32 cr; - cr = rtw_read16(padapter, REG_9346CR); + cr = usb_read16(padapter, REG_9346CR); /* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */ size = (cr & BOOT_FROM_EEPROM) ? 6 : 4; @@ -1914,11 +267,11 @@ static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); u16 LLTReg = REG_LLT_INIT; - rtw_write32(padapter, LLTReg, value); + usb_write32(padapter, LLTReg, value); /* polling */ do { - value = rtw_read32(padapter, LLTReg); + value = usb_read32(padapter, LLTReg); if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) break; @@ -1979,13 +332,13 @@ Hal_InitPGData88E(struct adapter *padapter) if (!pEEPROM->bautoload_fail_flag) { /* autoload OK. */ if (!is_boot_from_eeprom(padapter)) { /* Read EFUSE real map to shadow. */ - EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI); } } else {/* autoload fail */ RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n")); /* update to default value 0xFF */ if (!is_boot_from_eeprom(padapter)) - EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI); } } @@ -1998,23 +351,23 @@ Hal_EfuseParseIDCode88E( struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); u16 EEPROMId; - /* Check 0x8129 again for making sure autoload status!! */ + /* Checl 0x8129 again for making sure autoload status!! */ EEPROMId = le16_to_cpu(*((__le16 *)hwinfo)); if (EEPROMId != RTL_EEPROM_ID) { - pr_err("EEPROM ID(%#x) is invalid!!\n", EEPROMId); + DBG_88E("EEPROM ID(%#x) is invalid!!\n", EEPROMId); pEEPROM->bautoload_fail_flag = true; } else { pEEPROM->bautoload_fail_flag = false; } - pr_info("EEPROM ID = 0x%04x\n", EEPROMId); + DBG_88E("EEPROM ID = 0x%04x\n", EEPROMId); } static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail) { u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0; - _rtw_memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g)); + memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g)); if (AutoLoadFail) { for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { @@ -2312,7 +665,7 @@ void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */ pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x18)>>3; if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) - pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION&0x18)>>3;; + pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION&0x18)>>3; } else { pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */ } @@ -2351,44 +704,3 @@ void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool Aut } DBG_88E("ThermalMeter = 0x%x\n", pHalData->EEPROMThermalMeter); } - -void Hal_InitChannelPlan(struct adapter *padapter) -{ -} - -bool HalDetectPwrDownMode88E(struct adapter *Adapter) -{ - u8 tmpvalue = 0; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; - - EFUSE_ShadowRead(Adapter, 1, EEPROM_RF_FEATURE_OPTION_88E, (u32 *)&tmpvalue); - - /* 2010/08/25 MH INF priority > PDN Efuse value. */ - if (tmpvalue & BIT(4) && pwrctrlpriv->reg_pdnmode) - pHalData->pwrdown = true; - else - pHalData->pwrdown = false; - - DBG_88E("HalDetectPwrDownMode(): PDN =%d\n", pHalData->pwrdown); - - return pHalData->pwrdown; -} /* HalDetectPwrDownMode */ - -/* This function is used only for 92C to set REG_BCN_CTRL(0x550) register. */ -/* We just reserve the value of the register in variable pHalData->RegBcnCtrlVal and then operate */ -/* the value of the register via atomic operation. */ -/* This prevents from race condition when setting this register. */ -/* The value of pHalData->RegBcnCtrlVal is initialized in HwConfigureRTL8192CE() function. */ - -void SetBcnCtrlReg(struct adapter *padapter, u8 SetBits, u8 ClearBits) -{ - struct hal_data_8188e *pHalData; - - pHalData = GET_HAL_DATA(padapter); - - pHalData->RegBcnCtrlVal |= SetBits; - pHalData->RegBcnCtrlVal &= ~ClearBits; - - rtw_write8(padapter, REG_BCN_CTRL, (u8)pHalData->RegBcnCtrlVal); -} diff --git a/hal/rtl8188e_mp.c b/hal/rtl8188e_mp.c deleted file mode 100644 index e97ba02..0000000 --- a/hal/rtl8188e_mp.c +++ /dev/null @@ -1,860 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _RTL8188E_MP_C_ - -#include -#include -#include -#include - -s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); - - if (!netif_running(padapter->pnetdev)) { - RT_TRACE(_module_mp_, _drv_warning_, - ("SetPowerTracking! Fail: interface not opened!\n")); - return _FAIL; - } - - if (!check_fwstate(&padapter->mlmepriv, WIFI_MP_STATE)) { - RT_TRACE(_module_mp_, _drv_warning_, - ("SetPowerTracking! Fail: not in MP mode!\n")); - return _FAIL; - } - - if (enable) - pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; - else - pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = false; - - return _SUCCESS; -} - -void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); - - *enable = pDM_Odm->RFCalibrateInfo.TxPowerTrackControl; -} - -/*----------------------------------------------------------------------------- - * Function: mpt_SwitchRfSetting - * - * Overview: Change RF Setting when we siwthc channel/rate/BW for MP. - * - * Input: struct adapter * pAdapter - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 01/08/2009 MHC Suggestion from SD3 Willis for 92S series. - * 01/09/2009 MHC Add CCK modification for 40MHZ. Suggestion from SD3. - * - *---------------------------------------------------------------------------*/ -void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter) -{ - struct mp_priv *pmp = &pAdapter->mppriv; - - /* <20120525, Kordan> Dynamic mechanism for APK, asked by Dennis. */ - pmp->MptCtx.backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); - pmp->MptCtx.backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0); - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0, 0xD); - PHY_SetRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0, 0xD); - - return; -} -/*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/ - -/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ -void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14) -{ - u32 TempVal = 0, TempVal2 = 0, TempVal3 = 0; - u32 CurrCCKSwingVal = 0, CCKSwingIndex = 12; - u8 i; - - /* get current cck swing value and check 0xa22 & 0xa23 later to match the table. */ - CurrCCKSwingVal = read_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord); - - if (!bInCH14) { - /* Readback the current bb cck swing value and compare with the table to */ - /* get the current swing index */ - for (i = 0; i < CCK_TABLE_SIZE; i++) { - if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch1_Ch13[i][0]) && - (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch1_Ch13[i][1])) { - CCKSwingIndex = i; - break; - } - } - - /* Write 0xa22 0xa23 */ - TempVal = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][0] + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][1]<<8); - - - /* Write 0xa24 ~ 0xa27 */ - TempVal2 = 0; - TempVal2 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][2] + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][3]<<8) + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][4]<<16)+ - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][5]<<24); - - /* Write 0xa28 0xa29 */ - TempVal3 = 0; - TempVal3 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][6] + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][7]<<8); - } else { - for (i = 0; i < CCK_TABLE_SIZE; i++) { - if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch14[i][0]) && - (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch14[i][1])) { - CCKSwingIndex = i; - break; - } - } - - /* Write 0xa22 0xa23 */ - TempVal = CCKSwingTable_Ch14[CCKSwingIndex][0] + - (CCKSwingTable_Ch14[CCKSwingIndex][1]<<8); - - /* Write 0xa24 ~ 0xa27 */ - TempVal2 = 0; - TempVal2 = CCKSwingTable_Ch14[CCKSwingIndex][2] + - (CCKSwingTable_Ch14[CCKSwingIndex][3]<<8) + - (CCKSwingTable_Ch14[CCKSwingIndex][4]<<16)+ - (CCKSwingTable_Ch14[CCKSwingIndex][5]<<24); - - /* Write 0xa28 0xa29 */ - TempVal3 = 0; - TempVal3 = CCKSwingTable_Ch14[CCKSwingIndex][6] + - (CCKSwingTable_Ch14[CCKSwingIndex][7]<<8); - } - - write_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord, TempVal); - write_bbreg(Adapter, rCCK0_TxFilter2, bMaskDWord, TempVal2); - write_bbreg(Adapter, rCCK0_DebugPort, bMaskLWord, TempVal3); -} - -void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); - s32 TempCCk; - u8 CCK_index, CCK_index_old = 0; - u8 Action = 0; /* 0: no action, 1: even->odd, 2:odd->even */ - s32 i = 0; - - - if (!IS_92C_SERIAL(pHalData->VersionID)) - return; - if (beven && !pMptCtx->bMptIndexEven) { - /* odd->even */ - Action = 2; - pMptCtx->bMptIndexEven = true; - } else if (!beven && pMptCtx->bMptIndexEven) { - /* even->odd */ - Action = 1; - pMptCtx->bMptIndexEven = false; - } - - if (Action != 0) { - /* Query CCK default setting From 0xa24 */ - TempCCk = read_bbreg(pAdapter, rCCK0_TxFilter2, bMaskDWord) & bMaskCCK; - for (i = 0; i < CCK_TABLE_SIZE; i++) { - if (pDM_Odm->RFCalibrateInfo.bCCKinCH14) { - if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4)) { - CCK_index_old = (u8)i; - break; - } - } else { - if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4)) { - CCK_index_old = (u8)i; - break; - } - } - } - - if (Action == 1) - CCK_index = CCK_index_old - 1; - else - CCK_index = CCK_index_old + 1; - - /* Adjust CCK according to gain index */ - if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) { - rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch1_Ch13[CCK_index][0]); - rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch1_Ch13[CCK_index][1]); - rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch1_Ch13[CCK_index][2]); - rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch1_Ch13[CCK_index][3]); - rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch1_Ch13[CCK_index][4]); - rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch1_Ch13[CCK_index][5]); - rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch1_Ch13[CCK_index][6]); - rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch1_Ch13[CCK_index][7]); - } else { - rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch14[CCK_index][0]); - rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch14[CCK_index][1]); - rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch14[CCK_index][2]); - rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch14[CCK_index][3]); - rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch14[CCK_index][4]); - rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch14[CCK_index][5]); - rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch14[CCK_index][6]); - rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch14[CCK_index][7]); - } - } -} -/*---------------------------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 Hal_SetChannel(struct adapter *pAdapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - struct mp_priv *pmp = &pAdapter->mppriv; - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); - u8 eRFPath; - u8 channel = pmp->channel; - - /* set RF channel register */ - for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) - _write_rfreg(pAdapter, eRFPath, ODM_CHANNEL, 0x3FF, channel); - Hal_mpt_SwitchRfSetting(pAdapter); - - SelectChannel(pAdapter, channel); - - if (pHalData->CurrentChannel == 14 && !pDM_Odm->RFCalibrateInfo.bCCKinCH14) { - pDM_Odm->RFCalibrateInfo.bCCKinCH14 = true; - Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14); - } else if (pHalData->CurrentChannel != 14 && pDM_Odm->RFCalibrateInfo.bCCKinCH14) { - pDM_Odm->RFCalibrateInfo.bCCKinCH14 = false; - Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14); - } -} - -/* - * Notice - * Switch bandwitdth may change center frequency(channel) - */ -void Hal_SetBandwidth(struct adapter *pAdapter) -{ - struct mp_priv *pmp = &pAdapter->mppriv; - - - SetBWMode(pAdapter, pmp->bandwidth, pmp->prime_channel_offset); - Hal_mpt_SwitchRfSetting(pAdapter); -} - -void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 *TxPower) -{ - u32 tmpval = 0; - - - /* rf-A cck tx power */ - write_bbreg(pAdapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, TxPower[RF_PATH_A]); - tmpval = (TxPower[RF_PATH_A]<<16) | (TxPower[RF_PATH_A]<<8) | TxPower[RF_PATH_A]; - write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); - - /* rf-B cck tx power */ - write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, TxPower[RF_PATH_B]); - tmpval = (TxPower[RF_PATH_B]<<16) | (TxPower[RF_PATH_B]<<8) | TxPower[RF_PATH_B]; - write_bbreg(pAdapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); - - RT_TRACE(_module_mp_, _drv_notice_, - ("-SetCCKTxPower: A[0x%02x] B[0x%02x]\n", - TxPower[RF_PATH_A], TxPower[RF_PATH_B])); -} - -void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 *TxPower) -{ - u32 TxAGC = 0; - u8 tmpval = 0; - - /* HT Tx-rf(A) */ - tmpval = TxPower[RF_PATH_A]; - TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; - - write_bbreg(pAdapter, rTxAGC_A_Rate18_06, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_A_Rate54_24, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_A_Mcs03_Mcs00, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_A_Mcs07_Mcs04, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_A_Mcs11_Mcs08, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_A_Mcs15_Mcs12, bMaskDWord, TxAGC); - - /* HT Tx-rf(B) */ - tmpval = TxPower[RF_PATH_B]; - TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; - - write_bbreg(pAdapter, rTxAGC_B_Rate18_06, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_B_Rate54_24, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_B_Mcs03_Mcs00, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_B_Mcs07_Mcs04, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_B_Mcs11_Mcs08, bMaskDWord, TxAGC); - write_bbreg(pAdapter, rTxAGC_B_Mcs15_Mcs12, bMaskDWord, TxAGC); -} - -void Hal_SetAntennaPathPower(struct adapter *pAdapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - u8 TxPowerLevel[MAX_RF_PATH_NUMS]; - u8 rfPath; - - TxPowerLevel[RF_PATH_A] = pAdapter->mppriv.txpoweridx; - TxPowerLevel[RF_PATH_B] = pAdapter->mppriv.txpoweridx_b; - - switch (pAdapter->mppriv.antenna_tx) { - case ANTENNA_A: - default: - rfPath = RF_PATH_A; - break; - case ANTENNA_B: - rfPath = RF_PATH_B; - break; - case ANTENNA_C: - rfPath = RF_PATH_C; - break; - } - - switch (pHalData->rf_chip) { - case RF_8225: - case RF_8256: - case RF_6052: - Hal_SetCCKTxPower(pAdapter, TxPowerLevel); - if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ - Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); - Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); - break; - default: - break; - } -} - -void Hal_SetTxPower(struct adapter *pAdapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - u8 TxPower = pAdapter->mppriv.txpoweridx; - u8 TxPowerLevel[MAX_RF_PATH_NUMS]; - u8 rf, rfPath; - - for (rf = 0; rf < MAX_RF_PATH_NUMS; rf++) - TxPowerLevel[rf] = TxPower; - - switch (pAdapter->mppriv.antenna_tx) { - case ANTENNA_A: - default: - rfPath = RF_PATH_A; - break; - case ANTENNA_B: - rfPath = RF_PATH_B; - break; - case ANTENNA_C: - rfPath = RF_PATH_C; - break; - } - - switch (pHalData->rf_chip) { - /* 2008/09/12 MH Test only !! We enable the TX power tracking for MP!!!!! */ - /* We should call normal driver API later!! */ - case RF_8225: - case RF_8256: - case RF_6052: - Hal_SetCCKTxPower(pAdapter, TxPowerLevel); - if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ - Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); - Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); - break; - default: - break; - } -} - -void Hal_SetDataRate(struct adapter *pAdapter) -{ - Hal_mpt_SwitchRfSetting(pAdapter); -} - -void Hal_SetAntenna(struct adapter *pAdapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - - struct ant_sel_ofdm *p_ofdm_tx; /* OFDM Tx register */ - struct ant_sel_cck *p_cck_txrx; - u8 r_rx_antenna_ofdm = 0, r_ant_select_cck_val = 0; - u8 chgTx = 0, chgRx = 0; - u32 r_ant_select_ofdm_val = 0, r_ofdm_tx_en_val = 0; - - - p_ofdm_tx = (struct ant_sel_ofdm *)&r_ant_select_ofdm_val; - p_cck_txrx = (struct ant_sel_cck *)&r_ant_select_cck_val; - - p_ofdm_tx->r_ant_ht1 = 0x1; - p_ofdm_tx->r_ant_ht2 = 0x2; /* Second TX RF path is A */ - p_ofdm_tx->r_ant_non_ht = 0x3; /* 0x1+0x2=0x3 */ - - switch (pAdapter->mppriv.antenna_tx) { - case ANTENNA_A: - p_ofdm_tx->r_tx_antenna = 0x1; - r_ofdm_tx_en_val = 0x1; - p_ofdm_tx->r_ant_l = 0x1; - p_ofdm_tx->r_ant_ht_s1 = 0x1; - p_ofdm_tx->r_ant_non_ht_s1 = 0x1; - p_cck_txrx->r_ccktx_enable = 0x8; - chgTx = 1; - - /* From SD3 Willis suggestion !!! Set RF A=TX and B as standby */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 1); - r_ofdm_tx_en_val = 0x3; - - /* Power save */ - - /* We need to close RFB by SW control */ - if (pHalData->rf_type == RF_2T2R) { - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 0); - } - break; - case ANTENNA_B: - p_ofdm_tx->r_tx_antenna = 0x2; - r_ofdm_tx_en_val = 0x2; - p_ofdm_tx->r_ant_l = 0x2; - p_ofdm_tx->r_ant_ht_s1 = 0x2; - p_ofdm_tx->r_ant_non_ht_s1 = 0x2; - p_cck_txrx->r_ccktx_enable = 0x4; - chgTx = 1; - /* From SD3 Willis suggestion !!! Set RF A as standby */ - PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2); - - /* Power save */ - /* cosa r_ant_select_ofdm_val = 0x22222222; */ - - /* 2008/10/31 MH From SD3 Willi's suggestion. We must read RF 1T table. */ - /* 2009/01/08 MH From Sd3 Willis. We need to close RFA by SW control */ - if (pHalData->rf_type == RF_2T2R || pHalData->rf_type == RF_1T2R) { - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); - } - break; - case ANTENNA_AB: /* For 8192S */ - p_ofdm_tx->r_tx_antenna = 0x3; - r_ofdm_tx_en_val = 0x3; - p_ofdm_tx->r_ant_l = 0x3; - p_ofdm_tx->r_ant_ht_s1 = 0x3; - p_ofdm_tx->r_ant_non_ht_s1 = 0x3; - p_cck_txrx->r_ccktx_enable = 0xC; - chgTx = 1; - - /* From SD3 Willis suggestion !!! Set RF B as standby */ - PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2); - PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2); - - /* Disable Power save */ - /* cosa r_ant_select_ofdm_val = 0x3321333; */ - /* 2009/01/08 MH From Sd3 Willis. We need to enable RFA/B by SW control */ - if (pHalData->rf_type == RF_2T2R) { - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); - } - break; - default: - break; - } - - /* r_rx_antenna_ofdm, bit0=A, bit1=B, bit2=C, bit3=D */ - /* r_cckrx_enable : CCK default, 0=A, 1=B, 2=C, 3=D */ - /* r_cckrx_enable_2 : CCK option, 0=A, 1=B, 2=C, 3=D */ - switch (pAdapter->mppriv.antenna_rx) { - case ANTENNA_A: - r_rx_antenna_ofdm = 0x1; /* A */ - p_cck_txrx->r_cckrx_enable = 0x0; /* default: A */ - p_cck_txrx->r_cckrx_enable_2 = 0x0; /* option: A */ - chgRx = 1; - break; - case ANTENNA_B: - r_rx_antenna_ofdm = 0x2; /* B */ - p_cck_txrx->r_cckrx_enable = 0x1; /* default: B */ - p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option: B */ - chgRx = 1; - break; - case ANTENNA_AB: - r_rx_antenna_ofdm = 0x3; /* AB */ - p_cck_txrx->r_cckrx_enable = 0x0; /* default:A */ - p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option:B */ - chgRx = 1; - break; - default: - break; - } - - if (chgTx && chgRx) { - switch (pHalData->rf_chip) { - case RF_8225: - case RF_8256: - case RF_6052: - /* r_ant_sel_cck_val = r_ant_select_cck_val; */ - PHY_SetBBReg(pAdapter, rFPGA1_TxInfo, 0x7fffffff, r_ant_select_ofdm_val); /* OFDM Tx */ - PHY_SetBBReg(pAdapter, rFPGA0_TxInfo, 0x0000000f, r_ofdm_tx_en_val); /* OFDM Tx */ - PHY_SetBBReg(pAdapter, rOFDM0_TRxPathEnable, 0x0000000f, r_rx_antenna_ofdm); /* OFDM Rx */ - PHY_SetBBReg(pAdapter, rOFDM1_TRxPathEnable, 0x0000000f, r_rx_antenna_ofdm); /* OFDM Rx */ - PHY_SetBBReg(pAdapter, rCCK0_AFESetting, bMaskByte3, r_ant_select_cck_val); /* CCK TxRx */ - - break; - default: - break; - } - } - - RT_TRACE(_module_mp_, _drv_notice_, ("-SwitchAntenna: finished\n")); -} - -s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - - - if (!netif_running(pAdapter->pnetdev)) { - RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter! Fail: interface not opened!\n")); - return _FAIL; - } - - if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { - RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter: Fail! not in MP mode!\n")); - return _FAIL; - } - - target_ther &= 0xff; - if (target_ther < 0x07) - target_ther = 0x07; - else if (target_ther > 0x1d) - target_ther = 0x1d; - - pHalData->EEPROMThermalMeter = target_ther; - - return _SUCCESS; -} - -void Hal_TriggerRFThermalMeter(struct adapter *pAdapter) -{ - _write_rfreg(pAdapter, RF_PATH_A , RF_T_METER_88E , BIT17 | BIT16 , 0x03); -} - -u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter) -{ - u32 ThermalValue = 0; - - ThermalValue = _read_rfreg(pAdapter, RF_PATH_A, RF_T_METER_88E, 0xfc00); - return (u8)ThermalValue; -} - -void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value) -{ - Hal_TriggerRFThermalMeter(pAdapter); - rtw_msleep_os(1000); - *value = Hal_ReadRFThermalMeter(pAdapter); -} - -void Hal_SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) -{ - pAdapter->mppriv.MptCtx.bSingleCarrier = bStart; - if (bStart) { - /* Start Single Carrier. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test start\n")); - /* 1. if OFDM block on? */ - if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) - write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ - - /* 2. set CCK test mode off, set to CCK normal mode */ - write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable); - /* 3. turn on scramble setting */ - write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); - /* 4. Turn On Single Carrier Tx and turn off the other test modes. */ - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bEnable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); - /* for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); - } else { - /* Stop Single Carrier. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test stop\n")); - - /* Turn off all test modes. */ - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); - rtw_msleep_os(10); - - /* BB Reset */ - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); - - /* Stop for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); - } -} - - -void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - bool is92C = IS_92C_SERIAL(pHalData->VersionID); - - u8 rfPath; - u32 reg58 = 0x0; - switch (pAdapter->mppriv.antenna_tx) { - case ANTENNA_A: - default: - rfPath = RF_PATH_A; - break; - case ANTENNA_B: - rfPath = RF_PATH_B; - break; - case ANTENNA_C: - rfPath = RF_PATH_C; - break; - } - - pAdapter->mppriv.MptCtx.bSingleTone = bStart; - if (bStart) { - /* Start Single Tone. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test start\n")); - /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ - if (IS_HARDWARE_TYPE_8188E(pAdapter)) { - reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask); - reg58 &= 0xFFFFFFF0; - reg58 += 2; - PHY_SetRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask, reg58); - } - PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x0); - PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x0); - - if (is92C) { - _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x01); - rtw_usleep_os(100); - if (rfPath == RF_PATH_A) - write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x10000); /* PAD all on. */ - else if (rfPath == RF_PATH_B) - write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x10000); /* PAD all on. */ - write_rfreg(pAdapter, rfPath, 0x00, 0x2001f); /* PAD all on. */ - rtw_usleep_os(100); - } else { - write_rfreg(pAdapter, rfPath, 0x21, 0xd4000); - rtw_usleep_os(100); - write_rfreg(pAdapter, rfPath, 0x00, 0x2001f); /* PAD all on. */ - rtw_usleep_os(100); - } - - /* for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); - - } else { - /* Stop Single Tone. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test stop\n")); - - /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ - /* <20120326, Kordan> Only in single tone mode. (asked by Edlu) */ - if (IS_HARDWARE_TYPE_8188E(pAdapter)) { - reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask); - reg58 &= 0xFFFFFFF0; - PHY_SetRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask, reg58); - } - write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x1); - write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x1); - if (is92C) { - _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x00); - rtw_usleep_os(100); - write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x32d75); /* PAD all on. */ - write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x32d75); /* PAD all on. */ - rtw_usleep_os(100); - } else { - write_rfreg(pAdapter, rfPath, 0x21, 0x54000); - rtw_usleep_os(100); - write_rfreg(pAdapter, rfPath, 0x00, 0x30000); /* PAD all on. */ - rtw_usleep_os(100); - } - - /* Stop for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); - } -} - - - -void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) -{ - pAdapter->mppriv.MptCtx.bCarrierSuppression = bStart; - if (bStart) { - /* Start Carrier Suppression. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test start\n")); - if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { - /* 1. if CCK block on? */ - if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) - write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);/* set CCK block on */ - - /* Turn Off All Test Mode */ - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); - - write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); /* transmit mode */ - write_bbreg(pAdapter, rCCK0_System, bCCKScramble, 0x0); /* turn off scramble setting */ - - /* Set CCK Tx Test Rate */ - write_bbreg(pAdapter, rCCK0_System, bCCKTxRate, 0x0); /* Set FTxRate to 1Mbps */ - } - - /* for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); - } else { - /* Stop Carrier Suppression. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test stop\n")); - if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { - write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ - write_bbreg(pAdapter, rCCK0_System, bCCKScramble, 0x1); /* turn on scramble setting */ - - /* BB Reset */ - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); - } - - /* Stop for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); - } -} - -void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart) -{ - u32 cckrate; - - if (bStart) { - RT_TRACE(_module_mp_, _drv_alert_, - ("SetCCKContinuousTx: test start\n")); - - /* 1. if CCK block on? */ - if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) - write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);/* set CCK block on */ - - /* Turn Off All Test Mode */ - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); - /* Set CCK Tx Test Rate */ - cckrate = pAdapter->mppriv.rateidx; - write_bbreg(pAdapter, rCCK0_System, bCCKTxRate, cckrate); - write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); /* transmit mode */ - write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); /* turn on scramble setting */ - - /* for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); - } else { - RT_TRACE(_module_mp_, _drv_info_, - ("SetCCKContinuousTx: test stop\n")); - - write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ - write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); /* turn on scramble setting */ - - /* BB Reset */ - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); - - /* Stop for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); - } - - pAdapter->mppriv.MptCtx.bCckContTx = bStart; - pAdapter->mppriv.MptCtx.bOfdmContTx = false; -} /* mpt_StartCckContTx */ - -void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart) -{ - if (bStart) { - RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test start\n")); - /* 1. if OFDM block on? */ - if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) - write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ - - /* 2. set CCK test mode off, set to CCK normal mode */ - write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable); - - /* 3. turn on scramble setting */ - write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); - /* 4. Turn On Continue Tx and turn off the other test modes. */ - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bEnable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); - - /* for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); - - } else { - RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test stop\n")); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); - write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); - /* Delay 10 ms */ - rtw_msleep_os(10); - /* BB Reset */ - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); - write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); - - /* Stop for dynamic set Power index. */ - write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); - write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); - } - - pAdapter->mppriv.MptCtx.bCckContTx = false; - pAdapter->mppriv.MptCtx.bOfdmContTx = bStart; -} /* mpt_StartOfdmContTx */ - -void Hal_SetContinuousTx(struct adapter *pAdapter, u8 bStart) -{ - RT_TRACE(_module_mp_, _drv_info_, - ("SetContinuousTx: rate:%d\n", pAdapter->mppriv.rateidx)); - - pAdapter->mppriv.MptCtx.bStartContTx = bStart; - if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) - Hal_SetCCKContinuousTx(pAdapter, bStart); - else if ((pAdapter->mppriv.rateidx >= MPT_RATE_6M) && - (pAdapter->mppriv.rateidx <= MPT_RATE_MCS15)) - Hal_SetOFDMContinuousTx(pAdapter, bStart); -} diff --git a/hal/rtl8188e_phycfg.c b/hal/rtl8188e_phycfg.c deleted file mode 100644 index 68bb96d..0000000 --- a/hal/rtl8188e_phycfg.c +++ /dev/null @@ -1,1144 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _RTL8188E_PHYCFG_C_ - -#include -#include -#include -#include - -/*---------------------------Define Local Constant---------------------------*/ -/* Channel switch:The size of command tables for switch channel*/ -#define MAX_PRECMD_CNT 16 -#define MAX_RFDEPENDCMD_CNT 16 -#define MAX_POSTCMD_CNT 16 - -#define MAX_DOZE_WAITING_TIMES_9x 64 - -/*---------------------------Define Local Constant---------------------------*/ - - -/*------------------------Define global variable-----------------------------*/ - -/*------------------------Define local variable------------------------------*/ - - -/*--------------------Define export function prototype-----------------------*/ -/* Please refer to header file */ -/*--------------------Define export function prototype-----------------------*/ - -/*----------------------------Function Body----------------------------------*/ -/* */ -/* 1. BB register R/W API */ -/* */ - -/** -* Function: phy_CalculateBitShift -* -* OverView: Get shifted position of the BitMask -* -* Input: -* u32 BitMask, -* -* Output: none -* Return: u32 Return the shift bit bit position of the mask -*/ -static u32 phy_CalculateBitShift(u32 BitMask) -{ - u32 i; - - for (i = 0; i <= 31; i++) { - if (((BitMask>>i) & 0x1) == 1) - break; - } - return i; -} - -/** -* Function: PHY_QueryBBReg -* -* OverView: Read "sepcific bits" from BB register -* -* Input: -* struct adapter *Adapter, -* u32 RegAddr, The target address to be readback -* u32 BitMask The target bit position in the target address -* to be readback -* Output: None -* Return: u32 Data The readback register value -* Note: This function is equal to "GetRegSetting" in PHY programming guide -*/ -u32 -rtl8188e_PHY_QueryBBReg( - struct adapter *Adapter, - u32 RegAddr, - u32 BitMask - ) -{ - u32 ReturnValue = 0, OriginalValue, BitShift; - - OriginalValue = rtw_read32(Adapter, RegAddr); - BitShift = phy_CalculateBitShift(BitMask); - ReturnValue = (OriginalValue & BitMask) >> BitShift; - return ReturnValue; -} - - -/** -* Function: PHY_SetBBReg -* -* OverView: Write "Specific bits" to BB register (page 8~) -* -* Input: -* struct adapter *Adapter, -* u32 RegAddr, The target address to be modified -* u32 BitMask The target bit position in the target address -* to be modified -* u32 Data The new register value in the target bit position -* of the target address -* -* Output: None -* Return: None -* Note: This function is equal to "PutRegSetting" in PHY programming guide -*/ - -void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) -{ - u32 OriginalValue, BitShift; - - if (BitMask != bMaskDWord) { /* if not "double word" write */ - OriginalValue = rtw_read32(Adapter, RegAddr); - BitShift = phy_CalculateBitShift(BitMask); - Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); - } - - rtw_write32(Adapter, RegAddr, Data); -} - - -/* */ -/* 2. RF register R/W API */ -/* */ -/** -* Function: phy_RFSerialRead -* -* OverView: Read regster from RF chips -* -* Input: -* struct adapter *Adapter, -* enum rf_radio_path eRFPath, Radio path of A/B/C/D -* u32 Offset, The target address to be read -* -* Output: None -* Return: u32 reback value -* Note: Threre are three types of serial operations: -* 1. Software serial write -* 2. Hardware LSSI-Low Speed Serial Interface -* 3. Hardware HSSI-High speed -* serial write. Driver need to implement (1) and (2). -* This function is equal to the combination of RF_ReadReg() and RFLSSIRead() -*/ -static u32 -phy_RFSerialRead( - struct adapter *Adapter, - enum rf_radio_path eRFPath, - u32 Offset - ) -{ - u32 retValue = 0; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; - u32 NewOffset; - u32 tmplong, tmplong2; - u8 RfPiEnable = 0; - /* */ - /* Make sure RF register offset is correct */ - /* */ - Offset &= 0xff; - - /* */ - /* Switch page for 8256 RF IC */ - /* */ - NewOffset = Offset; - - /* For 92S LSSI Read RFLSSIRead */ - /* For RF A/B write 0x824/82c(does not work in the future) */ - /* We must use 0x824 for RF A and B to execute read trigger */ - tmplong = PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord); - if (eRFPath == RF_PATH_A) - tmplong2 = tmplong; - else - tmplong2 = PHY_QueryBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord); - - tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; /* T65 RF */ - - PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong&(~bLSSIReadEdge)); - rtw_udelay_os(10);/* PlatformStallExecution(10); */ - - PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2); - rtw_udelay_os(100);/* PlatformStallExecution(100); */ - - rtw_udelay_os(10);/* PlatformStallExecution(10); */ - - if (eRFPath == RF_PATH_A) - RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter1, BIT8); - else if (eRFPath == RF_PATH_B) - RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XB_HSSIParameter1, BIT8); - - if (RfPiEnable) { /* Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */ - retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBackPi, bLSSIReadBackData); - } else { /* Read from BBreg8a0, 12 bits for 8190, 20 bits for T65 RF */ - retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); - } - return retValue; -} - -/** -* Function: phy_RFSerialWrite -* -* OverView: Write data to RF register (page 8~) -* -* Input: -* struct adapter *Adapter, -* enum rf_radio_path eRFPath, Radio path of A/B/C/D -* u32 Offset, The target address to be read -* u32 Data The new register Data in the target bit position -* of the target to be read -* -* Output: None -* Return: None -* Note: Threre are three types of serial operations: -* 1. Software serial write -* 2. Hardware LSSI-Low Speed Serial Interface -* 3. Hardware HSSI-High speed -* serial write. Driver need to implement (1) and (2). -* This function is equal to the combination of RF_ReadReg() and RFLSSIRead() - * - * Note: For RF8256 only - * The total count of RTL8256(Zebra4) register is around 36 bit it only employs - * 4-bit RF address. RTL8256 uses "register mode control bit" (Reg00[12], Reg00[10]) - * to access register address bigger than 0xf. See "Appendix-4 in PHY Configuration - * programming guide" for more details. - * Thus, we define a sub-finction for RTL8526 register address conversion - * =========================================================== - * Register Mode RegCTL[1] RegCTL[0] Note - * (Reg00[12]) (Reg00[10]) - * =========================================================== - * Reg_Mode0 0 x Reg 0 ~15(0x0 ~ 0xf) - * ------------------------------------------------------------------ - * Reg_Mode1 1 0 Reg 16 ~30(0x1 ~ 0xf) - * ------------------------------------------------------------------ - * Reg_Mode2 1 1 Reg 31 ~ 45(0x1 ~ 0xf) - * ------------------------------------------------------------------ - * - * 2008/09/02 MH Add 92S RF definition - * - * - * -*/ -static void -phy_RFSerialWrite( - struct adapter *Adapter, - enum rf_radio_path eRFPath, - u32 Offset, - u32 Data - ) -{ - u32 DataAndAddr = 0; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; - u32 NewOffset; - - - /* 2009/06/17 MH We can not execute IO for power save or other accident mode. */ - - Offset &= 0xff; - - /* */ - /* Switch page for 8256 RF IC */ - /* */ - NewOffset = Offset; - - /* */ - /* Put write addr in [5:0] and write data in [31:16] */ - /* */ - DataAndAddr = ((NewOffset<<20) | (Data&0x000fffff)) & 0x0fffffff; /* T65 RF */ - - /* */ - /* Write Operation */ - /* */ - PHY_SetBBReg(Adapter, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); -} - -/** -* Function: PHY_QueryRFReg -* -* OverView: Query "Specific bits" to RF register (page 8~) -* -* Input: -* struct adapter *Adapter, -* enum rf_radio_path eRFPath, Radio path of A/B/C/D -* u32 RegAddr, The target address to be read -* u32 BitMask The target bit position in the target address -* to be read -* -* Output: None -* Return: u32 Readback value -* Note: This function is equal to "GetRFRegSetting" in PHY programming guide -*/ -u32 rtl8188e_PHY_QueryRFReg(struct adapter *Adapter, enum rf_radio_path eRFPath, - u32 RegAddr, u32 BitMask) -{ - u32 Original_Value, Readback_Value, BitShift; - - Original_Value = phy_RFSerialRead(Adapter, eRFPath, RegAddr); - - BitShift = phy_CalculateBitShift(BitMask); - Readback_Value = (Original_Value & BitMask) >> BitShift; - return Readback_Value; -} - -/** -* Function: PHY_SetRFReg -* -* OverView: Write "Specific bits" to RF register (page 8~) -* -* Input: -* struct adapter *Adapter, -* enum rf_radio_path eRFPath, Radio path of A/B/C/D -* u32 RegAddr, The target address to be modified -* u32 BitMask The target bit position in the target address -* to be modified -* u32 Data The new register Data in the target bit position -* of the target address -* -* Output: None -* Return: None -* Note: This function is equal to "PutRFRegSetting" in PHY programming guide -*/ -void -rtl8188e_PHY_SetRFReg( - struct adapter *Adapter, - enum rf_radio_path eRFPath, - u32 RegAddr, - u32 BitMask, - u32 Data - ) -{ - u32 Original_Value, BitShift; - - /* RF data is 12 bits only */ - if (BitMask != bRFRegOffsetMask) { - Original_Value = phy_RFSerialRead(Adapter, eRFPath, RegAddr); - BitShift = phy_CalculateBitShift(BitMask); - Data = ((Original_Value & (~BitMask)) | (Data << BitShift)); - } - - phy_RFSerialWrite(Adapter, eRFPath, RegAddr, Data); -} - -/* */ -/* 3. Initial MAC/BB/RF config by reading MAC/BB/RF txt. */ -/* */ - -/*----------------------------------------------------------------------------- - * Function: PHY_MACConfig8192C - * - * Overview: Condig MAC by header file or parameter file. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 08/12/2008 MHC Create Version 0. - * - *---------------------------------------------------------------------------*/ -s32 PHY_MACConfig8188E(struct adapter *Adapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - int rtStatus = _SUCCESS; - - /* */ - /* Config MAC */ - /* */ - if (HAL_STATUS_FAILURE == ODM_ConfigMACWithHeaderFile(&pHalData->odmpriv)) - rtStatus = _FAIL; - - /* 2010.07.13 AMPDU aggregation number B */ - rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); - - return rtStatus; -} - -/** -* Function: phy_InitBBRFRegisterDefinition -* -* OverView: Initialize Register definition offset for Radio Path A/B/C/D -* -* Input: -* struct adapter *Adapter, -* -* Output: None -* Return: None -* Note: The initialization value is constant and it should never be changes -*/ -static void -phy_InitBBRFRegisterDefinition( - struct adapter *Adapter -) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - - /* RF Interface Sowrtware Control */ - pHalData->PHYRegDef[RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 LSBs if read 32-bit from 0x870 */ - pHalData->PHYRegDef[RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872) */ - pHalData->PHYRegDef[RF_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;/* 16 LSBs if read 32-bit from 0x874 */ - pHalData->PHYRegDef[RF_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;/* 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876) */ - - /* RF Interface Readback Value */ - pHalData->PHYRegDef[RF_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; /* 16 LSBs if read 32-bit from 0x8E0 */ - pHalData->PHYRegDef[RF_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;/* 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2) */ - pHalData->PHYRegDef[RF_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;/* 16 LSBs if read 32-bit from 0x8E4 */ - pHalData->PHYRegDef[RF_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;/* 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6) */ - - /* RF Interface Output (and Enable) */ - pHalData->PHYRegDef[RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x860 */ - pHalData->PHYRegDef[RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x864 */ - - /* RF Interface (Output and) Enable */ - pHalData->PHYRegDef[RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) */ - pHalData->PHYRegDef[RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) */ - - /* Addr of LSSI. Wirte RF register by driver */ - pHalData->PHYRegDef[RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; /* LSSI Parameter */ - pHalData->PHYRegDef[RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; - - /* RF parameter */ - pHalData->PHYRegDef[RF_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; /* BB Band Select */ - pHalData->PHYRegDef[RF_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; - pHalData->PHYRegDef[RF_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; - pHalData->PHYRegDef[RF_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; - - /* Tx AGC Gain Stage (same for all path. Should we remove this?) */ - pHalData->PHYRegDef[RF_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ - pHalData->PHYRegDef[RF_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ - pHalData->PHYRegDef[RF_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ - pHalData->PHYRegDef[RF_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ - - /* Tranceiver A~D HSSI Parameter-1 */ - pHalData->PHYRegDef[RF_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; /* wire control parameter1 */ - pHalData->PHYRegDef[RF_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; /* wire control parameter1 */ - - /* Tranceiver A~D HSSI Parameter-2 */ - pHalData->PHYRegDef[RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; /* wire control parameter2 */ - pHalData->PHYRegDef[RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; /* wire control parameter2 */ - - /* RF switch Control */ - pHalData->PHYRegDef[RF_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; /* TR/Ant switch control */ - pHalData->PHYRegDef[RF_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; - pHalData->PHYRegDef[RF_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; - pHalData->PHYRegDef[RF_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; - - /* AGC control 1 */ - pHalData->PHYRegDef[RF_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; - pHalData->PHYRegDef[RF_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; - pHalData->PHYRegDef[RF_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; - pHalData->PHYRegDef[RF_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; - - /* AGC control 2 */ - pHalData->PHYRegDef[RF_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; - pHalData->PHYRegDef[RF_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; - pHalData->PHYRegDef[RF_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; - pHalData->PHYRegDef[RF_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; - - /* RX AFE control 1 */ - pHalData->PHYRegDef[RF_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; - pHalData->PHYRegDef[RF_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; - pHalData->PHYRegDef[RF_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; - pHalData->PHYRegDef[RF_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; - - /* RX AFE control 1 */ - pHalData->PHYRegDef[RF_PATH_A].rfRxAFE = rOFDM0_XARxAFE; - pHalData->PHYRegDef[RF_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; - pHalData->PHYRegDef[RF_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; - pHalData->PHYRegDef[RF_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; - - /* Tx AFE control 1 */ - pHalData->PHYRegDef[RF_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; - pHalData->PHYRegDef[RF_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; - pHalData->PHYRegDef[RF_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; - pHalData->PHYRegDef[RF_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; - - /* Tx AFE control 2 */ - pHalData->PHYRegDef[RF_PATH_A].rfTxAFE = rOFDM0_XATxAFE; - pHalData->PHYRegDef[RF_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; - pHalData->PHYRegDef[RF_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; - pHalData->PHYRegDef[RF_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; - - /* Tranceiver LSSI Readback SI mode */ - pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; - pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; - pHalData->PHYRegDef[RF_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; - pHalData->PHYRegDef[RF_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; - - /* Tranceiver LSSI Readback PI mode */ - pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; - pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback; -} - -void storePwrIndexDiffRateOffset(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - - if (RegAddr == rTxAGC_A_Rate18_06) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0] = Data; - if (RegAddr == rTxAGC_A_Rate54_24) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][1] = Data; - if (RegAddr == rTxAGC_A_CCK1_Mcs32) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][6] = Data; - if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0xffffff00) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][7] = Data; - if (RegAddr == rTxAGC_A_Mcs03_Mcs00) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][2] = Data; - if (RegAddr == rTxAGC_A_Mcs07_Mcs04) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][3] = Data; - if (RegAddr == rTxAGC_A_Mcs11_Mcs08) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][4] = Data; - if (RegAddr == rTxAGC_A_Mcs15_Mcs12) { - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][5] = Data; - if (pHalData->rf_type == RF_1T1R) - pHalData->pwrGroupCnt++; - } - if (RegAddr == rTxAGC_B_Rate18_06) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][8] = Data; - if (RegAddr == rTxAGC_B_Rate54_24) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][9] = Data; - if (RegAddr == rTxAGC_B_CCK1_55_Mcs32) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][14] = Data; - if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0x000000ff) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][15] = Data; - if (RegAddr == rTxAGC_B_Mcs03_Mcs00) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][10] = Data; - if (RegAddr == rTxAGC_B_Mcs07_Mcs04) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][11] = Data; - if (RegAddr == rTxAGC_B_Mcs11_Mcs08) - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][12] = Data; - if (RegAddr == rTxAGC_B_Mcs15_Mcs12) { - pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][13] = Data; - if (pHalData->rf_type != RF_1T1R) - pHalData->pwrGroupCnt++; - } -} - -static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter) -{ - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(Adapter); - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - int rtStatus = _SUCCESS; - - /* */ - /* 1. Read PHY_REG.TXT BB INIT!! */ - /* We will separate as 88C / 92C according to chip version */ - /* */ - if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG)) - rtStatus = _FAIL; - if (rtStatus != _SUCCESS) - goto phy_BB8190_Config_ParaFile_Fail; - - /* 2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ - if (!pEEPROM->bautoload_fail_flag) { - pHalData->pwrGroupCnt = 0; - - if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG_PG)) - rtStatus = _FAIL; - } - - if (rtStatus != _SUCCESS) - goto phy_BB8190_Config_ParaFile_Fail; - - /* 3. BB AGC table Initialization */ - if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_AGC_TAB)) - rtStatus = _FAIL; - - if (rtStatus != _SUCCESS) - goto phy_BB8190_Config_ParaFile_Fail; - -phy_BB8190_Config_ParaFile_Fail: - - return rtStatus; -} - -int -PHY_BBConfig8188E( - struct adapter *Adapter - ) -{ - int rtStatus = _SUCCESS; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u32 RegVal; - u8 CrystalCap; - - phy_InitBBRFRegisterDefinition(Adapter); - - - /* Enable BB and RF */ - RegVal = rtw_read16(Adapter, REG_SYS_FUNC_EN); - rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal|BIT13|BIT0|BIT1)); - - /* 20090923 Joseph: Advised by Steven and Jenyu. Power sequence before init RF. */ - - rtw_write8(Adapter, REG_RF_CTRL, RF_EN|RF_RSTB|RF_SDMRSTB); - - rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB); - - /* Config BB and AGC */ - rtStatus = phy_BB8188E_Config_ParaFile(Adapter); - - /* write 0x24[16:11] = 0x24[22:17] = CrystalCap */ - CrystalCap = pHalData->CrystalCap & 0x3F; - PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, 0x7ff800, (CrystalCap | (CrystalCap << 6))); - - return rtStatus; -} - -int PHY_RFConfig8188E(struct adapter *Adapter) -{ - int rtStatus = _SUCCESS; - - /* RF config */ - rtStatus = PHY_RF6052_Config8188E(Adapter); - return rtStatus; -} - - -/*----------------------------------------------------------------------------- - * Function: PHY_ConfigRFWithParaFile() - * - * Overview: This function read RF parameters from general file format, and do RF 3-wire - * - * Input: struct adapter *Adapter - * ps8 pFileName - * enum rf_radio_path eRFPath - * - * Output: NONE - * - * Return: RT_STATUS_SUCCESS: configuration file exist - * - * Note: Delay may be required for RF configuration - *---------------------------------------------------------------------------*/ -int rtl8188e_PHY_ConfigRFWithParaFile(struct adapter *Adapter, u8 *pFileName, enum rf_radio_path eRFPath) -{ - return _SUCCESS; -} - -void -rtl8192c_PHY_GetHWRegOriginalValue( - struct adapter *Adapter - ) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - - /* read rx initial gain */ - pHalData->DefaultInitialGain[0] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XAAGCCore1, bMaskByte0); - pHalData->DefaultInitialGain[1] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XBAGCCore1, bMaskByte0); - pHalData->DefaultInitialGain[2] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XCAGCCore1, bMaskByte0); - pHalData->DefaultInitialGain[3] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XDAGCCore1, bMaskByte0); - - /* read framesync */ - pHalData->framesync = (u8)PHY_QueryBBReg(Adapter, rOFDM0_RxDetector3, bMaskByte0); - pHalData->framesyncC34 = PHY_QueryBBReg(Adapter, rOFDM0_RxDetector2, bMaskDWord); -} - -/* */ -/* Description: */ -/* Map dBm into Tx power index according to */ -/* current HW model, for example, RF and PA, and */ -/* current wireless mode. */ -/* By Bruce, 2008-01-29. */ -/* */ -static u8 phy_DbmToTxPwrIdx(struct adapter *Adapter, enum wireless_mode WirelessMode, int PowerInDbm) -{ - u8 TxPwrIdx = 0; - int Offset = 0; - - - /* */ - /* Tested by MP, we found that CCK Index 0 equals to 8dbm, OFDM legacy equals to */ - /* 3dbm, and OFDM HT equals to 0dbm respectively. */ - /* Note: */ - /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ - /* By Bruce, 2008-01-29. */ - /* */ - switch (WirelessMode) { - case WIRELESS_MODE_B: - Offset = -7; - break; - - case WIRELESS_MODE_G: - case WIRELESS_MODE_N_24G: - default: - Offset = -8; - break; - } - - if ((PowerInDbm - Offset) > 0) - TxPwrIdx = (u8)((PowerInDbm - Offset) * 2); - else - TxPwrIdx = 0; - - /* Tx Power Index is too large. */ - if (TxPwrIdx > MAX_TXPWR_IDX_NMODE_92S) - TxPwrIdx = MAX_TXPWR_IDX_NMODE_92S; - - return TxPwrIdx; -} - -/* */ -/* Description: */ -/* Map Tx power index into dBm according to */ -/* current HW model, for example, RF and PA, and */ -/* current wireless mode. */ -/* By Bruce, 2008-01-29. */ -/* */ -static int phy_TxPwrIdxToDbm(struct adapter *Adapter, enum wireless_mode WirelessMode, u8 TxPwrIdx) -{ - int Offset = 0; - int PwrOutDbm = 0; - - /* */ - /* Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to -8dbm. */ - /* Note: */ - /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ - /* By Bruce, 2008-01-29. */ - /* */ - switch (WirelessMode) { - case WIRELESS_MODE_B: - Offset = -7; - break; - case WIRELESS_MODE_G: - case WIRELESS_MODE_N_24G: - default: - Offset = -8; - break; - } - - PwrOutDbm = TxPwrIdx / 2 + Offset; /* Discard the decimal part. */ - - return PwrOutDbm; -} - - -/*----------------------------------------------------------------------------- - * Function: GetTxPowerLevel8190() - * - * Overview: This function is export to "common" moudule - * - * Input: struct adapter *Adapter - * psByte Power Level - * - * Output: NONE - * - * Return: NONE - * - *---------------------------------------------------------------------------*/ -void PHY_GetTxPowerLevel8188E(struct adapter *Adapter, u32 *powerlevel) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 TxPwrLevel = 0; - int TxPwrDbm; - - /* */ - /* Because the Tx power indexes are different, we report the maximum of them to */ - /* meet the CCX TPC request. By Bruce, 2008-01-31. */ - /* */ - - /* CCK */ - TxPwrLevel = pHalData->CurrentCckTxPwrIdx; - TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_B, TxPwrLevel); - - /* Legacy OFDM */ - TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx + pHalData->LegacyHTTxPowerDiff; - - /* Compare with Legacy OFDM Tx power. */ - if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel) > TxPwrDbm) - TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel); - - /* HT OFDM */ - TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx; - - /* Compare with HT OFDM Tx power. */ - if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel) > TxPwrDbm) - TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel); - - *powerlevel = TxPwrDbm; -} - -static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, - u8 *ofdmPowerLevel, u8 *BW20PowerLevel, - u8 *BW40PowerLevel) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 index = (channel - 1); - u8 TxCount = 0, path_nums; - - if ((RF_1T2R == pHalData->rf_type) || (RF_1T1R == pHalData->rf_type)) - path_nums = 1; - else - path_nums = 2; - - for (TxCount = 0; TxCount < path_nums; TxCount++) { - if (TxCount == RF_PATH_A) { - /* 1. CCK */ - cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; - /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->OFDM_24G_Diff[TxCount][RF_PATH_A]; - /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]; - /* 2. BW40 */ - BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; - } else if (TxCount == RF_PATH_B) { - /* 1. CCK */ - cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; - /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[TxCount][index]; - /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]+ - pHalData->BW20_24G_Diff[TxCount][index]; - /* 2. BW40 */ - BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; - } else if (TxCount == RF_PATH_C) { - /* 1. CCK */ - cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; - /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ - pHalData->BW20_24G_Diff[TxCount][index]; - /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ - pHalData->BW20_24G_Diff[TxCount][index]; - /* 2. BW40 */ - BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; - } else if (TxCount == RF_PATH_D) { - /* 1. CCK */ - cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; - /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ - pHalData->BW20_24G_Diff[RF_PATH_C][index]+ - pHalData->BW20_24G_Diff[TxCount][index]; - - /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ - pHalData->BW20_24G_Diff[RF_PATH_C][index]+ - pHalData->BW20_24G_Diff[TxCount][index]; - - /* 2. BW40 */ - BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; - } - } -} - -static void phy_PowerIndexCheck88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, - u8 *ofdmPowerLevel, u8 *BW20PowerLevel, u8 *BW40PowerLevel) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - - pHalData->CurrentCckTxPwrIdx = cckPowerLevel[0]; - pHalData->CurrentOfdm24GTxPwrIdx = ofdmPowerLevel[0]; - pHalData->CurrentBW2024GTxPwrIdx = BW20PowerLevel[0]; - pHalData->CurrentBW4024GTxPwrIdx = BW40PowerLevel[0]; -} - -/*----------------------------------------------------------------------------- - * Function: SetTxPowerLevel8190() - * - * Overview: This function is export to "HalCommon" moudule - * We must consider RF path later!!!!!!! - * - * Input: struct adapter *Adapter - * u8 channel - * - * Output: NONE - * - * Return: NONE - * 2008/11/04 MHC We remove EEPROM_93C56. - * We need to move CCX relative code to independet file. - * 2009/01/21 MHC Support new EEPROM format from SD3 requirement. - * - *---------------------------------------------------------------------------*/ -void -PHY_SetTxPowerLevel8188E( - struct adapter *Adapter, - u8 channel - ) -{ - u8 cckPowerLevel[MAX_TX_COUNT] = {0}; - u8 ofdmPowerLevel[MAX_TX_COUNT] = {0};/* [0]:RF-A, [1]:RF-B */ - u8 BW20PowerLevel[MAX_TX_COUNT] = {0}; - u8 BW40PowerLevel[MAX_TX_COUNT] = {0}; - - getTxPowerIndex88E(Adapter, channel, &cckPowerLevel[0], &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0]); - - phy_PowerIndexCheck88E(Adapter, channel, &cckPowerLevel[0], &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0]); - - rtl8188e_PHY_RF6052SetCckTxPower(Adapter, &cckPowerLevel[0]); - rtl8188e_PHY_RF6052SetOFDMTxPower(Adapter, &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0], channel); -} - -/* */ -/* Description: */ -/* Update transmit power level of all channel supported. */ -/* */ -/* TODO: */ -/* A mode. */ -/* By Bruce, 2008-02-04. */ -/* */ -bool -PHY_UpdateTxPowerDbm8188E( - struct adapter *Adapter, - int powerInDbm - ) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 idx; - u8 rf_path; - - /* TODO: A mode Tx power. */ - u8 CckTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_B, powerInDbm); - u8 OfdmTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_N_24G, powerInDbm); - - if (OfdmTxPwrIdx - pHalData->LegacyHTTxPowerDiff > 0) - OfdmTxPwrIdx -= pHalData->LegacyHTTxPowerDiff; - else - OfdmTxPwrIdx = 0; - - for (idx = 0; idx < 14; idx++) { - for (rf_path = 0; rf_path < 2; rf_path++) { - pHalData->TxPwrLevelCck[rf_path][idx] = CckTxPwrIdx; - pHalData->TxPwrLevelHT40_1S[rf_path][idx] = - pHalData->TxPwrLevelHT40_2S[rf_path][idx] = OfdmTxPwrIdx; - } - } - return true; -} - -void -PHY_ScanOperationBackup8188E( - struct adapter *Adapter, - u8 Operation - ) -{ -} - -/*----------------------------------------------------------------------------- - * Function: PHY_SetBWModeCallback8192C() - * - * Overview: Timer callback function for SetSetBWMode - * - * Input: PRT_TIMER pTimer - * - * Output: NONE - * - * Return: NONE - * - * Note: (1) We do not take j mode into consideration now - * (2) Will two workitem of "switch channel" and "switch channel bandwidth" run - * concurrently? - *---------------------------------------------------------------------------*/ -static void -_PHY_SetBWMode92C( - struct adapter *Adapter -) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 regBwOpMode; - u8 regRRSR_RSC; - - if (pHalData->rf_chip == RF_PSEUDO_11N) - return; - - /* There is no 40MHz mode in RF_8225. */ - if (pHalData->rf_chip == RF_8225) - return; - - if (Adapter->bDriverStopped) - return; - - /* 3 */ - /* 3<1>Set MAC register */ - /* 3 */ - - regBwOpMode = rtw_read8(Adapter, REG_BWOPMODE); - regRRSR_RSC = rtw_read8(Adapter, REG_RRSR+2); - - switch (pHalData->CurrentChannelBW) { - case HT_CHANNEL_WIDTH_20: - regBwOpMode |= BW_OPMODE_20MHZ; - /* 2007/02/07 Mark by Emily because we have not verify whether this register works */ - rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); - break; - case HT_CHANNEL_WIDTH_40: - regBwOpMode &= ~BW_OPMODE_20MHZ; - /* 2007/02/07 Mark by Emily because we have not verify whether this register works */ - rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); - regRRSR_RSC = (regRRSR_RSC&0x90) | (pHalData->nCur40MhzPrimeSC<<5); - rtw_write8(Adapter, REG_RRSR+2, regRRSR_RSC); - break; - default: - break; - } - - /* 3 */ - /* 3 <2>Set PHY related register */ - /* 3 */ - switch (pHalData->CurrentChannelBW) { - /* 20 MHz channel*/ - case HT_CHANNEL_WIDTH_20: - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0); - PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0); - break; - /* 40 MHz channel*/ - case HT_CHANNEL_WIDTH_40: - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1); - PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1); - /* Set Control channel to upper or lower. These settings are required only for 40MHz */ - PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC>>1)); - PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); - PHY_SetBBReg(Adapter, 0x818, (BIT26 | BIT27), - (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); - break; - default: - break; - } - /* Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315 */ - - /* 3<3>Set RF related register */ - switch (pHalData->rf_chip) { - case RF_8225: - break; - case RF_8256: - /* Please implement this function in Hal8190PciPhy8256.c */ - break; - case RF_8258: - /* Please implement this function in Hal8190PciPhy8258.c */ - break; - case RF_PSEUDO_11N: - break; - case RF_6052: - rtl8188e_PHY_RF6052SetBandwidth(Adapter, pHalData->CurrentChannelBW); - break; - default: - break; - } -} - - /*----------------------------------------------------------------------------- - * Function: SetBWMode8190Pci() - * - * Overview: This function is export to "HalCommon" moudule - * - * Input: struct adapter *Adapter - * enum ht_channel_width Bandwidth 20M or 40M - * - * Output: NONE - * - * Return: NONE - * - * Note: We do not take j mode into consideration now - *---------------------------------------------------------------------------*/ -void PHY_SetBWMode8188E(struct adapter *Adapter, enum ht_channel_width Bandwidth, /* 20M or 40M */ - unsigned char Offset) /* Upper, Lower, or Don't care */ -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - enum ht_channel_width tmpBW = pHalData->CurrentChannelBW; - - pHalData->CurrentChannelBW = Bandwidth; - - pHalData->nCur40MhzPrimeSC = Offset; - - if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) - _PHY_SetBWMode92C(Adapter); - else - pHalData->CurrentChannelBW = tmpBW; -} - -static void _PHY_SwChnl8192C(struct adapter *Adapter, u8 channel) -{ - u8 eRFPath; - u32 param1, param2; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - - if (Adapter->bNotifyChannelChange) - DBG_88E("[%s] ch = %d\n", __func__, channel); - - /* s1. pre common command - CmdID_SetTxPowerLevel */ - PHY_SetTxPowerLevel8188E(Adapter, channel); - - /* s2. RF dependent command - CmdID_RF_WriteReg, param1=RF_CHNLBW, param2=channel */ - param1 = RF_CHNLBW; - param2 = channel; - for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { - pHalData->RfRegChnlVal[eRFPath] = ((pHalData->RfRegChnlVal[eRFPath] & 0xfffffc00) | param2); - PHY_SetRFReg(Adapter, (enum rf_radio_path)eRFPath, param1, bRFRegOffsetMask, pHalData->RfRegChnlVal[eRFPath]); - } -} - -void PHY_SwChnl8188E(struct adapter *Adapter, u8 channel) -{ - /* Call after initialization */ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 tmpchannel = pHalData->CurrentChannel; - bool bResult = true; - - if (pHalData->rf_chip == RF_PSEUDO_11N) - return; /* return immediately if it is peudo-phy */ - - if (channel == 0) - channel = 1; - - pHalData->CurrentChannel = channel; - - if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) { - _PHY_SwChnl8192C(Adapter, channel); - - if (bResult) - ; - else - pHalData->CurrentChannel = tmpchannel; - - } else { - pHalData->CurrentChannel = tmpchannel; - } -} diff --git a/hal/rtl8188e_rf6052.c b/hal/rtl8188e_rf6052.c deleted file mode 100644 index 299e03e..0000000 --- a/hal/rtl8188e_rf6052.c +++ /dev/null @@ -1,572 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -/****************************************************************************** - * - * - * Module: rtl8192c_rf6052.c ( Source C File) - * - * Note: Provide RF 6052 series relative API. - * - * Function: - * - * Export: - * - * Abbrev: - * - * History: - * Data Who Remark - * - * 09/25/2008 MHC Create initial version. - * 11/05/2008 MHC Add API for tw power setting. - * - * -******************************************************************************/ - -#define _RTL8188E_RF6052_C_ - -#include -#include - -#include - -/*---------------------------Define Local Constant---------------------------*/ -/* Define local structure for debug!!!!! */ -struct rf_shadow { - /* Shadow register value */ - u32 Value; - /* Compare or not flag */ - u8 Compare; - /* Record If it had ever modified unpredicted */ - u8 ErrorOrNot; - /* Recorver Flag */ - u8 Recorver; - /* */ - u8 Driver_Write; -}; - -/*---------------------------Define Local Constant---------------------------*/ - - -/*------------------------Define global variable-----------------------------*/ - -/*------------------------Define local variable------------------------------*/ - -/*----------------------------------------------------------------------------- - * Function: RF_ChangeTxPath - * - * Overview: For RL6052, we must change some RF settign for 1T or 2T. - * - * Input: u16 DataRate 0x80-8f, 0x90-9f - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 09/25/2008 MHC Create Version 0. - * Firmwaer support the utility later. - * - *---------------------------------------------------------------------------*/ -void rtl8188e_RF_ChangeTxPath(struct adapter *Adapter, u16 DataRate) -{ -/* We do not support gain table change inACUT now !!!! Delete later !!! */ -} /* RF_ChangeTxPath */ - - -/*----------------------------------------------------------------------------- - * Function: PHY_RF6052SetBandwidth() - * - * Overview: This function is called by SetBWModeCallback8190Pci() only - * - * Input: struct adapter *Adapter - * WIRELESS_BANDWIDTH_E Bandwidth 20M or 40M - * - * Output: NONE - * - * Return: NONE - * - * Note: For RF type 0222D - *---------------------------------------------------------------------------*/ -void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter, - enum ht_channel_width Bandwidth) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - - switch (Bandwidth) { - case HT_CHANNEL_WIDTH_20: - pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT(10) | BIT(11)); - PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); - break; - case HT_CHANNEL_WIDTH_40: - pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT(10)); - PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); - break; - default: - break; - } -} - -/*----------------------------------------------------------------------------- - * Function: PHY_RF6052SetCckTxPower - * - * Overview: - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/05/2008 MHC Simulate 8192series.. - * - *---------------------------------------------------------------------------*/ - -void -rtl8188e_PHY_RF6052SetCckTxPower( - struct adapter *Adapter, - u8 *pPowerlevel) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - u32 TxAGC[2] = {0, 0}, tmpval = 0, pwrtrac_value; - bool TurboScanOff = false; - u8 idx1, idx2; - u8 *ptr; - u8 direction; - /* FOR CE ,must disable turbo scan */ - TurboScanOff = true; - - - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { - TxAGC[RF_PATH_A] = 0x3f3f3f3f; - TxAGC[RF_PATH_B] = 0x3f3f3f3f; - - TurboScanOff = true;/* disable turbo scan */ - - if (TurboScanOff) { - for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - TxAGC[idx1] = - pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | - (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); - /* 2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */ - if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA) - TxAGC[idx1] = 0x20; - } - } - } else { - /* Driver dynamic Tx power shall not affect Tx power. - * It shall be determined by power training mechanism. -i * Currently, we cannot fully disable driver dynamic - * tx power mechanism because it is referenced by BT - * coexist mechanism. - * In the future, two mechanism shall be separated from - * each other and maintained independently. */ - if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { - TxAGC[RF_PATH_A] = 0x10101010; - TxAGC[RF_PATH_B] = 0x10101010; - } else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) { - TxAGC[RF_PATH_A] = 0x00000000; - TxAGC[RF_PATH_B] = 0x00000000; - } else { - for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - TxAGC[idx1] = - pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | - (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); - } - if (pHalData->EEPROMRegulatory == 0) { - tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][6]) + - (pHalData->MCSTxPowerLevelOriginalOffset[0][7]<<8); - TxAGC[RF_PATH_A] += tmpval; - - tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][14]) + - (pHalData->MCSTxPowerLevelOriginalOffset[0][15]<<24); - TxAGC[RF_PATH_B] += tmpval; - } - } - } - for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - ptr = (u8 *)(&(TxAGC[idx1])); - for (idx2 = 0; idx2 < 4; idx2++) { - if (*ptr > RF6052_MAX_TX_PWR) - *ptr = RF6052_MAX_TX_PWR; - ptr++; - } - } - ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 1, &direction, &pwrtrac_value); - - if (direction == 1) { - /* Increase TX power */ - TxAGC[0] += pwrtrac_value; - TxAGC[1] += pwrtrac_value; - } else if (direction == 2) { - /* Decrease TX power */ - TxAGC[0] -= pwrtrac_value; - TxAGC[1] -= pwrtrac_value; - } - - /* rf-A cck tx power */ - tmpval = TxAGC[RF_PATH_A]&0xff; - PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); - tmpval = TxAGC[RF_PATH_A]>>8; - PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); - - /* rf-B cck tx power */ - tmpval = TxAGC[RF_PATH_B]>>24; - PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); - tmpval = TxAGC[RF_PATH_B]&0x00ffffff; - PHY_SetBBReg(Adapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); -} /* PHY_RF6052SetCckTxPower */ - -/* */ -/* powerbase0 for OFDM rates */ -/* powerbase1 for HT MCS rates */ -/* */ -static void getpowerbase88e(struct adapter *Adapter, u8 *pPowerLevelOFDM, - u8 *pPowerLevelBW20, u8 *pPowerLevelBW40, u8 Channel, u32 *OfdmBase, u32 *MCSBase) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u32 powerBase0, powerBase1; - u8 i, powerlevel[2]; - - for (i = 0; i < 2; i++) { - powerBase0 = pPowerLevelOFDM[i]; - - powerBase0 = (powerBase0<<24) | (powerBase0<<16) | (powerBase0<<8) | powerBase0; - *(OfdmBase+i) = powerBase0; - } - for (i = 0; i < pHalData->NumTotalRFPath; i++) { - /* Check HT20 to HT40 diff */ - if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - powerlevel[i] = pPowerLevelBW20[i]; - else - powerlevel[i] = pPowerLevelBW40[i]; - powerBase1 = powerlevel[i]; - powerBase1 = (powerBase1<<24) | (powerBase1<<16) | (powerBase1<<8) | powerBase1; - *(MCSBase+i) = powerBase1; - } -} -static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, - u8 index, u32 *powerBase0, u32 *powerBase1, - u32 *pOutWriteVal) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - u8 i, chnlGroup = 0, pwr_diff_limit[4], customer_pwr_limit; - s8 pwr_diff = 0; - u32 writeVal, customer_limit, rf; - u8 Regulatory = pHalData->EEPROMRegulatory; - - /* Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate */ - - for (rf = 0; rf < 2; rf++) { - switch (Regulatory) { - case 0: /* Realtek better performance */ - /* increase power diff defined by Realtek for large power */ - chnlGroup = 0; - writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + - ((index < 2) ? powerBase0[rf] : powerBase1[rf]); - break; - case 1: /* Realtek regulatory */ - /* increase power diff defined by Realtek for regulatory */ - if (pHalData->pwrGroupCnt == 1) - chnlGroup = 0; - if (pHalData->pwrGroupCnt >= pHalData->PGMaxGroup) { - if (Channel < 3) /* Channel 1-2 */ - chnlGroup = 0; - else if (Channel < 6) /* Channel 3-5 */ - chnlGroup = 1; - else if (Channel < 9) /* Channel 6-8 */ - chnlGroup = 2; - else if (Channel < 12) /* Channel 9-11 */ - chnlGroup = 3; - else if (Channel < 14) /* Channel 12-13 */ - chnlGroup = 4; - else if (Channel == 14) /* Channel 14 */ - chnlGroup = 5; - } - writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + - ((index < 2) ? powerBase0[rf] : powerBase1[rf]); - break; - case 2: /* Better regulatory */ - /* don't increase any power diff */ - writeVal = ((index < 2) ? powerBase0[rf] : powerBase1[rf]); - break; - case 3: /* Customer defined power diff. */ - /* increase power diff defined by customer. */ - chnlGroup = 0; - - if (index < 2) - pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel-1]; - else if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel-1]; - - if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40) - customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel-1]; - else - customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel-1]; - - if (pwr_diff >= customer_pwr_limit) - pwr_diff = 0; - else - pwr_diff = customer_pwr_limit - pwr_diff; - - for (i = 0; i < 4; i++) { - pwr_diff_limit[i] = (u8)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)]&(0x7f<<(i*8)))>>(i*8)); - - if (pwr_diff_limit[i] > pwr_diff) - pwr_diff_limit[i] = pwr_diff; - } - customer_limit = (pwr_diff_limit[3]<<24) | (pwr_diff_limit[2]<<16) | - (pwr_diff_limit[1]<<8) | (pwr_diff_limit[0]); - writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); - break; - default: - chnlGroup = 0; - writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + - ((index < 2) ? powerBase0[rf] : powerBase1[rf]); - break; - } -/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism. */ -/* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ -/* In the future, two mechanism shall be separated from each other and maintained independently. Thanks for Lanhsin's reminder. */ - /* 92d do not need this */ - if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) - writeVal = 0x14141414; - else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) - writeVal = 0x00000000; - - /* 20100628 Joseph: High power mode for BT-Coexist mechanism. */ - /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */ - if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1) - writeVal = writeVal - 0x06060606; - else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2) - writeVal = writeVal; - *(pOutWriteVal+rf) = writeVal; - } -} -static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u16 regoffset_a[6] = { - rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24, - rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04, - rTxAGC_A_Mcs11_Mcs08, rTxAGC_A_Mcs15_Mcs12}; - u16 regoffset_b[6] = { - rTxAGC_B_Rate18_06, rTxAGC_B_Rate54_24, - rTxAGC_B_Mcs03_Mcs00, rTxAGC_B_Mcs07_Mcs04, - rTxAGC_B_Mcs11_Mcs08, rTxAGC_B_Mcs15_Mcs12}; - u8 i, rf, pwr_val[4]; - u32 writeVal; - u16 regoffset; - - for (rf = 0; rf < 2; rf++) { - writeVal = pValue[rf]; - for (i = 0; i < 4; i++) { - pwr_val[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8)); - if (pwr_val[i] > RF6052_MAX_TX_PWR) - pwr_val[i] = RF6052_MAX_TX_PWR; - } - writeVal = (pwr_val[3]<<24) | (pwr_val[2]<<16) | (pwr_val[1]<<8) | pwr_val[0]; - - if (rf == 0) - regoffset = regoffset_a[index]; - else - regoffset = regoffset_b[index]; - - PHY_SetBBReg(Adapter, regoffset, bMaskDWord, writeVal); - - /* 201005115 Joseph: Set Tx Power diff for Tx power training mechanism. */ - if (((pHalData->rf_type == RF_2T2R) && - (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs15_Mcs12)) || - ((pHalData->rf_type != RF_2T2R) && - (regoffset == rTxAGC_A_Mcs07_Mcs04 || regoffset == rTxAGC_B_Mcs07_Mcs04))) { - writeVal = pwr_val[3]; - if (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_A_Mcs07_Mcs04) - regoffset = 0xc90; - if (regoffset == rTxAGC_B_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs07_Mcs04) - regoffset = 0xc98; - for (i = 0; i < 3; i++) { - if (i != 2) - writeVal = (writeVal > 8) ? (writeVal-8) : 0; - else - writeVal = (writeVal > 6) ? (writeVal-6) : 0; - rtw_write8(Adapter, (u32)(regoffset+i), (u8)writeVal); - } - } - } -} - -/*----------------------------------------------------------------------------- - * Function: PHY_RF6052SetOFDMTxPower - * - * Overview: For legacy and HY OFDM, we must read EEPROM TX power index for - * different channel and read original value in TX power register area from - * 0xe00. We increase offset and original value to be correct tx pwr. - * - * Input: NONE - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 11/05/2008 MHC Simulate 8192 series method. - * 01/06/2009 MHC 1. Prevent Path B tx power overflow or underflow dure to - * A/B pwr difference or legacy/HT pwr diff. - * 2. We concern with path B legacy/HT OFDM difference. - * 01/22/2009 MHC Support new EPRO format from SD3. - * - *---------------------------------------------------------------------------*/ - -void -rtl8188e_PHY_RF6052SetOFDMTxPower( - struct adapter *Adapter, - u8 *pPowerLevelOFDM, - u8 *pPowerLevelBW20, - u8 *pPowerLevelBW40, - u8 Channel) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u32 writeVal[2], powerBase0[2], powerBase1[2], pwrtrac_value; - u8 direction; - u8 index = 0; - - getpowerbase88e(Adapter, pPowerLevelOFDM, pPowerLevelBW20, pPowerLevelBW40, Channel, &powerBase0[0], &powerBase1[0]); - - /* 2012/04/23 MH According to power tracking value, we need to revise OFDM tx power. */ - /* This is ued to fix unstable power tracking mode. */ - ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 0, &direction, &pwrtrac_value); - - for (index = 0; index < 6; index++) { - get_rx_power_val_by_reg(Adapter, Channel, index, - &powerBase0[0], &powerBase1[0], - &writeVal[0]); - - if (direction == 1) { - writeVal[0] += pwrtrac_value; - writeVal[1] += pwrtrac_value; - } else if (direction == 2) { - writeVal[0] -= pwrtrac_value; - writeVal[1] -= pwrtrac_value; - } - writeOFDMPowerReg88E(Adapter, index, &writeVal[0]); - } -} - -static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) -{ - struct bb_reg_def *pPhyReg; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u32 u4RegValue = 0; - u8 eRFPath; - int rtStatus = _SUCCESS; - - /* 3----------------------------------------------------------------- */ - /* 3 <2> Initialize RF */ - /* 3----------------------------------------------------------------- */ - for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { - pPhyReg = &pHalData->PHYRegDef[eRFPath]; - - /*----Store original RFENV control type----*/ - switch (eRFPath) { - case RF_PATH_A: - case RF_PATH_C: - u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); - break; - case RF_PATH_B: - case RF_PATH_D: - u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); - break; - } - /*----Set RF_ENV enable----*/ - PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); - rtw_udelay_os(1);/* PlatformStallExecution(1); */ - - /*----Set RF_ENV output high----*/ - PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); - rtw_udelay_os(1);/* PlatformStallExecution(1); */ - - /* Set bit number of Address and Data for RF register */ - PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ - rtw_udelay_os(1);/* PlatformStallExecution(1); */ - - PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ - rtw_udelay_os(1);/* PlatformStallExecution(1); */ - - /*----Initialize RF fom connfiguration file----*/ - switch (eRFPath) { - case RF_PATH_A: - if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum ODM_RF_RADIO_PATH)eRFPath, (enum ODM_RF_RADIO_PATH)eRFPath)) - rtStatus = _FAIL; - break; - case RF_PATH_B: - if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum ODM_RF_RADIO_PATH)eRFPath, (enum ODM_RF_RADIO_PATH)eRFPath)) - rtStatus = _FAIL; - break; - case RF_PATH_C: - break; - case RF_PATH_D: - break; - } - /*----Restore RFENV control type----*/; - switch (eRFPath) { - case RF_PATH_A: - case RF_PATH_C: - PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); - break; - case RF_PATH_B: - case RF_PATH_D: - PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); - break; - } - if (rtStatus != _SUCCESS) - goto phy_RF6052_Config_ParaFile_Fail; - } - return rtStatus; - -phy_RF6052_Config_ParaFile_Fail: - return rtStatus; -} - -int PHY_RF6052_Config8188E(struct adapter *Adapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - int rtStatus = _SUCCESS; - - /* */ - /* Initialize general global value */ - /* */ - /* TODO: Extend RF_PATH_C and RF_PATH_D in the future */ - if (pHalData->rf_type == RF_1T1R) - pHalData->NumTotalRFPath = 1; - else - pHalData->NumTotalRFPath = 2; - - /* */ - /* Config BB and RF */ - /* */ - rtStatus = phy_RF6052_Config_ParaFile(Adapter); - return rtStatus; -} diff --git a/hal/rtl8188e_rxdesc.c b/hal/rtl8188e_rxdesc.c index b076fe3..53cf3ba 100644 --- a/hal/rtl8188e_rxdesc.c +++ b/hal/rtl8188e_rxdesc.c @@ -23,9 +23,9 @@ #include #include -static void process_rssi(struct adapter *padapter, union recv_frame *prframe) +static void process_rssi(struct adapter *padapter, struct recv_frame *prframe) { - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &prframe->attrib; struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; if (signal_stat->update_req) { @@ -39,7 +39,8 @@ static void process_rssi(struct adapter *padapter, union recv_frame *prframe) signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; } /* Process_UI_RSSI_8192C */ -static void process_link_qual(struct adapter *padapter, union recv_frame *prframe) +static void process_link_qual(struct adapter *padapter, + struct recv_frame *prframe) { struct rx_pkt_attrib *pattrib; struct signal_stat *signal_stat; @@ -47,7 +48,7 @@ static void process_link_qual(struct adapter *padapter, union recv_frame *prfram if (prframe == NULL || padapter == NULL) return; - pattrib = &prframe->u.hdr.attrib; + pattrib = &prframe->attrib; signal_stat = &padapter->recvpriv.signal_qual_data; if (signal_stat->update_req) { @@ -63,7 +64,7 @@ static void process_link_qual(struct adapter *padapter, union recv_frame *prfram void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) { - union recv_frame *precvframe = (union recv_frame *)prframe; + struct recv_frame *precvframe = (struct recv_frame *)prframe; /* Check RSSI */ process_rssi(padapter, precvframe); @@ -71,7 +72,8 @@ void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) process_link_qual(padapter, precvframe); } -void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat *prxstat) +void update_recvframe_attrib_88e(struct recv_frame *precvframe, + struct recv_stat *prxstat) { struct rx_pkt_attrib *pattrib; struct recv_stat report; @@ -83,10 +85,10 @@ void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat report.rxdw4 = prxstat->rxdw4; report.rxdw5 = prxstat->rxdw5; - pattrib = &precvframe->u.hdr.attrib; - _rtw_memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); + pattrib = &precvframe->attrib; + memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); - pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);;/* u8)prxreport->crc32; */ + pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);/* u8)prxreport->crc32; */ /* update rx report to recv_frame attribute */ pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);/* prxreport->rpt_sel; */ @@ -136,12 +138,13 @@ void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat /* * Notice: * Before calling this function, - * precvframe->u.hdr.rx_data should be ready! + * precvframe->rx_data should be ready! */ -void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat *pphy_status) +void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, + struct phy_stat *pphy_status) { - struct adapter *padapter = precvframe->u.hdr.adapter; - struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; + struct adapter *padapter = precvframe->adapter; + struct rx_pkt_attrib *pattrib = &precvframe->attrib; struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info); u8 *wlanhdr; @@ -154,15 +157,15 @@ void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat pkt_info.bPacketToSelf = false; pkt_info.bPacketBeacon = false; - wlanhdr = get_recvframe_data(precvframe); + wlanhdr = precvframe->rx_data; pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && !pattrib->icv_err && !pattrib->crc_err && - _rtw_memcmp(get_hdr_bssid(wlanhdr), + !memcmp(get_hdr_bssid(wlanhdr), get_bssid(&padapter->mlmepriv), ETH_ALEN)); pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && - (_rtw_memcmp(get_da(wlanhdr), + (!memcmp(get_da(wlanhdr), myid(&padapter->eeprompriv), ETH_ALEN)); pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && @@ -183,19 +186,19 @@ void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat pkt_info.StationID = psta->mac_id; pkt_info.Rate = pattrib->mcs_rate; - ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info), padapter); + ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info)); - precvframe->u.hdr.psta = NULL; + precvframe->psta = NULL; if (pkt_info.bPacketMatchBSSID && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) { if (psta) { - precvframe->u.hdr.psta = psta; + precvframe->psta = psta; rtl8188e_process_phy_info(padapter, precvframe); } } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { if (psta) - precvframe->u.hdr.psta = psta; + precvframe->psta = psta; } rtl8188e_process_phy_info(padapter, precvframe); } diff --git a/hal/rtl8188e_sreset.c b/hal/rtl8188e_sreset.c deleted file mode 100644 index 96d698e..0000000 --- a/hal/rtl8188e_sreset.c +++ /dev/null @@ -1,80 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _RTL8188E_SRESET_C_ - -#include -#include - -void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter) -{ -} - -void rtl8188e_sreset_xmit_status_check(struct adapter *padapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct sreset_priv *psrtpriv = &pHalData->srestpriv; - - unsigned long current_time; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - unsigned int diff_time; - u32 txdma_status; - - txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS); - if (txdma_status != 0x00) { - DBG_88E("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status); - rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status); - rtl8188e_silentreset_for_specific_platform(padapter); - } - /* total xmit irp = 4 */ - current_time = rtw_get_current_time(); - if (0 == pxmitpriv->free_xmitbuf_cnt) { - diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time); - - if (diff_time > 2000) { - if (psrtpriv->last_tx_complete_time == 0) { - psrtpriv->last_tx_complete_time = current_time; - } else { - diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time); - if (diff_time > 4000) { - DBG_88E("%s tx hang\n", __func__); - rtl8188e_silentreset_for_specific_platform(padapter); - } - } - } - } -} - -void rtl8188e_sreset_linked_status_check(struct adapter *padapter) -{ - u32 rx_dma_status = 0; - u8 fw_status = 0; - rx_dma_status = rtw_read32(padapter, REG_RXDMA_STATUS); - if (rx_dma_status != 0x00) { - DBG_88E("%s REG_RXDMA_STATUS:0x%08x\n", __func__, rx_dma_status); - rtw_write32(padapter, REG_RXDMA_STATUS, rx_dma_status); - } - fw_status = rtw_read8(padapter, REG_FMETHR); - if (fw_status != 0x00) { - if (fw_status == 1) - DBG_88E("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!\n", __func__, fw_status); - else if (fw_status == 2) - DBG_88E("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!\n", __func__, fw_status); - } -} diff --git a/hal/rtl8188e_xmit.c b/hal/rtl8188e_xmit.c index 7ecbcf7..a6ba53b 100644 --- a/hal/rtl8188e_xmit.c +++ b/hal/rtl8188e_xmit.c @@ -25,7 +25,7 @@ void dump_txrpt_ccx_88e(void *buf) { - struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; + struct txrpt_ccx_88e *txrpt_ccx = buf; DBG_88E("%s:\n" "tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n" @@ -64,6 +64,7 @@ void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, { u8 dmp_txpkt; bool dump_txdesc = false; + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(dmp_txpkt)); if (dmp_txpkt == 1) {/* dump txdesc for data frame */ diff --git a/hal/rtl8188eu_led.c b/hal/rtl8188eu_led.c index 08dfd94..81d691d 100644 --- a/hal/rtl8188eu_led.c +++ b/hal/rtl8188eu_led.c @@ -22,6 +22,7 @@ #include #include #include +#include /* LED object. */ @@ -34,17 +35,8 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; - LedCfg = rtw_read8(padapter, REG_LEDCFG2); - switch (pLed->LedPin) { - case LED_PIN_LED0: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ - break; - case LED_PIN_LED1: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /* SW control led1 on. */ - break; - default: - break; - } + LedCfg = usb_read8(padapter, REG_LEDCFG2); + usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ pLed->bLedOn = true; } @@ -58,27 +50,17 @@ void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) if (padapter->bSurpriseRemoved || padapter->bDriverStopped) goto exit; - LedCfg = rtw_read8(padapter, REG_LEDCFG2);/* 0x4E */ + LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */ - switch (pLed->LedPin) { - case LED_PIN_LED0: - if (pHalData->bLedOpenDrain) { + if (pHalData->bLedOpenDrain) { /* Open-drain arrangement for controlling the LED) */ - LedCfg &= 0x90; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); - LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); - LedCfg &= 0xFE; - rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); - } else { - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); - } - break; - case LED_PIN_LED1: - LedCfg &= 0x0f; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); - break; - default: - break; + LedCfg &= 0x90; /* Set to software control. */ + usb_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG); + LedCfg &= 0xFE; + usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); + } else { + usb_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); } exit: pLed->bLedOn = false; @@ -92,12 +74,13 @@ exit: void rtl8188eu_InitSwLeds(struct adapter *padapter) { struct led_priv *pledpriv = &(padapter->ledpriv); + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); + pledpriv->bRegUseLed = true; pledpriv->LedControlHandler = LedControl8188eu; + haldata->bLedOpenDrain = true; - InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); - - InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1); + InitLed871x(padapter, &(pledpriv->SwLed0)); } /* Description: */ @@ -107,5 +90,4 @@ void rtl8188eu_DeInitSwLeds(struct adapter *padapter) struct led_priv *ledpriv = &(padapter->ledpriv); DeInitLed871x(&(ledpriv->SwLed0)); - DeInitLed871x(&(ledpriv->SwLed1)); } diff --git a/hal/rtl8188eu_recv.c b/hal/rtl8188eu_recv.c index 0f47b89..bc275b2 100644 --- a/hal/rtl8188eu_recv.c +++ b/hal/rtl8188eu_recv.c @@ -22,31 +22,12 @@ #include #include #include -#include -#include -#include -#include +#include #include #include -void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) -{ - precvbuf->transfer_len = 0; - - precvbuf->len = 0; - - precvbuf->ref_cnt = 0; - - if (precvbuf->pbuf) { - precvbuf->pdata = precvbuf->pbuf; - precvbuf->phead = precvbuf->pbuf; - precvbuf->ptail = precvbuf->pbuf; - precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ; - } -} - int rtl8188eu_init_recv_priv(struct adapter *padapter) { struct recv_priv *precvpriv = &padapter->recvpriv; @@ -60,27 +41,24 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) /* init recv_buf */ _rtw_init_queue(&precvpriv->free_recv_buf_queue); - precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); + precvpriv->pallocated_recv_buf = + kzalloc(NR_RECVBUFF * sizeof(struct recv_buf), GFP_KERNEL); if (precvpriv->pallocated_recv_buf == NULL) { res = _FAIL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("alloc recv_buf fail!\n")); goto exit; } - _rtw_memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF * sizeof(struct recv_buf) + 4); - precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_recv_buf), 4); + precvpriv->precv_buf = precvpriv->pallocated_recv_buf; precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - _rtw_init_listhead(&precvbuf->list); - _rtw_spinlock_init(&precvbuf->recvbuf_lock); - precvbuf->alloc_sz = MAX_RECVBUF_SZ; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if (res == _FAIL) break; - precvbuf->ref_cnt = 0; precvbuf->adapter = padapter; precvbuf++; } @@ -89,20 +67,23 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) { int i; size_t tmpaddr = 0; - size_t alignment = 0; + size_t alignm = 0; struct sk_buff *pskb = NULL; skb_queue_head_init(&precvpriv->free_recv_skb_queue); for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) { - pskb = __netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_KERNEL); + pskb = __netdev_alloc_skb(padapter->pnetdev, + MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, + GFP_KERNEL); if (pskb) { pskb->dev = padapter->pnetdev; tmpaddr = (size_t)pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); - skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); + alignm = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignm)); - skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); + skb_queue_tail(&precvpriv->free_recv_skb_queue, + pskb); } pskb = NULL; } @@ -120,7 +101,7 @@ void rtl8188eu_free_recv_priv(struct adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - rtw_os_recvbuf_resource_free(padapter, precvbuf); + usb_free_urb(precvbuf->purb); precvbuf++; } @@ -132,7 +113,8 @@ void rtl8188eu_free_recv_priv(struct adapter *padapter) if (skb_queue_len(&precvpriv->free_recv_skb_queue)) - DBG_88E(KERN_WARNING "free_recv_skb_queue not empty, %d\n", skb_queue_len(&precvpriv->free_recv_skb_queue)); + DBG_88E(KERN_WARNING "free_recv_skb_queue not empty, %d\n", + skb_queue_len(&precvpriv->free_recv_skb_queue)); skb_queue_purge(&precvpriv->free_recv_skb_queue); } diff --git a/hal/rtl8188eu_xmit.c b/hal/rtl8188eu_xmit.c index 8f43f49..594c1da 100644 --- a/hal/rtl8188eu_xmit.c +++ b/hal/rtl8188eu_xmit.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) @@ -35,10 +35,6 @@ s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) return _SUCCESS; } -void rtl8188eu_free_xmit_priv(struct adapter *adapt) -{ -} - static u8 urb_zero_packet_chk(struct adapter *adapt, int sz) { u8 set_tx_desc_offset; @@ -72,7 +68,7 @@ void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u /* Clear all status */ ptxdesc = (struct tx_desc *)desc; - _rtw_memset(desc, 0, TXDESC_SIZE); + memset(desc, 0, TXDESC_SIZE); /* offset 0 */ ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ @@ -196,7 +192,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag } } - _rtw_memset(ptxdesc, 0, sizeof(struct tx_desc)); + memset(ptxdesc, 0, sizeof(struct tx_desc)); /* 4 offset 0 */ ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); @@ -310,9 +306,6 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); } else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) { DBG_88E("pxmitframe->frame_tag == TXAGG_FRAMETAG\n"); - } else if (((pxmitframe->frame_tag&0x0f) == MP_FRAMETAG) && - (adapt->registrypriv.mp_mode == 1)) { - fill_txdesc_for_mp(adapt, ptxdesc); } else { DBG_88E("pxmitframe->frame_tag = %d\n", pxmitframe->frame_tag); @@ -343,7 +336,8 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw4 |= cpu_to_le32(HW_SSN); /* Hw set sequence number */ } - ODM_SetTxAntByTxInfo_88E(&haldata->odmpriv, pmem, pattrib->mac_id); + rtl88eu_dm_set_tx_ant_by_tx_info(&haldata->odmpriv, pmem, + pattrib->mac_id); rtl8188eu_cal_txdesc_chksum(ptxdesc); _dbg_dump_tx_info(adapt, pxmitframe->frame_tag, ptxdesc); @@ -397,7 +391,7 @@ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) } ff_hwaddr = rtw_get_ff_hwaddr(pxmitframe); - inner_ret = rtw_write_port(adapt, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf); + inner_ret = usb_write_port(adapt, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf); rtw_count_tx_stats(adapt, pxmitframe, sz); @@ -405,7 +399,7 @@ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) mem_addr += w_sz; - mem_addr = (u8 *)RND4(((size_t)(mem_addr))); + mem_addr = (u8 *)round_up((size_t)mem_addr, 4); } rtw_free_xmitframe(pxmitpriv, pxmitframe); @@ -445,7 +439,6 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp struct sta_info *psta = NULL; struct tx_servq *ptxservq = NULL; - unsigned long irql; struct list_head *xmitframe_plist = NULL, *xmitframe_phead = NULL; u32 pbuf; /* next pkt address */ @@ -498,7 +491,7 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp pfirstframe = pxmitframe; len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset*PACKET_OFFSET_SZ); pbuf_tail = len; - pbuf = _RND8(pbuf_tail); + pbuf = round_up(pbuf_tail, 8); /* check pkt amount in one bulk */ desc_cnt = 0; @@ -535,26 +528,26 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp phwxmit = pxmitpriv->hwxmits + 2; break; } - _enter_critical_bh(&pxmitpriv->lock, &irql); + spin_lock_bh(&pxmitpriv->lock); xmitframe_phead = get_list_head(&ptxservq->sta_pending); - xmitframe_plist = get_next(xmitframe_phead); + xmitframe_plist = xmitframe_phead->next; - while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); - xmitframe_plist = get_next(xmitframe_plist); + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + xmitframe_plist = xmitframe_plist->next; pxmitframe->agg_num = 0; /* not first frame of aggregation */ pxmitframe->pkt_offset = 0; /* not first frame of aggregation, no need to reserve offset */ len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset*PACKET_OFFSET_SZ); - if (_RND8(pbuf + len) > MAX_XMITBUF_SZ) { + if (round_up(pbuf + len, 8) > MAX_XMITBUF_SZ) { pxmitframe->agg_num = 1; pxmitframe->pkt_offset = 1; break; } - rtw_list_delete(&pxmitframe->list); + list_del_init(&pxmitframe->list); ptxservq->qcnt--; phwxmit->accnt--; @@ -572,7 +565,7 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp /* handle pointer and stop condition */ pbuf_tail = pbuf + len; - pbuf = _RND8(pbuf_tail); + pbuf = round_up(pbuf_tail, 8); pfirstframe->agg_num++; if (MAX_TX_AGG_PACKET_NUMBER == pfirstframe->agg_num) @@ -588,10 +581,10 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp } } /* end while (aggregate same priority and same DA(AP or STA) frames) */ - if (_rtw_queue_empty(&ptxservq->sta_pending) == true) - rtw_list_delete(&ptxservq->tx_pending); + if (list_empty(&ptxservq->sta_pending.queue)) + list_del_init(&ptxservq->tx_pending); - _exit_critical_bh(&pxmitpriv->lock, &irql); + spin_unlock_bh(&pxmitpriv->lock); if ((pfirstframe->attrib.ether_type != 0x0806) && (pfirstframe->attrib.ether_type != 0x888e) && (pfirstframe->attrib.ether_type != 0x88b4) && @@ -609,7 +602,7 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp /* 3 4. write xmit buffer to USB FIFO */ ff_hwaddr = rtw_get_ff_hwaddr(pfirstframe); - rtw_write_port(adapt, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf); + usb_write_port(adapt, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf); /* 3 5. update statisitc */ pbuf_tail -= (pfirstframe->agg_num * TXDESC_SIZE); @@ -641,14 +634,13 @@ static s32 xmitframe_direct(struct adapter *adapt, struct xmit_frame *pxmitframe */ static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) { - unsigned long irql; s32 res; struct xmit_buf *pxmitbuf = NULL; struct xmit_priv *pxmitpriv = &adapt->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct mlme_priv *pmlmepriv = &adapt->mlmepriv; - _enter_critical_bh(&pxmitpriv->lock, &irql); + spin_lock_bh(&pxmitpriv->lock); if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) goto enqueue; @@ -660,7 +652,7 @@ static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) if (pxmitbuf == NULL) goto enqueue; - _exit_critical_bh(&pxmitpriv->lock, &irql); + spin_unlock_bh(&pxmitpriv->lock); pxmitframe->pxmitbuf = pxmitbuf; pxmitframe->buf_addr = pxmitbuf->pbuf; @@ -675,7 +667,7 @@ static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) enqueue: res = rtw_xmitframe_enqueue(adapt, pxmitframe); - _exit_critical_bh(&pxmitpriv->lock, &irql); + spin_unlock_bh(&pxmitpriv->lock); if (res != _SUCCESS) { RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("pre_xmitframe: enqueue xmitframe fail\n")); diff --git a/hal/usb_halinit.c b/hal/usb_halinit.c index cca9732..14650e9 100644 --- a/hal/usb_halinit.c +++ b/hal/usb_halinit.c @@ -22,17 +22,14 @@ #include #include #include - +#include #include #include #include -#include #include -#include +#include -#define HAL_MAC_ENABLE 1 #define HAL_BB_ENABLE 1 -#define HAL_RF_ENABLE 1 static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe) { @@ -110,22 +107,24 @@ static u32 rtl8188eu_InitPowerOn(struct adapter *adapt) if (haldata->bMacPwrCtrlOn) return _SUCCESS; - if (!HalPwrSeqCmdParsing(adapt, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_PWR_ON_FLOW)) { + if (!rtl88eu_pwrseqcmdparsing(adapt, PWR_CUT_ALL_MSK, + PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, + Rtl8188E_NIC_PWR_ON_FLOW)) { DBG_88E(KERN_ERR "%s: run power on flow fail\n", __func__); return _FAIL; } /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ - rtw_write16(adapt, REG_CR, 0x00); /* suggseted by zhouzhou, by page, 20111230 */ + usb_write16(adapt, REG_CR, 0x00); /* suggseted by zhouzhou, by page, 20111230 */ /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ - value16 = rtw_read16(adapt, REG_CR); + value16 = usb_read16(adapt, REG_CR); value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN); /* for SDIO - Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ - rtw_write16(adapt, REG_CR, value16); + usb_write16(adapt, REG_CR, value16); haldata->bMacPwrCtrlOn = true; return _SUCCESS; @@ -139,27 +138,27 @@ static void _InitInterrupt(struct adapter *Adapter) struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); /* HISR write one to clear */ - rtw_write32(Adapter, REG_HISR_88E, 0xFFFFFFFF); + usb_write32(Adapter, REG_HISR_88E, 0xFFFFFFFF); /* HIMR - */ imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E; - rtw_write32(Adapter, REG_HIMR_88E, imr); + usb_write32(Adapter, REG_HIMR_88E, imr); haldata->IntrMask[0] = imr; imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E | IMR_RXFOVW_88E; - rtw_write32(Adapter, REG_HIMRE_88E, imr_ex); + usb_write32(Adapter, REG_HIMRE_88E, imr_ex); haldata->IntrMask[1] = imr_ex; /* REG_USB_SPECIAL_OPTION - BIT(4) */ /* 0; Use interrupt endpoint to upload interrupt pkt */ /* 1; Use bulk endpoint to upload interrupt pkt, */ - usb_opt = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); + usb_opt = usb_read8(Adapter, REG_USB_SPECIAL_OPTION); if (!adapter_to_dvobj(Adapter)->ishighspeed) usb_opt = usb_opt & (~INT_BULK_SEL); else usb_opt = usb_opt | (INT_BULK_SEL); - rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt); + usb_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt); } static void _InitQueueReservedPage(struct adapter *Adapter) @@ -185,27 +184,27 @@ static void _InitQueueReservedPage(struct adapter *Adapter) if (haldata->OutEpQueueSel & TX_SELE_NQ) numNQ = 0x1C; value8 = (u8)_NPQ(numNQ); - rtw_write8(Adapter, REG_RQPN_NPQ, value8); + usb_write8(Adapter, REG_RQPN_NPQ, value8); numPubQ = 0xA8 - numHQ - numLQ - numNQ; /* TX DMA */ value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; - rtw_write32(Adapter, REG_RQPN, value32); + usb_write32(Adapter, REG_RQPN, value32); } else { - rtw_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ - rtw_write16(Adapter, REG_RQPN_NPQ, 0x0d); - rtw_write32(Adapter, REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */ + usb_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ + usb_write16(Adapter, REG_RQPN_NPQ, 0x0d); + usb_write32(Adapter, REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */ } } static void _InitTxBufferBoundary(struct adapter *Adapter, u8 txpktbuf_bndy) { - rtw_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); - rtw_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); - rtw_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); - rtw_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); - rtw_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); + usb_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); + usb_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); + usb_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); + usb_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); + usb_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); } static void _InitPageBoundary(struct adapter *Adapter) @@ -214,20 +213,20 @@ static void _InitPageBoundary(struct adapter *Adapter) /* */ u16 rxff_bndy = MAX_RX_DMA_BUFFER_SIZE_88E-1; - rtw_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); + usb_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); } static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ, u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ, u16 hiQ) { - u16 value16 = (rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); + u16 value16 = (usb_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | _TXDMA_MGQ_MAP(mgtQ) | _TXDMA_HIQ_MAP(hiQ); - rtw_write16(Adapter, REG_TRXDMA_CTRL, value16); + usb_write16(Adapter, REG_TRXDMA_CTRL, value16); } static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter) @@ -341,11 +340,11 @@ static void _InitNetworkType(struct adapter *Adapter) { u32 value32; - value32 = rtw_read32(Adapter, REG_CR); + value32 = usb_read32(Adapter, REG_CR); /* TODO: use the other function to set network type */ value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP); - rtw_write32(Adapter, REG_CR, value32); + usb_write32(Adapter, REG_CR, value32); } static void _InitTransferPageSize(struct adapter *Adapter) @@ -354,12 +353,12 @@ static void _InitTransferPageSize(struct adapter *Adapter) u8 value8; value8 = _PSRX(PBP_128) | _PSTX(PBP_128); - rtw_write8(Adapter, REG_PBP, value8); + usb_write8(Adapter, REG_PBP, value8); } static void _InitDriverInfoSize(struct adapter *Adapter, u8 drvInfoSize) { - rtw_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); + usb_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); } static void _InitWMACSetting(struct adapter *Adapter) @@ -372,11 +371,11 @@ static void _InitWMACSetting(struct adapter *Adapter) RCR_APP_MIC | RCR_APP_PHYSTS; /* some REG_RCR will be modified later by phy_ConfigMACWithHeaderFile() */ - rtw_write32(Adapter, REG_RCR, haldata->ReceiveConfig); + usb_write32(Adapter, REG_RCR, haldata->ReceiveConfig); /* Accept all multicast address */ - rtw_write32(Adapter, REG_MAR, 0xFFFFFFFF); - rtw_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); + usb_write32(Adapter, REG_MAR, 0xFFFFFFFF); + usb_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); } static void _InitAdaptiveCtrl(struct adapter *Adapter) @@ -385,80 +384,64 @@ static void _InitAdaptiveCtrl(struct adapter *Adapter) u32 value32; /* Response Rate Set */ - value32 = rtw_read32(Adapter, REG_RRSR); + value32 = usb_read32(Adapter, REG_RRSR); value32 &= ~RATE_BITMAP_ALL; value32 |= RATE_RRSR_CCK_ONLY_1M; - rtw_write32(Adapter, REG_RRSR, value32); + usb_write32(Adapter, REG_RRSR, value32); /* CF-END Threshold */ /* SIFS (used in NAV) */ value16 = _SPEC_SIFS_CCK(0x10) | _SPEC_SIFS_OFDM(0x10); - rtw_write16(Adapter, REG_SPEC_SIFS, value16); + usb_write16(Adapter, REG_SPEC_SIFS, value16); /* Retry Limit */ value16 = _LRL(0x30) | _SRL(0x30); - rtw_write16(Adapter, REG_RL, value16); + usb_write16(Adapter, REG_RL, value16); } static void _InitEDCA(struct adapter *Adapter) { /* Set Spec SIFS (used in NAV) */ - rtw_write16(Adapter, REG_SPEC_SIFS, 0x100a); - rtw_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); + usb_write16(Adapter, REG_SPEC_SIFS, 0x100a); + usb_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); /* Set SIFS for CCK */ - rtw_write16(Adapter, REG_SIFS_CTX, 0x100a); + usb_write16(Adapter, REG_SIFS_CTX, 0x100a); /* Set SIFS for OFDM */ - rtw_write16(Adapter, REG_SIFS_TRX, 0x100a); + usb_write16(Adapter, REG_SIFS_TRX, 0x100a); /* TXOP */ - rtw_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); - rtw_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F); - rtw_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324); - rtw_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); -} - -static void _InitBeaconMaxError(struct adapter *Adapter, bool InfraMode) -{ -} - -static void _InitHWLed(struct adapter *Adapter) -{ - struct led_priv *pledpriv = &(Adapter->ledpriv); - - if (pledpriv->LedStrategy != HW_LED) - return; - -/* HW led control */ -/* to do .... */ -/* must consider cases of antenna diversity/ commbo card/solo card/mini card */ + usb_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); + usb_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F); + usb_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324); + usb_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); } static void _InitRDGSetting(struct adapter *Adapter) { - rtw_write8(Adapter, REG_RD_CTRL, 0xFF); - rtw_write16(Adapter, REG_RD_NAV_NXT, 0x200); - rtw_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); + usb_write8(Adapter, REG_RD_CTRL, 0xFF); + usb_write16(Adapter, REG_RD_NAV_NXT, 0x200); + usb_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); } static void _InitRxSetting(struct adapter *Adapter) { - rtw_write32(Adapter, REG_MACID, 0x87654321); - rtw_write32(Adapter, 0x0700, 0x87654321); + usb_write32(Adapter, REG_MACID, 0x87654321); + usb_write32(Adapter, 0x0700, 0x87654321); } static void _InitRetryFunction(struct adapter *Adapter) { u8 value8; - value8 = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL); + value8 = usb_read8(Adapter, REG_FWHW_TXQ_CTRL); value8 |= EN_AMPDU_RTY_NEW; - rtw_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); + usb_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); /* Set ACK timeout */ - rtw_write8(Adapter, REG_ACKTO, 0x40); + usb_write8(Adapter, REG_ACKTO, 0x40); } /*----------------------------------------------------------------------------- @@ -485,11 +468,11 @@ static void usb_AggSettingTxUpdate(struct adapter *Adapter) haldata->UsbTxAggMode = false; if (haldata->UsbTxAggMode) { - value32 = rtw_read32(Adapter, REG_TDECTRL); + value32 = usb_read32(Adapter, REG_TDECTRL); value32 = value32 & ~(BLK_DESC_NUM_MASK << BLK_DESC_NUM_SHIFT); value32 |= ((haldata->UsbTxAggDescNum & BLK_DESC_NUM_MASK) << BLK_DESC_NUM_SHIFT); - rtw_write32(Adapter, REG_TDECTRL, value32); + usb_write32(Adapter, REG_TDECTRL, value32); } } /* usb_AggSettingTxUpdate */ @@ -517,8 +500,8 @@ usb_AggSettingRxUpdate( u8 valueDMA; u8 valueUSB; - valueDMA = rtw_read8(Adapter, REG_TRXDMA_CTRL); - valueUSB = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); + valueDMA = usb_read8(Adapter, REG_TRXDMA_CTRL); + valueUSB = usb_read8(Adapter, REG_USB_SPECIAL_OPTION); switch (haldata->UsbRxAggMode) { case USB_RX_AGG_DMA: @@ -540,23 +523,23 @@ usb_AggSettingRxUpdate( break; } - rtw_write8(Adapter, REG_TRXDMA_CTRL, valueDMA); - rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, valueUSB); + usb_write8(Adapter, REG_TRXDMA_CTRL, valueDMA); + usb_write8(Adapter, REG_USB_SPECIAL_OPTION, valueUSB); switch (haldata->UsbRxAggMode) { case USB_RX_AGG_DMA: - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, haldata->UsbRxAggPageTimeout); + usb_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + usb_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, haldata->UsbRxAggPageTimeout); break; case USB_RX_AGG_USB: - rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); - rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + usb_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + usb_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); break; case USB_RX_AGG_MIX: - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ - rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); - rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + usb_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + usb_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ + usb_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + usb_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); break; case USB_RX_AGG_DISABLE: default: @@ -599,45 +582,41 @@ static void InitUsbAggregationSetting(struct adapter *Adapter) haldata->UsbRxHighSpeedMode = false; } -static void _InitOperationMode(struct adapter *Adapter) -{ -} - static void _InitBeaconParameters(struct adapter *Adapter) { struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - rtw_write16(Adapter, REG_BCN_CTRL, 0x1010); + usb_write16(Adapter, REG_BCN_CTRL, 0x1010); /* TODO: Remove these magic number */ - rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0x6404);/* ms */ - rtw_write8(Adapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME);/* 5ms */ - rtw_write8(Adapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /* 2ms */ + usb_write16(Adapter, REG_TBTT_PROHIBIT, 0x6404);/* ms */ + usb_write8(Adapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME);/* 5ms */ + usb_write8(Adapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /* 2ms */ /* Suggested by designer timchen. Change beacon AIFS to the largest number */ /* beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ - rtw_write16(Adapter, REG_BCNTCFG, 0x660F); + usb_write16(Adapter, REG_BCNTCFG, 0x660F); - haldata->RegBcnCtrlVal = rtw_read8(Adapter, REG_BCN_CTRL); - haldata->RegTxPause = rtw_read8(Adapter, REG_TXPAUSE); - haldata->RegFwHwTxQCtrl = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL+2); - haldata->RegReg542 = rtw_read8(Adapter, REG_TBTT_PROHIBIT+2); - haldata->RegCR_1 = rtw_read8(Adapter, REG_CR+1); + haldata->RegBcnCtrlVal = usb_read8(Adapter, REG_BCN_CTRL); + haldata->RegTxPause = usb_read8(Adapter, REG_TXPAUSE); + haldata->RegFwHwTxQCtrl = usb_read8(Adapter, REG_FWHW_TXQ_CTRL+2); + haldata->RegReg542 = usb_read8(Adapter, REG_TBTT_PROHIBIT+2); + haldata->RegCR_1 = usb_read8(Adapter, REG_CR+1); } static void _BeaconFunctionEnable(struct adapter *Adapter, bool Enable, bool Linked) { - rtw_write8(Adapter, REG_BCN_CTRL, (BIT4 | BIT3 | BIT1)); + usb_write8(Adapter, REG_BCN_CTRL, (BIT4 | BIT3 | BIT1)); - rtw_write8(Adapter, REG_RD_CTRL+1, 0x6F); + usb_write8(Adapter, REG_RD_CTRL+1, 0x6F); } /* Set CCK and OFDM Block "ON" */ static void _BBTurnOnBlock(struct adapter *Adapter) { - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bCCKEn, 0x1); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bOFDMEn, 0x1); + phy_set_bb_reg(Adapter, rFPGA0_RFMOD, bCCKEn, 0x1); + phy_set_bb_reg(Adapter, rFPGA0_RFMOD, bOFDMEn, 0x1); } enum { @@ -653,10 +632,10 @@ static void _InitAntenna_Selection(struct adapter *Adapter) return; DBG_88E("==> %s ....\n", __func__); - rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0)|BIT23); - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT13, 0x01); + usb_write32(Adapter, REG_LEDCFG0, usb_read32(Adapter, REG_LEDCFG0)|BIT23); + phy_set_bb_reg(Adapter, rFPGA0_XAB_RFParameter, BIT13, 0x01); - if (PHY_QueryBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) + if (phy_query_bb_reg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) haldata->CurAntenna = Antenna_A; else haldata->CurAntenna = Antenna_B; @@ -684,12 +663,12 @@ enum rt_rf_power_state RfOnOffDetect(struct adapter *adapt) enum rt_rf_power_state rfpowerstate = rf_off; if (adapt->pwrctrlpriv.bHWPowerdown) { - val8 = rtw_read8(adapt, REG_HSISR); + val8 = usb_read8(adapt, REG_HSISR); DBG_88E("pwrdown, 0x5c(BIT7)=%02x\n", val8); rfpowerstate = (val8 & BIT7) ? rf_off : rf_on; } else { /* rf on/off */ - rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT3)); - val8 = rtw_read8(adapt, REG_GPIO_IO_SEL); + usb_write8(adapt, REG_MAC_PINMUX_CFG, usb_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT3)); + val8 = usb_read8(adapt, REG_GPIO_IO_SEL); DBG_88E("GPIO_IN=%02x\n", val8); rfpowerstate = (val8 & BIT3) ? rf_on : rf_off; } @@ -705,26 +684,24 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u32 init_start_time = rtw_get_current_time(); + u32 init_start_time = jiffies; #define HAL_INIT_PROFILE_TAG(stage) do {} while (0) -_func_enter_; HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BEGIN); if (Adapter->pwrctrlpriv.bkeepfwalive) { - _ps_open_RF(Adapter); if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { - PHY_IQCalibrate_8188E(Adapter, true); + rtl88eu_phy_iq_calibrate(Adapter, true); } else { - PHY_IQCalibrate_8188E(Adapter, false); + rtl88eu_phy_iq_calibrate(Adapter, false); haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; } ODM_TXPowerTrackingCheck(&haldata->odmpriv); - PHY_LCCalibrate_8188E(Adapter); + rtl88eu_phy_lc_calibrate(Adapter); goto exit; } @@ -768,9 +745,9 @@ _func_enter_; Adapter->bFWReady = false; haldata->fw_ractrl = false; } else { - status = rtl8188e_FirmwareDownload(Adapter); + status = rtl88eu_download_fw(Adapter); - if (status != _SUCCESS) { + if (status) { DBG_88E("%s: Download Firmware failed!!\n", __func__); Adapter->bFWReady = false; haldata->fw_ractrl = false; @@ -783,35 +760,11 @@ _func_enter_; } rtl8188e_InitializeFirmwareVars(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MAC); -#if (HAL_MAC_ENABLE == 1) - status = PHY_MACConfig8188E(Adapter); - if (status == _FAIL) { - DBG_88E(" ### Failed to init MAC ......\n "); - goto exit; - } -#endif + rtl88eu_phy_mac_config(Adapter); - /* */ - /* d. Initialize BB related configurations. */ - /* */ - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BB); -#if (HAL_BB_ENABLE == 1) - status = PHY_BBConfig8188E(Adapter); - if (status == _FAIL) { - DBG_88E(" ### Failed to init BB ......\n "); - goto exit; - } -#endif + rtl88eu_phy_bb_config(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_RF); -#if (HAL_RF_ENABLE == 1) - status = PHY_RFConfig8188E(Adapter); - if (status == _FAIL) { - DBG_88E(" ### Failed to init RF ......\n "); - goto exit; - } -#endif + rtl88eu_phy_rf_config(Adapter); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_EFUSE_PATCH); status = rtl8188e_iol_efuse_patch(Adapter); @@ -841,41 +794,34 @@ _func_enter_; _InitEDCA(Adapter); _InitRetryFunction(Adapter); InitUsbAggregationSetting(Adapter); - _InitOperationMode(Adapter);/* todo */ _InitBeaconParameters(Adapter); - _InitBeaconMaxError(Adapter, true); - - /* */ /* Init CR MACTXEN, MACRXEN after setting RxFF boundary REG_TRXFF_BNDY to patch */ /* Hw bug which Hw initials RxFF boundary size to a value which is larger than the real Rx buffer size in 88E. */ - /* */ /* Enable MACTXEN/MACRXEN block */ - value16 = rtw_read16(Adapter, REG_CR); + value16 = usb_read16(Adapter, REG_CR); value16 |= (MACTXEN | MACRXEN); - rtw_write8(Adapter, REG_CR, value16); + usb_write8(Adapter, REG_CR, value16); if (haldata->bRDGEnable) _InitRDGSetting(Adapter); /* Enable TX Report */ /* Enable Tx Report Timer */ - value8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); - rtw_write8(Adapter, REG_TX_RPT_CTRL, (value8|BIT1|BIT0)); + value8 = usb_read8(Adapter, REG_TX_RPT_CTRL); + usb_write8(Adapter, REG_TX_RPT_CTRL, (value8|BIT1|BIT0)); /* Set MAX RPT MACID */ - rtw_write8(Adapter, REG_TX_RPT_CTRL+1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ + usb_write8(Adapter, REG_TX_RPT_CTRL+1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ /* Tx RPT Timer. Unit: 32us */ - rtw_write16(Adapter, REG_TX_RPT_TIME, 0xCdf0); + usb_write16(Adapter, REG_TX_RPT_TIME, 0xCdf0); - rtw_write8(Adapter, REG_EARLY_MODE_CONTROL, 0); + usb_write8(Adapter, REG_EARLY_MODE_CONTROL, 0); - rtw_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ - rtw_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ - - _InitHWLed(Adapter); + usb_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ + usb_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ /* Keep RfRegChnlVal for later use. */ - haldata->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); - haldata->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); + haldata->RfRegChnlVal[0] = phy_query_rf_reg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); + haldata->RfRegChnlVal[1] = phy_query_rf_reg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_TURN_ON_BLOCK); _BBTurnOnBlock(Adapter); @@ -885,7 +831,7 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_SECURITY); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); /* 2010/12/17 MH We need to set TX power according to EFUSE content at first. */ - PHY_SetTxPowerLevel8188E(Adapter, haldata->CurrentChannel); + phy_set_tx_power_level(Adapter, haldata->CurrentChannel); /* Move by Neo for USB SS to below setp */ /* _RfPowerSave(Adapter); */ @@ -896,94 +842,76 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); /* Disable BAR, suggested by Scott */ /* 2010.04.09 add by hpfan */ /* */ - rtw_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff); + usb_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff); /* HW SEQ CTRL */ /* set 0x0 to 0xFF by tynli. Default enable HW SEQ NUM. */ - rtw_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); + usb_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); if (pregistrypriv->wifi_spec) - rtw_write16(Adapter, REG_FAST_EDCA_CTRL, 0); + usb_write16(Adapter, REG_FAST_EDCA_CTRL, 0); /* Nav limit , suggest by scott */ - rtw_write8(Adapter, 0x652, 0x0); + usb_write8(Adapter, 0x652, 0x0); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); rtl8188e_InitHalDm(Adapter); - if (Adapter->registrypriv.mp_mode == 1) { - Adapter->mppriv.channel = haldata->CurrentChannel; - MPT_InitializeAdapter(Adapter, Adapter->mppriv.channel); - } else { - /* 2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */ - /* and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */ - /* call initstruct adapter. May cause some problem?? */ - /* Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */ - /* in MgntActSet_RF_State() after wake up, because the value of haldata->eRFPowerState */ - /* is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */ - /* Added by tynli. 2010.03.30. */ - pwrctrlpriv->rf_pwrstate = rf_on; + /* 2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */ + /* and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */ + /* call initstruct adapter. May cause some problem?? */ + /* Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */ + /* in MgntActSet_RF_State() after wake up, because the value of haldata->eRFPowerState */ + /* is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */ + /* Added by tynli. 2010.03.30. */ + pwrctrlpriv->rf_pwrstate = rf_on; - /* enable Tx report. */ - rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+1, 0x0F); + /* enable Tx report. */ + usb_write8(Adapter, REG_FWHW_TXQ_CTRL+1, 0x0F); - /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ - rtw_write8(Adapter, REG_EARLY_MODE_CONTROL+3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ + /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ + usb_write8(Adapter, REG_EARLY_MODE_CONTROL+3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ - /* tynli_test_tx_report. */ - rtw_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); + /* tynli_test_tx_report. */ + usb_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); - /* enable tx DMA to drop the redundate data of packet */ - rtw_write16(Adapter, REG_TXDMA_OFFSET_CHK, (rtw_read16(Adapter, REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); + /* enable tx DMA to drop the redundate data of packet */ + usb_write16(Adapter, REG_TXDMA_OFFSET_CHK, (usb_read16(Adapter, REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); /* 2010/08/26 MH Merge from 8192CE. */ - if (pwrctrlpriv->rf_pwrstate == rf_on) { - if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { - PHY_IQCalibrate_8188E(Adapter, true); - } else { - PHY_IQCalibrate_8188E(Adapter, false); - haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; - } + if (pwrctrlpriv->rf_pwrstate == rf_on) { + if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { + rtl88eu_phy_iq_calibrate(Adapter, true); + } else { + rtl88eu_phy_iq_calibrate(Adapter, false); + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + } HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_PW_TRACK); - ODM_TXPowerTrackingCheck(&haldata->odmpriv); + ODM_TXPowerTrackingCheck(&haldata->odmpriv); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); - PHY_LCCalibrate_8188E(Adapter); - } + rtl88eu_phy_lc_calibrate(Adapter); } /* HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PABIAS); */ /* _InitPABias(Adapter); */ - rtw_write8(Adapter, REG_USB_HRPWM, 0); + usb_write8(Adapter, REG_USB_HRPWM, 0); /* ack for xmit mgmt frames. */ - rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, rtw_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); + usb_write32(Adapter, REG_FWHW_TXQ_CTRL, usb_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); exit: HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); DBG_88E("%s in %dms\n", __func__, rtw_get_passing_time_ms(init_start_time)); -_func_exit_; return status; } -void _ps_open_RF(struct adapter *adapt) -{ - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ - /* phy_SsPwrSwitch92CU(adapt, rf_on, 1); */ -} - -static void _ps_close_RF(struct adapter *adapt) -{ - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ - /* phy_SsPwrSwitch92CU(adapt, rf_off, 1); */ -} - static void CardDisableRTL8188EU(struct adapter *Adapter) { u8 val8; @@ -992,52 +920,56 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("CardDisableRTL8188EU\n")); /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */ - val8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); - rtw_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT1)); + val8 = usb_read8(Adapter, REG_TX_RPT_CTRL); + usb_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT1)); /* stop rx */ - rtw_write8(Adapter, REG_CR, 0x0); + usb_write8(Adapter, REG_CR, 0x0); /* Run LPS WL RFOFF flow */ - HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_LPS_ENTER_FLOW); + rtl88eu_pwrseqcmdparsing(Adapter, PWR_CUT_ALL_MSK, + PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, + Rtl8188E_NIC_LPS_ENTER_FLOW); /* 2. 0x1F[7:0] = 0 turn off RF */ - val8 = rtw_read8(Adapter, REG_MCUFWDL); + val8 = usb_read8(Adapter, REG_MCUFWDL); if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) { /* 8051 RAM code */ /* Reset MCU 0x2[10]=0. */ - val8 = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); + val8 = usb_read8(Adapter, REG_SYS_FUNC_EN+1); val8 &= ~BIT(2); /* 0x2[10], FEN_CPUEN */ - rtw_write8(Adapter, REG_SYS_FUNC_EN+1, val8); + usb_write8(Adapter, REG_SYS_FUNC_EN+1, val8); } /* reset MCU ready status */ - rtw_write8(Adapter, REG_MCUFWDL, 0); + usb_write8(Adapter, REG_MCUFWDL, 0); /* YJ,add,111212 */ /* Disable 32k */ - val8 = rtw_read8(Adapter, REG_32K_CTRL); - rtw_write8(Adapter, REG_32K_CTRL, val8&(~BIT0)); + val8 = usb_read8(Adapter, REG_32K_CTRL); + usb_write8(Adapter, REG_32K_CTRL, val8&(~BIT0)); /* Card disable power action flow */ - HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_DISABLE_FLOW); + rtl88eu_pwrseqcmdparsing(Adapter, PWR_CUT_ALL_MSK, + PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, + Rtl8188E_NIC_DISABLE_FLOW); /* Reset MCU IO Wrapper */ - val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); - rtw_write8(Adapter, REG_RSV_CTRL+1, (val8&(~BIT3))); - val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); - rtw_write8(Adapter, REG_RSV_CTRL+1, val8|BIT3); + val8 = usb_read8(Adapter, REG_RSV_CTRL+1); + usb_write8(Adapter, REG_RSV_CTRL+1, (val8&(~BIT3))); + val8 = usb_read8(Adapter, REG_RSV_CTRL+1); + usb_write8(Adapter, REG_RSV_CTRL+1, val8|BIT3); /* YJ,test add, 111207. For Power Consumption. */ - val8 = rtw_read8(Adapter, GPIO_IN); - rtw_write8(Adapter, GPIO_OUT, val8); - rtw_write8(Adapter, GPIO_IO_SEL, 0xFF);/* Reg0x46 */ + val8 = usb_read8(Adapter, GPIO_IN); + usb_write8(Adapter, GPIO_OUT, val8); + usb_write8(Adapter, GPIO_IO_SEL, 0xFF);/* Reg0x46 */ - val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL); - rtw_write8(Adapter, REG_GPIO_IO_SEL, (val8<<4)); - val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL+1); - rtw_write8(Adapter, REG_GPIO_IO_SEL+1, val8|0x0F);/* Reg0x43 */ - rtw_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */ + val8 = usb_read8(Adapter, REG_GPIO_IO_SEL); + usb_write8(Adapter, REG_GPIO_IO_SEL, (val8<<4)); + val8 = usb_read8(Adapter, REG_GPIO_IO_SEL+1); + usb_write8(Adapter, REG_GPIO_IO_SEL+1, val8|0x0F);/* Reg0x43 */ + usb_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */ haldata->bMacPwrCtrlOn = false; Adapter->bFWReady = false; } @@ -1047,8 +979,8 @@ static void rtl8192cu_hw_power_down(struct adapter *adapt) /* Then enable power down control bit of register 0x04 BIT4 and BIT15 as 1. */ /* Enable register area 0x0-0xc. */ - rtw_write8(adapt, REG_RSV_CTRL, 0x0); - rtw_write16(adapt, REG_APS_FSMCO, 0x8812); + usb_write8(adapt, REG_RSV_CTRL, 0x0); + usb_write16(adapt, REG_APS_FSMCO, 0x8812); } static u32 rtl8188eu_hal_deinit(struct adapter *Adapter) @@ -1056,12 +988,11 @@ static u32 rtl8188eu_hal_deinit(struct adapter *Adapter) DBG_88E("==> %s\n", __func__); - rtw_write32(Adapter, REG_HIMR_88E, IMR_DISABLED_88E); - rtw_write32(Adapter, REG_HIMRE_88E, IMR_DISABLED_88E); + usb_write32(Adapter, REG_HIMR_88E, IMR_DISABLED_88E); + usb_write32(Adapter, REG_HIMRE_88E, IMR_DISABLED_88E); DBG_88E("bkeepfwalive(%x)\n", Adapter->pwrctrlpriv.bkeepfwalive); if (Adapter->pwrctrlpriv.bkeepfwalive) { - _ps_close_RF(Adapter); if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) rtl8192cu_hw_power_down(Adapter); } else { @@ -1080,13 +1011,7 @@ static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) u8 i; struct recv_buf *precvbuf; uint status; - struct intf_hdl *pintfhdl = &Adapter->iopriv.intf; struct recv_priv *precvpriv = &(Adapter->recvpriv); - u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - -_func_enter_; - - _read_port = pintfhdl->io_ops._read_port; status = _SUCCESS; @@ -1098,7 +1023,7 @@ _func_enter_; /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false) { + if (usb_read_port(Adapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); status = _FAIL; goto exit; @@ -1112,7 +1037,6 @@ exit: RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); -_func_exit_; return status; } @@ -1121,7 +1045,7 @@ static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) { RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); - rtw_read_port_cancel(Adapter); + usb_read_port_cancel(Adapter); RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n <=== usb_rx_deinit\n")); @@ -1133,16 +1057,6 @@ static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) /* EEPROM/EFUSE Content Parsing */ /* */ /* */ -static void _ReadLEDSetting(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) -{ - struct led_priv *pledpriv = &(Adapter->ledpriv); - struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - - pledpriv->bRegUseLed = true; - pledpriv->LedStrategy = SW_LED_MODE1; - haldata->bLedOpenDrain = true;/* Support Open-drain arrangement for controlling the LED. */ -} - static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) { struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); @@ -1188,10 +1102,6 @@ static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool eeprom->mac_addr[4], eeprom->mac_addr[5])); } -static void Hal_CustomizeByCustomerID_8188EU(struct adapter *adapt) -{ -} - static void readAdapterInfo_8188EU( struct adapter *adapt @@ -1214,13 +1124,6 @@ readAdapterInfo_8188EU( Hal_EfuseParseBoardType88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); Hal_ReadThermalMeter_88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - /* */ - /* The following part initialize some vars by PG info. */ - /* */ - Hal_InitChannelPlan(adapt); - Hal_CustomizeByCustomerID_8188EU(adapt); - - _ReadLEDSetting(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); } static void _ReadPROMContent( @@ -1231,7 +1134,7 @@ static void _ReadPROMContent( u8 eeValue; /* check system boot selection */ - eeValue = rtw_read8(Adapter, REG_9346CR); + eeValue = usb_read8(Adapter, REG_9346CR); eeprom->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; @@ -1249,9 +1152,9 @@ static void _ReadRFType(struct adapter *Adapter) haldata->rf_chip = RF_6052; } -static int _ReadAdapterInfo8188EU(struct adapter *Adapter) +static void _ReadAdapterInfo8188EU(struct adapter *Adapter) { - u32 start = rtw_get_current_time(); + u32 start = jiffies; MSG_88E("====> %s\n", __func__); @@ -1259,16 +1162,6 @@ static int _ReadAdapterInfo8188EU(struct adapter *Adapter) _ReadPROMContent(Adapter); MSG_88E("<==== %s in %d ms\n", __func__, rtw_get_passing_time_ms(start)); - - return _SUCCESS; -} - -static void ReadAdapterInfo8188EU(struct adapter *Adapter) -{ - /* Read EEPROM size before call any EEPROM function */ - Adapter->EepromAddressSize = GetEEPROMSize8188E(Adapter); - - _ReadAdapterInfo8188EU(Adapter); } #define GPIO_DEBUG_PORT_NUM 0 @@ -1283,11 +1176,11 @@ static void ResumeTxBeacon(struct adapter *adapt) /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT6); + usb_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT6); haldata->RegFwHwTxQCtrl |= BIT6; - rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0xff); + usb_write8(adapt, REG_TBTT_PROHIBIT+1, 0xff); haldata->RegReg542 |= BIT0; - rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); + usb_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); } static void StopTxBeacon(struct adapter *adapt) @@ -1297,11 +1190,11 @@ static void StopTxBeacon(struct adapter *adapt) /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT6)); + usb_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT6)); haldata->RegFwHwTxQCtrl &= (~BIT6); - rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0x64); + usb_write8(adapt, REG_TBTT_PROHIBIT+1, 0x64); haldata->RegReg542 &= ~(BIT0); - rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); + usb_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); /* todo: CheckFwRsvdPageContent(Adapter); 2010.06.23. Added by tynli. */ } @@ -1312,54 +1205,54 @@ static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) u8 mode = *((u8 *)val); /* disable Port0 TSF update */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)|BIT(4)); /* set net_type */ - val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 = usb_read8(Adapter, MSR)&0x0c; val8 |= mode; - rtw_write8(Adapter, MSR, val8); + usb_write8(Adapter, MSR, val8); DBG_88E("%s()-%d mode = %d\n", __func__, __LINE__, mode); if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) { StopTxBeacon(Adapter); - rtw_write8(Adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */ + usb_write8(Adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */ } else if ((mode == _HW_STATE_ADHOC_)) { ResumeTxBeacon(Adapter); - rtw_write8(Adapter, REG_BCN_CTRL, 0x1a); + usb_write8(Adapter, REG_BCN_CTRL, 0x1a); } else if (mode == _HW_STATE_AP_) { ResumeTxBeacon(Adapter); - rtw_write8(Adapter, REG_BCN_CTRL, 0x12); + usb_write8(Adapter, REG_BCN_CTRL, 0x12); /* Set RCR */ - rtw_write32(Adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */ + usb_write32(Adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */ /* enable to rx data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); /* enable to rx ps-poll */ - rtw_write16(Adapter, REG_RXFLTMAP1, 0x0400); + usb_write16(Adapter, REG_RXFLTMAP1, 0x0400); /* Beacon Control related register for first time */ - rtw_write8(Adapter, REG_BCNDMATIM, 0x02); /* 2ms */ + usb_write8(Adapter, REG_BCNDMATIM, 0x02); /* 2ms */ - rtw_write8(Adapter, REG_ATIMWND, 0x0a); /* 10ms */ - rtw_write16(Adapter, REG_BCNTCFG, 0x00); - rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0xff04); - rtw_write16(Adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/* +32767 (~32ms) */ + usb_write8(Adapter, REG_ATIMWND, 0x0a); /* 10ms */ + usb_write16(Adapter, REG_BCNTCFG, 0x00); + usb_write16(Adapter, REG_TBTT_PROHIBIT, 0xff04); + usb_write16(Adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/* +32767 (~32ms) */ /* reset TSF */ - rtw_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); + usb_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); /* BIT3 - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ - rtw_write8(Adapter, REG_MBID_NUM, rtw_read8(Adapter, REG_MBID_NUM) | BIT(3) | BIT(4)); + usb_write8(Adapter, REG_MBID_NUM, usb_read8(Adapter, REG_MBID_NUM) | BIT(3) | BIT(4)); /* enable BCN0 Function for if1 */ /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */ - rtw_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP|EN_BCN_FUNCTION | BIT(1))); + usb_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP|EN_BCN_FUNCTION | BIT(1))); /* dis BCN1 ATIM WND if if2 is station */ - rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1) | BIT(0)); + usb_write8(Adapter, REG_BCN_CTRL_1, usb_read8(Adapter, REG_BCN_CTRL_1) | BIT(0)); } } @@ -1371,7 +1264,7 @@ static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val) reg_macid = REG_MACID; for (idx = 0; idx < 6; idx++) - rtw_write8(Adapter, (reg_macid+idx), val[idx]); + usb_write8(Adapter, (reg_macid+idx), val[idx]); } static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) @@ -1382,7 +1275,7 @@ static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) reg_bssid = REG_BSSID; for (idx = 0; idx < 6; idx++) - rtw_write8(Adapter, (reg_bssid+idx), val[idx]); + usb_write8(Adapter, (reg_bssid+idx), val[idx]); } static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) @@ -1392,9 +1285,9 @@ static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) bcn_ctrl_reg = REG_BCN_CTRL; if (*((u8 *)val)) - rtw_write8(Adapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); + usb_write8(Adapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); else - rtw_write8(Adapter, bcn_ctrl_reg, rtw_read8(Adapter, bcn_ctrl_reg)&(~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); + usb_write8(Adapter, bcn_ctrl_reg, usb_read8(Adapter, bcn_ctrl_reg)&(~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); } static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) @@ -1402,25 +1295,24 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &haldata->dmpriv; struct odm_dm_struct *podmpriv = &haldata->odmpriv; -_func_enter_; switch (variable) { case HW_VAR_MEDIA_STATUS: { u8 val8; - val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 = usb_read8(Adapter, MSR)&0x0c; val8 |= *((u8 *)val); - rtw_write8(Adapter, MSR, val8); + usb_write8(Adapter, MSR, val8); } break; case HW_VAR_MEDIA_STATUS1: { u8 val8; - val8 = rtw_read8(Adapter, MSR) & 0x03; + val8 = usb_read8(Adapter, MSR) & 0x03; val8 |= *((u8 *)val) << 2; - rtw_write8(Adapter, MSR, val8); + usb_write8(Adapter, MSR, val8); } break; case HW_VAR_SET_OPMODE: @@ -1454,9 +1346,9 @@ _func_enter_; BrateCfg |= 0x01; /* default enable 1M ACK rate */ /* Set RRSR rate table. */ - rtw_write8(Adapter, REG_RRSR, BrateCfg & 0xff); - rtw_write8(Adapter, REG_RRSR+1, (BrateCfg >> 8) & 0xff); - rtw_write8(Adapter, REG_RRSR+2, rtw_read8(Adapter, REG_RRSR+2)&0xf0); + usb_write8(Adapter, REG_RRSR, BrateCfg & 0xff); + usb_write8(Adapter, REG_RRSR+1, (BrateCfg >> 8) & 0xff); + usb_write8(Adapter, REG_RRSR+2, usb_read8(Adapter, REG_RRSR+2)&0xf0); /* Set RTS initial rate */ while (BrateCfg > 0x1) { @@ -1464,11 +1356,11 @@ _func_enter_; RateIndex++; } /* Ziv - Check */ - rtw_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); + usb_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); } break; case HW_VAR_TXPAUSE: - rtw_write8(Adapter, REG_TXPAUSE, *((u8 *)val)); + usb_write8(Adapter, REG_TXPAUSE, *((u8 *)val)); break; case HW_VAR_BCN_FUNC: hw_var_set_bcn_func(Adapter, variable, val); @@ -1485,13 +1377,13 @@ _func_enter_; StopTxBeacon(Adapter); /* disable related TSF function */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(3))); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)&(~BIT(3))); - rtw_write32(Adapter, REG_TSFTR, tsf); - rtw_write32(Adapter, REG_TSFTR+4, tsf>>32); + usb_write32(Adapter, REG_TSFTR, tsf); + usb_write32(Adapter, REG_TSFTR+4, tsf>>32); /* enable related TSF function */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(3)); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)|BIT(3)); if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) ResumeTxBeacon(Adapter); @@ -1499,39 +1391,39 @@ _func_enter_; break; case HW_VAR_CHECK_BSSID: if (*((u8 *)val)) { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + usb_write32(Adapter, REG_RCR, usb_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); } else { u32 val32; - val32 = rtw_read32(Adapter, REG_RCR); + val32 = usb_read32(Adapter, REG_RCR); val32 &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN); - rtw_write32(Adapter, REG_RCR, val32); + usb_write32(Adapter, REG_RCR, val32); } break; case HW_VAR_MLME_DISCONNECT: /* Set RCR to not to receive data frame when NO LINK state */ /* reject all data frames */ - rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + usb_write16(Adapter, REG_RXFLTMAP2, 0x00); /* reset TSF */ - rtw_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); + usb_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); /* disable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)|BIT(4)); break; case HW_VAR_MLME_SITESURVEY: if (*((u8 *)val)) { /* under sitesurvey */ /* config RCR to receive different BSSID & not to receive data frame */ - u32 v = rtw_read32(Adapter, REG_RCR); + u32 v = usb_read32(Adapter, REG_RCR); v &= ~(RCR_CBSSID_BCN); - rtw_write32(Adapter, REG_RCR, v); + usb_write32(Adapter, REG_RCR, v); /* reject all data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + usb_write16(Adapter, REG_RXFLTMAP2, 0x00); /* disable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)|BIT(4)); } else { /* sitesurvey done */ struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -1539,24 +1431,24 @@ _func_enter_; if ((is_client_associated_to_ap(Adapter)) || ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) { /* enable to rx data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); } else if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { - rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); } if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + usb_write32(Adapter, REG_RCR, usb_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); } else { if (Adapter->in_cta_test) { - u32 v = rtw_read32(Adapter, REG_RCR); + u32 v = usb_read32(Adapter, REG_RCR); v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ - rtw_write32(Adapter, REG_RCR, v); + usb_write32(Adapter, REG_RCR, v); } else { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + usb_write32(Adapter, REG_RCR, usb_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); } } } @@ -1569,14 +1461,14 @@ _func_enter_; if (type == 0) { /* prepare to join */ /* enable to rx data frame.Accept all data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); if (Adapter->in_cta_test) { - u32 v = rtw_read32(Adapter, REG_RCR); + u32 v = usb_read32(Adapter, REG_RCR); v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ - rtw_write32(Adapter, REG_RCR, v); + usb_write32(Adapter, REG_RCR, v); } else { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + usb_write32(Adapter, REG_RCR, usb_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); } if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) @@ -1585,20 +1477,20 @@ _func_enter_; RetryLimit = 0x7; } else if (type == 1) { /* joinbss_event call back when join res < 0 */ - rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + usb_write16(Adapter, REG_RXFLTMAP2, 0x00); } else if (type == 2) { /* sta add event call back */ /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) RetryLimit = 0x7; } - rtw_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); + usb_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); } break; case HW_VAR_BEACON_INTERVAL: - rtw_write16(Adapter, REG_BCN_INTERVAL, *((u16 *)val)); + usb_write16(Adapter, REG_BCN_INTERVAL, *((u16 *)val)); break; case HW_VAR_SLOT_TIME: { @@ -1606,7 +1498,7 @@ _func_enter_; struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - rtw_write8(Adapter, REG_SLOT, val[0]); + usb_write8(Adapter, REG_SLOT, val[0]); if (pmlmeinfo->WMM_enable == 0) { if (pmlmeext->cur_wireless_mode == WIRELESS_11B) @@ -1617,20 +1509,20 @@ _func_enter_; u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime); /* Temporary removed, 2008.06.20. */ - rtw_write8(Adapter, REG_EDCA_VO_PARAM, u1bAIFS); - rtw_write8(Adapter, REG_EDCA_VI_PARAM, u1bAIFS); - rtw_write8(Adapter, REG_EDCA_BE_PARAM, u1bAIFS); - rtw_write8(Adapter, REG_EDCA_BK_PARAM, u1bAIFS); + usb_write8(Adapter, REG_EDCA_VO_PARAM, u1bAIFS); + usb_write8(Adapter, REG_EDCA_VI_PARAM, u1bAIFS); + usb_write8(Adapter, REG_EDCA_BE_PARAM, u1bAIFS); + usb_write8(Adapter, REG_EDCA_BK_PARAM, u1bAIFS); } } break; case HW_VAR_RESP_SIFS: /* RESP_SIFS for CCK */ - rtw_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ - rtw_write8(Adapter, REG_R2T_SIFS+1, val[1]); /* SIFS_R2T_CCK(0x08) */ + usb_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ + usb_write8(Adapter, REG_R2T_SIFS+1, val[1]); /* SIFS_R2T_CCK(0x08) */ /* RESP_SIFS for OFDM */ - rtw_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ - rtw_write8(Adapter, REG_T2T_SIFS+1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ + usb_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ + usb_write8(Adapter, REG_T2T_SIFS+1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ break; case HW_VAR_ACK_PREAMBLE: { @@ -1641,11 +1533,11 @@ _func_enter_; if (bShortPreamble) regTmp |= 0x80; - rtw_write8(Adapter, REG_RRSR+2, regTmp); + usb_write8(Adapter, REG_RRSR+2, regTmp); } break; case HW_VAR_SEC_CFG: - rtw_write8(Adapter, REG_SECCFG, *((u8 *)val)); + usb_write8(Adapter, REG_SECCFG, *((u8 *)val)); break; case HW_VAR_DM_FLAG: podmpriv->SupportAbility = *((u8 *)val); @@ -1685,41 +1577,41 @@ _func_enter_; ulCommand = CAM_CONTENT_COUNT*ucIndex+i; ulCommand = ulCommand | CAM_POLLINIG|CAM_WRITE; /* write content 0 is equall to mark invalid */ - rtw_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ - rtw_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ + usb_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ + usb_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ } } break; case HW_VAR_CAM_INVALID_ALL: - rtw_write32(Adapter, RWCAM, BIT(31)|BIT(30)); + usb_write32(Adapter, RWCAM, BIT(31)|BIT(30)); break; case HW_VAR_CAM_WRITE: { u32 cmd; u32 *cam_val = (u32 *)val; - rtw_write32(Adapter, WCAMI, cam_val[0]); + usb_write32(Adapter, WCAMI, cam_val[0]); cmd = CAM_POLLINIG | CAM_WRITE | cam_val[1]; - rtw_write32(Adapter, RWCAM, cmd); + usb_write32(Adapter, RWCAM, cmd); } break; case HW_VAR_AC_PARAM_VO: - rtw_write32(Adapter, REG_EDCA_VO_PARAM, ((u32 *)(val))[0]); + usb_write32(Adapter, REG_EDCA_VO_PARAM, ((u32 *)(val))[0]); break; case HW_VAR_AC_PARAM_VI: - rtw_write32(Adapter, REG_EDCA_VI_PARAM, ((u32 *)(val))[0]); + usb_write32(Adapter, REG_EDCA_VI_PARAM, ((u32 *)(val))[0]); break; case HW_VAR_AC_PARAM_BE: haldata->AcParam_BE = ((u32 *)(val))[0]; - rtw_write32(Adapter, REG_EDCA_BE_PARAM, ((u32 *)(val))[0]); + usb_write32(Adapter, REG_EDCA_BE_PARAM, ((u32 *)(val))[0]); break; case HW_VAR_AC_PARAM_BK: - rtw_write32(Adapter, REG_EDCA_BK_PARAM, ((u32 *)(val))[0]); + usb_write32(Adapter, REG_EDCA_BK_PARAM, ((u32 *)(val))[0]); break; case HW_VAR_ACM_CTRL: { u8 acm_ctrl = *((u8 *)val); - u8 AcmCtrl = rtw_read8(Adapter, REG_ACMHWCTRL); + u8 AcmCtrl = usb_read8(Adapter, REG_ACMHWCTRL); if (acm_ctrl > 1) AcmCtrl = AcmCtrl | 0x1; @@ -1740,7 +1632,7 @@ _func_enter_; AcmCtrl &= (~AcmHw_BeqEn); DBG_88E("[HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl); - rtw_write8(Adapter, REG_ACMHWCTRL, AcmCtrl); + usb_write8(Adapter, REG_ACMHWCTRL, AcmCtrl); } break; case HW_VAR_AMPDU_MIN_SPACE: @@ -1767,7 +1659,7 @@ _func_enter_; } if (MinSpacingToSet < SecMinSpace) MinSpacingToSet = SecMinSpace; - rtw_write8(Adapter, REG_AMPDU_MIN_SPACE, (rtw_read8(Adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | MinSpacingToSet); + usb_write8(Adapter, REG_AMPDU_MIN_SPACE, (usb_read8(Adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | MinSpacingToSet); } } break; @@ -1781,7 +1673,7 @@ _func_enter_; pRegToSet = RegToSet_Normal; /* 0xb972a841; */ FactorToSet = *((u8 *)val); if (FactorToSet <= 3) { - FactorToSet = (1<<(FactorToSet + 2)); + FactorToSet = 1 << (FactorToSet + 2); if (FactorToSet > 0xf) FactorToSet = 0xf; @@ -1792,7 +1684,7 @@ _func_enter_; if ((pRegToSet[index] & 0x0f) > FactorToSet) pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet); - rtw_write8(Adapter, (REG_AGGLEN_LMT+index), pRegToSet[index]); + usb_write8(Adapter, (REG_AGGLEN_LMT+index), pRegToSet[index]); } } } @@ -1802,7 +1694,7 @@ _func_enter_; u8 threshold = *((u8 *)val); if (threshold == 0) threshold = haldata->UsbRxAggPageCount; - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, threshold); + usb_write8(Adapter, REG_RXDMA_AGG_PG_TH, threshold); } break; case HW_VAR_SET_RPWM: @@ -1824,14 +1716,6 @@ _func_enter_; rtl8188e_set_FwJoinBssReport_cmd(Adapter, mstatus); } break; -#ifdef CONFIG_88EU_P2P - case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: - { - u8 p2p_ps_state = (*(u8 *)val); - rtl8188e_set_p2p_ps_offload_cmd(Adapter, p2p_ps_state); - } - break; -#endif case HW_VAR_INITIAL_GAIN: { struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; @@ -1861,7 +1745,7 @@ _func_enter_; /* switch antenna to Optimum_antenna */ if (haldata->CurAntenna != Optimum_antenna) { Ant = (Optimum_antenna == 2) ? MAIN_ANT : AUX_ANT; - ODM_UpdateRxIdleAnt_88E(&haldata->odmpriv, Ant); + rtl88eu_dm_update_rx_idle_ant(&haldata->odmpriv, Ant); haldata->CurAntenna = Optimum_antenna; } @@ -1876,25 +1760,25 @@ _func_enter_; u8 trycnt = 100; /* pause tx */ - rtw_write8(Adapter, REG_TXPAUSE, 0xff); + usb_write8(Adapter, REG_TXPAUSE, 0xff); /* keep sn */ - Adapter->xmitpriv.nqos_ssn = rtw_read16(Adapter, REG_NQOS_SEQ); + Adapter->xmitpriv.nqos_ssn = usb_read16(Adapter, REG_NQOS_SEQ); if (!pwrpriv->bkeepfwalive) { /* RX DMA stop */ - rtw_write32(Adapter, REG_RXPKT_NUM, (rtw_read32(Adapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + usb_write32(Adapter, REG_RXPKT_NUM, (usb_read32(Adapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); do { - if (!(rtw_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) + if (!(usb_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) break; } while (trycnt--); if (trycnt == 0) DBG_88E("Stop RX DMA failed......\n"); /* RQPN Load 0 */ - rtw_write16(Adapter, REG_RQPN_NPQ, 0x0); - rtw_write32(Adapter, REG_RQPN, 0x80000000); - rtw_mdelay_os(10); + usb_write16(Adapter, REG_RQPN_NPQ, 0x0); + usb_write32(Adapter, REG_RQPN, 0x80000000); + mdelay(10); } } break; @@ -1908,7 +1792,7 @@ _func_enter_; { u8 maxMacid = *val; DBG_88E("### MacID(%d),Set Max Tx RPT MID(%d)\n", maxMacid, maxMacid+1); - rtw_write8(Adapter, REG_TX_RPT_CTRL+1, maxMacid+1); + usb_write8(Adapter, REG_TX_RPT_CTRL+1, maxMacid+1); } break; case HW_VAR_H2C_MEDIA_STATUS_RPT: @@ -1916,29 +1800,27 @@ _func_enter_; break; case HW_VAR_BCN_VALID: /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ - rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT0); + usb_write8(Adapter, REG_TDECTRL+2, usb_read8(Adapter, REG_TDECTRL+2) | BIT0); break; default: break; } -_func_exit_; } static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) { struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct odm_dm_struct *podmpriv = &haldata->odmpriv; -_func_enter_; switch (variable) { case HW_VAR_BASIC_RATE: *((u16 *)(val)) = haldata->BasicRateSet; case HW_VAR_TXPAUSE: - val[0] = rtw_read8(Adapter, REG_TXPAUSE); + val[0] = usb_read8(Adapter, REG_TXPAUSE); break; case HW_VAR_BCN_VALID: /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ - val[0] = (BIT0 & rtw_read8(Adapter, REG_TDECTRL+2)) ? true : false; + val[0] = (BIT0 & usb_read8(Adapter, REG_TDECTRL+2)) ? true : false; break; case HW_VAR_DM_FLAG: val[0] = podmpriv->SupportAbility; @@ -1955,7 +1837,7 @@ _func_enter_; val[0] = true; } else { u32 valRCR; - valRCR = rtw_read32(Adapter, REG_RCR); + valRCR = usb_read32(Adapter, REG_RCR); valRCR &= 0x00070000; if (valRCR) val[0] = false; @@ -1974,13 +1856,12 @@ _func_enter_; *val = haldata->bMacPwrCtrlOn; break; case HW_VAR_CHK_HI_QUEUE_EMPTY: - *val = ((rtw_read32(Adapter, REG_HGQ_INFORMATION)&0x0000ff00) == 0) ? true : false; + *val = ((usb_read32(Adapter, REG_HGQ_INFORMATION)&0x0000ff00) == 0) ? true : false; break; default: break; } -_func_exit_; } /* */ @@ -2113,7 +1994,7 @@ static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eV } else if (dm_func == 6) {/* turn on all dynamic func */ if (!(podmpriv->SupportAbility & DYNAMIC_BB_DIG)) { struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; - pDigTable->CurIGValue = rtw_read8(Adapter, 0xc50); + pDigTable->CurIGValue = usb_read8(Adapter, 0xc50); } podmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE; DBG_88E("==> Turn on all dynamic function...\n"); @@ -2131,7 +2012,7 @@ static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eV u8 bRSSIDump = *((u8 *)pValue); struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); if (bRSSIDump) - dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT ; + dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT; else dm_ocm->DebugComponents = 0; } @@ -2243,29 +2124,29 @@ static void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt) /* reset TSF, enable update TSF, correcting TSF On Beacon */ /* BCN interval */ - rtw_write16(adapt, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); - rtw_write8(adapt, REG_ATIMWND, 0x02);/* 2ms */ + usb_write16(adapt, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); + usb_write8(adapt, REG_ATIMWND, 0x02);/* 2ms */ _InitBeaconParameters(adapt); - rtw_write8(adapt, REG_SLOT, 0x09); + usb_write8(adapt, REG_SLOT, 0x09); - value32 = rtw_read32(adapt, REG_TCR); + value32 = usb_read32(adapt, REG_TCR); value32 &= ~TSFRST; - rtw_write32(adapt, REG_TCR, value32); + usb_write32(adapt, REG_TCR, value32); value32 |= TSFRST; - rtw_write32(adapt, REG_TCR, value32); + usb_write32(adapt, REG_TCR, value32); /* NOTE: Fix test chip's bug (about contention windows's randomness) */ - rtw_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50); - rtw_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50); + usb_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50); + usb_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50); _BeaconFunctionEnable(adapt, true, true); ResumeTxBeacon(adapt); - rtw_write8(adapt, bcn_ctrl_reg, rtw_read8(adapt, bcn_ctrl_reg)|BIT(1)); + usb_write8(adapt, bcn_ctrl_reg, usb_read8(adapt, bcn_ctrl_reg)|BIT(1)); } static void rtl8188eu_init_default_value(struct adapter *adapt) @@ -2292,22 +2173,14 @@ static void rtl8188eu_init_default_value(struct adapter *adapt) haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0; } -static u8 rtl8188eu_ps_func(struct adapter *Adapter, enum hal_intf_ps_func efunc_id, u8 *val) -{ - u8 bResult = true; - return bResult; -} - void rtl8188eu_set_hal_ops(struct adapter *adapt) { struct hal_ops *halfunc = &adapt->HalFunc; -_func_enter_; - adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); + adapt->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL); if (adapt->HalData == NULL) DBG_88E("cant not alloc memory for HAL DATA\n"); - adapt->hal_data_sz = sizeof(struct hal_data_8188e); halfunc->hal_power_on = rtl8188eu_InitPowerOn; halfunc->hal_init = &rtl8188eu_hal_init; @@ -2317,7 +2190,6 @@ _func_enter_; halfunc->inirp_deinit = &rtl8188eu_inirp_deinit; halfunc->init_xmit_priv = &rtl8188eu_init_xmit_priv; - halfunc->free_xmit_priv = &rtl8188eu_free_xmit_priv; halfunc->init_recv_priv = &rtl8188eu_init_recv_priv; halfunc->free_recv_priv = &rtl8188eu_free_recv_priv; @@ -2326,7 +2198,7 @@ _func_enter_; halfunc->init_default_value = &rtl8188eu_init_default_value; halfunc->intf_chip_configure = &rtl8188eu_interface_configure; - halfunc->read_adapter_info = &ReadAdapterInfo8188EU; + halfunc->read_adapter_info = &_ReadAdapterInfo8188EU; halfunc->SetHwRegHandler = &SetHwReg8188EU; halfunc->GetHwRegHandler = &GetHwReg8188EU; @@ -2339,8 +2211,5 @@ _func_enter_; halfunc->hal_xmit = &rtl8188eu_hal_xmit; halfunc->mgnt_xmit = &rtl8188eu_mgnt_xmit; - halfunc->interface_ps_func = &rtl8188eu_ps_func; - rtl8188e_set_hal_ops(halfunc); -_func_exit_; } diff --git a/hal/usb_ops_linux.c b/hal/usb_ops_linux.c deleted file mode 100644 index 3263fe7..0000000 --- a/hal/usb_ops_linux.c +++ /dev/null @@ -1,728 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define _HCI_OPS_OS_C_ - -#include -#include -#include -#include -#include -#include - -static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) -{ - struct adapter *adapt = pintfhdl->padapter; - struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); - struct usb_device *udev = dvobjpriv->pusbdev; - unsigned int pipe; - int status = 0; - u8 reqtype; - u8 *pIo_buf; - int vendorreq_times = 0; - - if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usbctrl_vendorreq:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); - status = -EPERM; - goto exit; - } - - if (len > MAX_VENDOR_REQ_CMD_SIZE) { - DBG_88E("[%s] Buffer len error ,vendor request failed\n", __func__); - status = -EINVAL; - goto exit; - } - - _enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); - - /* Acquire IO memory for vendorreq */ - pIo_buf = dvobjpriv->usb_vendor_req_buf; - - if (pIo_buf == NULL) { - DBG_88E("[%s] pIo_buf == NULL\n", __func__); - status = -ENOMEM; - goto release_mutex; - } - - while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { - _rtw_memset(pIo_buf, 0, len); - - if (requesttype == 0x01) { - pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ - reqtype = REALTEK_USB_VENQT_READ; - } else { - pipe = usb_sndctrlpipe(udev, 0);/* write_out */ - reqtype = REALTEK_USB_VENQT_WRITE; - memcpy(pIo_buf, pdata, len); - } - - status = rtw_usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); - - if (status == len) { /* Success this control transfer. */ - rtw_reset_continual_urb_error(dvobjpriv); - if (requesttype == 0x01) - memcpy(pdata, pIo_buf, len); - } else { /* error cases */ - DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n", - value, (requesttype == 0x01) ? "read" : "write", - len, status, *(u32 *)pdata, vendorreq_times); - - if (status < 0) { - if (status == (-ESHUTDOWN) || status == -ENODEV) { - adapt->bSurpriseRemoved = true; - } else { - struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - haldata->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; - } - } else { /* status != len && status >= 0 */ - if (status > 0) { - if (requesttype == 0x01) { - /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ - memcpy(pdata, pIo_buf, len); - } - } - } - - if (rtw_inc_and_chk_continual_urb_error(dvobjpriv)) { - adapt->bSurpriseRemoved = true; - break; - } - - } - - /* firmware download is checksumed, don't retry */ - if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len) - break; - } -release_mutex: - _exit_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); -exit: - return status; -} - -static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) -{ - u8 request; - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u8 data = 0; - - _func_enter_; - - request = 0x05; - requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ - - wvalue = (u16)(addr&0x0000ffff); - len = 1; - - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - - _func_exit_; - - return data; - -} - -static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) -{ - u8 request; - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - __le32 data; - -_func_enter_; - request = 0x05; - requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); - len = 2; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); -_func_exit_; - - return (u16)(le32_to_cpu(data)&0xffff); -} - -static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) -{ - u8 request; - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - __le32 data; - -_func_enter_; - - request = 0x05; - requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ - - wvalue = (u16)(addr&0x0000ffff); - len = 4; - - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - -_func_exit_; - - return le32_to_cpu(data); -} - -static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) -{ - u8 request; - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u8 data; - int ret; - - _func_enter_; - request = 0x05; - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); - len = 1; - data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - _func_exit_; - return ret; -} - -static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) -{ - u8 request; - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - __le32 data; - int ret; - - _func_enter_; - - request = 0x05; - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ - - wvalue = (u16)(addr&0x0000ffff); - len = 2; - - data = cpu_to_le32(val & 0x0000ffff); - - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - - _func_exit_; - - return ret; -} - -static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) -{ - u8 request; - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - __le32 data; - int ret; - - _func_enter_; - - request = 0x05; - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ - - wvalue = (u16)(addr&0x0000ffff); - len = 4; - data = cpu_to_le32(val); - - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - - _func_exit_; - - return ret; -} - -static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) -{ - u8 request; - u8 requesttype; - u16 wvalue; - u16 index; - u16 len; - u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; - int ret; - - _func_enter_; - - request = 0x05; - requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ - - wvalue = (u16)(addr&0x0000ffff); - len = length; - memcpy(buf, pdata, len); - - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); - - _func_exit_; - - return ret; -} - -static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) -{ - struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - - if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) { - DBG_88E("%s Invalid interrupt content length (%d)!\n", __func__, pkt_len); - return; - } - - /* HISR */ - memcpy(&(haldata->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); - memcpy(&(haldata->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); - - /* C2H Event */ - if (pbuf[0] != 0) - memcpy(&(haldata->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); -} - -static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) -{ - u8 *pbuf; - u8 shift_sz = 0; - u16 pkt_cnt; - u32 pkt_offset, skb_len, alloc_sz; - s32 transfer_len; - struct recv_stat *prxstat; - struct phy_stat *pphy_status = NULL; - struct sk_buff *pkt_copy = NULL; - union recv_frame *precvframe = NULL; - struct rx_pkt_attrib *pattrib = NULL; - struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - struct recv_priv *precvpriv = &adapt->recvpriv; - struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; - - transfer_len = (s32)pskb->len; - pbuf = pskb->data; - - prxstat = (struct recv_stat *)pbuf; - pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; - - do { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", - prxstat->rxdw0, prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4)); - - prxstat = (struct recv_stat *)pbuf; - - precvframe = rtw_alloc_recvframe(pfree_recv_queue); - if (precvframe == NULL) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); - DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); - goto _exit_recvbuf2recvframe; - } - - _rtw_init_listhead(&precvframe->u.hdr.list); - precvframe->u.hdr.precvbuf = NULL; /* can't access the precvbuf for new arch. */ - precvframe->u.hdr.len = 0; - - update_recvframe_attrib_88e(precvframe, prxstat); - - pattrib = &precvframe->u.hdr.attrib; - - if ((pattrib->crc_err) || (pattrib->icv_err)) { - DBG_88E("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); - - rtw_free_recvframe(precvframe, pfree_recv_queue); - goto _exit_recvbuf2recvframe; - } - - if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX)) - pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET); - - pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; - - if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<=0\n")); - DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len\n", __func__, __LINE__); - rtw_free_recvframe(precvframe, pfree_recv_queue); - goto _exit_recvbuf2recvframe; - } - - /* Modified by Albert 20101213 */ - /* For 8 bytes IP header alignment. */ - if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ - shift_sz = 6; - else - shift_sz = 0; - - skb_len = pattrib->pkt_len; - - /* for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */ - /* modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */ - if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { - if (skb_len <= 1650) - alloc_sz = 1664; - else - alloc_sz = skb_len + 14; - } else { - alloc_sz = skb_len; - /* 6 is for IP header 8 bytes alignment in QoS packet case. */ - /* 8 is for skb->data 4 bytes alignment. */ - alloc_sz += 14; - } - - pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz); - if (pkt_copy) { - pkt_copy->dev = adapt->pnetdev; - precvframe->u.hdr.pkt = pkt_copy; - precvframe->u.hdr.rx_head = pkt_copy->data; - precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz; - skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ - skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */ - memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); - precvframe->u.hdr.rx_tail = pkt_copy->data; - precvframe->u.hdr.rx_data = pkt_copy->data; - } else { - if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { - DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n"); - rtw_free_recvframe(precvframe, pfree_recv_queue); - goto _exit_recvbuf2recvframe; - } - precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC); - if (precvframe->u.hdr.pkt) { - precvframe->u.hdr.rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE; - precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_tail; - precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail; - precvframe->u.hdr.rx_end = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz; - } else { - DBG_88E("recvbuf2recvframe: skb_clone fail\n"); - rtw_free_recvframe(precvframe, pfree_recv_queue); - goto _exit_recvbuf2recvframe; - } - } - - recvframe_put(precvframe, skb_len); - - switch (haldata->UsbRxAggMode) { - case USB_RX_AGG_DMA: - case USB_RX_AGG_MIX: - pkt_offset = (u16)_RND128(pkt_offset); - break; - case USB_RX_AGG_USB: - pkt_offset = (u16)_RND4(pkt_offset); - break; - case USB_RX_AGG_DISABLE: - default: - break; - } - if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ - if (pattrib->physt) - update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status); - if (rtw_recv_entry(precvframe) != _SUCCESS) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); - } - } else { - /* enqueue recvframe to txrtp queue */ - if (pattrib->pkt_rpt_type == TX_REPORT1) { - /* CCX-TXRPT ack for xmit mgmt frames. */ - handle_txrpt_ccx_88e(adapt, precvframe->u.hdr.rx_data); - } else if (pattrib->pkt_rpt_type == TX_REPORT2) { - ODM_RA_TxRPT2Handle_8188E( - &haldata->odmpriv, - precvframe->u.hdr.rx_data, - pattrib->pkt_len, - pattrib->MacIDValidEntry[0], - pattrib->MacIDValidEntry[1] - ); - } else if (pattrib->pkt_rpt_type == HIS_REPORT) { - interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->u.hdr.rx_data); - } - rtw_free_recvframe(precvframe, pfree_recv_queue); - } - pkt_cnt--; - transfer_len -= pkt_offset; - pbuf += pkt_offset; - precvframe = NULL; - pkt_copy = NULL; - - if (transfer_len > 0 && pkt_cnt == 0) - pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; - - } while ((transfer_len > 0) && (pkt_cnt > 0)); - -_exit_recvbuf2recvframe: - - return _SUCCESS; -} - -void rtl8188eu_recv_tasklet(void *priv) -{ - struct sk_buff *pskb; - struct adapter *adapt = (struct adapter *)priv; - struct recv_priv *precvpriv = &adapt->recvpriv; - - while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { - if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) { - DBG_88E("recv_tasklet => bDriverStopped or bSurpriseRemoved\n"); - dev_kfree_skb_any(pskb); - break; - } - recvbuf2recvframe(adapt, pskb); - skb_reset_tail_pointer(pskb); - pskb->len = 0; - skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); - } -} - -static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) -{ - struct recv_buf *precvbuf = (struct recv_buf *)purb->context; - struct adapter *adapt = (struct adapter *)precvbuf->adapter; - struct recv_priv *precvpriv = &adapt->recvpriv; - - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete!!!\n")); - - precvpriv->rx_pending_cnt--; - - if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", - adapt->bDriverStopped, adapt->bSurpriseRemoved)); - - precvbuf->reuse = true; - DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", - __func__, adapt->bDriverStopped, - adapt->bSurpriseRemoved, adapt->bReadPortCancel); - goto exit; - } - - if (purb->status == 0) { /* SUCCESS */ - if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); - precvbuf->reuse = true; - rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); - DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__); - } else { - rtw_reset_continual_urb_error(adapter_to_dvobj(adapt)); - - precvbuf->transfer_len = purb->actual_length; - skb_put(precvbuf->pskb, purb->actual_length); - skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb); - - if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1) - tasklet_schedule(&precvpriv->recv_tasklet); - - precvbuf->pskb = NULL; - precvbuf->reuse = false; - rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); - } - } else { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); - - DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status); - skb_put(precvbuf->pskb, purb->actual_length); - precvbuf->pskb = NULL; - - if (rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(adapt))) - adapt->bSurpriseRemoved = true; - - switch (purb->status) { - case -EINVAL: - case -EPIPE: - case -ENODEV: - case -ESHUTDOWN: - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bSurpriseRemoved=true\n")); - case -ENOENT: - adapt->bDriverStopped = true; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); - break; - case -EPROTO: - case -EOVERFLOW: - { - struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - haldata->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; - } - precvbuf->reuse = true; - rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); - break; - case -EINPROGRESS: - DBG_88E("ERROR: URB IS IN PROGRESS!/n"); - break; - default: - break; - } - } - -exit: -_func_exit_; -} - -static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) -{ - struct urb *purb = NULL; - struct recv_buf *precvbuf = (struct recv_buf *)rmem; - struct adapter *adapter = pintfhdl->padapter; - struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); - struct recv_priv *precvpriv = &adapter->recvpriv; - struct usb_device *pusbd = pdvobj->pusbdev; - int err; - unsigned int pipe; - size_t tmpaddr = 0; - size_t alignment = 0; - u32 ret = _SUCCESS; - -_func_enter_; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved || - adapter->pwrctrlpriv.pnp_bstop_trx) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); - return _FAIL; - } - - if (!precvbuf) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port:precvbuf==NULL\n")); - return _FAIL; - } - - if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { - precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); - if (NULL != precvbuf->pskb) - precvbuf->reuse = true; - } - - rtl8188eu_init_recvbuf(adapter, precvbuf); - - /* re-assign for linux based on skb */ - if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { - precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); - if (precvbuf->pskb == NULL) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); - DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); - return _FAIL; - } - - tmpaddr = (size_t)precvbuf->pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); - skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); - - precvbuf->phead = precvbuf->pskb->head; - precvbuf->pdata = precvbuf->pskb->data; - precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); - precvbuf->pend = skb_end_pointer(precvbuf->pskb); - precvbuf->pbuf = precvbuf->pskb->data; - } else { /* reuse skb */ - precvbuf->phead = precvbuf->pskb->head; - precvbuf->pdata = precvbuf->pskb->data; - precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); - precvbuf->pend = skb_end_pointer(precvbuf->pskb); - precvbuf->pbuf = precvbuf->pskb->data; - - precvbuf->reuse = false; - } - - precvpriv->rx_pending_cnt++; - - purb = precvbuf->purb; - - /* translate DMA FIFO addr to pipehandle */ - pipe = ffaddr2pipehdl(pdvobj, addr); - - usb_fill_bulk_urb(purb, pusbd, pipe, - precvbuf->pbuf, - MAX_RECVBUF_SZ, - usb_read_port_complete, - precvbuf);/* context is precvbuf */ - - err = usb_submit_urb(purb, GFP_ATOMIC); - if ((err) && (err != (-EPERM))) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x", - err, purb->status)); - DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n", - err, purb->status); - ret = _FAIL; - } - -_func_exit_; - return ret; -} - -void rtl8188eu_xmit_tasklet(void *priv) -{ - int ret = false; - struct adapter *adapt = (struct adapter *)priv; - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - - if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) - return; - - while (1) { - if ((adapt->bDriverStopped) || - (adapt->bSurpriseRemoved) || - (adapt->bWritePortCancel)) { - DBG_88E("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n"); - break; - } - - ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv, NULL); - - if (!ret) - break; - } -} - -void rtl8188eu_set_intf_ops(struct _io_ops *pops) -{ - _func_enter_; - _rtw_memset((u8 *)pops, 0, sizeof(struct _io_ops)); - pops->_read8 = &usb_read8; - pops->_read16 = &usb_read16; - pops->_read32 = &usb_read32; - pops->_read_mem = &usb_read_mem; - pops->_read_port = &usb_read_port; - pops->_write8 = &usb_write8; - pops->_write16 = &usb_write16; - pops->_write32 = &usb_write32; - pops->_writeN = &usb_writeN; - pops->_write_mem = &usb_write_mem; - pops->_write_port = &usb_write_port; - pops->_read_port_cancel = &usb_read_port_cancel; - pops->_write_port_cancel = &usb_write_port_cancel; - _func_exit_; -} - -void rtl8188eu_set_hw_type(struct adapter *adapt) -{ - adapt->chip_type = RTL8188E; - adapt->HardwareType = HARDWARE_TYPE_RTL8188EU; - DBG_88E("CHIP TYPE: RTL8188E\n"); -} diff --git a/include/Hal8188EPhyCfg.h b/include/Hal8188EPhyCfg.h index 25cae81..20e6b40 100644 --- a/include/Hal8188EPhyCfg.h +++ b/include/Hal8188EPhyCfg.h @@ -198,42 +198,15 @@ struct ant_sel_cck { /* */ /* BB and RF register read/write */ /* */ -u32 rtl8188e_PHY_QueryBBReg(struct adapter *adapter, u32 regaddr, u32 mask); -void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, - u32 mask, u32 data); -u32 rtl8188e_PHY_QueryRFReg(struct adapter *adapter, enum rf_radio_path rfpath, - u32 regaddr, u32 mask); -void rtl8188e_PHY_SetRFReg(struct adapter *adapter, enum rf_radio_path rfpath, - u32 regaddr, u32 mask, u32 data); - -/* Initialization related function */ -/* MAC/BB/RF HAL config */ -int PHY_MACConfig8188E(struct adapter *adapter); -int PHY_BBConfig8188E(struct adapter *adapter); -int PHY_RFConfig8188E(struct adapter *adapter); - -/* RF config */ -int rtl8188e_PHY_ConfigRFWithParaFile(struct adapter *adapter, u8 *filename, - enum rf_radio_path rfpath); -int rtl8188e_PHY_ConfigRFWithHeaderFile(struct adapter *adapter, - enum rf_radio_path rfpath); /* Read initi reg value for tx power setting. */ void rtl8192c_PHY_GetHWRegOriginalValue(struct adapter *adapter); /* BB TX Power R/W */ void PHY_GetTxPowerLevel8188E(struct adapter *adapter, u32 *powerlevel); -void PHY_SetTxPowerLevel8188E(struct adapter *adapter, u8 channel); -bool PHY_UpdateTxPowerDbm8188E(struct adapter *adapter, int power); void PHY_ScanOperationBackup8188E(struct adapter *Adapter, u8 Operation); -/* Switch bandwidth for 8192S */ -void PHY_SetBWMode8188E(struct adapter *adapter, - enum ht_channel_width chnlwidth, unsigned char offset); - -/* channel switch related funciton */ -void PHY_SwChnl8188E(struct adapter *adapter, u8 channel); /* Call after initialization */ void ChkFwCmdIoDone(struct adapter *adapter); @@ -246,19 +219,8 @@ void PHY_EnableHostClkReq(struct adapter *adapter); bool SetAntennaConfig92C(struct adapter *adapter, u8 defaultant); -void storePwrIndexDiffRateOffset(struct adapter *adapter, u32 regaddr, - u32 mask, u32 data); /*--------------------------Exported Function prototype---------------------*/ -#define PHY_QueryBBReg(adapt, regaddr, mask) \ - rtl8188e_PHY_QueryBBReg((adapt), (regaddr), (mask)) -#define PHY_SetBBReg(adapt, regaddr, bitmask, data) \ - rtl8188e_PHY_SetBBReg((adapt), (regaddr), (bitmask), (data)) -#define PHY_QueryRFReg(adapt, rfpath, regaddr, bitmask) \ - rtl8188e_PHY_QueryRFReg((adapt), (rfpath), (regaddr), (bitmask)) -#define PHY_SetRFReg(adapt, rfpath, regaddr, bitmask, data) \ - rtl8188e_PHY_SetRFReg((adapt), (rfpath), (regaddr), (bitmask), (data)) - #define PHY_SetMacReg PHY_SetBBReg #define SIC_HW_SUPPORT 0 diff --git a/include/drv_types.h b/include/drv_types.h index 1888ddb..c813179 100644 --- a/include/drv_types.h +++ b/include/drv_types.h @@ -28,12 +28,9 @@ #define __DRV_TYPES_H__ #define DRV_NAME "r8188eu" -#define CONFIG_88EU_AP_MODE 1 -#define CONFIG_88EU_P2P 1 #include #include -#include #include #include #include @@ -43,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -52,17 +48,7 @@ #include #include #include -#include #include -#include -#include - -enum _NIC_VERSION { - RTL8711_NIC, - RTL8712_NIC, - RTL8713_NIC, - RTL8716_NIC -}; #define SPEC_DEV_ID_NONE BIT(0) #define SPEC_DEV_ID_DISABLE_HT BIT(1) @@ -71,12 +57,6 @@ enum _NIC_VERSION { #define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4) #define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5) -struct specific_device_id { - u32 flags; - u16 idVendor; - u16 idProduct; -}; - struct registry_priv { u8 chip_version; u8 rfintfs; @@ -161,15 +141,8 @@ struct registry_priv { #define MAX_CONTINUAL_URB_ERR 4 -struct rt_firmware { - u8 *szFwBuffer; - u32 ulFwLength; -}; - struct dvobj_priv { struct adapter *if1; - struct adapter *if2; - /* For 92D, DMDP have 2 interface. */ u8 InterfaceNumber; u8 NumInterfaces; @@ -179,10 +152,6 @@ struct dvobj_priv { int RtOutPipe[3]; u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */ - u8 irq_alloc; - - struct rt_firmware firmware; - /*-------- below is for USB INTERFACE --------*/ u8 nr_endpoint; @@ -190,18 +159,12 @@ struct dvobj_priv { u8 RtNumInPipes; u8 RtNumOutPipes; int ep_num[5]; /* endpoint number */ - int RegUsbSS; - struct semaphore usb_suspend_sema; struct mutex usb_vendor_req_mutex; - u8 *usb_alloc_vendor_req_buf; u8 *usb_vendor_req_buf; struct usb_interface *pusbintf; struct usb_device *pusbdev; - - ATOMIC_T continual_urb_error; - u8 signal_strength; }; static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) @@ -211,39 +174,14 @@ static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) return &dvobj->pusbintf->dev; }; -enum _IFACE_TYPE { - IFACE_PORT0, /* mapping to port0 for C/D series chips */ - IFACE_PORT1, /* mapping to port1 for C/D series chip */ - MAX_IFACE_PORT, -}; - -enum _ADAPTER_TYPE { - PRIMARY_ADAPTER, - SECONDARY_ADAPTER, - MAX_ADAPTER, -}; - -enum driver_state { - DRIVER_NORMAL = 0, - DRIVER_DISAPPEAR = 1, - DRIVER_REPLACE_DONGLE = 2, -}; - struct adapter { - int DriverState;/* for disable driver using module, use dongle toi - * replace module. */ int pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */ - int bDongle;/* build-in module or external dongle */ u16 chip_type; - u16 HardwareType; - u16 interface_type;/* USB,SDIO,SPI,PCI */ struct dvobj_priv *dvobj; struct mlme_priv mlmepriv; struct mlme_ext_priv mlmeextpriv; struct cmd_priv cmdpriv; - struct evt_priv evtpriv; - struct io_priv iopriv; struct xmit_priv xmitpriv; struct recv_priv recvpriv; struct sta_priv stapriv; @@ -252,7 +190,6 @@ struct adapter { struct pwrctrl_priv pwrctrlpriv; struct eeprom_priv eeprompriv; struct led_priv ledpriv; - struct mp_priv mppriv; #ifdef CONFIG_88EU_AP_MODE struct hostapd_priv *phostapdpriv; @@ -261,27 +198,15 @@ struct adapter { struct wifidirect_info wdinfo; void *HalData; - u32 hal_data_sz; struct hal_ops HalFunc; s32 bDriverStopped; s32 bSurpriseRemoved; - s32 bCardDisableWOHSM; - u32 IsrContent; - u32 ImrContent; - - u8 EepromAddressSize; u8 hw_init_completed; - u8 bDriverIsGoingToUnload; - u8 init_adpt_in_progress; - u8 bHaltInProgress; - s8 signal_strength; void *cmdThread; void *evtThread; - void *xmitThread; - void *recvThread; void (*intf_start)(struct adapter *adapter); void (*intf_stop)(struct adapter *adapter); struct net_device *pnetdev; @@ -301,32 +226,16 @@ struct adapter { int net_closed; u8 bFWReady; - u8 bBTFWReady; u8 bReadPortCancel; u8 bWritePortCancel; u8 bRxRSSIDisplay; /* The driver will show up the desired channel number * when this flag is 1. */ u8 bNotifyChannelChange; -#ifdef CONFIG_88EU_P2P - /* The driver will show the current P2P status when the - * upper application reads it. */ - u8 bShowGetP2PState; -#endif - struct adapter *pbuddy_adapter; - struct mutex *hw_init_mutex; + struct mutex hw_init_mutex; spinlock_t br_ext_lock; - struct nat25_network_db_entry *nethash[NAT25_HASH_SIZE]; - int pppoe_connection_in_progress; - unsigned char pppoe_addr[MACADDRLEN]; - unsigned char scdb_mac[MACADDRLEN]; - unsigned char scdb_ip[4]; - struct nat25_network_db_entry *scdb_entry; - unsigned char br_mac[MACADDRLEN]; - unsigned char br_ip[4]; - struct br_ext_info ethBrExtInfo; u8 fix_rate; diff --git a/include/fw.h b/include/fw.h new file mode 100644 index 0000000..7884d8f --- /dev/null +++ b/include/fw.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2013 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * Larry Finger + * + *****************************************************************************/ +#include "drv_types.h" +#include + +#ifndef __RTL92C__FW__H__ +#define __RTL92C__FW__H__ + +#define FW_8192C_START_ADDRESS 0x1000 +#define FW_8192C_PAGE_SIZE 4096 +#define FW_8192C_POLLING_DELAY 5 + +struct rtl92c_firmware_header { + __le16 signature; + u8 category; + u8 function; + u16 version; + u8 subversion; + u8 rsvd1; + u8 month; + u8 date; + u8 hour; + u8 minute; + u16 ramcodesize; + u16 rsvd2; + u32 svnindex; + u32 rsvd3; + u32 rsvd4; + u32 rsvd5; +}; + +int rtl88eu_download_fw(struct adapter *adapt); + +#endif diff --git a/include/hal_com.h b/include/hal_com.h index 81c2709..47715d9 100644 --- a/include/hal_com.h +++ b/include/hal_com.h @@ -166,8 +166,4 @@ void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg); bool Hal_MappingOutPipe(struct adapter *pAdapter, u8 NumOutPipe); void hal_init_macaddr(struct adapter *adapter); - -void c2h_evt_clear(struct adapter *adapter); -s32 c2h_evt_read(struct adapter *adapter, u8 *buf); - #endif /* __HAL_COMMON_H__ */ diff --git a/include/hal_intf.h b/include/hal_intf.h index 439c3c9..9191993 100644 --- a/include/hal_intf.h +++ b/include/hal_intf.h @@ -144,8 +144,6 @@ enum hal_intf_ps_func { HAL_MAX_ID, }; -typedef s32 (*c2h_id_filter)(u8 id); - struct hal_ops { u32 (*hal_power_on)(struct adapter *padapter); u32 (*hal_init)(struct adapter *padapter); @@ -157,7 +155,6 @@ struct hal_ops { u32 (*inirp_deinit)(struct adapter *padapter); s32 (*init_xmit_priv)(struct adapter *padapter); - void (*free_xmit_priv)(struct adapter *padapter); s32 (*init_recv_priv)(struct adapter *padapter); void (*free_recv_priv)(struct adapter *padapter); @@ -166,7 +163,6 @@ struct hal_ops { void (*DeInitSwLeds)(struct adapter *padapter); void (*dm_init)(struct adapter *padapter); - void (*dm_deinit)(struct adapter *padapter); void (*read_chip_version)(struct adapter *padapter); void (*init_default_value)(struct adapter *padapter); @@ -198,9 +194,6 @@ struct hal_ops { enum hal_def_variable eVariable, void *pValue); - void (*GetHalODMVarHandler)(struct adapter *padapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet); void (*SetHalODMVarHandler)(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet); @@ -211,25 +204,15 @@ struct hal_ops { void (*Add_RateATid)(struct adapter *adapter, u32 bitmap, u8 arg, u8 rssi_level); - void (*run_thread)(struct adapter *adapter); - void (*cancel_thread)(struct adapter *adapter); u8 (*AntDivBeforeLinkHandler)(struct adapter *adapter); void (*AntDivCompareHandler)(struct adapter *adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src); - u8 (*interface_ps_func)(struct adapter *padapter, - enum hal_intf_ps_func efunc_id, u8 *val); - s32 (*hal_xmit)(struct adapter *padapter, struct xmit_frame *pxmitframe); s32 (*mgnt_xmit)(struct adapter *padapter, struct xmit_frame *pmgntframe); - - u32 (*read_bbreg)(struct adapter *padapter, u32 RegAddr, - u32 BitMask); - void (*write_bbreg)(struct adapter *padapter, u32 RegAddr, - u32 BitMask, u32 Data); u32 (*read_rfreg)(struct adapter *padapter, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask); @@ -237,40 +220,11 @@ struct hal_ops { enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data); - void (*EfusePowerSwitch)(struct adapter *padapter, u8 bWrite, - u8 PwrState); - void (*ReadEFuse)(struct adapter *padapter, u8 efuseType, u16 _offset, - u16 _size_byte, u8 *pbuf, bool bPseudoTest); - void (*EFUSEGetEfuseDefinition)(struct adapter *padapter, u8 efuseType, - u8 type, void *pOut, bool bPseudoTest); - u16 (*EfuseGetCurrentSize)(struct adapter *padapter, u8 efuseType, - bool bPseudoTest); - int (*Efuse_PgPacketRead)(struct adapter *adapter, u8 offset, - u8 *data, bool bPseudoTest); - int (*Efuse_PgPacketWrite)(struct adapter *padapter, u8 offset, - u8 word_en, u8 *data, bool bPseudoTest); - u8 (*Efuse_WordEnableDataWrite)(struct adapter *padapter, - u16 efuse_addr, u8 word_en, - u8 *data, bool bPseudoTest); - bool (*Efuse_PgPacketWrite_BT)(struct adapter *padapter, u8 offset, - u8 word_en, u8 *data, bool test); - void (*sreset_init_value)(struct adapter *padapter); - void (*sreset_reset_value)(struct adapter *padapter); - void (*silentreset)(struct adapter *padapter); - void (*sreset_xmit_status_check)(struct adapter *padapter); - void (*sreset_linked_status_check) (struct adapter *padapter); u8 (*sreset_get_wifi_status)(struct adapter *padapter); - int (*IOL_exec_cmds_sync)(struct adapter *padapter, - struct xmit_frame *frame, u32 max_wait, - u32 bndy_cnt); - void (*hal_notch_filter)(struct adapter *adapter, bool enable); void (*hal_reset_security_engine)(struct adapter *adapter); - s32 (*c2h_handler)(struct adapter *padapter, - struct c2h_evt_hdr *c2h_evt); - c2h_id_filter c2h_id_filter_ccx; }; enum rt_eeprom_type { @@ -286,39 +240,10 @@ enum rt_eeprom_type { #define RF_CHANGE_BY_SW BIT31 enum hardware_type { - HARDWARE_TYPE_RTL8180, - HARDWARE_TYPE_RTL8185, - HARDWARE_TYPE_RTL8187, - HARDWARE_TYPE_RTL8188, - HARDWARE_TYPE_RTL8190P, - HARDWARE_TYPE_RTL8192E, - HARDWARE_TYPE_RTL819xU, - HARDWARE_TYPE_RTL8192SE, - HARDWARE_TYPE_RTL8192SU, - HARDWARE_TYPE_RTL8192CE, - HARDWARE_TYPE_RTL8192CU, - HARDWARE_TYPE_RTL8192DE, - HARDWARE_TYPE_RTL8192DU, - HARDWARE_TYPE_RTL8723AE, - HARDWARE_TYPE_RTL8723AU, - HARDWARE_TYPE_RTL8723AS, - HARDWARE_TYPE_RTL8188EE, HARDWARE_TYPE_RTL8188EU, - HARDWARE_TYPE_RTL8188ES, HARDWARE_TYPE_MAX, }; -/* RTL8188E Series */ -#define IS_HARDWARE_TYPE_8188EE(_Adapter) \ -(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EE) -#define IS_HARDWARE_TYPE_8188EU(_Adapter) \ -(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EU) -#define IS_HARDWARE_TYPE_8188ES(_Adapter) \ -(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188ES) -#define IS_HARDWARE_TYPE_8188E(_Adapter) \ -(IS_HARDWARE_TYPE_8188EE(_Adapter) || IS_HARDWARE_TYPE_8188EU(_Adapter) || \ - IS_HARDWARE_TYPE_8188ES(_Adapter)) - #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) #define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse) @@ -328,7 +253,6 @@ void rtw_hal_def_value_init(struct adapter *padapter); void rtw_hal_free_data(struct adapter *padapter); void rtw_hal_dm_init(struct adapter *padapter); -void rtw_hal_dm_deinit(struct adapter *padapter); void rtw_hal_sw_led_init(struct adapter *padapter); void rtw_hal_sw_led_deinit(struct adapter *padapter); @@ -351,9 +275,6 @@ u8 rtw_hal_get_def_var(struct adapter *padapter, void rtw_hal_set_odm_var(struct adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet); -void rtw_hal_get_odm_var(struct adapter *padapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet); void rtw_hal_enable_interrupt(struct adapter *padapter); void rtw_hal_disable_interrupt(struct adapter *padapter); @@ -361,15 +282,11 @@ void rtw_hal_disable_interrupt(struct adapter *padapter); u32 rtw_hal_inirp_init(struct adapter *padapter); u32 rtw_hal_inirp_deinit(struct adapter *padapter); -u8 rtw_hal_intf_ps_func(struct adapter *padapter, - enum hal_intf_ps_func efunc_id, u8 *val); - s32 rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe); s32 rtw_hal_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe); s32 rtw_hal_init_xmit_priv(struct adapter *padapter); -void rtw_hal_free_xmit_priv(struct adapter *padapter); s32 rtw_hal_init_recv_priv(struct adapter *padapter); void rtw_hal_free_recv_priv(struct adapter *padapter); @@ -378,14 +295,9 @@ void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level); void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, u8 level); void rtw_hal_clone_data(struct adapter *dst_adapt, struct adapter *src_adapt); -void rtw_hal_start_thread(struct adapter *padapter); -void rtw_hal_stop_thread(struct adapter *padapter); void rtw_hal_bcn_related_reg_setting(struct adapter *padapter); -u32 rtw_hal_read_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask); -void rtw_hal_write_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask, - u32 Data); u32 rtw_hal_read_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask); void rtw_hal_write_rfreg(struct adapter *padapter, @@ -405,21 +317,11 @@ void rtw_hal_antdiv_rssi_compared(struct adapter *padapter, struct wlan_bssid_ex *src); void rtw_hal_sreset_init(struct adapter *padapter); -void rtw_hal_sreset_reset(struct adapter *padapter); -void rtw_hal_sreset_reset_value(struct adapter *padapter); -void rtw_hal_sreset_xmit_status_check(struct adapter *padapter); -void rtw_hal_sreset_linked_status_check(struct adapter *padapter); u8 rtw_hal_sreset_get_wifi_status(struct adapter *padapter); -int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame, - u32 max_wating_ms, u32 bndy_cnt); - void rtw_hal_notch_filter(struct adapter *adapter, bool enable); void rtw_hal_reset_security_engine(struct adapter *adapter); -s32 rtw_hal_c2h_handler(struct adapter *adapter, - struct c2h_evt_hdr *c2h_evt); -c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter); void indicate_wx_scan_complete_event(struct adapter *padapter); u8 rtw_do_join(struct adapter *padapter); diff --git a/include/ieee80211.h b/include/ieee80211.h index c4d38d1..3299571 100644 --- a/include/ieee80211.h +++ b/include/ieee80211.h @@ -1233,19 +1233,6 @@ u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, void dump_ies(u8 *buf, u32 buf_len); void dump_wps_ie(u8 *ie, u32 ie_len); -#ifdef CONFIG_88EU_P2P -void dump_p2p_ie(u8 *ie, u32 ie_len); -u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen); -u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, - u8 *buf_attr, u32 *len_attr); -u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, - u8 *buf_content, uint *len_content); -u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, - u8 *pdata_attr); -void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, - u8 attr_id); -#endif - uint rtw_get_rateset_len(u8 *rateset); struct registry_priv; diff --git a/include/ieee80211_ext.h b/include/ieee80211_ext.h index 1052d18..15e53d3 100644 --- a/include/ieee80211_ext.h +++ b/include/ieee80211_ext.h @@ -103,24 +103,24 @@ struct wme_parameter_element { #define WPA_PUT_LE16(a, val) \ do { \ - (a)[1] = ((u16) (val)) >> 8; \ - (a)[0] = ((u16) (val)) & 0xff; \ + (a)[1] = ((u16)(val)) >> 8; \ + (a)[0] = ((u16)(val)) & 0xff; \ } while (0) #define WPA_PUT_BE32(a, val) \ do { \ - (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[3] = (u8) (((u32) (val)) & 0xff); \ + (a)[0] = (u8)((((u32) (val)) >> 24) & 0xff); \ + (a)[1] = (u8)((((u32) (val)) >> 16) & 0xff); \ + (a)[2] = (u8)((((u32) (val)) >> 8) & 0xff); \ + (a)[3] = (u8)(((u32) (val)) & 0xff); \ } while (0) #define WPA_PUT_LE32(a, val) \ do { \ - (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[0] = (u8) (((u32) (val)) & 0xff); \ + (a)[3] = (u8)((((u32) (val)) >> 24) & 0xff); \ + (a)[2] = (u8)((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8)((((u32) (val)) >> 8) & 0xff); \ + (a)[0] = (u8)(((u32) (val)) & 0xff); \ } while (0) #define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *)(a), (val)) diff --git a/include/odm.h b/include/odm.h index eaa4bc1..525eb10 100644 --- a/include/odm.h +++ b/include/odm.h @@ -90,14 +90,6 @@ #define ANTTESTA 0x01 /* Ant A will be Testing */ #define ANTTESTB 0x02 /* Ant B will be testing */ -/* structure and define */ - -/* Add for AP/ADSLpseudo DM structuer requirement. */ -/* We need to remove to other position??? */ -struct rtl8192cd_priv { - u8 temp; -}; - struct rtw_dig { u8 Dig_Enable_Flag; u8 Dig_Ext_Port_Stage; @@ -151,7 +143,7 @@ struct rtl_ps { int Rssi_val_min; u8 initialize; - u32 Reg874,RegC70,Reg85C,RegA74; + u32 Reg874, RegC70, Reg85C, RegA74; }; @@ -172,14 +164,6 @@ struct false_alarm_stats { u32 Cnt_BW_LSC; /* Gary */ }; -struct dyn_primary_cca { - u8 PriCCA_flag; - u8 intf_flag; - u8 intf_type; - u8 DupRTS_flag; - u8 Monitor_flag; -}; - struct rx_hpc { u8 RXHP_flag; u8 PSD_func_trigger; @@ -454,29 +438,7 @@ enum odm_ability_def { ODM_RF_CALIBRATION = BIT26, }; -/* ODM_CMNINFO_INTERFACE */ -enum odm_interface_def { - ODM_ITRF_PCIE = 0x1, - ODM_ITRF_USB = 0x2, - ODM_ITRF_SDIO = 0x4, - ODM_ITRF_ALL = 0x7, -}; - -/* ODM_CMNINFO_IC_TYPE */ -enum odm_ic_type { - ODM_RTL8192S = BIT0, - ODM_RTL8192C = BIT1, - ODM_RTL8192D = BIT2, - ODM_RTL8723A = BIT3, - ODM_RTL8188E = BIT4, - ODM_RTL8812 = BIT5, - ODM_RTL8821 = BIT6, -}; - -#define ODM_IC_11N_SERIES \ - (ODM_RTL8192S | ODM_RTL8192C | ODM_RTL8192D | \ - ODM_RTL8723A | ODM_RTL8188E) -#define ODM_IC_11AC_SERIES (ODM_RTL8812) +#define ODM_RTL8188E BIT4 /* ODM_CMNINFO_CUT_VER */ enum odm_cut_version { @@ -897,7 +859,6 @@ struct odm_dm_struct { struct fast_ant_train DM_FatTable; struct rtw_dig DM_DigTable; struct rtl_ps DM_PSTable; - struct dyn_primary_cca DM_PriCCA; struct rx_hpc DM_RXHP_Table; struct false_alarm_stats FalseAlmCnt; struct false_alarm_stats FlaseAlmCntBuddyAdapter; @@ -950,13 +911,6 @@ struct odm_dm_struct { #define ODM_RF_PATH_MAX 3 -enum ODM_RF_RADIO_PATH { - ODM_RF_PATH_A = 0, /* Radio Path A */ - ODM_RF_PATH_B = 1, /* Radio Path B */ - ODM_RF_PATH_C = 2, /* Radio Path C */ - ODM_RF_PATH_D = 3, /* Radio Path D */ -}; - enum ODM_RF_CONTENT { odm_radioa_txt = 0x1000, odm_radiob_txt = 0x1001, @@ -1128,69 +1082,28 @@ extern u8 CCKSwingTable_Ch14 [CCK_TABLE_SIZE][8]; #define SWAW_STEP_PEAK 0 #define SWAW_STEP_DETERMINE 1 -void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI); -void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres); - -void ODM_SetAntenna(struct odm_dm_struct *pDM_Odm, u8 Antenna); - - -#define dm_RF_Saving ODM_RF_Saving -void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal); - -#define SwAntDivRestAfterLink ODM_SwAntDivRestAfterLink -void ODM_SwAntDivRestAfterLink(struct odm_dm_struct *pDM_Odm); - #define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck -void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm); +#define dm_RF_Saving ODM_RF_Saving +void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal); +void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm); +void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm); +void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres); bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate, u8 *pRATRState); - -#define dm_SWAW_RSSI_Check ODM_SwAntDivChkPerPktRssi -void ODM_SwAntDivChkPerPktRssi(struct odm_dm_struct *pDM_Odm, u8 StationID, - struct odm_phy_status_info *pPhyInfo); - u32 ConvertTo_dB(u32 Value); - -u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, - u8 initial_gain_psd); - -void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm); - u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u8 rssi_level); - -void ODM_DMInit(struct odm_dm_struct *pDM_Odm); - -void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm); - void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u32 Value); - +void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value); void ODM_CmnInfoHook(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, void *pValue); - void ODM_CmnInfoPtrArrayHook(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u16 Index, void *pValue); - -void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value); - -void ODM_InitAllTimers(struct odm_dm_struct *pDM_Odm); - -void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm); - -void ODM_ReleaseAllTimers(struct odm_dm_struct *pDM_Odm); - -void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm); - -void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, - u32 PWDBAll, bool isCCKrate); - -void ODM_SingleDualAntennaDefaultSetting(struct odm_dm_struct *pDM_Odm); - -bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode); - -void odm_dtc(struct odm_dm_struct *pDM_Odm); +void ODM_DMInit(struct odm_dm_struct *pDM_Odm); +void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm); +void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI); #endif diff --git a/include/odm_HWConfig.h b/include/odm_HWConfig.h index 2c48abf..1de4e63 100644 --- a/include/odm_HWConfig.h +++ b/include/odm_HWConfig.h @@ -111,8 +111,7 @@ void odm_Init_RSSIForDM(struct odm_dm_struct *pDM_Odm); void ODM_PhyStatusQuery(struct odm_dm_struct *pDM_Odm, struct odm_phy_status_info *pPhyInfo, u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo, - struct adapter *adapt); + struct odm_per_pkt_info *pPktinfo); void ODM_MacStatusQuery(struct odm_dm_struct *pDM_Odm, u8 *pMacStatus, @@ -121,13 +120,7 @@ void ODM_MacStatusQuery(struct odm_dm_struct *pDM_Odm, bool bPacketToSelf, bool bPacketBeacon); -enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *pDM_Odm, - enum ODM_RF_RADIO_PATH Content, - enum ODM_RF_RADIO_PATH eRFPath); - enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *pDM_Odm, enum odm_bb_config_type ConfigType); -enum HAL_STATUS ODM_ConfigMACWithHeaderFile(struct odm_dm_struct *pDM_Odm); - #endif diff --git a/include/odm_RTL8188E.h b/include/odm_RTL8188E.h index f96ad5a..14dce6c 100644 --- a/include/odm_RTL8188E.h +++ b/include/odm_RTL8188E.h @@ -29,17 +29,17 @@ void ODM_DIG_LowerBound_88E(struct odm_dm_struct *pDM_Odm); -void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *pDM_Odm); +void rtl88eu_dm_antenna_div_init(struct odm_dm_struct *dm_odm); -void ODM_AntennaDiversity_88E(struct odm_dm_struct *pDM_Odm); +void rtl88eu_dm_antenna_diversity(struct odm_dm_struct *dm_odm); -void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *pDM_Odm, u8 *pDesc, - u8 macId); +void rtl88eu_dm_set_tx_ant_by_tx_info(struct odm_dm_struct *dm_odm, u8 *desc, + u8 mac_id); -void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *pDM_Odm, u8 Ant); +void rtl88eu_dm_update_rx_idle_ant(struct odm_dm_struct *dm_odm, u8 ant); -void ODM_AntselStatistics_88E(struct odm_dm_struct *pDM_Odm, u8 antsel_tr_mux, - u32 MacId, u8 RxPWDBAll); +void rtl88eu_dm_ant_sel_statistics(struct odm_dm_struct *dm_odm, u8 antsel_tr_mux, + u32 mac_id, u8 rx_pwdb_all); void odm_FastAntTraining(struct odm_dm_struct *pDM_Odm); @@ -47,10 +47,6 @@ void odm_FastAntTrainingCallback(struct odm_dm_struct *pDM_Odm); void odm_FastAntTrainingWorkItemCallback(struct odm_dm_struct *pDM_Odm); -void odm_PrimaryCCA_Init(struct odm_dm_struct *pDM_Odm); - bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *pDM_Odm); -void odm_DynamicPrimaryCCA(struct odm_dm_struct *pDM_Odm); - #endif diff --git a/include/odm_debug.h b/include/odm_debug.h index 622f4c1..914f831 100644 --- a/include/odm_debug.h +++ b/include/odm_debug.h @@ -83,9 +83,8 @@ #define ODM_COMP_INIT BIT31 /*------------------------Export Marco Definition---------------------------*/ -#define DbgPrint pr_info #define RT_PRINTK(fmt, args...) \ - DbgPrint( "%s(): " fmt, __func__, ## args); + pr_info("%s(): " fmt, __func__, ## args); #ifndef ASSERT #define ASSERT(expr) @@ -94,51 +93,18 @@ #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ if (((comp) & pDM_Odm->DebugComponents) && \ (level <= pDM_Odm->DebugLevel)) { \ - if (pDM_Odm->SupportICType == ODM_RTL8192C) \ - DbgPrint("[ODM-92C] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8192D) \ - DbgPrint("[ODM-92D] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8723A) \ - DbgPrint("[ODM-8723A] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8188E) \ - DbgPrint("[ODM-8188E] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8812) \ - DbgPrint("[ODM-8812] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8821) \ - DbgPrint("[ODM-8821] "); \ - RT_PRINTK fmt; \ - } - -#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ - if (((comp) & pDM_Odm->DebugComponents) && \ - (level <= pDM_Odm->DebugLevel)) { \ + pr_info("[ODM-8188E] "); \ RT_PRINTK fmt; \ } #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ if (!(expr)) { \ - DbgPrint( "Assertion failed! %s at ......\n", #expr); \ - DbgPrint( " ......%s,%s,line=%d\n", __FILE__, \ + pr_info("Assertion failed! %s at ......\n", #expr); \ + pr_info(" ......%s,%s,line=%d\n", __FILE__, \ __func__, __LINE__); \ RT_PRINTK fmt; \ ASSERT(false); \ } -#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); } -#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } -#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } - -#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ - if (((comp) & pDM_Odm->DebugComponents) && \ - (level <= pDM_Odm->DebugLevel)) { \ - int __i; \ - u8 *__ptr = (u8 *)ptr; \ - DbgPrint("[ODM] "); \ - DbgPrint(title_str); \ - DbgPrint(" "); \ - for (__i = 0; __i < 6; __i++) \ - DbgPrint("%02X%s", __ptr[__i], (__i==5)?"":"-");\ - DbgPrint("\n"); \ - } void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); diff --git a/include/odm_precomp.h b/include/odm_precomp.h index d1d95f4..0f236da 100644 --- a/include/odm_precomp.h +++ b/include/odm_precomp.h @@ -30,29 +30,20 @@ #include #include #include +#include /* 2 OutSrc Header Files */ #include "odm.h" #include "odm_HWConfig.h" #include "odm_debug.h" -#include "odm_RegDefine11AC.h" #include "odm_RegDefine11N.h" -#include "HalPhyRf.h" -#include "HalPhyRf_8188e.h"/* for IQK,LCK,Power-tracking */ #include "Hal8188ERateAdaptive.h"/* for RA,Power training */ #include "rtl8188e_hal.h" -#include "odm_interface.h" #include "odm_reg.h" -#include "HalHWImg8188E_MAC.h" -#include "HalHWImg8188E_RF.h" -#include "HalHWImg8188E_BB.h" -#include "Hal8188EReg.h" - -#include "odm_RegConfig8188E.h" #include "odm_RTL8188E.h" void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm); @@ -64,7 +55,6 @@ void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm); void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm); void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm); void odm_SwAntDivInit_NIC(struct odm_dm_struct *pDM_Odm); -void odm_GlobalAdapterCheck(void); void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm); void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm); void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm); @@ -74,24 +64,17 @@ void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm); void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm); void odm_SwAntDivChkAntSwitch(struct odm_dm_struct *pDM_Odm, u8 Step); void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm); -void odm_DynamicTxPower(struct odm_dm_struct *pDM_Odm); void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm); -void odm_SwAntDivInit(struct odm_dm_struct *pDM_Odm); void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm); void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm); void odm_1R_CCA(struct odm_dm_struct *pDM_Odm); void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm); void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm); void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm); -void odm_DynamicTxPowerAP(struct odm_dm_struct *pDM_Odm); -void odm_RSSIMonitorCheckMP(struct odm_dm_struct *pDM_Odm); void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm); -void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm); void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm); void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm); void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm); -void odm_TXPowerTrackingCheckMP(struct odm_dm_struct *pDM_Odm); -void odm_TXPowerTrackingCheckAP(struct odm_dm_struct *pDM_Odm); void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm); void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm); diff --git a/include/odm_types.h b/include/odm_types.h index 78ee2ba..c1355b9 100644 --- a/include/odm_types.h +++ b/include/odm_types.h @@ -20,31 +20,13 @@ #ifndef __ODM_TYPES_H__ #define __ODM_TYPES_H__ -/* */ -/* Define Different SW team support */ -/* */ -#define ODM_AP 0x01 /* BIT0 */ -#define ODM_ADSL 0x02 /* BIT1 */ #define ODM_CE 0x04 /* BIT2 */ -#define ODM_MP 0x08 /* BIT3 */ - -#define RT_PCI_INTERFACE 1 -#define RT_USB_INTERFACE 2 -#define RT_SDIO_INTERFACE 3 enum HAL_STATUS { HAL_STATUS_SUCCESS, HAL_STATUS_FAILURE, }; -enum RT_SPINLOCK_TYPE { - RT_TEMP = 1, -}; - -#include - -#define DEV_BUS_TYPE RT_USB_INTERFACE - #define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 24, 1, __Value) #define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ @@ -52,11 +34,4 @@ enum RT_SPINLOCK_TYPE { #define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ SET_BITS_TO_LE_4BYTE(__pTxDesc+28, 29, 1, __Value) -/* define useless flag to avoid compile warning */ -#define USE_WORKITEM 0 -#define FOR_BRAZIL_PRETEST 0 -#define BT_30_SUPPORT 0 -#define FPGA_TWO_MAC_VERIFICATION 0 - - #endif /* __ODM_TYPES_H__ */ diff --git a/include/osdep_intf.h b/include/osdep_intf.h index c4599c5..efa7868 100644 --- a/include/osdep_intf.h +++ b/include/osdep_intf.h @@ -24,38 +24,8 @@ #include #include -struct intf_priv { - u8 *intf_dev; - u32 max_iosz; /* USB2.0: 128, USB1.1: 64, SDIO:64 */ - u32 max_xmitsz; /* USB2.0: unlimited, SDIO:512 */ - u32 max_recvsz; /* USB2.0: unlimited, SDIO:512 */ - - u8 *io_rwmem; - u8 *allocated_io_rwmem; - u32 io_wsz; /* unit: 4bytes */ - u32 io_rsz;/* unit: 4bytes */ - u8 intf_status; - - void (*_bus_io)(u8 *priv); - -/* -Under Sync. IRP (SDIO/USB) -A protection mechanism is necessary for the io_rwmem(read/write protocol) - -Under Async. IRP (SDIO/USB) -The protection mechanism is through the pending queue. -*/ - struct mutex ioctl_mutex; - /* when in USB, IO is through interrupt in/out endpoints */ - struct usb_device *udev; - struct urb *piorw_urb; - u8 io_irp_cnt; - u8 bio_irp_pending; - struct semaphore io_retevt; - struct timer_list io_timer; - u8 bio_irp_timeout; - u8 bio_timer_cancel; -}; +extern char *rtw_initmac; +extern int rtw_mc2u_disable; u8 rtw_init_drv_sw(struct adapter *padapter); u8 rtw_free_drv_sw(struct adapter *padapter); @@ -73,11 +43,9 @@ u16 rtw_recv_select_queue(struct sk_buff *skb); void rtw_proc_init_one(struct net_device *dev); void rtw_proc_remove_one(struct net_device *dev); +int pm_netdev_open(struct net_device *pnetdev, u8 bnormal); void rtw_ips_dev_unload(struct adapter *padapter); - int rtw_ips_pwr_up(struct adapter *padapter); void rtw_ips_pwr_down(struct adapter *padapter); -int rtw_hw_suspend(struct adapter *padapter); -int rtw_hw_resume(struct adapter *padapter); #endif /* _OSDEP_INTF_H_ */ diff --git a/include/osdep_service.h b/include/osdep_service.h index dfa3a57..82f58f8 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -24,13 +24,12 @@ #define _FAIL 0 #define _SUCCESS 1 -#define RTW_RX_HANDLED 2 +#define RTW_RX_HANDLED 2 #include #include #include #include -#include #include #include #include @@ -39,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,54 +62,13 @@ struct __queue { spinlock_t lock; }; -#define thread_exit() complete_and_exit(NULL, 0) - -static inline struct list_head *get_next(struct list_head *list) -{ - return list->next; -} - static inline struct list_head *get_list_head(struct __queue *queue) { - return (&(queue->queue)); + return &(queue->queue); } - -#define LIST_CONTAINOR(ptr, type, member) \ - ((type *)((char *)(ptr)-(size_t)(&((type *)0)->member))) - - -static inline void _enter_critical(spinlock_t *plock, unsigned long *pirqL) -{ - spin_lock_irqsave(plock, *pirqL); -} - -static inline void _exit_critical(spinlock_t *plock, unsigned long *pirqL) -{ - spin_unlock_irqrestore(plock, *pirqL); -} - -static inline void _enter_critical_ex(spinlock_t *plock, unsigned long *pirqL) -{ - spin_lock_irqsave(plock, *pirqL); -} - -static inline void _exit_critical_ex(spinlock_t *plock, unsigned long *pirqL) -{ - spin_unlock_irqrestore(plock, *pirqL); -} - -static inline void _enter_critical_bh(spinlock_t *plock, unsigned long *pirqL) -{ - spin_lock_bh(plock); -} - -static inline void _exit_critical_bh(spinlock_t *plock, unsigned long *pirqL) -{ - spin_unlock_bh(plock); -} - -static inline int _enter_critical_mutex(struct mutex *pmutex, unsigned long *pirqL) +static inline int _enter_critical_mutex(struct mutex *pmutex, + unsigned long *pirqL) { int ret; @@ -118,70 +76,24 @@ static inline int _enter_critical_mutex(struct mutex *pmutex, unsigned long *pir return ret; } - -static inline void _exit_critical_mutex(struct mutex *pmutex, unsigned long *pirqL) -{ - mutex_unlock(pmutex); -} - -static inline void rtw_list_delete(struct list_head *plist) -{ - list_del_init(plist); -} - -static inline void _init_timer(struct timer_list *ptimer,struct net_device *nic_hdl,void *pfunc,void* cntx) +static inline void _init_timer(struct timer_list *ptimer, + struct net_device *nic_hdl, + void *pfunc, void *cntx) { ptimer->function = pfunc; ptimer->data = (unsigned long)cntx; init_timer(ptimer); } -static inline void _set_timer(struct timer_list *ptimer,u32 delay_time) +static inline void _set_timer(struct timer_list *ptimer, u32 delay_time) { mod_timer(ptimer , (jiffies+(delay_time*HZ/1000))); } -static inline void _cancel_timer(struct timer_list *ptimer,u8 *bcancelled) -{ - del_timer_sync(ptimer); - *bcancelled= true;/* true ==1; false==0 */ -} - #define RTW_TIMER_HDL_ARGS void *FunctionContext #define RTW_TIMER_HDL_NAME(name) rtw_##name##_timer_hdl -#define RTW_DECLARE_TIMER_HDL(name) void RTW_TIMER_HDL_NAME(name)(RTW_TIMER_HDL_ARGS) - -static inline void _init_workitem(struct work_struct *pwork, void *pfunc, void * cntx) -{ - INIT_WORK(pwork, pfunc); -} - -static inline void _set_workitem(struct work_struct *pwork) -{ - schedule_work(pwork); -} - -static inline void _cancel_workitem_sync(struct work_struct *pwork) -{ - cancel_work_sync(pwork); -} -/* */ -/* Global Mutex: can only be used at PASSIVE level. */ -/* */ - -#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ - while (atomic_inc_return((atomic_t *)&(_MutexCounter)) != 1)\ - { \ - atomic_dec((atomic_t *)&(_MutexCounter)); \ - msleep(10); \ - } \ -} - -#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ -{ \ - atomic_dec((atomic_t *)&(_MutexCounter)); \ -} +#define RTW_DECLARE_TIMER_HDL(name) \ + void RTW_TIMER_HDL_NAME(name)(RTW_TIMER_HDL_ARGS) static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) { @@ -191,24 +103,6 @@ static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)); } -static inline void rtw_netif_wake_queue(struct net_device *pnetdev) -{ - netif_tx_wake_all_queues(pnetdev); -} - -static inline void rtw_netif_start_queue(struct net_device *pnetdev) -{ - netif_tx_start_all_queues(pnetdev); -} - -static inline void rtw_netif_stop_queue(struct net_device *pnetdev) -{ - netif_tx_stop_all_queues(pnetdev); -} - -#ifndef BIT - #define BIT(x) ( 1 << (x)) -#endif #define BIT0 0x00000001 #define BIT1 0x00000002 @@ -250,185 +144,17 @@ static inline void rtw_netif_stop_queue(struct net_device *pnetdev) extern int RTW_STATUS_CODE(int error_code); -/* flags used for rtw_update_mem_stat() */ -enum { - MEM_STAT_VIR_ALLOC_SUCCESS, - MEM_STAT_VIR_ALLOC_FAIL, - MEM_STAT_VIR_FREE, - MEM_STAT_PHY_ALLOC_SUCCESS, - MEM_STAT_PHY_ALLOC_FAIL, - MEM_STAT_PHY_FREE, - MEM_STAT_TX, /* used to distinguish TX/RX, asigned from caller */ - MEM_STAT_TX_ALLOC_SUCCESS, - MEM_STAT_TX_ALLOC_FAIL, - MEM_STAT_TX_FREE, - MEM_STAT_RX, /* used to distinguish TX/RX, asigned from caller */ - MEM_STAT_RX_ALLOC_SUCCESS, - MEM_STAT_RX_ALLOC_FAIL, - MEM_STAT_RX_FREE -}; - -extern unsigned char MCS_rate_2R[16]; -extern unsigned char MCS_rate_1R[16]; -extern unsigned char RTW_WPA_OUI[]; -extern unsigned char WPA_TKIP_CIPHER[4]; -extern unsigned char RSN_TKIP_CIPHER[4]; - #define rtw_update_mem_stat(flag, sz) do {} while (0) -u8 *_rtw_vmalloc(u32 sz); -u8 *_rtw_zvmalloc(u32 sz); -void _rtw_vmfree(u8 *pbuf, u32 sz); -u8 *_rtw_zmalloc(u32 sz); u8 *_rtw_malloc(u32 sz); -void _rtw_mfree(u8 *pbuf, u32 sz); -#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) -#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) -#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) #define rtw_malloc(sz) _rtw_malloc((sz)) -#define rtw_zmalloc(sz) _rtw_zmalloc((sz)) -#define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) void *rtw_malloc2d(int h, int w, int size); -void rtw_mfree2d(void *pbuf, int h, int w, int size); -void _rtw_memcpy(void *dec, void *sour, u32 sz); -int _rtw_memcmp(void *dst, void *src, u32 sz); -void _rtw_memset(void *pbuf, int c, u32 sz); - -void _rtw_init_listhead(struct list_head *list); -u32 rtw_is_list_empty(struct list_head *phead); -void rtw_list_insert_head(struct list_head *plist, struct list_head *phead); -void rtw_list_insert_tail(struct list_head *plist, struct list_head *phead); -void rtw_list_delete(struct list_head *plist); - -void _rtw_init_sema(struct semaphore *sema, int init_val); -void _rtw_free_sema(struct semaphore *sema); -void _rtw_up_sema(struct semaphore *sema); u32 _rtw_down_sema(struct semaphore *sema); -void _rtw_mutex_init(struct mutex *pmutex); -void _rtw_mutex_free(struct mutex *pmutex); -void _rtw_spinlock_init(spinlock_t *plock); -void _rtw_spinlock_free(spinlock_t *plock); void _rtw_init_queue(struct __queue *pqueue); -u32 _rtw_queue_empty(struct __queue *pqueue); -u32 rtw_end_of_queue_search(struct list_head *queue, struct list_head *pelement); -u32 rtw_get_current_time(void); -u32 rtw_systime_to_ms(u32 systime); -u32 rtw_ms_to_systime(u32 ms); s32 rtw_get_passing_time_ms(u32 start); -s32 rtw_get_time_interval_ms(u32 start, u32 end); - -void rtw_sleep_schedulable(int ms); - -void rtw_msleep_os(int ms); -void rtw_usleep_os(int us); - -u32 rtw_atoi(u8 *s); - -void rtw_mdelay_os(int ms); -void rtw_udelay_os(int us); - -void rtw_yield_os(void); - -static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) -{ - return del_timer_sync(ptimer); -} - -static __inline void thread_enter(char *name) -{ -#ifdef daemonize - daemonize("%s", name); -#endif - allow_signal(SIGTERM); -} - -static inline void flush_signals_thread(void) -{ - if (signal_pending (current)) - flush_signals(current); -} - -static inline int res_to_status(int res) -{ - return res; -} - -#define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r)) -#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0: 1)) << 2) - -static inline u32 _RND4(u32 sz) -{ - u32 val; - - val = ((sz >> 2) + ((sz & 3) ? 1: 0)) << 2; - return val; -} - -static inline u32 _RND8(u32 sz) -{ - u32 val; - - val = ((sz >> 3) + ((sz & 7) ? 1: 0)) << 3; - return val; -} - -static inline u32 _RND128(u32 sz) -{ - u32 val; - - val = ((sz >> 7) + ((sz & 127) ? 1: 0)) << 7; - return val; -} - -static inline u32 _RND256(u32 sz) -{ - u32 val; - - val = ((sz >> 8) + ((sz & 255) ? 1: 0)) << 8; - return val; -} - -static inline u32 _RND512(u32 sz) -{ - u32 val; - - val = ((sz >> 9) + ((sz & 511) ? 1: 0)) << 9; - return val; -} - -static inline u32 bitshift(u32 bitmask) -{ - u32 i; - - for (i = 0; i <= 31; i++) - if (((bitmask>>i) & 0x1) == 1) break; - return i; -} - -/* limitation of path length */ -#define PATH_LENGTH_MAX PATH_MAX - -void rtw_suspend_lock_init(void); -void rtw_suspend_lock_uninit(void); -void rtw_lock_suspend(void); -void rtw_unlock_suspend(void); - -/* Atomic integer operations */ -#define ATOMIC_T atomic_t - -void ATOMIC_SET(ATOMIC_T *v, int i); -int ATOMIC_READ(ATOMIC_T *v); -void ATOMIC_ADD(ATOMIC_T *v, int i); -void ATOMIC_SUB(ATOMIC_T *v, int i); -void ATOMIC_INC(ATOMIC_T *v); -void ATOMIC_DEC(ATOMIC_T *v); -int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i); -int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i); -int ATOMIC_INC_RETURN(ATOMIC_T *v); -int ATOMIC_DEC_RETURN(ATOMIC_T *v); struct rtw_netdev_priv_indicator { void *priv; @@ -436,7 +162,6 @@ struct rtw_netdev_priv_indicator { }; struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv); -struct net_device *rtw_alloc_etherdev(int sizeof_priv); #define rtw_netdev_priv(netdev) \ (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv) @@ -451,92 +176,15 @@ void rtw_free_netdev(struct net_device *netdev); #define FUNC_ADPT_FMT "%s(%s)" #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name -#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1) +#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1) u64 rtw_modular64(u64 x, u64 y); -u64 rtw_division64(u64 x, u64 y); /* Macros for handling unaligned memory accesses */ -#define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1])) -#define RTW_PUT_BE16(a, val) \ - do { \ - (a)[0] = ((u16) (val)) >> 8; \ - (a)[1] = ((u16) (val)) & 0xff; \ - } while (0) - -#define RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0])) -#define RTW_PUT_LE16(a, val) \ - do { \ - (a)[1] = ((u16) (val)) >> 8; \ - (a)[0] = ((u16) (val)) & 0xff; \ - } while (0) - -#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ - ((u32) (a)[2])) -#define RTW_PUT_BE24(a, val) \ - do { \ - (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[2] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ - (((u32) (a)[2]) << 8) | ((u32) (a)[3])) -#define RTW_PUT_BE32(a, val) \ - do { \ - (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[3] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \ - (((u32) (a)[1]) << 8) | ((u32) (a)[0])) -#define RTW_PUT_LE32(a, val) \ - do { \ - (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[0] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \ - (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \ - (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \ - (((u64) (a)[6]) << 8) | ((u64) (a)[7])) -#define RTW_PUT_BE64(a, val) \ - do { \ - (a)[0] = (u8) (((u64) (val)) >> 56); \ - (a)[1] = (u8) (((u64) (val)) >> 48); \ - (a)[2] = (u8) (((u64) (val)) >> 40); \ - (a)[3] = (u8) (((u64) (val)) >> 32); \ - (a)[4] = (u8) (((u64) (val)) >> 24); \ - (a)[5] = (u8) (((u64) (val)) >> 16); \ - (a)[6] = (u8) (((u64) (val)) >> 8); \ - (a)[7] = (u8) (((u64) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \ - (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \ - (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ - (((u64) (a)[1]) << 8) | ((u64) (a)[0])) +#define RTW_GET_BE24(a) ((((u32)(a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ + ((u32)(a)[2])) void rtw_buf_free(u8 **buf, u32 *buf_len); void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); - -struct rtw_cbuf { - u32 write; - u32 read; - u32 size; - void *bufs[0]; -}; - -bool rtw_cbuf_full(struct rtw_cbuf *cbuf); -bool rtw_cbuf_empty(struct rtw_cbuf *cbuf); -bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf); -void *rtw_cbuf_pop(struct rtw_cbuf *cbuf); -struct rtw_cbuf *rtw_cbuf_alloc(u32 size); -int wifirate2_ratetbl_inx(unsigned char rate); - #endif diff --git a/include/phy.h b/include/phy.h new file mode 100644 index 0000000..9a9ab82 --- /dev/null +++ b/include/phy.h @@ -0,0 +1,30 @@ +#include + +#define IQK_DELAY_TIME_88E 10 +#define index_mapping_NUM_88E 15 +#define AVG_THERMAL_NUM_88E 4 +#define ODM_TARGET_CHNL_NUM_2G_5G 59 + +bool rtl88eu_phy_mac_config(struct adapter *adapt); +bool rtl88eu_phy_rf_config(struct adapter *adapt); +bool rtl88eu_phy_bb_config(struct adapter *adapt); + +u32 phy_query_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask); +void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data); +u32 phy_query_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path, + u32 reg_addr, u32 bit_mask); +void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path, + u32 reg_addr, u32 bit_mask, u32 data); + +void phy_set_tx_power_level(struct adapter *adapt, u8 channel); + +void phy_set_bw_mode(struct adapter *adapt, enum ht_channel_width bandwidth, + unsigned char offset); +void phy_sw_chnl(struct adapter *adapt, u8 channel); + +void rtl88eu_dm_txpower_track_adjust(struct odm_dm_struct *dm_odm, + u8 type, u8 *dir, u32 *out_write); + +void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt); +void rtl88eu_phy_iq_calibrate(struct adapter *adapter, bool recovery); +void rtl88eu_phy_lc_calibrate(struct adapter *adapter); diff --git a/include/pwrseq.h b/include/pwrseq.h new file mode 100644 index 0000000..43db92d --- /dev/null +++ b/include/pwrseq.h @@ -0,0 +1,341 @@ + +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HAL8188EPWRSEQ_H__ +#define __HAL8188EPWRSEQ_H__ + +#include "pwrseqcmd.h" + +/* + Check document WM-20110607-Paul-RTL8188E_Power_Architecture-R02.vsd + There are 6 HW Power States: + 0: POFF--Power Off + 1: PDN--Power Down + 2: CARDEMU--Card Emulation + 3: ACT--Active Mode + 4: LPS--Low Power State + 5: SUS--Suspend + + The transision from different states are defined below + TRANS_CARDEMU_TO_ACT + TRANS_ACT_TO_CARDEMU + TRANS_CARDEMU_TO_SUS + TRANS_SUS_TO_CARDEMU + TRANS_CARDEMU_TO_PDN + TRANS_ACT_TO_LPS + TRANS_LPS_TO_ACT + + TRANS_END + + PWR SEQ Version: rtl8188E_PwrSeq_V09.h +*/ +#define RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS 10 +#define RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS 10 +#define RTL8188E_TRANS_SUS_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS 10 +#define RTL8188E_TRANS_PDN_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_ACT_TO_LPS_STEPS 15 +#define RTL8188E_TRANS_LPS_TO_ACT_STEPS 15 +#define RTL8188E_TRANS_END_STEPS 1 + + +#define RTL8188E_TRANS_CARDEMU_TO_ACT \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value + * }, + * comment here + */ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, BIT1}, \ + /* wait till 0x04[17] = 1 power ready*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0|BIT1, 0}, \ + /* 0x02[1:0] = 0 reset BB*/ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, \ + /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0}, \ + /* 0x04[15] = 0 disable HWPDN (control by DRV)*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4|BIT3, 0}, \ + /*0x04[12:11] = 2b'00 disable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, BIT0}, \ + /*0x04[8] = 1 polling until return 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT0, 0}, \ + /*wait till 0x04[8] = 0*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, \ + /*LDO normal mode*/ \ + {0x0074, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, \ + /*SDIO Driving*/ + +#define RTL8188E_TRANS_ACT_TO_CARDEMU \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value + * }, + * comments here + */ \ + {0x001F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, \ + /*0x1F[7:0] = 0 turn off RF*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, \ + /*LDO Sleep mode*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, \ + /*0x04[9] = 1 turn off MAC by HW state machine*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, 0}, \ + /*wait till 0x04[9] = 0 polling until return 0 to disable*/ + +#define RTL8188E_TRANS_CARDEMU_TO_SUS \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, BIT3|BIT4, BIT3}, \ + /* 0x04[12:11] = 2b'01enable WL suspend */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3|BIT4}, \ + /* 0x04[12:11] = 2b'11enable WL suspend for PCIe */ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, 0xFF, BIT7}, \ + /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */\ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, BIT4, 0}, \ + /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, BIT4, BIT4}, \ + /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, \ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, \ + /*wait power state to suspend*/ + +#define RTL8188E_TRANS_SUS_TO_CARDEMU \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, \ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, \ + /*wait power state to suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, \ + /*0x04[12:11] = 2b'01enable WL suspend*/ + +#define RTL8188E_TRANS_CARDEMU_TO_CARDDIS \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, \ + /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, BIT3|BIT4, BIT3}, \ + /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, 0xFF, 0}, \ + /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */\ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, BIT4, 0}, \ + /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, \ + /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, \ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, \ + /*wait power state to suspend*/ + +#define RTL8188E_TRANS_CARDDIS_TO_CARDEMU \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, \ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, \ + /*wait power state to suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, \ + /*0x04[12:11] = 2b'01enable WL suspend*/ + +#define RTL8188E_TRANS_CARDEMU_TO_PDN \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0}, \ + /* 0x04[16] = 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, \ + /* 0x04[15] = 1*/ + +#define RTL8188E_TRANS_PDN_TO_CARDEMU \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0}, \ + /* 0x04[15] = 0*/ + +/* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */ +#define RTL8188E_TRANS_ACT_TO_LPS \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x7F},/*Tx Pause*/ \ + {0x05F8, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x05F9, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x05FA, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x05FB, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0}, \ + /*CCK and OFDM are disabled,and clock are gated*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, \ + PWRSEQ_DELAY_US},/*Delay 1us*/ \ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x3F},/*Reset MAC TRX*/ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, 0},/*check if removed later*/\ + {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT5, BIT5}, \ + /*Respond TxOK to scheduler*/ + + +#define RTL8188E_TRANS_LPS_TO_ACT \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0x0080, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO, PWR_CMD_WRITE, 0xFF, 0x84}, /*SDIO RPWM*/ \ + {0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*USB RPWM*/ \ + {0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*PCIe RPWM*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, /*Delay*/ \ + {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, \ + /* 0x08[4] = 0 switch TSF to 40M */ \ + {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT7, 0}, \ + /* Polling 0x109[7]=0 TSF in 40M */ \ + {0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT6|BIT7, 0}, \ + /* 0x29[7:6] = 2b'00 enable BB clock */ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, \ + /* 0x101[1] = 1 */ \ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF}, \ + /* 0x100[7:0] = 0xFF enable WMAC TRX */ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1|BIT0, BIT1|BIT0}, \ + /* 0x02[1:0] = 2b'11 enable BB macro */ \ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ + +#define RTL8188E_TRANS_END \ + /* format + * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, + * value }, + * comments here + */ \ + {0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, 0, \ + PWR_CMD_END, 0, 0}, + + +extern struct wl_pwr_cfg rtl8188E_power_on_flow + [RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_radio_off_flow + [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_card_disable_flow + [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_card_enable_flow + [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_suspend_flow[ + RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_resume_flow + [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_hwpdn_flow + [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_enter_lps_flow + [RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_leave_lps_flow + [RTL8188E_TRANS_LPS_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS]; + +#endif /* __HAL8188EPWRSEQ_H__ */ diff --git a/include/pwrseqcmd.h b/include/pwrseqcmd.h new file mode 100644 index 0000000..980a497 --- /dev/null +++ b/include/pwrseqcmd.h @@ -0,0 +1,90 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HALPWRSEQCMD_H__ +#define __HALPWRSEQCMD_H__ + +#include + +/* The value of cmd: 4 bits */ +#define PWR_CMD_READ 0x00 +#define PWR_CMD_WRITE 0x01 +#define PWR_CMD_POLLING 0x02 +#define PWR_CMD_DELAY 0x03 +#define PWR_CMD_END 0x04 + +/* The value of base: 4 bits */ +/* define the base address of each block */ +#define PWR_BASEADDR_MAC 0x00 +#define PWR_BASEADDR_USB 0x01 +#define PWR_BASEADDR_PCIE 0x02 +#define PWR_BASEADDR_SDIO 0x03 + +/* The value of interface_msk: 4 bits */ +#define PWR_INTF_SDIO_MSK BIT(0) +#define PWR_INTF_USB_MSK BIT(1) +#define PWR_INTF_PCI_MSK BIT(2) +#define PWR_INTF_ALL_MSK (BIT(0)|BIT(1)|BIT(2)|BIT(3)) + +/* The value of fab_msk: 4 bits */ +#define PWR_FAB_TSMC_MSK BIT(0) +#define PWR_FAB_UMC_MSK BIT(1) +#define PWR_FAB_ALL_MSK (BIT(0)|BIT(1)|BIT(2)|BIT(3)) + +/* The value of cut_msk: 8 bits */ +#define PWR_CUT_TESTCHIP_MSK BIT(0) +#define PWR_CUT_A_MSK BIT(1) +#define PWR_CUT_B_MSK BIT(2) +#define PWR_CUT_C_MSK BIT(3) +#define PWR_CUT_D_MSK BIT(4) +#define PWR_CUT_E_MSK BIT(5) +#define PWR_CUT_F_MSK BIT(6) +#define PWR_CUT_G_MSK BIT(7) +#define PWR_CUT_ALL_MSK 0xFF + + +enum pwrseq_cmd_delat_unit { + PWRSEQ_DELAY_US, + PWRSEQ_DELAY_MS, +}; + +struct wl_pwr_cfg { + u16 offset; + u8 cut_msk; + u8 fab_msk:4; + u8 interface_msk:4; + u8 base:4; + u8 cmd:4; + u8 msk; + u8 value; +}; + +#define GET_PWR_CFG_OFFSET(__PWR_CMD) __PWR_CMD.offset +#define GET_PWR_CFG_CUT_MASK(__PWR_CMD) __PWR_CMD.cut_msk +#define GET_PWR_CFG_FAB_MASK(__PWR_CMD) __PWR_CMD.fab_msk +#define GET_PWR_CFG_INTF_MASK(__PWR_CMD) __PWR_CMD.interface_msk +#define GET_PWR_CFG_BASE(__PWR_CMD) __PWR_CMD.base +#define GET_PWR_CFG_CMD(__PWR_CMD) __PWR_CMD.cmd +#define GET_PWR_CFG_MASK(__PWR_CMD) __PWR_CMD.msk +#define GET_PWR_CFG_VALUE(__PWR_CMD) __PWR_CMD.value + +u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, + u8 ifacetype, struct wl_pwr_cfg pwrcfgCmd[]); + +#endif diff --git a/include/recv_osdep.h b/include/recv_osdep.h index 6912380..5aabd39 100644 --- a/include/recv_osdep.h +++ b/include/recv_osdep.h @@ -28,27 +28,22 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void _rtw_free_recv_priv(struct recv_priv *precvpriv); -s32 rtw_recv_entry(union recv_frame *precv_frame); -int rtw_recv_indicatepkt(struct adapter *adapter, union recv_frame *recv_frame); +s32 rtw_recv_entry(struct recv_frame *precv_frame); +int rtw_recv_indicatepkt(struct adapter *adapter, + struct recv_frame *recv_frame); void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *retpkt); -void rtw_hostapd_mlme_rx(struct adapter *padapter, union recv_frame *recv_fr); void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void rtw_free_recv_priv(struct recv_priv *precvpriv); -int rtw_os_recv_resource_init(struct recv_priv *recvpr, struct adapter *adapt); -int rtw_os_recv_resource_alloc(struct adapter *adapt, union recv_frame *recvfr); -void rtw_os_recv_resource_free(struct recv_priv *precvpriv); +int rtw_os_recv_resource_alloc(struct adapter *adapt, + struct recv_frame *recvfr); int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); -int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf); - -void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf); void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl); -int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb); int _netdev_open(struct net_device *pnetdev); int netdev_open(struct net_device *pnetdev); int netdev_close(struct net_device *pnetdev); diff --git a/include/rf.h b/include/rf.h new file mode 100644 index 0000000..98a5551 --- /dev/null +++ b/include/rf.h @@ -0,0 +1,11 @@ +#define RF6052_MAX_TX_PWR 0x3F +#define RF6052_MAX_REG 0x3F + +void rtl88eu_phy_rf6052_set_bandwidth(struct adapter *adapt, + enum ht_channel_width bandwidth); +void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, + u8 *powerlevel); +void rtl88eu_phy_rf6052_set_ofdm_txpower(struct adapter *adapt, + u8 *powerlevel_ofdm, + u8 *powerlevel_bw20, + u8 *powerlevel_bw40, u8 channel); diff --git a/include/rtl8188e_cmd.h b/include/rtl8188e_cmd.h index b32bc28..0e78e2a 100644 --- a/include/rtl8188e_cmd.h +++ b/include/rtl8188e_cmd.h @@ -112,11 +112,6 @@ u8 rtl8188e_set_raid_cmd(struct adapter *padapter, u32 mask); void rtl8188e_Add_RateATid(struct adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); -#ifdef CONFIG_88EU_P2P -void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state); -#endif /* CONFIG_88EU_P2P */ - -void CheckFwRsvdPageContent(struct adapter *adapt); void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt); #endif/* __RTL8188E_CMD_H__ */ diff --git a/include/rtl8188e_dm.h b/include/rtl8188e_dm.h index 97a3175..5e0ac31 100644 --- a/include/rtl8188e_dm.h +++ b/include/rtl8188e_dm.h @@ -51,7 +51,6 @@ struct dm_priv { }; void rtl8188e_init_dm_priv(struct adapter *adapt); -void rtl8188e_deinit_dm_priv(struct adapter *adapt); void rtl8188e_InitHalDm(struct adapter *adapt); void rtl8188e_HalDmWatchDog(struct adapter *adapt); diff --git a/include/rtl8188e_hal.h b/include/rtl8188e_hal.h index f81bd66..42ab1d2 100644 --- a/include/rtl8188e_hal.h +++ b/include/rtl8188e_hal.h @@ -25,15 +25,13 @@ #include "rtl8188e_spec.h" #include "Hal8188EPhyReg.h" #include "Hal8188EPhyCfg.h" -#include "rtl8188e_rf.h" #include "rtl8188e_dm.h" #include "rtl8188e_recv.h" #include "rtl8188e_xmit.h" #include "rtl8188e_cmd.h" -#include "Hal8188EPwrSeq.h" -#include "rtl8188e_sreset.h" +#include "pwrseq.h" #include "rtw_efuse.h" - +#include "rtw_sreset.h" #include "odm_precomp.h" /* Fw Array */ @@ -71,45 +69,10 @@ #define MAX_PAGE_SIZE 4096 /* @ page : 4k bytes */ #define IS_FW_HEADER_EXIST(_pFwHdr) \ - ((le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x92C0 || \ - (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88C0 || \ - (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x2300 || \ - (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88E0) - -/* This structure must be careful with byte-ordering */ - -struct rt_firmware_hdr { - /* 8-byte alinment required */ - /* LONG WORD 0 ---- */ - __le16 Signature; /* 92C0: test chip; 92C, - * 88C0: test chip; 88C1: MP A-cut; - * 92C1: MP A-cut */ - u8 Category; /* AP/NIC and USB/PCI */ - u8 Function; /* Reserved for different FW function - * indcation, for further use when - * driver needs to download different - * FW for different conditions */ - __le16 Version; /* FW Version */ - u8 Subversion; /* FW Subversion, default 0x00 */ - u16 Rsvd1; - - /* LONG WORD 1 ---- */ - u8 Month; /* Release time Month field */ - u8 Date; /* Release time Date field */ - u8 Hour; /* Release time Hour field */ - u8 Minute; /* Release time Minute field */ - __le16 RamCodeSize; /* The size of RAM code */ - u8 Foundry; - u8 Rsvd2; - - /* LONG WORD 2 ---- */ - __le32 SvnIdx; /* The SVN entry index */ - u32 Rsvd3; - - /* LONG WORD 3 ---- */ - u32 Rsvd4; - u32 Rsvd5; -}; + ((le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x92C0 || \ + (le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x88C0 || \ + (le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x2300 || \ + (le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x88E0) #define DRIVER_EARLY_INT_TIME 0x05 #define BCN_DMA_ATIME_INT_TIME 0x02 @@ -241,10 +204,10 @@ enum rt_regulator_mode { struct hal_data_8188e { struct HAL_VERSION VersionID; - enum rt_multi_func MultiFunc; /* For multi-function consideration. */ enum rt_regulator_mode RegulatorMode; /* switching regulator or LDO */ u16 CustomerID; - + u8 *pfirmware; + u32 fwsize; u16 FirmwareVersion; u16 FirmwareVersionRev; u16 FirmwareSubVersion; @@ -387,10 +350,6 @@ struct hal_data_8188e { u16 EfuseUsedBytes; -#ifdef CONFIG_88EU_P2P - struct P2P_PS_Offload_t p2p_ps_offload; -#endif - /* Auto FSM to Turn On, include clock, isolation, power control * for MAC only */ u8 bMacPwrCtrlOn; @@ -425,7 +384,6 @@ struct hal_data_8188e { (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS) /* rtl8188e_hal_init.c */ -s32 rtl8188e_FirmwareDownload(struct adapter *padapter); void _8051Reset88E(struct adapter *padapter); void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); @@ -445,9 +403,9 @@ void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail); void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail); -void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter,u8 *PROMContent, +void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail); -void Hal_ReadThermalMeter_88E(struct adapter * dapter, u8 *PROMContent, +void Hal_ReadThermalMeter_88E(struct adapter *dapter, u8 *PROMContent, bool AutoloadFail); void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail); @@ -456,21 +414,16 @@ void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, void Hal_ReadPowerSavingMode88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail); -bool HalDetectPwrDownMode88E(struct adapter *Adapter); - -void Hal_InitChannelPlan(struct adapter *padapter); void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc); /* register */ -void SetBcnCtrlReg(struct adapter *padapter, u8 SetBits, u8 ClearBits); -void rtl8188e_clone_haldata(struct adapter *dst, struct adapter *src); void rtl8188e_start_thread(struct adapter *padapter); void rtl8188e_stop_thread(struct adapter *padapter); -void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int len); +s32 iol_execute(struct adapter *padapter, u8 control); +void iol_mode_enable(struct adapter *padapter, u8 enable); s32 rtl8188e_iol_efuse_patch(struct adapter *padapter); void rtw_cancel_all_timer(struct adapter *padapter); -void _ps_open_RF(struct adapter *adapt); #endif /* __RTL8188E_HAL_H__ */ diff --git a/include/rtl8188e_recv.h b/include/rtl8188e_recv.h index 02ccb40..5fed30d 100644 --- a/include/rtl8188e_recv.h +++ b/include/rtl8188e_recv.h @@ -56,14 +56,14 @@ enum rx_packet_type { }; #define INTERRUPT_MSG_FORMAT_LEN 60 -void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *buf); s32 rtl8188eu_init_recv_priv(struct adapter *padapter); -void rtl8188eu_free_recv_priv(struct adapter * padapter); -void rtl8188eu_recv_hdl(struct adapter * padapter, struct recv_buf *precvbuf); +void rtl8188eu_free_recv_priv(struct adapter *padapter); +void rtl8188eu_recv_hdl(struct adapter *padapter, struct recv_buf *precvbuf); void rtl8188eu_recv_tasklet(void *priv); -void rtl8188e_query_rx_phy_status(union recv_frame *fr, struct phy_stat *phy); -void rtl8188e_process_phy_info(struct adapter * padapter, void *prframe); -void update_recvframe_phyinfo_88e(union recv_frame *fra, struct phy_stat *phy); -void update_recvframe_attrib_88e(union recv_frame *fra, struct recv_stat *stat); +void rtl8188e_query_rx_phy_status(struct recv_frame *fr, struct phy_stat *phy); +void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe); +void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy); +void update_recvframe_attrib_88e(struct recv_frame *fra, + struct recv_stat *stat); #endif diff --git a/include/rtl8188e_spec.h b/include/rtl8188e_spec.h index c12c56b..2c33eb3 100644 --- a/include/rtl8188e_spec.h +++ b/include/rtl8188e_spec.h @@ -68,7 +68,7 @@ #define DISABLE_TRXPKT_BUF_ACCESS 0x0 -/* 0x0000h ~ 0x00FFh System Configuration */ +/* 0x0000h ~ 0x00FFh System Configuration */ #define REG_SYS_ISO_CTRL 0x0000 #define REG_SYS_FUNC_EN 0x0002 #define REG_APS_FSMCO 0x0004 @@ -142,7 +142,7 @@ #define REG_MAC_PHY_CTRL_NORMAL 0x00f8 -/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ +/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ #define REG_CR 0x0100 #define REG_PBP 0x0104 #define REG_PKT_BUFF_ACCESS_CTRL 0x0106 @@ -188,7 +188,7 @@ #define REG_LLT_INIT 0x01E0 -/* 0x0200h ~ 0x027Fh TXDMA Configuration */ +/* 0x0200h ~ 0x027Fh TXDMA Configuration */ #define REG_RQPN 0x0200 #define REG_FIFOPAGE 0x0204 #define REG_TDECTRL 0x0208 @@ -196,12 +196,12 @@ #define REG_TXDMA_STATUS 0x0210 #define REG_RQPN_NPQ 0x0214 -/* 0x0280h ~ 0x02FFh RXDMA Configuration */ +/* 0x0280h ~ 0x02FFh RXDMA Configuration */ #define REG_RXDMA_AGG_PG_TH 0x0280 #define REG_RXPKT_NUM 0x0284 #define REG_RXDMA_STATUS 0x0288 -/* 0x0300h ~ 0x03FFh PCIe */ +/* 0x0300h ~ 0x03FFh PCIe */ #define REG_PCIE_CTRL_REG 0x0300 #define REG_INT_MIG 0x0304 /* Interrupt Migration */ #define REG_BCNQ_DESA 0x0308 /* TX Beacon Descr Address */ @@ -222,7 +222,7 @@ #define REG_PCIE_HISR 0x03A0 /* spec version 11 */ -/* 0x0400h ~ 0x047Fh Protocol Configuration */ +/* 0x0400h ~ 0x047Fh Protocol Configuration */ #define REG_VOQ_INFORMATION 0x0400 #define REG_VIQ_INFORMATION 0x0404 #define REG_BEQ_INFORMATION 0x0408 @@ -276,7 +276,7 @@ #define REG_TX_RPT_TIME 0x04F0 /* 2 byte */ #define REG_DUMMY 0x04FC -/* 0x0500h ~ 0x05FFh EDCA Configuration */ +/* 0x0500h ~ 0x05FFh EDCA Configuration */ #define REG_EDCA_VO_PARAM 0x0500 #define REG_EDCA_VI_PARAM 0x0504 #define REG_EDCA_BE_PARAM 0x0508 @@ -294,16 +294,16 @@ #define REG_DIS_TXREQ_CLR 0x0523 #define REG_RD_CTRL 0x0524 /* Format for offset 540h-542h: */ -/* [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting +/* [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting * beacon content before TBTT. */ -/* [7:4]: Reserved. */ -/* [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding +/* [7:4]: Reserved. */ +/* [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding * to send the beacon packet. */ -/* [23:20]: Reserved */ +/* [23:20]: Reserved */ /* Description: */ -/* | */ +/* | */ /* |<--Setup--|--Hold------------>| */ -/* --------------|---------------------- */ +/* --------------|---------------------- */ /* | */ /* TBTT */ /* Note: We cannot update beacon content to HW or send any AC packets during @@ -335,7 +335,7 @@ #define REG_FW_RESET_TSF_CNT_0 0x05FD #define REG_FW_BCN_DIS_CNT 0x05FE -/* 0x0600h ~ 0x07FFh WMAC Configuration */ +/* 0x0600h ~ 0x07FFh WMAC Configuration */ #define REG_APSD_CTRL 0x0600 #define REG_BWOPMODE 0x0603 #define REG_TCR 0x0604 @@ -382,7 +382,7 @@ #define _RXERR_RPT_SEL(type) ((type) << 28) /* Note: */ -/* The NAV upper value is very important to WiFi 11n 5.2.3 NAV test. +/* The NAV upper value is very important to WiFi 11n 5.2.3 NAV test. * The default value is always too small, but the WiFi TestPlan test * by 25,000 microseconds of NAV through sending CTS in the air. * We must update this value greater than 25,000 microseconds to pass @@ -422,7 +422,7 @@ #define REG_MACID1 0x0700 #define REG_BSSID1 0x0708 -/* 0xFE00h ~ 0xFE55h USB Configuration */ +/* 0xFE00h ~ 0xFE55h USB Configuration */ #define REG_USB_INFO 0xFE17 #define REG_USB_SPECIAL_OPTION 0xFE55 #define REG_USB_DMA_AGG_TO 0xFE5B @@ -689,13 +689,13 @@ Current IOREG MAP 0x0600h ~ 0x07FFh WMAC Configuration (512 Bytes) 0x2000h ~ 0x3FFFh 8051 FW Download Region (8196 Bytes) */ -/* 8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */ +/* 8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */ /* Note: */ -/* The bits of stopping AC(VO/VI/BE/BK) queue in datasheet +/* The bits of stopping AC(VO/VI/BE/BK) queue in datasheet * RTL8192S/RTL8192C are wrong, */ -/* the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, +/* the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, * and BK - Bit3. */ -/* 8723 and 88E may be not correct either in the earlier version. */ +/* 8723 and 88E may be not correct either in the earlier version. */ #define StopBecon BIT6 #define StopHigh BIT5 #define StopMgt BIT4 @@ -733,7 +733,7 @@ Current IOREG MAP #define RCR_MXDMA_OFFSET 8 #define RCR_FIFO_OFFSET 13 -/* 0xFE00h ~ 0xFE55h USB Configuration */ +/* 0xFE00h ~ 0xFE55h USB Configuration */ #define REG_USB_INFO 0xFE17 #define REG_USB_SPECIAL_OPTION 0xFE55 #define REG_USB_DMA_AGG_TO 0xFE5B @@ -743,7 +743,7 @@ Current IOREG MAP #define REG_USB_HRPWM 0xFE58 #define REG_USB_HCPWM 0xFE57 /* 8192C Regsiter Bit and Content definition */ -/* 0x0000h ~ 0x00FFh System Configuration */ +/* 0x0000h ~ 0x00FFh System Configuration */ /* 2 SYS_ISO_CTRL */ #define ISO_MD2PP BIT(0) @@ -914,7 +914,7 @@ Current IOREG MAP /* 2SYS_CFG */ #define RTL_ID BIT(23) /* TestChip ID, 1:Test(RLE); 0:MP(RL) */ -/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ +/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ /* 2 Function Enable Registers */ /* 2 CR */ @@ -975,9 +975,9 @@ Current IOREG MAP #define _TXDMA_HIQ_MAP(x) (((x)&0x3) << 14) #define _TXDMA_MGQ_MAP(x) (((x)&0x3) << 12) #define _TXDMA_BKQ_MAP(x) (((x)&0x3) << 10) -#define _TXDMA_BEQ_MAP(x) (((x)&0x3) << 8 ) -#define _TXDMA_VIQ_MAP(x) (((x)&0x3) << 6 ) -#define _TXDMA_VOQ_MAP(x) (((x)&0x3) << 4 ) +#define _TXDMA_BEQ_MAP(x) (((x)&0x3) << 8) +#define _TXDMA_VIQ_MAP(x) (((x)&0x3) << 6) +#define _TXDMA_VOQ_MAP(x) (((x)&0x3) << 4) #define QUEUE_LOW 1 #define QUEUE_NORMAL 2 @@ -995,7 +995,7 @@ Current IOREG MAP #define _LLT_OP(x) (((x) & 0x3) << 30) #define _LLT_OP_VALUE(x) (((x) >> 30) & 0x3) -/* 0x0200h ~ 0x027Fh TXDMA Configuration */ +/* 0x0200h ~ 0x027Fh TXDMA Configuration */ /* 2RQPN */ #define _HPQ(x) ((x) & 0xFF) #define _LPQ(x) (((x) & 0xFF) << 8) @@ -1019,7 +1019,7 @@ Current IOREG MAP /* 2 TXDMA_OFFSET_CHK */ #define DROP_DATA_EN BIT(9) -/* 0x0280h ~ 0x028Bh RX DMA Configuration */ +/* 0x0280h ~ 0x028Bh RX DMA Configuration */ /* REG_RXDMA_CONTROL, 0x0286h */ @@ -1028,7 +1028,7 @@ Current IOREG MAP #define RXDMA_IDLE BIT(17) #define RW_RELEASE_EN BIT(18) -/* 0x0400h ~ 0x047Fh Protocol Configuration */ +/* 0x0400h ~ 0x047Fh Protocol Configuration */ /* 2 FWHW_TXQ_CTRL */ #define EN_AMPDU_RTY_NEW BIT(7) @@ -1040,7 +1040,7 @@ Current IOREG MAP #define RETRY_LIMIT_SHORT_SHIFT 8 #define RETRY_LIMIT_LONG_SHIFT 0 -/* 0x0500h ~ 0x05FFh EDCA Configuration */ +/* 0x0500h ~ 0x05FFh EDCA Configuration */ /* 2 EDCA setting */ #define AC_PARAM_TXOP_LIMIT_OFFSET 16 @@ -1071,7 +1071,7 @@ Current IOREG MAP #define AcmHw_ViqStatus BIT(5) #define AcmHw_VoqStatus BIT(6) -/* 0x0600h ~ 0x07FFh WMAC Configuration */ +/* 0x0600h ~ 0x07FFh WMAC Configuration */ /* 2APSD_CTRL */ #define APSDOFF BIT(6) #define APSDOFF_STATUS BIT(7) @@ -1128,7 +1128,7 @@ Current IOREG MAP #define SCR_TXBCUSEDK BIT(6) /* Force Tx Bcast pkt Use Default Key */ #define SCR_RXBCUSEDK BIT(7) /* Force Rx Bcast pkt Use Default Key */ -/* RTL8188E SDIO Configuration */ +/* RTL8188E SDIO Configuration */ /* I/O bus domain address mapping */ #define SDIO_LOCAL_BASE 0x10250000 @@ -1264,7 +1264,7 @@ Current IOREG MAP #define SDIO_TX_FREE_PG_QUEUE 4 #define SDIO_TX_FIFO_PAGE_SZ 128 -/* 0xFE00h ~ 0xFE55h USB Configuration */ +/* 0xFE00h ~ 0xFE55h USB Configuration */ /* 2 USB Information (0xFE17) */ #define USB_IS_HIGH_SPEED 0 @@ -1331,7 +1331,7 @@ Current IOREG MAP /* 8192C EEPROM/EFUSE share register definition. */ -/* EEPROM/Efuse PG Offset for 88EE/88EU/88ES */ +/* EEPROM/Efuse PG Offset for 88EE/88EU/88ES */ #define EEPROM_TX_PWR_INX_88E 0x10 #define EEPROM_ChannelPlan_88E 0xB8 @@ -1362,7 +1362,7 @@ Current IOREG MAP /* RTL88ES */ #define EEPROM_MAC_ADDR_88ES 0x11A -/* EEPROM/Efuse Value Type */ +/* EEPROM/Efuse Value Type */ #define EETYPE_TX_PWR 0x0 /* Default Value for EEPROM or EFUSE!!! */ diff --git a/include/rtl8188e_xmit.h b/include/rtl8188e_xmit.h index cf7267a..0b96d42 100644 --- a/include/rtl8188e_xmit.h +++ b/include/rtl8188e_xmit.h @@ -159,7 +159,6 @@ struct txrpt_ccx_88e { void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); -void rtl8188eu_free_xmit_priv(struct adapter *padapter); s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); diff --git a/include/rtw_cmd.h b/include/rtw_cmd.h index 8cafd7a..9e9f5f4 100644 --- a/include/rtw_cmd.h +++ b/include/rtw_cmd.h @@ -24,16 +24,11 @@ #include #include -#define C2H_MEM_SZ (16*1024) - #include #include /* */ -#define FREE_CMDOBJ_SZ 128 - #define MAX_CMDSZ 1024 #define MAX_RSPSZ 512 -#define MAX_EVTSZ 1024 #define CMDBUFF_ALIGN_SZ 512 @@ -52,32 +47,13 @@ struct cmd_priv { struct semaphore cmd_queue_sema; struct semaphore terminate_cmdthread_sema; struct __queue cmd_queue; - u8 cmd_seq; - u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ - u8 *cmd_allocated_buf; - u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ - u8 *rsp_allocated_buf; - u32 cmd_issued_cnt; - u32 cmd_done_cnt; - u32 rsp_cnt; u8 cmdthd_running; struct adapter *padapter; }; -struct evt_priv { - struct work_struct c2h_wk; - bool c2h_wk_alive; - struct rtw_cbuf *c2h_queue; - #define C2H_QUEUE_MAX_LEN 10 - ATOMIC_T event_seq; - u8 *evt_buf; /* shall be non-paged, and 4 bytes aligned */ - u8 *evt_allocated_buf; - u32 evt_done_cnt; -}; - #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \ do {\ - _rtw_init_listhead(&pcmd->list);\ + INIT_LIST_HEAD(&pcmd->list);\ pcmd->cmdcode = code;\ pcmd->parmbuf = (u8 *)(pparm);\ pcmd->cmdsz = sizeof(*pparm);\ @@ -85,31 +61,13 @@ do {\ pcmd->rspsz = 0;\ } while (0) -struct c2h_evt_hdr { - u8 id:4; - u8 plen:4; - u8 seq; - u8 payload[0]; -}; - -#define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen) - u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); -struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv); +struct cmd_obj *rtw_dequeue_cmd(struct __queue *queue); void rtw_free_cmd_obj(struct cmd_obj *pcmd); int rtw_cmd_thread(void *context); -u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); -void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv); - -u32 rtw_init_evt_priv(struct evt_priv *pevtpriv); -void rtw_free_evt_priv(struct evt_priv *pevtpriv); -void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv); -void rtw_evt_notify_isr(struct evt_priv *pevtpriv); -#ifdef CONFIG_88EU_P2P -u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType); -#endif /* CONFIG_88EU_P2P */ +int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); enum rtw_drvextra_cmd_id { NONE_WK_CID, @@ -146,39 +104,6 @@ enum RFINTFS { /* Caller Mode: Infra, Ad-HoC(C) -Notes: To enter USB suspend mode - -Command Mode - -*/ -struct usb_suspend_parm { - u32 action;/* 1: sleep, 0:resume */ -}; - -/* -Caller Mode: Infra, Ad-HoC - -Notes: To join a known BSS. - -Command-Event Mode - -*/ - -/* -Caller Mode: Infra, Ad-Hoc - -Notes: To join the specified bss - -Command Event Mode - -*/ -struct joinbss_parm { - struct wlan_bssid_ex network; -}; - -/* -Caller Mode: Infra, Ad-HoC(C) - Notes: To disconnect the current associated BSS Command Mode @@ -188,17 +113,6 @@ struct disconnect_parm { u32 deauth_timeout_ms; }; -/* -Caller Mode: AP, Ad-HoC(M) - -Notes: To create a BSS - -Command Mode -*/ -struct createbss_parm { - struct wlan_bssid_ex network; -}; - struct setopmode_parm { u8 mode; u8 rsvd[3]; @@ -328,161 +242,6 @@ struct setstapwrstate_parm { u8 hwaddr[6]; }; -/* -Caller Mode: Any - -Notes: To setup the basic rate of RTL8711 - -Command Mode - -*/ -struct setbasicrate_parm { - u8 basicrates[NumRates]; -}; - -/* -Caller Mode: Any - -Notes: To read the current basic rate - -Command-Rsp Mode - -*/ -struct getbasicrate_parm { - u32 rsvd; -}; - -struct getbasicrate_rsp { - u8 basicrates[NumRates]; -}; - -/* -Caller Mode: Any - -Notes: To setup the data rate of RTL8711 - -Command Mode - -*/ -struct setdatarate_parm { - u8 mac_id; - u8 datarates[NumRates]; -}; - -/* -Caller Mode: Any - -Notes: To read the current data rate - -Command-Rsp Mode - -*/ -struct getdatarate_parm { - u32 rsvd; - -}; -struct getdatarate_rsp { - u8 datarates[NumRates]; -}; - -/* -Caller Mode: Any -AP: AP can use the info for the contents of beacon frame -Infra: STA can use the info when sitesurveying -Ad-HoC(M): Like AP -Ad-HoC(C): Like STA - -Notes: To set the phy capability of the NIC - -Command Mode - -*/ - -struct setphyinfo_parm { - struct regulatory_class class_sets[NUM_REGULATORYS]; - u8 status; -}; - -struct getphyinfo_parm { - u32 rsvd; -}; - -struct getphyinfo_rsp { - struct regulatory_class class_sets[NUM_REGULATORYS]; - u8 status; -}; - -/* -Caller Mode: Any - -Notes: To set the channel/modem/band -This command will be used when channel/modem/band is changed. - -Command Mode - -*/ -struct setphy_parm { - u8 rfchannel; - u8 modem; -}; - -/* -Caller Mode: Any - -Notes: To get the current setting of channel/modem/band - -Command-Rsp Mode - -*/ -struct getphy_parm { - u32 rsvd; - -}; -struct getphy_rsp { - u8 rfchannel; - u8 modem; -}; - -struct readBB_parm { - u8 offset; -}; -struct readBB_rsp { - u8 value; -}; - -struct readTSSI_parm { - u8 offset; -}; -struct readTSSI_rsp { - u8 value; -}; - -struct writeBB_parm { - u8 offset; - u8 value; -}; - -struct readRF_parm { - u8 offset; -}; -struct readRF_rsp { - u32 value; -}; - -struct writeRF_parm { - u32 offset; - u32 value; -}; - -struct getrfintfs_parm { - u8 rfintfs; -}; - -struct Tx_Beacon_param -{ - struct wlan_bssid_ex network; -}; - /* Notes: This command is used for H2C/C2H loopback testing @@ -541,167 +300,6 @@ struct drvextra_cmd_parm { unsigned char *pbuf; }; -/*------------------- Below are used for RF/BB tunning ---------------------*/ - -struct setantenna_parm { - u8 tx_antset; - u8 rx_antset; - u8 tx_antenna; - u8 rx_antenna; -}; - -struct enrateadaptive_parm { - u32 en; -}; - -struct settxagctbl_parm { - u32 txagc[MAX_RATES_LENGTH]; -}; - -struct gettxagctbl_parm { - u32 rsvd; -}; -struct gettxagctbl_rsp { - u32 txagc[MAX_RATES_LENGTH]; -}; - -struct setagcctrl_parm { - u32 agcctrl; /* 0: pure hw, 1: fw */ -}; - -struct setssup_parm { - u32 ss_ForceUp[MAX_RATES_LENGTH]; -}; - -struct getssup_parm { - u32 rsvd; -}; - -struct getssup_rsp { - u8 ss_ForceUp[MAX_RATES_LENGTH]; -}; - -struct setssdlevel_parm { - u8 ss_DLevel[MAX_RATES_LENGTH]; -}; - -struct getssdlevel_parm { - u32 rsvd; -}; - -struct getssdlevel_rsp { - u8 ss_DLevel[MAX_RATES_LENGTH]; -}; - -struct setssulevel_parm { - u8 ss_ULevel[MAX_RATES_LENGTH]; -}; - -struct getssulevel_parm { - u32 rsvd; -}; - -struct getssulevel_rsp { - u8 ss_ULevel[MAX_RATES_LENGTH]; -}; - -struct setcountjudge_parm { - u8 count_judge[MAX_RATES_LENGTH]; -}; - -struct getcountjudge_parm { - u32 rsvd; -}; - -struct getcountjudge_rsp { - u8 count_judge[MAX_RATES_LENGTH]; -}; - -struct setratable_parm { - u8 ss_ForceUp[NumRates]; - u8 ss_ULevel[NumRates]; - u8 ss_DLevel[NumRates]; - u8 count_judge[NumRates]; -}; - -struct getratable_parm { - uint rsvd; -}; - -struct getratable_rsp { - u8 ss_ForceUp[NumRates]; - u8 ss_ULevel[NumRates]; - u8 ss_DLevel[NumRates]; - u8 count_judge[NumRates]; -}; - -/* to get TX,RX retry count */ - -struct gettxretrycnt_parm { - unsigned int rsvd; -}; - -struct gettxretrycnt_rsp { - unsigned long tx_retrycnt; -}; - -struct getrxretrycnt_parm { - unsigned int rsvd; -}; - -struct getrxretrycnt_rsp { - unsigned long rx_retrycnt; -}; - -/* to get BCNOK,BCNERR count */ -struct getbcnokcnt_parm { - unsigned int rsvd; -}; - -struct getbcnokcnt_rsp { - unsigned long bcnokcnt; -}; - -struct getbcnerrcnt_parm { - unsigned int rsvd; -}; - -struct getbcnerrcnt_rsp { - unsigned long bcnerrcnt; -}; - -/* to get current TX power level */ -struct getcurtxpwrlevel_parm { - unsigned int rsvd; -}; -struct getcurtxpwrlevel_rspi { - unsigned short tx_power; -}; - -struct setprobereqextraie_parm { - unsigned char e_id; - unsigned char ie_len; - unsigned char ie[0]; -}; - -struct setassocreqextraie_parm { - unsigned char e_id; - unsigned char ie_len; - unsigned char ie[0]; -}; - -struct setproberspextraie_parm { - unsigned char e_id; - unsigned char ie_len; - unsigned char ie[0]; -}; - -struct setassocrspextraie_parm { - unsigned char e_id; - unsigned char ie_len; - unsigned char ie[0]; -}; - struct addBaReq_parm { unsigned int tid; u8 addr[ETH_ALEN]; @@ -715,30 +313,10 @@ struct set_ch_parm { }; /*H2C Handler index: 59 */ -struct SetChannelPlan_param -{ +struct SetChannelPlan_param { u8 channel_plan; }; -/*H2C Handler index: 60 */ -struct LedBlink_param -{ - struct LED_871x *pLed; -}; - -/*H2C Handler index: 61 */ -struct SetChannelSwitch_param -{ - u8 new_ch_no; -}; - -/*H2C Handler index: 62 */ -struct TDLSoption_param -{ - u8 addr[ETH_ALEN]; - u8 option; -}; - #define GEN_CMD_CODE(cmd) cmd ## _CMD_ /* @@ -752,75 +330,46 @@ Result: */ -#define H2C_RSP_OFFSET 512 - #define H2C_SUCCESS 0x00 #define H2C_SUCCESS_RSP 0x01 -#define H2C_DUPLICATED 0x02 #define H2C_DROPPED 0x03 #define H2C_PARAMETERS_ERROR 0x04 #define H2C_REJECTED 0x05 -#define H2C_CMD_OVERFLOW 0x06 -#define H2C_RESERVED 0x07 -u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr); -u8 rtw_setstandby_cmd(struct adapter *padapter, uint action); -u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, +u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num); -u8 rtw_createbss_cmd(struct adapter *padapter); -u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, - unsigned int sz); -u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch); +u8 rtw_createbss_cmd(struct adapter *padapter); u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key); -u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue); -u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network* pnetwork); -u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue); -u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype); -u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset); -u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset); -u8 rtw_setbbreg_cmd(struct adapter * padapter, u8 offset, u8 val); -u8 rtw_setrfreg_cmd(struct adapter * padapter, u8 offset, u32 val); -u8 rtw_getbbreg_cmd(struct adapter * padapter, u8 offset, u8 * pval); -u8 rtw_getrfreg_cmd(struct adapter * padapter, u8 offset, u8 * pval); -u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode); -u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_table); -u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval); - -u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset,u8 *pval); -u8 rtw_setfwdig_cmd(struct adapter*padapter, u8 type); -u8 rtw_setfwra_cmd(struct adapter*padapter, u8 type); - -u8 rtw_addbareq_cmd(struct adapter*padapter, u8 tid, u8 *addr); +u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, + u8 enqueue); +u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork); +u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, + bool enqueue); +u8 rtw_setopmode_cmd(struct adapter *padapter, + enum ndis_802_11_network_infra networktype); +u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr); u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter); -u8 rtw_lps_ctrl_wk_cmd(struct adapter*padapter, u8 lps_ctrl_type, u8 enqueue); -u8 rtw_rpt_timer_cfg_cmd(struct adapter*padapter, u16 minRptTime); +u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue); +u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 minRptTime); - u8 rtw_antenna_select_cmd(struct adapter*padapter, u8 antenna,u8 enqueue); -u8 rtw_ps_cmd(struct adapter*padapter); +u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue); +u8 rtw_ps_cmd(struct adapter *padapter); #ifdef CONFIG_88EU_AP_MODE -u8 rtw_chk_hi_queue_cmd(struct adapter*padapter); +u8 rtw_chk_hi_queue_cmd(struct adapter *padapter); #endif -u8 rtw_set_ch_cmd(struct adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue); -u8 rtw_set_chplan_cmd(struct adapter*padapter, u8 chplan, u8 enqueue); -u8 rtw_led_blink_cmd(struct adapter*padapter, struct LED_871x * pLed); -u8 rtw_set_csa_cmd(struct adapter*padapter, u8 new_ch_no); -u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option); - -u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt); - +u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue); u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf); void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); void rtw_createbss_cmd_callback(struct adapter *adapt, struct cmd_obj *pcmd); -void rtw_getbbrfreg_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); -void rtw_readtssi_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); +void rtw_readtssi_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); void rtw_setstaKey_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); void rtw_setassocsta_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cm); @@ -832,159 +381,42 @@ struct _cmd_callback { }; enum rtw_h2c_cmd { - GEN_CMD_CODE(_Read_MACREG), /*0*/ - GEN_CMD_CODE(_Write_MACREG), - GEN_CMD_CODE(_Read_BBREG), - GEN_CMD_CODE(_Write_BBREG), - GEN_CMD_CODE(_Read_RFREG), - GEN_CMD_CODE(_Write_RFREG), /*5*/ - GEN_CMD_CODE(_Read_EEPROM), - GEN_CMD_CODE(_Write_EEPROM), - GEN_CMD_CODE(_Read_EFUSE), - GEN_CMD_CODE(_Write_EFUSE), - - GEN_CMD_CODE(_Read_CAM), /*10*/ - GEN_CMD_CODE(_Write_CAM), - GEN_CMD_CODE(_setBCNITV), - GEN_CMD_CODE(_setMBIDCFG), - GEN_CMD_CODE(_JoinBss), /*14*/ - GEN_CMD_CODE(_DisConnect), /*15*/ + GEN_CMD_CODE(_JoinBss), + GEN_CMD_CODE(_DisConnect), GEN_CMD_CODE(_CreateBss), GEN_CMD_CODE(_SetOpMode), - GEN_CMD_CODE(_SiteSurvey), /*18*/ + GEN_CMD_CODE(_SiteSurvey), GEN_CMD_CODE(_SetAuth), - - GEN_CMD_CODE(_SetKey), /*20*/ + GEN_CMD_CODE(_SetKey), GEN_CMD_CODE(_SetStaKey), GEN_CMD_CODE(_SetAssocSta), - GEN_CMD_CODE(_DelAssocSta), - GEN_CMD_CODE(_SetStaPwrState), - GEN_CMD_CODE(_SetBasicRate), /*25*/ - GEN_CMD_CODE(_GetBasicRate), - GEN_CMD_CODE(_SetDataRate), - GEN_CMD_CODE(_GetDataRate), - GEN_CMD_CODE(_SetPhyInfo), - - GEN_CMD_CODE(_GetPhyInfo), /*30*/ - GEN_CMD_CODE(_SetPhy), - GEN_CMD_CODE(_GetPhy), - GEN_CMD_CODE(_readRssi), - GEN_CMD_CODE(_readGain), - GEN_CMD_CODE(_SetAtim), /*35*/ - GEN_CMD_CODE(_SetPwrMode), - GEN_CMD_CODE(_JoinbssRpt), - GEN_CMD_CODE(_SetRaTable), - GEN_CMD_CODE(_GetRaTable), - - GEN_CMD_CODE(_GetCCXReport), /*40*/ - GEN_CMD_CODE(_GetDTMReport), - GEN_CMD_CODE(_GetTXRateStatistics), - GEN_CMD_CODE(_SetUsbSuspend), - GEN_CMD_CODE(_SetH2cLbk), - GEN_CMD_CODE(_AddBAReq), /*45*/ - GEN_CMD_CODE(_SetChannel), /*46*/ - GEN_CMD_CODE(_SetTxPower), - GEN_CMD_CODE(_SwitchAntenna), - GEN_CMD_CODE(_SetCrystalCap), - GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/ - - GEN_CMD_CODE(_SetSingleToneTx),/*51*/ - GEN_CMD_CODE(_SetCarrierSuppressionTx), - GEN_CMD_CODE(_SetContinuousTx), - GEN_CMD_CODE(_SwitchBandwidth), /*54*/ - GEN_CMD_CODE(_TX_Beacon), /*55*/ - - GEN_CMD_CODE(_Set_MLME_EVT), /*56*/ - GEN_CMD_CODE(_Set_Drv_Extra), /*57*/ - GEN_CMD_CODE(_Set_H2C_MSG), /*58*/ - - GEN_CMD_CODE(_SetChannelPlan), /*59*/ - GEN_CMD_CODE(_LedBlink), /*60*/ - - GEN_CMD_CODE(_SetChannelSwitch), /*61*/ - GEN_CMD_CODE(_TDLS), /*62*/ + GEN_CMD_CODE(_AddBAReq), + GEN_CMD_CODE(_SetChannel), + GEN_CMD_CODE(_TX_Beacon), + GEN_CMD_CODE(_Set_MLME_EVT), + GEN_CMD_CODE(_Set_Drv_Extra), + GEN_CMD_CODE(_SetChannelPlan), MAX_H2CCMD }; -#define _GetBBReg_CMD_ _Read_BBREG_CMD_ -#define _SetBBReg_CMD_ _Write_BBREG_CMD_ -#define _GetRFReg_CMD_ _Read_RFREG_CMD_ -#define _SetRFReg_CMD_ _Write_RFREG_CMD_ - #ifdef _RTW_CMD_C_ -static struct _cmd_callback rtw_cmd_callback[] = -{ - {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ - {GEN_CMD_CODE(_Write_MACREG), NULL}, - {GEN_CMD_CODE(_Read_BBREG), &rtw_getbbrfreg_cmdrsp_callback}, - {GEN_CMD_CODE(_Write_BBREG), NULL}, - {GEN_CMD_CODE(_Read_RFREG), &rtw_getbbrfreg_cmdrsp_callback}, - {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ - {GEN_CMD_CODE(_Read_EEPROM), NULL}, - {GEN_CMD_CODE(_Write_EEPROM), NULL}, - {GEN_CMD_CODE(_Read_EFUSE), NULL}, - {GEN_CMD_CODE(_Write_EFUSE), NULL}, - - {GEN_CMD_CODE(_Read_CAM), NULL}, /*10*/ - {GEN_CMD_CODE(_Write_CAM), NULL}, - {GEN_CMD_CODE(_setBCNITV), NULL}, - {GEN_CMD_CODE(_setMBIDCFG), NULL}, - {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd_callback}, /*14*/ - {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd_callback}, /*15*/ +static struct _cmd_callback rtw_cmd_callback[] = { + {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd_callback}, + {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd_callback}, {GEN_CMD_CODE(_CreateBss), &rtw_createbss_cmd_callback}, {GEN_CMD_CODE(_SetOpMode), NULL}, - {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback}, /*18*/ + {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback}, {GEN_CMD_CODE(_SetAuth), NULL}, - - {GEN_CMD_CODE(_SetKey), NULL}, /*20*/ + {GEN_CMD_CODE(_SetKey), NULL}, {GEN_CMD_CODE(_SetStaKey), &rtw_setstaKey_cmdrsp_callback}, {GEN_CMD_CODE(_SetAssocSta), &rtw_setassocsta_cmdrsp_callback}, - {GEN_CMD_CODE(_DelAssocSta), NULL}, - {GEN_CMD_CODE(_SetStaPwrState), NULL}, - {GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/ - {GEN_CMD_CODE(_GetBasicRate), NULL}, - {GEN_CMD_CODE(_SetDataRate), NULL}, - {GEN_CMD_CODE(_GetDataRate), NULL}, - {GEN_CMD_CODE(_SetPhyInfo), NULL}, - - {GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/ - {GEN_CMD_CODE(_SetPhy), NULL}, - {GEN_CMD_CODE(_GetPhy), NULL}, - {GEN_CMD_CODE(_readRssi), NULL}, - {GEN_CMD_CODE(_readGain), NULL}, - {GEN_CMD_CODE(_SetAtim), NULL}, /*35*/ - {GEN_CMD_CODE(_SetPwrMode), NULL}, - {GEN_CMD_CODE(_JoinbssRpt), NULL}, - {GEN_CMD_CODE(_SetRaTable), NULL}, - {GEN_CMD_CODE(_GetRaTable), NULL}, - - {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/ - {GEN_CMD_CODE(_GetDTMReport), NULL}, - {GEN_CMD_CODE(_GetTXRateStatistics), NULL}, - {GEN_CMD_CODE(_SetUsbSuspend), NULL}, - {GEN_CMD_CODE(_SetH2cLbk), NULL}, - {GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/ - {GEN_CMD_CODE(_SetChannel), NULL}, /*46*/ - {GEN_CMD_CODE(_SetTxPower), NULL}, - {GEN_CMD_CODE(_SwitchAntenna), NULL}, - {GEN_CMD_CODE(_SetCrystalCap), NULL}, - {GEN_CMD_CODE(_SetSingleCarrierTx), NULL}, /*50*/ - - {GEN_CMD_CODE(_SetSingleToneTx), NULL}, /*51*/ - {GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL}, - {GEN_CMD_CODE(_SetContinuousTx), NULL}, - {GEN_CMD_CODE(_SwitchBandwidth), NULL}, /*54*/ - {GEN_CMD_CODE(_TX_Beacon), NULL},/*55*/ - - {GEN_CMD_CODE(_Set_MLME_EVT), NULL},/*56*/ - {GEN_CMD_CODE(_Set_Drv_Extra), NULL},/*57*/ - {GEN_CMD_CODE(_Set_H2C_MSG), NULL},/*58*/ - {GEN_CMD_CODE(_SetChannelPlan), NULL},/*59*/ - {GEN_CMD_CODE(_LedBlink), NULL},/*60*/ - - {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*61*/ - {GEN_CMD_CODE(_TDLS), NULL},/*62*/ + {GEN_CMD_CODE(_AddBAReq), NULL}, + {GEN_CMD_CODE(_SetChannel), NULL}, + {GEN_CMD_CODE(_TX_Beacon), NULL}, + {GEN_CMD_CODE(_Set_MLME_EVT), NULL}, + {GEN_CMD_CODE(_Set_Drv_Extra), NULL}, + {GEN_CMD_CODE(_SetChannelPlan), NULL}, }; #endif diff --git a/include/rtw_debug.h b/include/rtw_debug.h index c6b193a..673f190 100644 --- a/include/rtw_debug.h +++ b/include/rtw_debug.h @@ -23,7 +23,7 @@ #include #include - +#define DRIVERVERSION "v4.1.4_6773.20130222" #define _drv_always_ 1 #define _drv_emerg_ 2 #define _drv_alert_ 3 @@ -75,7 +75,7 @@ extern u32 GlobalDebugLevel; #define DBG_88E_LEVEL(_level, fmt, arg...) \ do { \ if (_level <= GlobalDebugLevel) \ - pr_info(DRIVER_PREFIX"ERROR " fmt, ##arg); \ + pr_info(DRIVER_PREFIX"Info " fmt, ##arg); \ } while (0) #define DBG_88E(...) \ @@ -99,20 +99,6 @@ extern u32 GlobalDebugLevel; } \ } while (0) -#define _func_enter_ \ - do { \ - if (GlobalDebugLevel >= _drv_debug_) \ - pr_info("%s : %s enters at %d\n", \ - DRIVER_PREFIX, __func__, __LINE__); \ - } while (0) - -#define _func_exit_ \ - do { \ - if (GlobalDebugLevel >= _drv_debug_) \ - pr_info("%s : %s exits at %d\n", \ - DRIVER_PREFIX, __func__, __LINE__); \ - } while (0) - #define RT_PRINT_DATA(_comp, _level, _titlestring, _hexdata, _hexdatalen)\ do { \ if (_level <= GlobalDebugLevel) { \ @@ -120,7 +106,7 @@ extern u32 GlobalDebugLevel; u8 *ptr = (u8 *)_hexdata; \ pr_info("%s", DRIVER_PREFIX); \ pr_info(_titlestring); \ - for (__i = 0; __i < (int)_hexdatalen; __i++ ) { \ + for (__i = 0; __i < (int)_hexdatalen; __i++) { \ pr_info("%02X%s", ptr[__i], \ (((__i + 1) % 4) == 0) ? \ " " : " "); \ @@ -277,14 +263,4 @@ int proc_get_rssi_disp(char *page, char **start, int proc_set_rssi_disp(struct file *file, const char __user *buffer, unsigned long count, void *data); -#ifdef CONFIG_BT_COEXIST -int proc_get_btcoex_dbg(char *page, char **start, - off_t offset, int count, - int *eof, void *data); - -int proc_set_btcoex_dbg(struct file *file, const char *buffer, - signed long count, void *data); - -#endif /* CONFIG_BT_COEXIST */ - #endif /* __RTW_DEBUG_H__ */ diff --git a/include/rtw_eeprom.h b/include/rtw_eeprom.h index 0b27eb7..904fea1 100644 --- a/include/rtw_eeprom.h +++ b/include/rtw_eeprom.h @@ -108,7 +108,7 @@ enum RT_CUSTOMER_ID { RT_CID_CC_C = 38, RT_CID_819x_Xavi = 39, RT_CID_819x_FUNAI_TV = 40, - RT_CID_819x_ALPHA_WD=41, + RT_CID_819x_ALPHA_WD = 41, }; struct eeprom_priv { @@ -118,7 +118,7 @@ struct eeprom_priv { u8 mac_addr[6]; /* PermanentAddress */ u16 channel_plan; u8 EepromOrEfuse; - u8 efuse_eeprom_data[HWSET_MAX_SIZE_512] __aligned(4); + u8 efuse_eeprom_data[HWSET_MAX_SIZE_512]; }; void eeprom_write16(struct adapter *padapter, u16 reg, u16 data); diff --git a/include/rtw_efuse.h b/include/rtw_efuse.h index cee6b5e..5660eed 100644 --- a/include/rtw_efuse.h +++ b/include/rtw_efuse.h @@ -99,52 +99,20 @@ struct efuse_hal { u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]; }; -/*------------------------Export global variable----------------------------*/ -extern u8 fakeEfuseBank; -extern u32 fakeEfuseUsedBytes; -extern u8 fakeEfuseContent[]; -extern u8 fakeEfuseInitMap[]; -extern u8 fakeEfuseModifiedMap[]; - -extern u32 BTEfuseUsedBytes; -extern u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; -extern u8 BTEfuseInitMap[]; -extern u8 BTEfuseModifiedMap[]; - -extern u32 fakeBTEfuseUsedBytes; -extern u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; -extern u8 fakeBTEfuseInitMap[]; -extern u8 fakeBTEfuseModifiedMap[]; -/*------------------------Export global variable----------------------------*/ - -u8 efuse_GetCurrentSize(struct adapter *adapter, u16 *size); -u16 efuse_GetMaxSize(struct adapter *adapter); -u8 rtw_efuse_access(struct adapter *adapter, u8 read, u16 start_addr, - u16 cnts, u8 *data); -u8 rtw_efuse_map_read(struct adapter *adapter, u16 addr, u16 cnts, u8 *data); -u8 rtw_efuse_map_write(struct adapter *adapter, u16 addr, u16 cnts, u8 *data); -u8 rtw_BT_efuse_map_read(struct adapter *adapter, u16 addr, - u16 cnts, u8 *data); -u8 rtw_BT_efuse_map_write(struct adapter *adapter, u16 addr, - u16 cnts, u8 *data); -u16 Efuse_GetCurrentSize(struct adapter *adapter, u8 efusetype, bool test); u8 Efuse_CalculateWordCnts(u8 word_en); -void ReadEFuseByte(struct adapter *adapter, u16 _offset, u8 *pbuf, bool test); void EFUSE_GetEfuseDefinition(struct adapter *adapt, u8 type, u8 type1, - void *out, bool bPseudoTest); -u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data, bool test); -u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data, bool test); + void *out); +u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data); +u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data); -void Efuse_PowerSwitch(struct adapter *adapt,u8 bWrite,u8 PwrState); -int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data, bool test); -int Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data, - bool test); +void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, + u16 _size_byte, u8 *pbuf); +void Efuse_PowerSwitch(struct adapter *adapt, u8 bWrite, u8 PwrState); +int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data); +bool Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data); void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); u8 Efuse_WordEnableDataWrite(struct adapter *adapter, u16 efuse_addr, - u8 word_en, u8 *data, bool test); - -u8 EFUSE_Read1Byte(struct adapter *adapter, u16 address); -void EFUSE_ShadowMapUpdate(struct adapter *adapter, u8 efusetype, bool test); -void EFUSE_ShadowRead(struct adapter *adapt, u8 type, u16 offset, u32 *val); + u8 word_en, u8 *data); +void EFUSE_ShadowMapUpdate(struct adapter *adapter, u8 efusetype); #endif diff --git a/include/rtw_ioctl.h b/include/rtw_ioctl.h index 8772d1d..f3aa924 100644 --- a/include/rtw_ioctl.h +++ b/include/rtw_ioctl.h @@ -102,8 +102,6 @@ struct oid_obj_priv { #if defined(_RTW_MP_IOCTL_C_) static int oid_null_function(struct oid_par_priv *poid_par_priv) { - _func_enter_; - _func_exit_; return NDIS_STATUS_SUCCESS; } #endif diff --git a/include/rtw_ioctl_set.h b/include/rtw_ioctl_set.h index 49efb23..fa9d655 100644 --- a/include/rtw_ioctl_set.h +++ b/include/rtw_ioctl_set.h @@ -25,26 +25,18 @@ typedef u8 NDIS_802_11_PMKID_VALUE[16]; -u8 rtw_set_802_11_add_key(struct adapter *adapt, struct ndis_802_11_key *key); u8 rtw_set_802_11_authentication_mode(struct adapter *adapt, enum ndis_802_11_auth_mode authmode); -u8 rtw_set_802_11_bssid(struct adapter*adapter, u8 *bssid); +u8 rtw_set_802_11_bssid(struct adapter *adapter, u8 *bssid); u8 rtw_set_802_11_add_wep(struct adapter *adapter, struct ndis_802_11_wep *wep); u8 rtw_set_802_11_disassociate(struct adapter *adapter); -u8 rtw_set_802_11_bssid_list_scan(struct adapter*adapter, +u8 rtw_set_802_11_bssid_list_scan(struct adapter *adapter, struct ndis_802_11_ssid *pssid, int ssid_max_num); u8 rtw_set_802_11_infrastructure_mode(struct adapter *adapter, enum ndis_802_11_network_infra type); -u8 rtw_set_802_11_remove_wep(struct adapter *adapter, u32 keyindex); u8 rtw_set_802_11_ssid(struct adapter *adapt, struct ndis_802_11_ssid *ssid); -u8 rtw_set_802_11_remove_key(struct adapter *adapt, - struct ndis_802_11_remove_key *key); -u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid); u16 rtw_get_cur_max_rate(struct adapter *adapter); -int rtw_set_scan_mode(struct adapter *adapter, enum rt_scan_type scan_mode); -int rtw_set_channel_plan(struct adapter *adapter, u8 channel_plan); int rtw_set_country(struct adapter *adapter, const char *country_code); -int rtw_change_ifname(struct adapter *padapter, const char *ifname); #endif diff --git a/include/rtw_iol.h b/include/rtw_iol.h index 6949922..68aae7f 100644 --- a/include/rtw_iol.h +++ b/include/rtw_iol.h @@ -23,62 +23,6 @@ #include #include -#define IOREG_CMD_END_LEN 4 - -struct ioreg_cfg { - u8 length; - u8 cmd_id; - __le16 address; - __le32 data; - __le32 mask; -}; - -enum ioreg_cmd { - IOREG_CMD_LLT = 0x01, - IOREG_CMD_REFUSE = 0x02, - IOREG_CMD_EFUSE_PATH = 0x03, - IOREG_CMD_WB_REG = 0x04, - IOREG_CMD_WW_REG = 0x05, - IOREG_CMD_WD_REG = 0x06, - IOREG_CMD_W_RF = 0x07, - IOREG_CMD_DELAY_US = 0x10, - IOREG_CMD_DELAY_MS = 0x11, - IOREG_CMD_END = 0xFF, -}; - -struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter); -int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, - u32 cmd_len); -int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary); -int rtw_IOL_exec_cmds_sync(struct adapter *adapter, - struct xmit_frame *xmit_frame, u32 max_wating_ms, - u32 bndy_cnt); bool rtw_IOL_applied(struct adapter *adapter); -int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us); -int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms); -int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame); - -void read_efuse_from_txpktbuf(struct adapter *adapter, int bcnhead, - u8 *content, u16 *size); - -int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, - u8 value, u8 mask); -int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, - u16 value, u16 mask); -int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, - u32 value, u32 mask); -int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, - u16 addr, u32 value, u32 mask); -#define rtw_IOL_append_WB_cmd(xmit_frame, addr, value, mask) \ - _rtw_IOL_append_WB_cmd((xmit_frame), (addr), (value) ,(mask)) -#define rtw_IOL_append_WW_cmd(xmit_frame, addr, value, mask) \ - _rtw_IOL_append_WW_cmd((xmit_frame), (addr), (value),(mask)) -#define rtw_IOL_append_WD_cmd(xmit_frame, addr, value, mask) \ - _rtw_IOL_append_WD_cmd((xmit_frame), (addr), (value), (mask)) -#define rtw_IOL_append_WRF_cmd(xmit_frame, rf_path, addr, value, mask) \ - _rtw_IOL_append_WRF_cmd((xmit_frame),(rf_path), (addr), (value), (mask)) - -u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame); -void rtw_IOL_cmd_buf_dump(struct adapter *Adapter,int buf_len,u8 *pbuf); #endif /* __RTW_IOL_H_ */ diff --git a/include/rtw_led.h b/include/rtw_led.h index d0da4fd..dec8dbc 100644 --- a/include/rtw_led.h +++ b/include/rtw_led.h @@ -23,92 +23,43 @@ #include #include -#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) - -#define LED_BLINK_NORMAL_INTERVAL 100 -#define LED_BLINK_SLOWLY_INTERVAL 200 -#define LED_BLINK_LONG_INTERVAL 400 - #define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000 #define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */ #define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */ #define LED_BLINK_FASTER_INTERVAL_ALPHA 50 #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000 -#define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100 -#define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000 - -#define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000 -#define LED_BLINK_NORMAL_INTERVAL_PORNET 100 - -#define LED_BLINK_FAST_INTERVAL_BITLAND 30 - -/* 060403, rcnjko: Customized for AzWave. */ -#define LED_CM2_BLINK_ON_INTERVAL 250 -#define LED_CM2_BLINK_OFF_INTERVAL 4750 - -#define LED_CM8_BLINK_INTERVAL 500 /* for QMI */ -#define LED_CM8_BLINK_OFF_INTERVAL 3750 /* for QMI */ - -/* 080124, lanhsin: Customized for RunTop */ -#define LED_RunTop_BLINK_INTERVAL 300 - -/* 060421, rcnjko: Customized for Sercomm Printer Server case. */ -#define LED_CM3_BLINK_INTERVAL 1500 - enum LED_CTL_MODE { - LED_CTL_POWER_ON = 1, - LED_CTL_LINK = 2, - LED_CTL_NO_LINK = 3, - LED_CTL_TX = 4, - LED_CTL_RX = 5, - LED_CTL_SITE_SURVEY = 6, - LED_CTL_POWER_OFF = 7, - LED_CTL_START_TO_LINK = 8, - LED_CTL_START_WPS = 9, - LED_CTL_STOP_WPS = 10, - LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */ - LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */ - LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */ - LED_CTL_CONNECTION_NO_TRANSFER = 14, + LED_CTL_POWER_ON, + LED_CTL_LINK, + LED_CTL_NO_LINK, + LED_CTL_TX, + LED_CTL_RX , + LED_CTL_SITE_SURVEY, + LED_CTL_POWER_OFF, + LED_CTL_START_TO_LINK, + LED_CTL_START_WPS, + LED_CTL_STOP_WPS, + LED_CTL_START_WPS_BOTTON, + LED_CTL_STOP_WPS_FAIL }; enum LED_STATE_871x { - LED_UNKNOWN = 0, - RTW_LED_ON = 1, - RTW_LED_OFF = 2, - LED_BLINK_NORMAL = 3, - LED_BLINK_SLOWLY = 4, - LED_BLINK_POWER_ON = 5, - LED_BLINK_SCAN = 6, /* LED is blinking during scanning period, - * the # of times to blink is depend on time - * for scanning. */ - LED_BLINK_NO_LINK = 7, /* LED is blinking during no link state. */ - LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer - * Server case */ - LED_BLINK_TXRX = 9, - LED_BLINK_WPS = 10, /* LED is blinkg during WPS communication */ - LED_BLINK_WPS_STOP = 11, /* for ALPHA */ - LED_BLINK_WPS_STOP_OVERLAP = 12, /* for BELKIN */ - LED_BLINK_RUNTOP = 13, /* Customized for RunTop */ - LED_BLINK_CAMEO = 14, - LED_BLINK_XAVI = 15, - LED_BLINK_ALWAYS_ON = 16, -}; - -enum LED_PIN_871x { - LED_PIN_NULL = 0, - LED_PIN_LED0 = 1, - LED_PIN_LED1 = 2, - LED_PIN_LED2 = 3, - LED_PIN_GPIO0 = 4, + LED_UNKNOWN, + RTW_LED_ON, + RTW_LED_OFF, + LED_BLINK_NORMAL, + LED_BLINK_SLOWLY, + LED_BLINK_POWER_ON, + LED_BLINK_SCAN, + LED_BLINK_TXRX, + LED_BLINK_WPS, + LED_BLINK_WPS_STOP }; struct LED_871x { struct adapter *padapter; - enum LED_PIN_871x LedPin; /* Identify how to implement this - * SW led. */ enum LED_STATE_871x CurrLedState; /* Current LED state. */ enum LED_STATE_871x BlinkingLedState; /* Next state for blinking, * either RTW_LED_ON or RTW_LED_OFF are. */ @@ -139,34 +90,11 @@ struct LED_871x { ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \ ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress) -#define IS_LED_BLINKING(_LED_871x) \ - (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \ - ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress) - -/* LED customization. */ - -enum LED_STRATEGY_871x { - SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option.*/ - SW_LED_MODE1= 1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */ - SW_LED_MODE2 = 2, /* SW control 1 LED via GPIO0, customized for AzWave - * 8187 minicard. */ - SW_LED_MODE3 = 3, /* SW control 1 LED via GPIO0, customized for Sercomm - * Printer Server case. */ - SW_LED_MODE4 = 4, /* for Edimax / Belkin */ - SW_LED_MODE5 = 5, /* for Sercomm / Belkin */ - SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */ - HW_LED = 50, /* HW control 2 LEDs, LED0 and LED1 (there are 4 - * different control modes, see MAC.CONFIG1 for details.)*/ - LED_ST_NONE = 99, -}; - void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); -struct led_priv{ +struct led_priv { /* add for led control */ struct LED_871x SwLed0; - struct LED_871x SwLed1; - enum LED_STRATEGY_871x LedStrategy; u8 bRegUseLed; void (*LedControlHandler)(struct adapter *padapter, enum LED_CTL_MODE LedAction); @@ -182,15 +110,14 @@ struct led_priv{ void BlinkTimerCallback(void *data); void BlinkWorkItemCallback(struct work_struct *work); -void ResetLedStatus(struct LED_871x * pLed); +void ResetLedStatus(struct LED_871x *pLed); -void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, - enum LED_PIN_871x LedPin); +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed); void DeInitLed871x(struct LED_871x *pLed); /* hal... */ -void BlinkHandler(struct LED_871x * pLed); +void BlinkHandler(struct LED_871x *pLed); void SwLedOn(struct adapter *padapter, struct LED_871x *pLed); void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); diff --git a/include/rtw_mlme.h b/include/rtw_mlme.h index 4a7143e..8d83f7c 100644 --- a/include/rtw_mlme.h +++ b/include/rtw_mlme.h @@ -106,13 +106,6 @@ SHALL not lock up more than one lock at a time! #define traffic_threshold 10 #define traffic_scan_period 500 -struct sitesurvey_ctrl { - u64 last_tx_pkts; - uint last_rx_pkts; - int traffic_busy; - struct timer_list sitesurvey_ctrl_timer; -}; - struct rt_link_detect { u32 NumTxOkInPeriod; u32 NumRxOkInPeriod; @@ -129,17 +122,17 @@ struct rt_link_detect { struct profile_info { u8 ssidlen; - u8 ssid[ WLAN_SSID_MAXLEN ]; - u8 peermac[ ETH_ALEN ]; + u8 ssid[WLAN_SSID_MAXLEN]; + u8 peermac[ETH_ALEN]; }; struct tx_invite_req_info { u8 token; u8 benable; - u8 go_ssid[ WLAN_SSID_MAXLEN ]; + u8 go_ssid[WLAN_SSID_MAXLEN]; u8 ssidlen; - u8 go_bssid[ ETH_ALEN ]; - u8 peer_macaddr[ ETH_ALEN ]; + u8 go_bssid[ETH_ALEN]; + u8 peer_macaddr[ETH_ALEN]; u8 operating_ch; /* This information will be set by using the * p2p_set op_ch=x */ u8 peer_ch; /* The listen channel for peer P2P device */ @@ -182,9 +175,9 @@ struct tx_nego_req_info { }; struct group_id_info { - u8 go_device_addr[ ETH_ALEN ]; /* The GO's device address of + u8 go_device_addr[ETH_ALEN]; /* The GO's device address of * this P2P group */ - u8 ssid[ WLAN_SSID_MAXLEN ]; /* The SSID of this P2P group */ + u8 ssid[WLAN_SSID_MAXLEN]; /* The SSID of this P2P group */ }; struct scan_limit_info { @@ -304,31 +297,6 @@ struct wifidirect_info { u32 noa_start_time[P2P_MAX_NOA_NUM]; }; -struct tdls_ss_record { /* signal strength record */ - u8 macaddr[ETH_ALEN]; - u8 RxPWDBAll; - u8 is_tdls_sta; /* true: direct link sta, false: else */ -}; - -struct tdls_info { - u8 ap_prohibited; - uint setup_state; - u8 sta_cnt; - u8 sta_maximum; /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */ - struct tdls_ss_record ss_record; - u8 macid_index; /* macid entry that is ready to write */ - u8 clear_cam; /* cam entry that is trying to clear, using it in direct link teardown */ - u8 ch_sensing; - u8 cur_channel; - u8 candidate_ch; - u8 collect_pkt_num[MAX_CHANNEL_NUM]; - spinlock_t cmd_lock; - spinlock_t hdl_lock; - u8 watchdog_count; - u8 dev_discovered; /* WFD_TDLS: for sigma test */ - u8 enable; -}; - struct mlme_priv { spinlock_t lock; int fw_state; /* shall we protect this variable? maybe not necessarily... */ @@ -388,7 +356,7 @@ struct mlme_priv { u8 *assoc_rsp; u32 assoc_rsp_len; -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) /* Number of associated Non-ERP stations (i.e., stations using 802.11b * in 802.11g BSS) */ int num_sta_non_erp; @@ -468,11 +436,9 @@ void indicate_wx_scan_complete_event(struct adapter *padapter); void rtw_indicate_wx_assoc_event(struct adapter *padapter); void rtw_indicate_wx_disassoc_event(struct adapter *padapter); int event_thread(void *context); -void rtw_join_timeout_handler(void *FunctionContext); -void _rtw_scan_timeout_handler(void *FunctionContext); void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall); int rtw_init_mlme_priv(struct adapter *adapter); -void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv); +void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv); int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv); int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, int keyid, u8 set_tx); @@ -508,7 +474,7 @@ static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state) { pmlmepriv->fw_state |= state; /* FOR HW integration */ - if (_FW_UNDER_SURVEY==state) + if (_FW_UNDER_SURVEY == state) pmlmepriv->bScanInProcess = true; } @@ -516,7 +482,7 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state) { pmlmepriv->fw_state &= ~state; /* FOR HW integration */ - if (_FW_UNDER_SURVEY==state) + if (_FW_UNDER_SURVEY == state) pmlmepriv->bScanInProcess = false; } @@ -526,48 +492,38 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state) */ static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state) { - unsigned long irql; - - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, state) == true) pmlmepriv->fw_state ^= state; - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); } static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state) { - unsigned long irql; - - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); _clr_fwstate_(pmlmepriv, state); - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); } static inline void up_scanned_network(struct mlme_priv *pmlmepriv) { - unsigned long irql; - - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); pmlmepriv->num_of_scanned++; - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); } static inline void down_scanned_network(struct mlme_priv *pmlmepriv) { - unsigned long irql; - - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); pmlmepriv->num_of_scanned--; - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); } static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, int val) { - unsigned long irql; - - _enter_critical_bh(&pmlmepriv->lock, &irql); + spin_lock_bh(&pmlmepriv->lock); pmlmepriv->num_of_scanned = val; - _exit_critical_bh(&pmlmepriv->lock, &irql); + spin_unlock_bh(&pmlmepriv->lock); } u16 rtw_get_capability(struct wlan_bssid_ex *bss); @@ -582,7 +538,7 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue); void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue); void rtw_indicate_disconnect(struct adapter *adapter); void rtw_indicate_connect(struct adapter *adapter); -void rtw_indicate_scan_done( struct adapter *padapter, bool aborted); +void rtw_indicate_scan_done(struct adapter *padapter, bool aborted); void rtw_scan_abort(struct adapter *adapter); int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, @@ -595,47 +551,27 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter); void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter); -void _rtw_join_timeout_handler(struct adapter *adapter); -void rtw_scan_timeout_handler(struct adapter *adapter); +void _rtw_join_timeout_handler(void *function_context); +void rtw_scan_timeout_handler(void *function_context); - void rtw_dynamic_check_timer_handlder(struct adapter *adapter); +void rtw_dynamic_check_timer_handlder(void *function_context); #define rtw_is_scan_deny(adapter) false #define rtw_clear_scan_deny(adapter) do {} while (0) #define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0) #define rtw_set_scan_deny(adapter, ms) do {} while (0) - -int _rtw_init_mlme_priv(struct adapter *padapter); - void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); -void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv); +struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv); -int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork); - -struct wlan_network *_rtw_dequeue_network(struct __queue *queue); - - struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv); - - -void _rtw_free_network(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork, u8 isfreeall); void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); - -struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, u8 *addr); - -void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall); - int rtw_if_up(struct adapter *padapter); - u8 *rtw_get_capability_from_ie(u8 *ie); -u8 *rtw_get_timestampe_from_ie(u8 *ie); u8 *rtw_get_beacon_interval_from_ie(u8 *ie); - void rtw_joinbss_reset(struct adapter *padapter); unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, @@ -650,6 +586,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst); void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); -void rtw_stassoc_hw_rpt(struct adapter *adapter,struct sta_info *psta); +void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta); #endif /* __RTL871X_MLME_H_ */ diff --git a/include/rtw_mlme_ext.h b/include/rtw_mlme_ext.h index b1bfa2e..8d72ccf 100644 --- a/include/rtw_mlme_ext.h +++ b/include/rtw_mlme_ext.h @@ -236,13 +236,13 @@ enum SCAN_STATE { struct mlme_handler { unsigned int num; char *str; - unsigned int (*func)(struct adapter *adapt, union recv_frame *frame); + unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); }; struct action_handler { unsigned int num; - char* str; - unsigned int (*func)(struct adapter *adapt, union recv_frame *frame); + char *str; + unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); }; struct ss_res { @@ -401,7 +401,7 @@ struct p2p_oper_class_map { struct mlme_ext_priv { struct adapter *padapter; u8 mlmeext_init; - ATOMIC_T event_seq; + atomic_t event_seq; u16 mgnt_seq; unsigned char cur_channel; @@ -448,7 +448,7 @@ struct mlme_ext_priv { int init_mlme_ext_priv(struct adapter *adapter); int init_hw_mlme_ext(struct adapter *padapter); -void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext); +void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext); extern void init_mlme_ext_timer(struct adapter *padapter); extern void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta); extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); @@ -484,13 +484,13 @@ void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key); void clear_cam_entry(struct adapter *padapter, u8 entry); void invalidate_cam_all(struct adapter *padapter); -void CAM_empty_entry(struct adapter * Adapter, u8 ucIndex); +void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex); int allocate_fw_sta_entry(struct adapter *padapter); void flush_all_cam_entry(struct adapter *padapter); void site_survey(struct adapter *padapter); -u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, +u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid); void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct adapter *adapter, bool update_ie); @@ -544,15 +544,16 @@ unsigned int is_ap_in_wep(struct adapter *padapter); unsigned int should_forbid_n_rate(struct adapter *padapter); void report_join_res(struct adapter *padapter, int res); -void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame); +void report_survey_event(struct adapter *padapter, + struct recv_frame *precv_frame); void report_surveydone_event(struct adapter *padapter); void report_del_sta_event(struct adapter *padapter, unsigned char *addr, unsigned short reason); -void report_add_sta_event(struct adapter *padapter, unsigned char* addr, +void report_add_sta_event(struct adapter *padapter, unsigned char *addr, int cam_idx); void beacon_timing_control(struct adapter *padapter); -extern u8 set_tx_beacon_cmd(struct adapter*padapter); +extern u8 set_tx_beacon_cmd(struct adapter *padapter); unsigned int setup_beacon_frame(struct adapter *padapter, unsigned char *beacon_frame); void update_mgnt_tx_rate(struct adapter *padapter, u8 rate); @@ -564,18 +565,6 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe); -#ifdef CONFIG_88EU_P2P -void issue_probersp_p2p(struct adapter *padapter, unsigned char *da); -void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, - u8 ussidlen, u8 *pdev_raddr); -void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr); -void issue_probereq_p2p(struct adapter *padapter, u8 *da); -int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, - int wait_ms); -void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, - u8 dialogToken, u8 success); -void issue_p2p_invitation_request(struct adapter *padapter, u8* raddr); -#endif /* CONFIG_88EU_P2P */ void issue_beacon(struct adapter *padapter, int timeout_ms); void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq); @@ -587,7 +576,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da); s32 issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid, - u8* da, int try_cnt, int wait_ms); + u8 *da, int try_cnt, int wait_ms); int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms); int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, @@ -609,46 +598,46 @@ void start_clnt_join(struct adapter *padapter); void start_create_ibss(struct adapter *padapter); unsigned int OnAssocReq(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAssocRsp(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnProbeReq(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnProbeRsp(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int DoReserved(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnBeacon(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAtim(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnDisassoc(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAuth(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAuthClient(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnDeAuth(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int on_action_spct(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_qos(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_dls(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_back(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int on_action_public(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_ht(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_wmm(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); unsigned int OnAction_p2p(struct adapter *padapter, - union recv_frame *precv_frame); + struct recv_frame *precv_frame); void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res); void mlmeext_sta_del_event_callback(struct adapter *padapter); @@ -657,9 +646,9 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, void linked_status_chk(struct adapter *padapter); -void survey_timer_hdl (struct adapter *padapter); -void link_timer_hdl (struct adapter *padapter); -void addba_timer_hdl(struct sta_info *psta); +void survey_timer_hdl(void *function_context); +void link_timer_hdl(void *funtion_context); +void addba_timer_hdl(void *function_context); #define set_survey_timer(mlmeext, ms) \ do { \ @@ -719,78 +708,21 @@ u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf); #ifdef _RTW_CMD_C_ static struct cmd_hdl wlancmds[] = { - GEN_DRV_CMD_HANDLER(0, NULL) /*0*/ - GEN_DRV_CMD_HANDLER(0, NULL) - GEN_DRV_CMD_HANDLER(0, NULL) - GEN_DRV_CMD_HANDLER(0, NULL) - GEN_DRV_CMD_HANDLER(0, NULL) - GEN_DRV_CMD_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) /*10*/ - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct joinbss_parm), join_cmd_hdl) /*14*/ - GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct createbss_parm), createbss_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), - sitesurvey_cmd_hdl) /*18*/ - GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl) /*20*/ - GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl) - GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL) /*30*/ - GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL) - GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) /*40*/ - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), join_cmd_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct disconnect_parm), disconnect_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), createbss_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct setopmode_parm), setopmode_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct setauth_parm), setauth_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct setkey_parm), setkey_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct set_stakey_parm), set_stakey_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct set_assocsta_parm), NULL) GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl) - GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl) /* 46 */ - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) /*50*/ - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(0, NULL) - GEN_MLME_EXT_HANDLER(sizeof(struct Tx_Beacon_param), - tx_beacon_hdl) /*55*/ - - GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl) /*56*/ - GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl) /*57*/ - - GEN_MLME_EXT_HANDLER(0, h2c_msg_hdl) /*58*/ - GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), - set_chplan_hdl) /*59*/ - GEN_MLME_EXT_HANDLER(sizeof(struct LedBlink_param), - led_blink_hdl) /*60*/ - - GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param), - set_csa_hdl) /*61*/ - GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param), - tdls_hdl) /*62*/ + GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), tx_beacon_hdl) + GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl) + GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), set_chplan_hdl) }; #endif @@ -855,7 +787,7 @@ static struct fwevent wlanevents[] = { {0, NULL}, {0, NULL}, {0, &rtw_survey_event_callback}, /*8*/ - {sizeof (struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ + {sizeof(struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ {0, &rtw_joinbss_event_callback}, /*10*/ {sizeof(struct stassoc_event), &rtw_stassoc_event_callback}, {sizeof(struct stadel_event), &rtw_stadel_event_callback}, diff --git a/include/rtw_pwrctrl.h b/include/rtw_pwrctrl.h index d4b8acb..54dfbf0 100644 --- a/include/rtw_pwrctrl.h +++ b/include/rtw_pwrctrl.h @@ -99,12 +99,7 @@ struct reportpwrstate_parm { static inline void _init_pwrlock(struct semaphore *plock) { - _rtw_init_sema(plock, 1); -} - -static inline void _free_pwrlock(struct semaphore *plock) -{ - _rtw_free_sema(plock); + sema_init(plock, 1); } static inline void _enter_pwrlock(struct semaphore *plock) @@ -114,7 +109,7 @@ static inline void _enter_pwrlock(struct semaphore *plock) static inline void _exit_pwrlock(struct semaphore *plock) { - _rtw_up_sema(plock); + up(plock); } #define LPS_DELAY_TIME 1*HZ /* 1 sec */ @@ -197,7 +192,7 @@ struct pwrctrl_priv { u8 ips_mode_req; /* used to accept the mode setting request, * will update to ipsmode later */ uint bips_processing; - u32 ips_deny_time; /* will deny IPS when system time less than this */ + unsigned long ips_deny_time; /* will deny IPS when system time less than this */ u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */ u8 bLeisurePs; @@ -211,10 +206,6 @@ struct pwrctrl_priv { u8 bInternalAutoSuspend; u8 bInSuspend; -#ifdef CONFIG_BT_COEXIST - u8 bAutoResume; - u8 autopm_cnt; -#endif u8 bSupportRemoteWakeup; struct timer_list pwr_state_check_timer; int pwr_state_check_interval; @@ -251,7 +242,6 @@ struct pwrctrl_priv { (pwrctrl)->pwr_state_check_interval) void rtw_init_pwrctrl_priv(struct adapter *adapter); -void rtw_free_pwrctrl_priv(struct adapter *adapter); void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode); @@ -268,8 +258,6 @@ s32 LPS_RF_ON_check(struct adapter *adapter, u32 delay_ms); void LPS_Enter(struct adapter *adapter); void LPS_Leave(struct adapter *adapter); -u8 rtw_interface_ps_func(struct adapter *adapter, - enum hal_intf_ps_func efunc_id, u8 *val); void rtw_set_ips_deny(struct adapter *adapter, u32 ms); int _rtw_pwr_wakeup(struct adapter *adapter, u32 ips_defer_ms, const char *caller); diff --git a/include/rtw_recv.h b/include/rtw_recv.h index be9c30c..f0c26ef 100644 --- a/include/rtw_recv.h +++ b/include/rtw_recv.h @@ -175,7 +175,6 @@ recv_thread(passive) ; returnpkt(dispatch) using enter_critical section to protect */ struct recv_priv { - spinlock_t lock; struct __queue free_recv_queue; struct __queue recv_pending_queue; struct __queue uc_swdec_pending_queue; @@ -189,11 +188,6 @@ struct recv_priv { u64 rx_drop; u64 last_rx_bytes; - uint rx_icv_err; - uint rx_largepacket_crcerr; - uint rx_smallpacket_crcerr; - uint rx_middlepacket_crcerr; - struct semaphore allrxreturnevt; uint ff_hwaddr; u8 rx_pending_cnt; @@ -213,9 +207,7 @@ struct recv_priv { u8 signal_strength; u8 signal_qual; u8 noise; - int RxSNRdB[2]; s8 RxRssi[2]; - int FalseAlmCnt_all; struct timer_list signal_stat_timer; u32 signal_stat_sampling_interval; @@ -235,22 +227,8 @@ struct sta_recv_priv { }; struct recv_buf { - struct list_head list; - spinlock_t recvbuf_lock; - u32 ref_cnt; struct adapter *adapter; - u8 *pbuf; - u8 *pallocated_buf; - u32 len; - u8 *phead; - u8 *pdata; - u8 *ptail; - u8 *pend; struct urb *purb; - dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ - u32 alloc_sz; - u8 irp_pending; - int transfer_len; struct sk_buff *pskb; u8 reuse; }; @@ -270,94 +248,47 @@ struct recv_buf { len = (unsigned int )(tail - data); */ -struct recv_frame_hdr { +struct recv_frame { struct list_head list; struct sk_buff *pkt; struct sk_buff *pkt_newalloc; struct adapter *adapter; - u8 fragcnt; - int frame_tag; struct rx_pkt_attrib attrib; uint len; u8 *rx_head; u8 *rx_data; u8 *rx_tail; u8 *rx_end; - void *precvbuf; struct sta_info *psta; /* for A-MPDU Rx reordering buffer control */ struct recv_reorder_ctrl *preorder_ctrl; }; -union recv_frame { - union { - struct list_head list; - struct recv_frame_hdr hdr; - uint mem[RECVFRAME_HDR_ALIGN>>2]; - } u; -}; - -union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); -union recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); -void rtw_init_recvframe(union recv_frame *precvframe, +struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +void rtw_init_recvframe(struct recv_frame *precvframe, struct recv_priv *precvpriv); -int rtw_free_recvframe(union recv_frame *precvframe, +int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue); #define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue) -int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue); -int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue); +int _rtw_enqueue_recvframe(struct recv_frame *precvframe, + struct __queue *queue); +int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue); u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); -int rtw_enqueue_recvbuf_to_head(struct recv_buf *buf, struct __queue *queue); -int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); -struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue); void rtw_reordering_ctrl_timeout_handler(void *pcontext); -static inline u8 *get_rxmem(union recv_frame *precvframe) +static inline u8 *get_rxmem(struct recv_frame *precvframe) { /* always return rx_head... */ if (precvframe == NULL) return NULL; - return precvframe->u.hdr.rx_head; + return precvframe->rx_head; } -static inline u8 *get_rx_status(union recv_frame *precvframe) -{ - return get_rxmem(precvframe); -} - -static inline u8 *get_recvframe_data(union recv_frame *precvframe) -{ - /* always return rx_data */ - if (precvframe == NULL) - return NULL; - - return precvframe->u.hdr.rx_data; -} - -static inline u8 *recvframe_push(union recv_frame *precvframe, int sz) -{ - /* append data before rx_data */ - - /* add data to the start of recv_frame - * - * This function extends the used data area of the recv_frame at the buffer - * start. rx_data must be still larger than rx_head, after pushing. - */ - if (precvframe == NULL) - return NULL; - precvframe->u.hdr.rx_data -= sz ; - if (precvframe->u.hdr.rx_data < precvframe->u.hdr.rx_head) { - precvframe->u.hdr.rx_data += sz; - return NULL; - } - precvframe->u.hdr.len += sz; - return precvframe->u.hdr.rx_data; -} - -static inline u8 *recvframe_pull(union recv_frame *precvframe, int sz) +static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz) { /* rx_data += sz; move rx_data sz bytes hereafter */ @@ -366,16 +297,16 @@ static inline u8 *recvframe_pull(union recv_frame *precvframe, int sz) if (precvframe == NULL) return NULL; - precvframe->u.hdr.rx_data += sz; - if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) { - precvframe->u.hdr.rx_data -= sz; + precvframe->rx_data += sz; + if (precvframe->rx_data > precvframe->rx_tail) { + precvframe->rx_data -= sz; return NULL; } - precvframe->u.hdr.len -= sz; - return precvframe->u.hdr.rx_data; + precvframe->len -= sz; + return precvframe->rx_data; } -static inline u8 *recvframe_put(union recv_frame *precvframe, int sz) +static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz) { /* used for append sz bytes from ptr to rx_tail, update rx_tail * and return the updated rx_tail to the caller */ @@ -384,17 +315,17 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, int sz) if (precvframe == NULL) return NULL; - precvframe->u.hdr.rx_tail += sz; + precvframe->rx_tail += sz; - if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) { - precvframe->u.hdr.rx_tail -= sz; + if (precvframe->rx_tail > precvframe->rx_end) { + precvframe->rx_tail -= sz; return NULL; } - precvframe->u.hdr.len += sz; - return precvframe->u.hdr.rx_tail; + precvframe->len += sz; + return precvframe->rx_tail; } -static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, int sz) +static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz) { /* rmv data from rx_tail (by yitsen) */ @@ -404,64 +335,13 @@ static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, int sz) if (precvframe == NULL) return NULL; - precvframe->u.hdr.rx_tail -= sz; - if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) { - precvframe->u.hdr.rx_tail += sz; + precvframe->rx_tail -= sz; + if (precvframe->rx_tail < precvframe->rx_data) { + precvframe->rx_tail += sz; return NULL; } - precvframe->u.hdr.len -= sz; - return precvframe->u.hdr.rx_tail; -} - -static inline unsigned char *get_rxbuf_desc(union recv_frame *precvframe) -{ - unsigned char *buf_desc; - - if (precvframe == NULL) - return NULL; - return buf_desc; -} - -static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem) -{ - /* due to the design of 2048 bytes alignment of recv_frame, - * we can reference the union recv_frame */ - /* from any given member of recv_frame. */ - /* rxmem indicates the any member/address in recv_frame */ - - return (union recv_frame *)(((size_t)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN); -} - -static inline union recv_frame *pkt_to_recvframe(struct sk_buff *pkt) -{ - u8 *buf_star; - union recv_frame *precv_frame; - precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); - - return precv_frame; -} - -static inline u8 *pkt_to_recvmem(struct sk_buff *pkt) -{ - /* return the rx_head */ - - union recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->u.hdr.rx_head; -} - -static inline u8 *pkt_to_recvdata(struct sk_buff *pkt) -{ - /* return the rx_data */ - - union recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->u.hdr.rx_data; -} - -static inline int get_recvframe_len(union recv_frame *precvframe) -{ - return precvframe->u.hdr.len; + precvframe->len -= sz; + return precvframe->rx_tail; } static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) @@ -480,6 +360,6 @@ struct sta_info; void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); -void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame); +void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame); #endif diff --git a/include/rtw_security.h b/include/rtw_security.h index 23c7814..66d60aa 100644 --- a/include/rtw_security.h +++ b/include/rtw_security.h @@ -354,7 +354,7 @@ static const unsigned long K[64] = { #define RORc(x, y) \ (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y)&31)) | \ ((unsigned long)(x) << (unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) -#define Ch(x, y ,z) (z ^ (x & (y ^ z))) +#define Ch(x, y , z) (z ^ (x & (y ^ z))) #define Maj(x, y, z) (((x | y) & z) | (x & y)) #define S(x, n) RORc((x), (n)) #define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) @@ -378,6 +378,5 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe); u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe); u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe); void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe); -void rtw_use_tkipkey_handler(void *FunctionContext); #endif /* __RTL871X_SECURITY_H_ */ diff --git a/include/rtw_sreset.h b/include/rtw_sreset.h index 2a1244f..580e850 100644 --- a/include/rtw_sreset.h +++ b/include/rtw_sreset.h @@ -24,11 +24,7 @@ #include struct sreset_priv { - struct mutex silentreset_mutex; - u8 silent_reset_inprogress; u8 Wifi_Error_Status; - unsigned long last_tx_time; - unsigned long last_tx_complete_time; }; #include @@ -43,7 +39,6 @@ struct sreset_priv { #define WIFI_IF_NOT_EXIST BIT6 void sreset_init_value(struct adapter *padapter); -void sreset_reset_value(struct adapter *padapter); u8 sreset_get_wifi_status(struct adapter *padapter); void sreset_set_wifi_error_status(struct adapter *padapter, u32 status); diff --git a/include/rtw_xmit.h b/include/rtw_xmit.h index 1ac1dd3..62f5db1 100644 --- a/include/rtw_xmit.h +++ b/include/rtw_xmit.h @@ -105,11 +105,6 @@ struct tx_desc { __le32 txdw7; }; -union txdesc { - struct tx_desc txdesc; - unsigned int value[TXDESC_SIZE>>2]; -}; - struct hw_xmit { struct __queue *sta_queue; int accnt; diff --git a/include/sta_info.h b/include/sta_info.h index 3e909db..9612490 100644 --- a/include/sta_info.h +++ b/include/sta_info.h @@ -182,21 +182,6 @@ struct sta_info { unsigned int sleepq_ac_len; #endif /* CONFIG_88EU_AP_MODE */ -#ifdef CONFIG_88EU_P2P - /* p2p priv data */ - u8 is_p2p_device; - u8 p2p_status_code; - - /* p2p client info */ - u8 dev_addr[ETH_ALEN]; - u8 dev_cap; - u16 config_methods; - u8 primary_dev_type[8]; - u8 num_of_secdev_type; - u8 secdev_types_list[32];/* 32/8 == 4; */ - u16 dev_name_len; - u8 dev_name[32]; -#endif /* CONFIG_88EU_P2P */ u8 under_exist_checking; u8 keep_alive_trycnt; diff --git a/include/usb_ops_linux.h b/include/usb_ops_linux.h index e5b758a..01b3810 100644 --- a/include/usb_ops_linux.h +++ b/include/usb_ops_linux.h @@ -29,6 +29,16 @@ #define RTW_USB_BULKOUT_TIME 5000/* ms */ +#define REALTEK_USB_VENQT_READ 0xC0 +#define REALTEK_USB_VENQT_WRITE 0x40 + +#define ALIGNMENT_UNIT 16 +#define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ +#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) + +#define USB_HIGH_SPEED_BULK_SIZE 512 +#define USB_FULL_SPEED_BULK_SIZE 64 + #define _usbctrl_vendorreq_async_callback(urb, regs) \ _usbctrl_vendorreq_async_callback(urb) #define usb_bulkout_zero_complete(purb, regs) \ @@ -42,14 +52,36 @@ #define usb_read_interrupt_complete(purb, regs) \ usb_read_interrupt_complete(purb) +static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter, + int buf_len) +{ + u8 rst = true; + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + + if (pdvobjpriv->ishighspeed) + rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? + true : false; + else + rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? + true : false; + return rst; +} + unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr); -void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); -void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); +u8 usb_read8(struct adapter *adapter, u32 addr); +u16 usb_read16(struct adapter *adapter, u32 addr); +u32 usb_read32(struct adapter *adapter, u32 addr); -void usb_read_port_cancel(struct intf_hdl *pintfhdl); +u32 usb_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void usb_read_port_cancel(struct adapter *adapter); -u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); -void usb_write_port_cancel(struct intf_hdl *pintfhdl); +int usb_write8(struct adapter *adapter, u32 addr, u8 val); +int usb_write16(struct adapter *adapter, u32 addr, u16 val); +int usb_write32(struct adapter *adapter, u32 addr, u32 val); +int usb_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata); + +u32 usb_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void usb_write_port_cancel(struct adapter *adapter); #endif diff --git a/include/wifi.h b/include/wifi.h index 84e5199..8dbdfaf 100644 --- a/include/wifi.h +++ b/include/wifi.h @@ -694,7 +694,7 @@ struct WMM_para_element { struct ADDBA_request { unsigned char dialog_token; - unsigned short BA_para_set; + __le16 BA_para_set; unsigned short BA_timeout_value; unsigned short BA_starting_seqctrl; } __packed; @@ -766,27 +766,27 @@ enum ht_cap_ampdu_factor { #define OP_MODE_20MHZ_HT_STA_ASSOCED 2 #define OP_MODE_MIXED 3 -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2)) -#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) -#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) -#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8)BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8)BIT(0)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8)BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8)BIT(2)) +#define HT_INFO_HT_PARAM_RIFS_MODE ((u8)BIT(3)) +#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8)BIT(4)) +#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8)BIT(5)) #define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ - ((u16) (0x0001 | 0x0002)) + ((u16)(0x0001 | 0x0002)) #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 -#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2)) -#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3)) -#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4)) +#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8)BIT(2)) +#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8)BIT(3)) +#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8)BIT(4)) -#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) -#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) -#define HT_INFO_STBC_PARAM_SECONDARY_BC ((u16) BIT(8)) -#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9)) -#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10)) -#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11)) +#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16)BIT(6)) +#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16)BIT(7)) +#define HT_INFO_STBC_PARAM_SECONDARY_BC ((u16)BIT(8)) +#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16)BIT(9)) +#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16)BIT(10)) +#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16)BIT(11)) /* ===============WPS Section=============== */ /* For WPSv1.0 */ @@ -1080,7 +1080,7 @@ enum P2P_PROTO_WK_ID { P2P_PRE_TX_PROVDISC_PROCESS_WK = 2, P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3, P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4, - P2P_AP_P2P_CH_SWITCH_PROCESS_WK =5, + P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5, P2P_RO_CH_WK = 6, }; diff --git a/include/wlan_bssdef.h b/include/wlan_bssdef.h index e70075d..53b1bd8 100644 --- a/include/wlan_bssdef.h +++ b/include/wlan_bssdef.h @@ -340,8 +340,4 @@ struct ndis_802_11_cap { struct ndis_802_11_auth_encrypt AuthenticationEncryptionSupported[1]; }; -u8 key_2char2num(u8 hch, u8 lch); -u8 key_char2num(u8 ch); -u8 str_2char2num(u8 hch, u8 lch); - #endif /* ifndef WLAN_BSSDEF_H_ */ diff --git a/include/xmit_osdep.h b/include/xmit_osdep.h index 2ff622b..13965f2 100644 --- a/include/xmit_osdep.h +++ b/include/xmit_osdep.h @@ -32,10 +32,6 @@ struct pkt_file { size_t buf_len; }; -extern int rtw_ht_enable; -extern int rtw_cbw40_enable; -extern int rtw_ampdu_enable;/* for enable tx_ampdu */ - #define NR_XMITFRAME 256 struct xmit_priv; @@ -53,8 +49,6 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz); -void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib); - uint rtw_remainder_len(struct pkt_file *pfile); void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile); uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen); diff --git a/os_dep/ioctl_linux.c b/os_dep/ioctl_linux.c index eb05efb..24a8f5a 100644 --- a/os_dep/ioctl_linux.c +++ b/os_dep/ioctl_linux.c @@ -28,13 +28,11 @@ #include #include #include -#include -#include -#include #include -#include #include +#include +#include "osdep_intf.h" #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) @@ -55,48 +53,6 @@ #define WEXT_CSCAN_HOME_DWELL_SECTION 'H' #define WEXT_CSCAN_TYPE_SECTION 'T' -static struct mp_ioctl_handler mp_ioctl_hdl[] = { -/*0*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_start_test_hdl, OID_RT_PRO_START_TEST) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_stop_test_hdl, OID_RT_PRO_STOP_TEST) - - GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_read_register_hdl, OID_RT_PRO_READ_REGISTER) - GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_write_register_hdl, OID_RT_PRO_WRITE_REGISTER) - GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_read_bb_reg_hdl, OID_RT_PRO_READ_BB_REG) -/*5*/ GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_write_bb_reg_hdl, OID_RT_PRO_WRITE_BB_REG) - GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_read_rf_reg_hdl, OID_RT_PRO_RF_READ_REGISTRY) - GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_write_rf_reg_hdl, OID_RT_PRO_RF_WRITE_REGISTRY) - - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl, OID_RT_PRO_SET_CHANNEL_DIRECT_CALL) - GEN_HANDLER(sizeof(struct txpower_param), rtl8188eu_oid_rt_pro_set_tx_power_control_hdl, OID_RT_PRO_SET_TX_POWER_CONTROL) -/*10*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_data_rate_hdl, OID_RT_PRO_SET_DATA_RATE) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_bandwidth_hdl, OID_RT_SET_BANDWIDTH) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_antenna_bb_hdl, OID_RT_PRO_SET_ANTENNA_BB) - - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_continuous_tx_hdl, OID_RT_PRO_SET_CONTINUOUS_TX) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl, OID_RT_PRO_SET_SINGLE_CARRIER_TX) -/*15*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl, OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl, OID_RT_PRO_SET_SINGLE_TONE_TX) - - EXT_MP_IOCTL_HANDLER(0, xmit_packet, 0) - - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_rx_packet_type_hdl, OID_RT_SET_RX_PACKET_TYPE) - GEN_HANDLER(0, rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl, OID_RT_RESET_PHY_RX_PACKET_COUNT) -/*20*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl, OID_RT_GET_PHY_RX_PACKET_RECEIVED) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl, OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR) - - GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) - GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) - GEN_HANDLER(sizeof(struct efuse_access_struct), rtl8188eu_oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE) -/*25*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_efuse_map_hdl, OID_RT_PRO_EFUSE_MAP) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_max_size_hdl, OID_RT_GET_EFUSE_MAX_SIZE) - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_current_size_hdl, OID_RT_GET_EFUSE_CURRENT_SIZE) - - GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_thermal_meter_hdl, OID_RT_PRO_GET_THERMAL_METER) - GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_pro_set_power_tracking_hdl, OID_RT_PRO_SET_POWER_TRACKING) -/*30*/ GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_set_power_down_hdl, OID_RT_SET_POWER_DOWN) -/*31*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_trigger_gpio_hdl, 0) -}; - static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; @@ -106,49 +62,11 @@ static const char * const iw_operation_mode[] = { "Secondary", "Monitor" }; -static int hex2num_i(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - return -1; -} - -/** - * hwaddr_aton - Convert ASCII string to MAC address - * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") - * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) - * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) - */ -static int hwaddr_aton_i(const char *txt, u8 *addr) -{ - int i; - - for (i = 0; i < 6; i++) { - int a, b; - - a = hex2num_i(*txt++); - if (a < 0) - return -1; - b = hex2num_i(*txt++); - if (b < 0) - return -1; - *addr++ = (a << 4) | b; - if (i < 5 && *txt++ != ':') - return -1; - } - - return 0; -} - void indicate_wx_scan_complete_event(struct adapter *padapter) { union iwreq_data wrqu; - _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); + memset(&wrqu, 0, sizeof(union iwreq_data)); wireless_send_event(padapter->pnetdev, SIOCGIWSCAN, &wrqu, NULL); } @@ -157,7 +75,7 @@ void rtw_indicate_wx_assoc_event(struct adapter *padapter) union iwreq_data wrqu; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); + memset(&wrqu, 0, sizeof(union iwreq_data)); wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -171,10 +89,10 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter) { union iwreq_data wrqu; - _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); + memset(&wrqu, 0, sizeof(union iwreq_data)); wrqu.ap_addr.sa_family = ARPHRD_ETHER; - _rtw_memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); + memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); DBG_88E_LEVEL(_drv_always_, "indicate disassoc\n"); wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); @@ -197,35 +115,6 @@ static char *translate_scan(struct adapter *padapter, u8 bw_40MHz = 0, short_GI = 0; u16 mcs_rate = 0; u8 ss, sq; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - u32 blnGotP2PIE = false; - - /* User is doing the P2P device discovery */ - /* The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. */ - /* If not, the driver should ignore this AP and go to the next AP. */ - - /* Verifying the SSID */ - if (!memcmp(pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN)) { - u32 p2pielen = 0; - - if (pnetwork->network.Reserved[0] == 2) {/* Probe Request */ - /* Verifying the P2P IE */ - if (rtw_get_p2p_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &p2pielen)) - blnGotP2PIE = true; - } else {/* Beacon or Probe Respones */ - /* Verifying the P2P IE */ - if (rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen)) - blnGotP2PIE = true; - } - } - - if (!blnGotP2PIE) - return start; - } -#endif /* CONFIG_88EU_P2P */ /* AP MAC address */ iwe.cmd = SIOCGIWAP; @@ -357,33 +246,33 @@ static char *translate_scan(struct adapter *padapter, if (wpa_len > 0) { p = buf; - _rtw_memset(buf, 0, MAX_WPA_IE_LEN); - p += sprintf(p, "wpa_ie ="); + memset(buf, 0, MAX_WPA_IE_LEN); + p += sprintf(p, "wpa_ie="); for (i = 0; i < wpa_len; i++) p += sprintf(p, "%02x", wpa_ie[i]); - _rtw_memset(&iwe, 0, sizeof(iwe)); + memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); start = iwe_stream_add_point(info, start, stop, &iwe, buf); - _rtw_memset(&iwe, 0, sizeof(iwe)); + memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVGENIE; iwe.u.data.length = wpa_len; start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie); } if (rsn_len > 0) { p = buf; - _rtw_memset(buf, 0, MAX_WPA_IE_LEN); - p += sprintf(p, "rsn_ie ="); + memset(buf, 0, MAX_WPA_IE_LEN); + p += sprintf(p, "rsn_ie="); for (i = 0; i < rsn_len; i++) p += sprintf(p, "%02x", rsn_ie[i]); - _rtw_memset(&iwe, 0, sizeof(iwe)); + memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = strlen(buf); start = iwe_stream_add_point(info, start, stop, &iwe, buf); - _rtw_memset(&iwe, 0, sizeof(iwe)); + memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVGENIE; iwe.u.data.length = rsn_len; start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie); @@ -468,16 +357,11 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ - -_func_enter_; param->u.crypt.err = 0; param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - if (param_len < (u32) ((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { + if (param_len < (u32)((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { ret = -EINVAL; goto exit; } @@ -521,7 +405,7 @@ _func_enter_; RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); goto exit; } - _rtw_memset(pwep, 0, wep_total_len); + memset(pwep, 0, wep_total_len); pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; if (wep_key_len == 13) { @@ -590,10 +474,6 @@ _func_enter_; padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); -#ifdef CONFIG_88EU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_DONE); -#endif /* CONFIG_88EU_P2P */ } } pbcmc_sta = rtw_get_bcmc_stainfo(padapter); @@ -614,9 +494,6 @@ _func_enter_; exit: kfree(pwep); - -_func_exit_; - return ret; } @@ -625,9 +502,6 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie u8 *buf = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) { _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); @@ -638,14 +512,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie } if (ielen) { - buf = rtw_zmalloc(ielen); + buf = kmemdup(pie, ielen, GFP_KERNEL); if (buf == NULL) { ret = -ENOMEM; goto exit; } - memcpy(buf, pie, ielen); - /* dump */ { int i; @@ -733,10 +605,6 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); -#ifdef CONFIG_88EU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK)) - rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING); -#endif /* CONFIG_88EU_P2P */ cnt += buf[cnt+1]+2; break; } else { @@ -770,8 +638,6 @@ static int rtw_wx_get_name(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); - _func_enter_; - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { /* parsing HT_CAP_IE */ p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); @@ -806,9 +672,6 @@ static int rtw_wx_get_name(struct net_device *dev, } else { snprintf(wrqu->name, IFNAMSIZ, "unassociated"); } - - _func_exit_; - return 0; } @@ -816,12 +679,7 @@ static int rtw_wx_set_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - _func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n")); - - _func_exit_; - return 0; } @@ -854,8 +712,6 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, enum ndis_802_11_network_infra networkType; int ret = 0; - _func_enter_; - if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -EPERM; goto exit; @@ -894,7 +750,6 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, } rtw_setopmode_cmd(padapter, networkType); exit: - _func_exit_; return ret; } @@ -906,8 +761,6 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); - _func_enter_; - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) wrqu->mode = IW_MODE_INFRA; else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || @@ -918,8 +771,6 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, else wrqu->mode = IW_MODE_AUTO; - _func_exit_; - return 0; } @@ -976,14 +827,14 @@ static int rtw_wx_set_pmkid(struct net_device *dev, for (j = 0; j < NUM_PMKID_CACHE; j++) { if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ - _rtw_memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN); + memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN); psecuritypriv->PMKIDList[j].bUsed = false; break; } } } else if (pPMK->cmd == IW_PMKSA_FLUSH) { DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); - _rtw_memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); psecuritypriv->PMKIDIndex = 0; ret = true; } @@ -1011,12 +862,10 @@ static int rtw_wx_get_range(struct net_device *dev, u16 val; int i; - _func_enter_; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd)); wrqu->data.length = sizeof(*range); - _rtw_memset(range, 0, sizeof(*range)); + memset(range, 0, sizeof(*range)); /* Let's try to keep this struct in the same order as in * linux/include/wireless.h @@ -1093,8 +942,6 @@ static int rtw_wx_get_range(struct net_device *dev, range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL | IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; - _func_exit_; - return 0; } @@ -1108,7 +955,6 @@ static int rtw_wx_set_wap(struct net_device *dev, union iwreq_data *awrq, char *extra) { - unsigned long irqL; uint ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct sockaddr *temp = (struct sockaddr *)awrq; @@ -1119,8 +965,6 @@ static int rtw_wx_set_wap(struct net_device *dev, struct wlan_network *pnetwork = NULL; enum ndis_802_11_auth_mode authmode; - _func_enter_; - if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -1; goto exit; @@ -1137,17 +981,14 @@ static int rtw_wx_set_wap(struct net_device *dev, } authmode = padapter->securitypriv.ndisauthtype; - _enter_critical_bh(&queue->lock, &irqL); + spin_lock_bh(&queue->lock); phead = get_list_head(queue); - pmlmepriv->pscanned = get_next(phead); + pmlmepriv->pscanned = phead->next; - while (1) { - if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true) - break; + while (phead != pmlmepriv->pscanned) { + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); - - pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + pmlmepriv->pscanned = pmlmepriv->pscanned->next; dst_bssid = pnetwork->network.MacAddress; @@ -1156,14 +997,14 @@ static int rtw_wx_set_wap(struct net_device *dev, if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { ret = -1; - _exit_critical_bh(&queue->lock, &irqL); + spin_unlock_bh(&queue->lock); goto exit; } break; } } - _exit_critical_bh(&queue->lock, &irqL); + spin_unlock_bh(&queue->lock); rtw_set_802_11_authentication_mode(padapter, authmode); /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ @@ -1174,8 +1015,6 @@ static int rtw_wx_set_wap(struct net_device *dev, exit: - _func_exit_; - return ret; } @@ -1189,21 +1028,16 @@ static int rtw_wx_get_wap(struct net_device *dev, wrqu->ap_addr.sa_family = ARPHRD_ETHER; - _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); - _func_enter_; - if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); else - _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - - _func_exit_; - + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); return 0; } @@ -1248,13 +1082,8 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; - unsigned long irqL; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); -#endif /* CONFIG_88EU_P2P */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); -_func_enter_; if (padapter->registrypriv.mp_mode == 1) { if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { ret = -1; @@ -1299,33 +1128,25 @@ _func_enter_; /* the pmlmepriv->scan_interval is always equal to 3. */ /* So, the wpa_supplicant won't find out the WPS SoftAP. */ -#ifdef CONFIG_88EU_P2P - if (pwdinfo->p2p_state != P2P_STATE_NONE) { - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_FULL); - rtw_free_network_queue(padapter, true); - } -#endif /* CONFIG_88EU_P2P */ - - _rtw_memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); + memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); if (wrqu->data.length == sizeof(struct iw_scan_req)) { struct iw_scan_req *req = (struct iw_scan_req *)extra; if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { - int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); + int len = min_t(int, req->essid_len, + IW_ESSID_MAX_SIZE); memcpy(ssid[0].Ssid, req->essid, len); ssid[0].SsidLength = len; DBG_88E("IW_SCAN_THIS_ESSID, ssid =%s, len =%d\n", req->essid, req->essid_len); - _enter_critical_bh(&pmlmepriv->lock, &irqL); + spin_lock_bh(&pmlmepriv->lock); _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); - _exit_critical_bh(&pmlmepriv->lock, &irqL); + spin_unlock_bh(&pmlmepriv->lock); } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { DBG_88E("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n"); } @@ -1385,14 +1206,12 @@ _func_enter_; exit: -_func_exit_; return ret; } static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - unsigned long irqL; struct list_head *plist, *phead; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -1404,72 +1223,51 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, u32 cnt = 0; u32 wait_for_surveydone; int wait_status; -#ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_88EU_P2P */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n")); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n")); - _func_enter_; - if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { ret = -EINVAL; goto exit; } -#ifdef CONFIG_88EU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - /* P2P is enabled */ - wait_for_surveydone = 200; - } else { - /* P2P is disabled */ - wait_for_surveydone = 100; - } -#else - { - wait_for_surveydone = 100; - } -#endif /* CONFIG_88EU_P2P */ + wait_for_surveydone = 100; wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; while (check_fwstate(pmlmepriv, wait_status)) { - rtw_msleep_os(30); + msleep(30); cnt++; if (cnt > wait_for_surveydone) break; } - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist)) - break; + plist = phead->next; + while (phead != plist) { if ((stop - ev) < SCAN_ITEM_SIZE) { ret = -E2BIG; break; } - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) ev = translate_scan(padapter, a, pnetwork, ev, stop); - plist = get_next(plist); + plist = plist->next; } - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); wrqu->data.length = ev-extra; wrqu->data.flags = 0; exit: - _func_exit_; return ret; } @@ -1482,7 +1280,6 @@ static int rtw_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - unsigned long irqL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *queue = &pmlmepriv->scanned_queue; @@ -1494,7 +1291,6 @@ static int rtw_wx_set_essid(struct net_device *dev, uint ret = 0, len; - _func_enter_; RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); @@ -1526,27 +1322,20 @@ static int rtw_wx_set_essid(struct net_device *dev, if (wrqu->essid.length != 33) DBG_88E("ssid =%s, len =%d\n", extra, wrqu->essid.length); - _rtw_memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); + memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); ndis_ssid.SsidLength = len; memcpy(ndis_ssid.Ssid, extra, len); src_ssid = ndis_ssid.Ssid; RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid)); - _enter_critical_bh(&queue->lock, &irqL); + spin_lock_bh(&queue->lock); phead = get_list_head(queue); - pmlmepriv->pscanned = get_next(phead); + pmlmepriv->pscanned = phead->next; - while (1) { - if (rtw_end_of_queue_search(phead, pmlmepriv->pscanned) == true) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_, - ("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n")); + while (phead != pmlmepriv->pscanned) { + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); - break; - } - - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); - - pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + pmlmepriv->pscanned = pmlmepriv->pscanned->next; dst_ssid = pnetwork->network.Ssid.Ssid; @@ -1566,14 +1355,14 @@ static int rtw_wx_set_essid(struct net_device *dev, if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { ret = -1; - _exit_critical_bh(&queue->lock, &irqL); + spin_unlock_bh(&queue->lock); goto exit; } break; } } - _exit_critical_bh(&queue->lock, &irqL); + spin_unlock_bh(&queue->lock); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("set ssid: set_802_11_auth. mode =%d\n", authmode)); rtw_set_802_11_authentication_mode(padapter, authmode); @@ -1587,7 +1376,6 @@ exit: DBG_88E("<=%s, ret %d\n", __func__, ret); - _func_exit_; return ret; } @@ -1603,7 +1391,6 @@ static int rtw_wx_get_essid(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); - _func_enter_; if ((check_fwstate(pmlmepriv, _FW_LINKED)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { @@ -1621,7 +1408,6 @@ static int rtw_wx_get_essid(struct net_device *dev, exit: - _func_exit_; return ret; } @@ -1630,15 +1416,13 @@ static int rtw_wx_set_rate(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - int i, ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int i; u8 datarates[NumRates]; u32 target_rate = wrqu->bitrate.value; u32 fixed = wrqu->bitrate.fixed; u32 ratevalue = 0; u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); @@ -1705,14 +1489,7 @@ set_rate: RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("datarate_inx =%d\n", datarates[i])); } - if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("rtw_wx_set_rate Fail!!!\n")); - ret = -1; - } - -_func_exit_; - - return ret; + return 0; } static int rtw_wx_get_rate(struct net_device *dev, @@ -1738,7 +1515,6 @@ static int rtw_wx_set_rts(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; if (wrqu->rts.disabled) { padapter->registrypriv.rts_thresh = 2347; @@ -1752,7 +1528,6 @@ static int rtw_wx_set_rts(struct net_device *dev, DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); - _func_exit_; return 0; } @@ -1763,7 +1538,6 @@ static int rtw_wx_get_rts(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); @@ -1771,7 +1545,6 @@ static int rtw_wx_get_rts(struct net_device *dev, wrqu->rts.fixed = 0; /* no auto select */ /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ - _func_exit_; return 0; } @@ -1782,7 +1555,6 @@ static int rtw_wx_set_frag(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; if (wrqu->frag.disabled) { padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; @@ -1796,7 +1568,6 @@ static int rtw_wx_set_frag(struct net_device *dev, DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); - _func_exit_; return 0; } @@ -1807,14 +1578,12 @@ static int rtw_wx_get_frag(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - _func_enter_; DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); wrqu->frag.value = padapter->xmitpriv.frag_len; wrqu->frag.fixed = 0; /* no auto select */ - _func_exit_; return 0; } @@ -1844,11 +1613,10 @@ static int rtw_wx_set_enc(struct net_device *dev, struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; DBG_88E("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags); - _rtw_memset(&wep, 0, sizeof(struct ndis_802_11_wep)); + memset(&wep, 0, sizeof(struct ndis_802_11_wep)); key = erq->flags & IW_ENCODE_INDEX; - _func_enter_; if (erq->flags & IW_ENCODE_DISABLED) { DBG_88E("EncryptionDisabled\n"); @@ -1943,7 +1711,6 @@ static int rtw_wx_set_enc(struct net_device *dev, exit: - _func_exit_; return ret; } @@ -1957,7 +1724,6 @@ static int rtw_wx_get_enc(struct net_device *dev, struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - _func_enter_; if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { @@ -2011,7 +1777,6 @@ static int rtw_wx_get_enc(struct net_device *dev, erq->flags |= IW_ENCODE_DISABLED; break; } - _func_exit_; return ret; } @@ -2137,10 +1902,10 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, if (param == NULL) return -1; - _rtw_memset(param, 0, param_len); + memset(param, 0, param_len); param->cmd = IEEE_CMD_SET_ENCRYPTION; - _rtw_memset(param->sta_addr, 0xff, ETH_ALEN); + memset(param->sta_addr, 0xff, ETH_ALEN); switch (pext->alg) { case IW_ENCODE_ALG_NONE: @@ -2158,7 +1923,8 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, alg_name = "CCMP"; break; default: - return -1; + ret = -1; + goto exit; } strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); @@ -2185,6 +1951,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, ret = wpa_set_encryption(dev, param, param_len); +exit: kfree(param); return ret; } @@ -2203,2478 +1970,12 @@ static int rtw_wx_get_nick(struct net_device *dev, return 0; } -static int rtw_wx_read32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter; - struct iw_point *p; - u16 len; - u32 addr; - u32 data32; - u32 bytes; - u8 *ptmp; - - padapter = (struct adapter *)rtw_netdev_priv(dev); - p = &wrqu->data; - len = p->length; - ptmp = (u8 *)rtw_malloc(len); - if (NULL == ptmp) - return -ENOMEM; - - if (copy_from_user(ptmp, p->pointer, len)) { - kfree(ptmp); - return -EFAULT; - } - - bytes = 0; - addr = 0; - sscanf(ptmp, "%d,%x", &bytes, &addr); - - switch (bytes) { - case 1: - data32 = rtw_read8(padapter, addr); - sprintf(extra, "0x%02X", data32); - break; - case 2: - data32 = rtw_read16(padapter, addr); - sprintf(extra, "0x%04X", data32); - break; - case 4: - data32 = rtw_read32(padapter, addr); - sprintf(extra, "0x%08X", data32); - break; - default: - DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); - return -EINVAL; - } - DBG_88E(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra); - - kfree(ptmp); - return 0; -} - -static int rtw_wx_write32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - u32 addr; - u32 data32; - u32 bytes; - - bytes = 0; - addr = 0; - data32 = 0; - sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32); - - switch (bytes) { - case 1: - rtw_write8(padapter, addr, (u8)data32); - DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32); - break; - case 2: - rtw_write16(padapter, addr, (u16)data32); - DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32); - break; - case 4: - rtw_write32(padapter, addr, data32); - DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32); - break; - default: - DBG_88E(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); - return -EINVAL; - } - - return 0; -} - -static int rtw_wx_read_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u32 path, addr, data32; - - path = *(u32 *)extra; - addr = *((u32 *)extra + 1); - data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF); - /* - * IMPORTANT!! - * Only when wireless private ioctl is at odd order, - * "extra" would be copied to user space. - */ - sprintf(extra, "0x%05x", data32); - - return 0; -} - -static int rtw_wx_write_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u32 path, addr, data32; - - path = *(u32 *)extra; - addr = *((u32 *)extra + 1); - data32 = *((u32 *)extra + 2); - rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32); - - return 0; -} - -static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - return -1; -} - static int dummy(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { return -1; } -static int rtw_wx_set_channel_plan(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 channel_plan_req = (u8) (*((int *)wrqu)); - - if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1)) - DBG_88E("%s set channel_plan = 0x%02X\n", __func__, pmlmepriv->ChannelPlan); - else - return -EPERM; - - return 0; -} - -static int rtw_wx_set_mtk_wps_probe_ie(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - return 0; -} - -static int rtw_wx_get_sensitivity(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *buf) -{ - return 0; -} - -static int rtw_wx_set_mtk_wps_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - -/* - * For all data larger than 16 octets, we need to use a - * pointer to memory allocated in user space. - */ -static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - -static void rtw_dbg_mode_hdl(struct adapter *padapter, u32 id, u8 *pdata, u32 len) -{ - struct mp_rw_reg *RegRWStruct; - struct rf_reg_param *prfreg; - u8 path; - u8 offset; - u32 value; - - DBG_88E("%s\n", __func__); - - switch (id) { - case GEN_MP_IOCTL_SUBCODE(MP_START): - DBG_88E("871x_driver is only for normal mode, can't enter mp mode\n"); - break; - case GEN_MP_IOCTL_SUBCODE(READ_REG): - RegRWStruct = (struct mp_rw_reg *)pdata; - switch (RegRWStruct->width) { - case 1: - RegRWStruct->value = rtw_read8(padapter, RegRWStruct->offset); - break; - case 2: - RegRWStruct->value = rtw_read16(padapter, RegRWStruct->offset); - break; - case 4: - RegRWStruct->value = rtw_read32(padapter, RegRWStruct->offset); - break; - default: - break; - } - - break; - case GEN_MP_IOCTL_SUBCODE(WRITE_REG): - RegRWStruct = (struct mp_rw_reg *)pdata; - switch (RegRWStruct->width) { - case 1: - rtw_write8(padapter, RegRWStruct->offset, (u8)RegRWStruct->value); - break; - case 2: - rtw_write16(padapter, RegRWStruct->offset, (u16)RegRWStruct->value); - break; - case 4: - rtw_write32(padapter, RegRWStruct->offset, (u32)RegRWStruct->value); - break; - default: - break; - } - - break; - case GEN_MP_IOCTL_SUBCODE(READ_RF_REG): - - prfreg = (struct rf_reg_param *)pdata; - - path = (u8)prfreg->path; - offset = (u8)prfreg->offset; - - value = rtw_hal_read_rfreg(padapter, path, offset, 0xffffffff); - - prfreg->value = value; - - break; - case GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG): - - prfreg = (struct rf_reg_param *)pdata; - - path = (u8)prfreg->path; - offset = (u8)prfreg->offset; - value = prfreg->value; - - rtw_hal_write_rfreg(padapter, path, offset, 0xffffffff, value); - - break; - case GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO): - DBG_88E("==> trigger gpio 0\n"); - rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, NULL); - break; - case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS): - *pdata = rtw_hal_sreset_get_wifi_status(padapter); - break; - default: - break; - } -} - -static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - u32 BytesRead, BytesWritten, BytesNeeded; - struct oid_par_priv oid_par; - struct mp_ioctl_handler *phandler; - struct mp_ioctl_param *poidparam; - uint status = 0; - u16 len; - u8 *pparmbuf = NULL, bset; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *p = &wrqu->data; - - if ((!p->length) || (!p->pointer)) { - ret = -EINVAL; - goto _rtw_mp_ioctl_hdl_exit; - } - pparmbuf = NULL; - bset = (u8)(p->flags & 0xFFFF); - len = p->length; - pparmbuf = (u8 *)rtw_malloc(len); - if (pparmbuf == NULL) { - ret = -ENOMEM; - goto _rtw_mp_ioctl_hdl_exit; - } - - if (copy_from_user(pparmbuf, p->pointer, len)) { - ret = -EFAULT; - goto _rtw_mp_ioctl_hdl_exit; - } - - poidparam = (struct mp_ioctl_param *)pparmbuf; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("rtw_mp_ioctl_hdl: subcode [%d], len[%d], buffer_len[%d]\r\n", - poidparam->subcode, poidparam->len, len)); - - if (poidparam->subcode >= MAX_MP_IOCTL_SUBCODE) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("no matching drvext subcodes\r\n")); - ret = -EINVAL; - goto _rtw_mp_ioctl_hdl_exit; - } - - if (padapter->registrypriv.mp_mode == 1) { - phandler = mp_ioctl_hdl + poidparam->subcode; - - if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, - ("no matching drvext param size %d vs %d\r\n", - poidparam->len, phandler->paramsize)); - ret = -EINVAL; - goto _rtw_mp_ioctl_hdl_exit; - } - - if (phandler->handler) { - oid_par.adapter_context = padapter; - oid_par.oid = phandler->oid; - oid_par.information_buf = poidparam->data; - oid_par.information_buf_len = poidparam->len; - oid_par.dbg = 0; - - BytesWritten = 0; - BytesNeeded = 0; - - if (bset) { - oid_par.bytes_rw = &BytesRead; - oid_par.bytes_needed = &BytesNeeded; - oid_par.type_of_oid = SET_OID; - } else { - oid_par.bytes_rw = &BytesWritten; - oid_par.bytes_needed = &BytesNeeded; - oid_par.type_of_oid = QUERY_OID; - } - - status = phandler->handler(&oid_par); - } else { - DBG_88E("rtw_mp_ioctl_hdl(): err!, subcode =%d, oid =%d, handler =%p\n", - poidparam->subcode, phandler->oid, phandler->handler); - ret = -EFAULT; - goto _rtw_mp_ioctl_hdl_exit; - } - } else { - rtw_dbg_mode_hdl(padapter, poidparam->subcode, poidparam->data, poidparam->len); - } - - if (bset == 0x00) {/* query info */ - if (copy_to_user(p->pointer, pparmbuf, len)) - ret = -EFAULT; - } - - if (status) { - ret = -EFAULT; - goto _rtw_mp_ioctl_hdl_exit; - } - -_rtw_mp_ioctl_hdl_exit: - - kfree(pparmbuf); - return ret; -} - -static int rtw_get_ap_info(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - u32 cnt = 0, wpa_ielen; - unsigned long irqL; - struct list_head *plist, *phead; - unsigned char *pbuf; - u8 bssid[ETH_ALEN]; - char data[32]; - struct wlan_network *pnetwork = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct iw_point *pdata = &wrqu->data; - - DBG_88E("+rtw_get_aplist_info\n"); - - if ((padapter->bDriverStopped) || (pdata == NULL)) { - ret = -EINVAL; - goto exit; - } - - while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)))) { - rtw_msleep_os(30); - cnt++; - if (cnt > 100) - break; - } - pdata->flags = 0; - if (pdata->length >= 32) { - if (copy_from_user(data, pdata->pointer, 32)) { - ret = -EINVAL; - goto exit; - } - } else { - ret = -EINVAL; - goto exit; - } - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - - if (hwaddr_aton_i(data, bssid)) { - DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data); - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - return -EINVAL; - } - - if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { - /* BSSID match, then check if supporting wpa/wpa2 */ - DBG_88E("BSSID:%pM\n", (bssid)); - - pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); - if (pbuf && (wpa_ielen > 0)) { - pdata->flags = 1; - break; - } - - pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); - if (pbuf && (wpa_ielen > 0)) { - pdata->flags = 2; - break; - } - } - - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (pdata->length >= 34) { - if (copy_to_user(pdata->pointer+32, (u8 *)&pdata->flags, 1)) { - ret = -EINVAL; - goto exit; - } - } - -exit: - - return ret; -} - -static int rtw_set_pid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - int *pdata = (int *)wrqu; - int selector; - - if ((padapter->bDriverStopped) || (pdata == NULL)) { - ret = -EINVAL; - goto exit; - } - - selector = *pdata; - if (selector < 3 && selector >= 0) { - padapter->pid[selector] = *(pdata+1); - ui_pid[selector] = *(pdata+1); - DBG_88E("%s set pid[%d] =%d\n", __func__, selector, padapter->pid[selector]); - } else { - DBG_88E("%s selector %d error\n", __func__, selector); - } -exit: - return ret; -} - -static int rtw_wps_start(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - u32 u32wps_start = 0; - - ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); - if (ret) { - ret = -EINVAL; - goto exit; - } - - if ((padapter->bDriverStopped) || (pdata == NULL)) { - ret = -EINVAL; - goto exit; - } - - if (u32wps_start == 0) - u32wps_start = *extra; - - DBG_88E("[%s] wps_start = %d\n", __func__, u32wps_start); - - if (u32wps_start == 1) /* WPS Start */ - rtw_led_control(padapter, LED_CTL_START_WPS); - else if (u32wps_start == 2) /* WPS Stop because of wps success */ - rtw_led_control(padapter, LED_CTL_STOP_WPS); - else if (u32wps_start == 3) /* WPS Stop because of wps fail */ - rtw_led_control(padapter, LED_CTL_STOP_WPS_FAIL); - -exit: - return ret; -} - -#ifdef CONFIG_88EU_P2P -static int rtw_wext_p2p_enable(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - enum P2P_ROLE init_role = P2P_ROLE_DISABLE; - - if (*extra == '0') - init_role = P2P_ROLE_DISABLE; - else if (*extra == '1') - init_role = P2P_ROLE_DEVICE; - else if (*extra == '2') - init_role = P2P_ROLE_CLIENT; - else if (*extra == '3') - init_role = P2P_ROLE_GO; - - if (_FAIL == rtw_p2p_enable(padapter, init_role)) { - ret = -EFAULT; - goto exit; - } - - /* set channel/bandwidth */ - if (init_role != P2P_ROLE_DISABLE) { - u8 channel, ch_offset; - u16 bwmode; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) { - /* Stay at the listen state and wait for discovery. */ - channel = pwdinfo->listen_channel; - pwdinfo->operating_channel = pwdinfo->listen_channel; - ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - bwmode = HT_CHANNEL_WIDTH_20; - } else { - pwdinfo->operating_channel = pmlmeext->cur_channel; - - channel = pwdinfo->operating_channel; - ch_offset = pmlmeext->cur_ch_offset; - bwmode = pmlmeext->cur_bwmode; - } - - set_channel_bwmode(padapter, channel, ch_offset, bwmode); - } - -exit: - return ret; -} - -static int rtw_p2p_set_go_nego_ssid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] ssid = %s, len = %zu\n", __func__, extra, strlen(extra)); - memcpy(pwdinfo->nego_ssid, extra, strlen(extra)); - pwdinfo->nego_ssidlen = strlen(extra); - - return ret; -} - -static int rtw_p2p_set_intent(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 intent = pwdinfo->intent; - - switch (wrqu->data.length) { - case 1: - intent = extra[0] - '0'; - break; - case 2: - intent = str_2char2num(extra[0], extra[1]); - break; - } - if (intent <= 15) - pwdinfo->intent = intent; - else - ret = -1; - DBG_88E("[%s] intent = %d\n", __func__, intent); - return ret; -} - -static int rtw_p2p_set_listen_ch(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 listen_ch = pwdinfo->listen_channel; /* Listen channel number */ - - switch (wrqu->data.length) { - case 1: - listen_ch = extra[0] - '0'; - break; - case 2: - listen_ch = str_2char2num(extra[0], extra[1]); - break; - } - - if ((listen_ch == 1) || (listen_ch == 6) || (listen_ch == 11)) { - pwdinfo->listen_channel = listen_ch; - set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - } else { - ret = -1; - } - - DBG_88E("[%s] listen_ch = %d\n", __func__, pwdinfo->listen_channel); - - return ret; -} - -static int rtw_p2p_set_op_ch(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ -/* Commented by Albert 20110524 */ -/* This function is used to set the operating channel if the driver will become the group owner */ - - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 op_ch = pwdinfo->operating_channel; /* Operating channel number */ - - switch (wrqu->data.length) { - case 1: - op_ch = extra[0] - '0'; - break; - case 2: - op_ch = str_2char2num(extra[0], extra[1]); - break; - } - - if (op_ch > 0) - pwdinfo->operating_channel = op_ch; - else - ret = -1; - - DBG_88E("[%s] op_ch = %d\n", __func__, pwdinfo->operating_channel); - - return ret; -} - -static int rtw_p2p_profilefound(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - /* Comment by Albert 2010/10/13 */ - /* Input data format: */ - /* Ex: 0 */ - /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ - /* 0 => Reflush the profile record list. */ - /* 1 => Add the profile list */ - /* XX:XX:XX:XX:XX:XX => peer's MAC Address (ex: 00:E0:4C:00:00:01) */ - /* YY => SSID Length */ - /* SSID => SSID for persistence group */ - - DBG_88E("[%s] In value = %s, len = %d\n", __func__, extra, wrqu->data.length - 1); - - /* The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - if (extra[0] == '0') { - /* Remove all the profile information of wifidirect_info structure. */ - _rtw_memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); - pwdinfo->profileindex = 0; - } else { - if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) { - ret = -1; - } else { - int jj, kk; - - /* Add this profile information into pwdinfo->profileinfo */ - /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ - for (jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3) - pwdinfo->profileinfo[pwdinfo->profileindex].peermac[jj] = key_2char2num(extra[kk], extra[kk + 1]); - - pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen = (extra[18] - '0') * 10 + (extra[19] - '0'); - memcpy(pwdinfo->profileinfo[pwdinfo->profileindex].ssid, &extra[20], pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen); - pwdinfo->profileindex++; - } - } - } - - return ret; -} - -static int rtw_p2p_setDN(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] %s %d\n", __func__, extra, wrqu->data.length - 1); - _rtw_memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); - memcpy(pwdinfo->device_name, extra, wrqu->data.length - 1); - pwdinfo->device_name_len = wrqu->data.length - 1; - - return ret; -} - -static int rtw_p2p_get_status(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - if (padapter->bShowGetP2PState) - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], - pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); - - /* Commented by Albert 2010/10/12 */ - /* Because of the output size limitation, I had removed the "Role" information. */ - /* About the "Role" information, we will use the new private IOCTL to get the "Role" information. */ - sprintf(extra, "\n\nStatus =%.2d\n", rtw_p2p_state(pwdinfo)); - wrqu->data.length = strlen(extra); - - return ret; -} - -/* Commented by Albert 20110520 */ -/* This function will return the config method description */ -/* This config method description will show us which config method the remote P2P device is intended to use */ -/* by sending the provisioning discovery request frame. */ - -static int rtw_p2p_get_req_cm(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - sprintf(extra, "\n\nCM =%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); - wrqu->data.length = strlen(extra); - return ret; -} - -static int rtw_p2p_get_role(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], - pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); - - sprintf(extra, "\n\nRole =%.2d\n", rtw_p2p_role(pwdinfo)); - wrqu->data.length = strlen(extra); - return ret; -} - -static int rtw_p2p_get_peer_ifaddr(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, - rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_interface_addr); - sprintf(extra, "\nMAC %pM", - pwdinfo->p2p_peer_interface_addr); - wrqu->data.length = strlen(extra); - return ret; -} - -static int rtw_p2p_get_peer_devaddr(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) - -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, - rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->rx_prov_disc_info.peerDevAddr); - sprintf(extra, "\n%pM", - pwdinfo->rx_prov_disc_info.peerDevAddr); - wrqu->data.length = strlen(extra); - return ret; -} - -static int rtw_p2p_get_peer_devaddr_by_invitation(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) - -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", - __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), - pwdinfo->p2p_peer_device_addr); - sprintf(extra, "\nMAC %pM", - pwdinfo->p2p_peer_device_addr); - wrqu->data.length = strlen(extra); - return ret; -} - -static int rtw_p2p_get_groupid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) - -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - sprintf(extra, "\n%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s", - pwdinfo->groupid_info.go_device_addr[0], pwdinfo->groupid_info.go_device_addr[1], - pwdinfo->groupid_info.go_device_addr[2], pwdinfo->groupid_info.go_device_addr[3], - pwdinfo->groupid_info.go_device_addr[4], pwdinfo->groupid_info.go_device_addr[5], - pwdinfo->groupid_info.ssid); - wrqu->data.length = strlen(extra); - return ret; -} - -static int rtw_p2p_get_op_ch(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) - -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] Op_ch = %02x\n", __func__, pwdinfo->operating_channel); - - sprintf(extra, "\n\nOp_ch =%.2d\n", pwdinfo->operating_channel); - wrqu->data.length = strlen(extra); - return ret; -} - -static int rtw_p2p_get_wps_configmethod(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u8 peerMAC[ETH_ALEN] = {0x00}; - int jj, kk; - u8 peerMACStr[17] = {0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long irqL; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u16 attr_content = 0; - uint attr_contentlen = 0; - /* 6 is the string "wpsCM =", 17 is the MAC addr, we have to clear it at wrqu->data.pointer */ - u8 attr_content_str[6 + 17] = {0x00}; - - /* Commented by Albert 20110727 */ - /* The input data is the MAC address which the application wants to know its WPS config method. */ - /* After knowing its WPS config method, the application can decide the config method for provisioning discovery. */ - /* Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 */ - - DBG_88E("[%s] data = %s\n", __func__, (char *)extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 6, 17)) - return -EFAULT; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { - u8 *wpsie; - uint wpsie_len = 0; - __be16 be_tmp; - - /* The mac address is matched. */ - wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); - if (wpsie) { - rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *) &be_tmp, &attr_contentlen); - if (attr_contentlen) { - attr_content = be16_to_cpu(be_tmp); - sprintf(attr_content_str, "\n\nM =%.4d", attr_content); - blnMatch = 1; - } - } - break; - } - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (!blnMatch) - sprintf(attr_content_str, "\n\nM = 0000"); - - if (copy_to_user(wrqu->data.pointer, attr_content_str, 6 + 17)) - return -EFAULT; - return ret; -} - -static int rtw_p2p_get_go_device_address(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u8 peerMAC[ETH_ALEN] = {0x00}; - int jj, kk; - u8 peerMACStr[17] = {0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long irqL; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; - u8 attr_content[100] = {0x00}; - - u8 go_devadd_str[17 + 10] = {0x00}; - /* +10 is for the str "go_devadd =", we have to clear it at wrqu->data.pointer */ - - /* Commented by Albert 20121209 */ - /* The input data is the GO's interface address which the application wants to know its device address. */ - /* Format: iwpriv wlanx p2p_get2 go_devadd = 00:E0:4C:00:00:05 */ - - DBG_88E("[%s] data = %s\n", __func__, (char *)extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 10, 17)) - return -EFAULT; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { - /* Commented by Albert 2011/05/18 */ - /* Match the device address located in the P2P IE */ - /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - - p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); - if (p2pie) { - while (p2pie) { - /* The P2P Device ID attribute is included in the Beacon frame. */ - /* The P2P Device Info attribute is included in the probe response frame. */ - - _rtw_memset(attr_content, 0x00, 100); - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { - /* Handle the P2P Device ID attribute of Beacon first */ - blnMatch = 1; - break; - } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { - /* Handle the P2P Device Info attribute of probe response */ - blnMatch = 1; - break; - } - - /* Get the next P2P IE */ - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); - } - } - } - - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (!blnMatch) - sprintf(go_devadd_str, "\n\ndev_add = NULL"); - else - sprintf(go_devadd_str, "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", - attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]); - - if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17)) - return -EFAULT; - return ret; -} - -static int rtw_p2p_get_device_type(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u8 peerMAC[ETH_ALEN] = {0x00}; - int jj, kk; - u8 peerMACStr[17] = {0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long irqL; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 dev_type[8] = {0x00}; - uint dev_type_len = 0; - u8 dev_type_str[17 + 9] = {0x00}; /* +9 is for the str "dev_type =", we have to clear it at wrqu->data.pointer */ - - /* Commented by Albert 20121209 */ - /* The input data is the MAC address which the application wants to know its device type. */ - /* Such user interface could know the device type. */ - /* Format: iwpriv wlanx p2p_get2 dev_type = 00:E0:4C:00:00:05 */ - - DBG_88E("[%s] data = %s\n", __func__, (char *)extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 9, 17)) - return -EFAULT; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { - u8 *wpsie; - uint wpsie_len = 0; - - /* The mac address is matched. */ - - wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], - pnetwork->network.IELength - 12, - NULL, &wpsie_len); - if (wpsie) { - rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_PRIMARY_DEV_TYPE, dev_type, &dev_type_len); - if (dev_type_len) { - u16 type = 0; - __be16 be_tmp; - - memcpy(&be_tmp, dev_type, 2); - type = be16_to_cpu(be_tmp); - sprintf(dev_type_str, "\n\nN =%.2d", type); - blnMatch = 1; - } - } - break; - } - - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (!blnMatch) - sprintf(dev_type_str, "\n\nN = 00"); - - if (copy_to_user(wrqu->data.pointer, dev_type_str, 9 + 17)) { - return -EFAULT; - } - - return ret; -} - -static int rtw_p2p_get_device_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u8 peerMAC[ETH_ALEN] = {0x00}; - int jj, kk; - u8 peerMACStr[17] = {0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long irqL; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = {0x00}; - uint dev_len = 0; - u8 dev_name_str[WPS_MAX_DEVICE_NAME_LEN + 5] = {0x00}; /* +5 is for the str "devN =", we have to clear it at wrqu->data.pointer */ - - /* Commented by Albert 20121225 */ - /* The input data is the MAC address which the application wants to know its device name. */ - /* Such user interface could show peer device's device name instead of ssid. */ - /* Format: iwpriv wlanx p2p_get2 devN = 00:E0:4C:00:00:05 */ - - DBG_88E("[%s] data = %s\n", __func__, (char *)extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 5, 17)) - return -EFAULT; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { - u8 *wpsie; - uint wpsie_len = 0; - - /* The mac address is matched. */ - wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); - if (wpsie) { - rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_DEVICE_NAME, dev_name, &dev_len); - if (dev_len) { - sprintf(dev_name_str, "\n\nN =%s", dev_name); - blnMatch = 1; - } - } - break; - } - - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (!blnMatch) - sprintf(dev_name_str, "\n\nN = 0000"); - - if (copy_to_user(wrqu->data.pointer, dev_name_str, 5 + ((dev_len > 17) ? dev_len : 17))) - return -EFAULT; - return ret; -} - -static int rtw_p2p_get_invitation_procedure(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - u8 peerMAC[ETH_ALEN] = {0x00}; - int jj, kk; - u8 peerMACStr[17] = {0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long irqL; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - u8 blnMatch = 0; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; - u8 attr_content[2] = {0x00}; - - u8 inv_proc_str[17 + 8] = {0x00}; - /* +8 is for the str "InvProc =", we have to clear it at wrqu->data.pointer */ - - /* Commented by Ouden 20121226 */ - /* The application wants to know P2P initiation procedure is supported or not. */ - /* Format: iwpriv wlanx p2p_get2 InvProc = 00:E0:4C:00:00:05 */ - - DBG_88E("[%s] data = %s\n", __func__, (char *)extra); - if (copy_from_user(peerMACStr, wrqu->data.pointer + 8, 17)) - return -EFAULT; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { - /* Commented by Albert 20121226 */ - /* Match the device address located in the P2P IE */ - /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - - p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); - if (p2pie) { - while (p2pie) { - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen)) { - /* Handle the P2P capability attribute */ - blnMatch = 1; - break; - } - - /* Get the next P2P IE */ - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); - } - } - } - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (!blnMatch) { - sprintf(inv_proc_str, "\nIP =-1"); - } else { - if (attr_content[0] & 0x20) - sprintf(inv_proc_str, "\nIP = 1"); - else - sprintf(inv_proc_str, "\nIP = 0"); - } - if (copy_to_user(wrqu->data.pointer, inv_proc_str, 8 + 17)) - return -EFAULT; - return ret; -} - -static int rtw_p2p_connect(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ETH_ALEN] = {0x00}; - int jj, kk; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long irqL; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - uint uintPeerChannel = 0; - - /* Commented by Albert 20110304 */ - /* The input data contains two informations. */ - /* 1. First information is the MAC address which wants to formate with */ - /* 2. Second information is the WPS PINCode or "pbc" string for push button method */ - /* Format: 00:E0:4C:00:00:05 */ - /* Format: 00:E0:4C:00:00:05 */ - - DBG_88E("[%s] data = %s\n", __func__, extra); - - if (pwdinfo->p2p_state == P2P_STATE_NONE) { - DBG_88E("[%s] WiFi Direct is disable!\n", __func__); - return ret; - } - - if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) - return -1; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { - uintPeerChannel = pnetwork->network.Configuration.DSConfig; - break; - } - - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (uintPeerChannel) { - _rtw_memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); - _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - - pwdinfo->nego_req_info.peer_channel_num[0] = uintPeerChannel; - memcpy(pwdinfo->nego_req_info.peerDevAddr, pnetwork->network.MacAddress, ETH_ALEN); - pwdinfo->nego_req_info.benable = true; - - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - if (rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK) { - /* Restore to the listen state if the current p2p state is not nego OK */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - } - - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); - - DBG_88E("[%s] Start PreTx Procedure!\n", __func__); - _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); - _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_GO_NEGO_TIMEOUT); - } else { - DBG_88E("[%s] Not Found in Scanning Queue~\n", __func__); - ret = -1; - } - return ret; -} - -static int rtw_p2p_invite_req(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - int jj, kk; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - uint uintPeerChannel = 0; - u8 attr_content[50] = {0x00}; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; - unsigned long irqL; - struct tx_invite_req_info *pinvite_req_info = &pwdinfo->invitereq_info; - - /* The input data contains two informations. */ - /* 1. First information is the P2P device address which you want to send to. */ - /* 2. Second information is the group id which combines with GO's mac address, space and GO's ssid. */ - /* Command line sample: iwpriv wlan0 p2p_set invite ="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" */ - /* Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy */ - - DBG_88E("[%s] data = %s\n", __func__, extra); - - if (wrqu->data.length <= 37) { - DBG_88E("[%s] Wrong format!\n", __func__); - return ret; - } - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - DBG_88E("[%s] WiFi Direct is disable!\n", __func__); - return ret; - } else { - /* Reset the content of struct tx_invite_req_info */ - pinvite_req_info->benable = false; - _rtw_memset(pinvite_req_info->go_bssid, 0x00, ETH_ALEN); - _rtw_memset(pinvite_req_info->go_ssid, 0x00, WLAN_SSID_MAXLEN); - pinvite_req_info->ssidlen = 0x00; - pinvite_req_info->operating_ch = pwdinfo->operating_channel; - _rtw_memset(pinvite_req_info->peer_macaddr, 0x00, ETH_ALEN); - pinvite_req_info->token = 3; - } - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - pinvite_req_info->peer_macaddr[jj] = key_2char2num(extra[kk], extra[kk + 1]); - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - - /* Commented by Albert 2011/05/18 */ - /* Match the device address located in the P2P IE */ - /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - - p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); - if (p2pie) { - /* The P2P Device ID attribute is included in the Beacon frame. */ - /* The P2P Device Info attribute is included in the probe response frame. */ - - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { - /* Handle the P2P Device ID attribute of Beacon first */ - if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { - uintPeerChannel = pnetwork->network.Configuration.DSConfig; - break; - } - } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { - /* Handle the P2P Device Info attribute of probe response */ - if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { - uintPeerChannel = pnetwork->network.Configuration.DSConfig; - break; - } - } - } - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (uintPeerChannel) { - /* Store the GO's bssid */ - for (jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3) - pinvite_req_info->go_bssid[jj] = key_2char2num(extra[kk], extra[kk + 1]); - - /* Store the GO's ssid */ - pinvite_req_info->ssidlen = wrqu->data.length - 36; - memcpy(pinvite_req_info->go_ssid, &extra[36], (u32) pinvite_req_info->ssidlen); - pinvite_req_info->benable = true; - pinvite_req_info->peer_ch = uintPeerChannel; - - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INVITE_REQ); - - set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - - _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); - - _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_INVITE_TIMEOUT); - } else { - DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); - } - return ret; -} - -static int rtw_p2p_set_persistent(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - /* The input data is 0 or 1 */ - /* 0: disable persistent group functionality */ - /* 1: enable persistent group founctionality */ - - DBG_88E("[%s] data = %s\n", __func__, extra); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - DBG_88E("[%s] WiFi Direct is disable!\n", __func__); - return ret; - } else { - if (extra[0] == '0') /* Disable the persistent group function. */ - pwdinfo->persistent_supported = false; - else if (extra[0] == '1') /* Enable the persistent group function. */ - pwdinfo->persistent_supported = true; - else - pwdinfo->persistent_supported = false; - } - pr_info("[%s] persistent_supported = %d\n", __func__, pwdinfo->persistent_supported); - return ret; -} - -static int rtw_p2p_prov_disc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - u8 peerMAC[ETH_ALEN] = {0x00}; - int jj, kk; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - uint uintPeerChannel = 0; - u8 attr_content[100] = {0x00}; - u8 *p2pie; - uint p2pielen = 0, attr_contentlen = 0; - unsigned long irqL; - - /* The input data contains two informations. */ - /* 1. First information is the MAC address which wants to issue the provisioning discovery request frame. */ - /* 2. Second information is the WPS configuration method which wants to discovery */ - /* Format: 00:E0:4C:00:00:05_display */ - /* Format: 00:E0:4C:00:00:05_keypad */ - /* Format: 00:E0:4C:00:00:05_pbc */ - /* Format: 00:E0:4C:00:00:05_label */ - - DBG_88E("[%s] data = %s\n", __func__, extra); - - if (pwdinfo->p2p_state == P2P_STATE_NONE) { - DBG_88E("[%s] WiFi Direct is disable!\n", __func__); - return ret; - } else { - /* Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. */ - _rtw_memset(pwdinfo->tx_prov_disc_info.peerDevAddr, 0x00, ETH_ALEN); - _rtw_memset(pwdinfo->tx_prov_disc_info.peerIFAddr, 0x00, ETH_ALEN); - _rtw_memset(&pwdinfo->tx_prov_disc_info.ssid, 0x00, sizeof(struct ndis_802_11_ssid)); - pwdinfo->tx_prov_disc_info.peer_channel_num[0] = 0; - pwdinfo->tx_prov_disc_info.peer_channel_num[1] = 0; - pwdinfo->tx_prov_disc_info.benable = false; - } - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); - - if (!memcmp(&extra[18], "display", 7)) { - pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA; - } else if (!memcmp(&extra[18], "keypad", 7)) { - pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_KEYPAD; - } else if (!memcmp(&extra[18], "pbc", 3)) { - pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_PUSH_BUTTON; - } else if (!memcmp(&extra[18], "label", 5)) { - pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_LABEL; - } else { - DBG_88E("[%s] Unknown WPS config methodn", __func__); - return ret; - } - - _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - phead = get_list_head(queue); - plist = get_next(phead); - - while (1) { - if (rtw_end_of_queue_search(phead, plist) == true) - break; - - if (uintPeerChannel != 0) - break; - - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); - - /* Commented by Albert 2011/05/18 */ - /* Match the device address located in the P2P IE */ - /* This is for the case that the P2P device address is not the same as the P2P interface address. */ - - p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); - if (p2pie) { - while (p2pie) { - /* The P2P Device ID attribute is included in the Beacon frame. */ - /* The P2P Device Info attribute is included in the probe response frame. */ - - if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { - /* Handle the P2P Device ID attribute of Beacon first */ - if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { - uintPeerChannel = pnetwork->network.Configuration.DSConfig; - break; - } - } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { - /* Handle the P2P Device Info attribute of probe response */ - if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { - uintPeerChannel = pnetwork->network.Configuration.DSConfig; - break; - } - } - - /* Get the next P2P IE */ - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); - } - } - - plist = get_next(plist); - } - - _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); - - if (uintPeerChannel) { - DBG_88E("[%s] peer channel: %d!\n", __func__, uintPeerChannel); - memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN); - memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN); - pwdinfo->tx_prov_disc_info.peer_channel_num[0] = (u16) uintPeerChannel; - pwdinfo->tx_prov_disc_info.benable = true; - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ); - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - memcpy(&pwdinfo->tx_prov_disc_info.ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid)); - } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - memcpy(pwdinfo->tx_prov_disc_info.ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); - pwdinfo->tx_prov_disc_info.ssid.SsidLength = P2P_WILDCARD_SSID_LEN; - } - - set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - - _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); - - _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); - } else { - DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); - } - return ret; -} - -/* This function is used to inform the driver the user had specified the pin code value or pbc */ -/* to application. */ - -static int rtw_p2p_got_wpsinfo(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); - - DBG_88E("[%s] data = %s\n", __func__, extra); - /* Added by Albert 20110328 */ - /* if the input data is P2P_NO_WPSINFO -> reset the wpsinfo */ - /* if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. */ - /* if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. */ - /* if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC */ - - if (*extra == '0') - pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; - else if (*extra == '1') - pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PEER_DISPLAY_PIN; - else if (*extra == '2') - pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_SELF_DISPLAY_PIN; - else if (*extra == '3') - pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PBC; - else - pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; - return ret; -} - -#endif /* CONFIG_88EU_P2P */ - -static int rtw_p2p_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - -#ifdef CONFIG_88EU_P2P - DBG_88E("[%s] extra = %s\n", __func__, extra); - if (!memcmp(extra, "enable =", 7)) { - rtw_wext_p2p_enable(dev, info, wrqu, &extra[7]); - } else if (!memcmp(extra, "setDN =", 6)) { - wrqu->data.length -= 6; - rtw_p2p_setDN(dev, info, wrqu, &extra[6]); - } else if (!memcmp(extra, "profilefound =", 13)) { - wrqu->data.length -= 13; - rtw_p2p_profilefound(dev, info, wrqu, &extra[13]); - } else if (!memcmp(extra, "prov_disc =", 10)) { - wrqu->data.length -= 10; - rtw_p2p_prov_disc(dev, info, wrqu, &extra[10]); - } else if (!memcmp(extra, "nego =", 5)) { - wrqu->data.length -= 5; - rtw_p2p_connect(dev, info, wrqu, &extra[5]); - } else if (!memcmp(extra, "intent =", 7)) { - /* Commented by Albert 2011/03/23 */ - /* The wrqu->data.length will include the null character */ - /* So, we will decrease 7 + 1 */ - wrqu->data.length -= 8; - rtw_p2p_set_intent(dev, info, wrqu, &extra[7]); - } else if (!memcmp(extra, "ssid =", 5)) { - wrqu->data.length -= 5; - rtw_p2p_set_go_nego_ssid(dev, info, wrqu, &extra[5]); - } else if (!memcmp(extra, "got_wpsinfo =", 12)) { - wrqu->data.length -= 12; - rtw_p2p_got_wpsinfo(dev, info, wrqu, &extra[12]); - } else if (!memcmp(extra, "listen_ch =", 10)) { - /* Commented by Albert 2011/05/24 */ - /* The wrqu->data.length will include the null character */ - /* So, we will decrease (10 + 1) */ - wrqu->data.length -= 11; - rtw_p2p_set_listen_ch(dev, info, wrqu, &extra[10]); - } else if (!memcmp(extra, "op_ch =", 6)) { - /* Commented by Albert 2011/05/24 */ - /* The wrqu->data.length will include the null character */ - /* So, we will decrease (6 + 1) */ - wrqu->data.length -= 7; - rtw_p2p_set_op_ch(dev, info, wrqu, &extra[6]); - } else if (!memcmp(extra, "invite =", 7)) { - wrqu->data.length -= 8; - rtw_p2p_invite_req(dev, info, wrqu, &extra[7]); - } else if (!memcmp(extra, "persistent =", 11)) { - wrqu->data.length -= 11; - rtw_p2p_set_persistent(dev, info, wrqu, &extra[11]); - } -#endif /* CONFIG_88EU_P2P */ - - return ret; -} - -static int rtw_p2p_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - -#ifdef CONFIG_88EU_P2P - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - if (padapter->bShowGetP2PState) - DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); - if (!memcmp(wrqu->data.pointer, "status", 6)) { - rtw_p2p_get_status(dev, info, wrqu, extra); - } else if (!memcmp(wrqu->data.pointer, "role", 4)) { - rtw_p2p_get_role(dev, info, wrqu, extra); - } else if (!memcmp(wrqu->data.pointer, "peer_ifa", 8)) { - rtw_p2p_get_peer_ifaddr(dev, info, wrqu, extra); - } else if (!memcmp(wrqu->data.pointer, "req_cm", 6)) { - rtw_p2p_get_req_cm(dev, info, wrqu, extra); - } else if (!memcmp(wrqu->data.pointer, "peer_deva", 9)) { - /* Get the P2P device address when receiving the provision discovery request frame. */ - rtw_p2p_get_peer_devaddr(dev, info, wrqu, extra); - } else if (!memcmp(wrqu->data.pointer, "group_id", 8)) { - rtw_p2p_get_groupid(dev, info, wrqu, extra); - } else if (!memcmp(wrqu->data.pointer, "peer_deva_inv", 9)) { - /* Get the P2P device address when receiving the P2P Invitation request frame. */ - rtw_p2p_get_peer_devaddr_by_invitation(dev, info, wrqu, extra); - } else if (!memcmp(wrqu->data.pointer, "op_ch", 5)) { - rtw_p2p_get_op_ch(dev, info, wrqu, extra); - } -#endif /* CONFIG_88EU_P2P */ - return ret; -} - -static int rtw_p2p_get2(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - -#ifdef CONFIG_88EU_P2P - DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); - if (!memcmp(extra, "wpsCM =", 6)) { - wrqu->data.length -= 6; - rtw_p2p_get_wps_configmethod(dev, info, wrqu, &extra[6]); - } else if (!memcmp(extra, "devN =", 5)) { - wrqu->data.length -= 5; - rtw_p2p_get_device_name(dev, info, wrqu, &extra[5]); - } else if (!memcmp(extra, "dev_type =", 9)) { - wrqu->data.length -= 9; - rtw_p2p_get_device_type(dev, info, wrqu, &extra[9]); - } else if (!memcmp(extra, "go_devadd =", 10)) { - wrqu->data.length -= 10; - rtw_p2p_get_go_device_address(dev, info, wrqu, &extra[10]); - } else if (!memcmp(extra, "InvProc =", 8)) { - wrqu->data.length -= 8; - rtw_p2p_get_invitation_procedure(dev, info, wrqu, &extra[8]); - } - -#endif /* CONFIG_88EU_P2P */ - - return ret; -} - -static int rtw_cta_test_start(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - DBG_88E("%s %s\n", __func__, extra); - if (!strcmp(extra, "1")) - padapter->in_cta_test = 1; - else - padapter->in_cta_test = 0; - - if (padapter->in_cta_test) { - u32 v = rtw_read32(padapter, REG_RCR); - v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ - rtw_write32(padapter, REG_RCR, v); - DBG_88E("enable RCR_ADF\n"); - } else { - u32 v = rtw_read32(padapter, REG_RCR); - v |= RCR_CBSSID_DATA | RCR_CBSSID_BCN;/* RCR_ADF */ - rtw_write32(padapter, REG_RCR, v); - DBG_88E("disable RCR_ADF\n"); - } - return ret; -} - -static int rtw_rereg_nd_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct rereg_nd_name_data *rereg_priv = &padapter->rereg_nd_name_priv; - char new_ifname[IFNAMSIZ]; - - if (rereg_priv->old_ifname[0] == 0) { - char *reg_ifname; - reg_ifname = padapter->registrypriv.if2name; - - strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ-1] = 0; - } - - if (wrqu->data.length > IFNAMSIZ) - return -EFAULT; - - if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) - return -EFAULT; - - if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) - return ret; - - DBG_88E("%s new_ifname:%s\n", __func__, new_ifname); - ret = rtw_change_ifname(padapter, new_ifname); - if (0 != ret) - goto exit; - - if (!memcmp(rereg_priv->old_ifname, "disable%d", 9)) { - padapter->ledpriv.bRegUseLed = rereg_priv->old_bRegUseLed; - rtw_hal_sw_led_init(padapter); - rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); - } - - strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ-1] = 0; - - if (!memcmp(new_ifname, "disable%d", 9)) { - DBG_88E("%s disable\n", __func__); - /* free network queue for Android's timming issue */ - rtw_free_network_queue(padapter, true); - - /* close led */ - rtw_led_control(padapter, LED_CTL_POWER_OFF); - rereg_priv->old_bRegUseLed = padapter->ledpriv.bRegUseLed; - padapter->ledpriv.bRegUseLed = false; - rtw_hal_sw_led_deinit(padapter); - - /* the interface is being "disabled", we can do deeper IPS */ - rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv); - rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); - } -exit: - return ret; -} - -static void mac_reg_dump(struct adapter *padapter) -{ - int i, j = 1; - pr_info("\n ======= MAC REG =======\n"); - for (i = 0x0; i < 0x300; i += 4) { - if (j%4 == 1) - pr_info("0x%02x", i); - pr_info(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) - pr_info("\n"); - } - for (i = 0x400; i < 0x800; i += 4) { - if (j%4 == 1) - pr_info("0x%02x", i); - pr_info(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) - pr_info("\n"); - } -} - -static void bb_reg_dump(struct adapter *padapter) -{ - int i, j = 1; - pr_info("\n ======= BB REG =======\n"); - for (i = 0x800; i < 0x1000; i += 4) { - if (j%4 == 1) - pr_info("0x%02x", i); - - pr_info(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) - pr_info("\n"); - } -} - -static void rf_reg_dump(struct adapter *padapter) -{ - int i, j = 1, path; - u32 value; - u8 rf_type, path_nums = 0; - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - - pr_info("\n ======= RF REG =======\n"); - if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) - path_nums = 1; - else - path_nums = 2; - - for (path = 0; path < path_nums; path++) { - pr_info("\nRF_Path(%x)\n", path); - for (i = 0; i < 0x100; i++) { - value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) - pr_info("0x%02x ", i); - pr_info(" 0x%08x ", value); - if ((j++)%4 == 0) - pr_info("\n"); - } - } -} - -static int rtw_dbg_port(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - unsigned long irqL; - int ret = 0; - u8 major_cmd, minor_cmd; - u16 arg; - s32 extra_arg; - u32 *pdata, val32; - struct sta_info *psta; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct wlan_network *cur_network = &(pmlmepriv->cur_network); - struct sta_priv *pstapriv = &padapter->stapriv; - - pdata = (u32 *)&wrqu->data; - - val32 = *pdata; - arg = (u16)(val32 & 0x0000ffff); - major_cmd = (u8)(val32 >> 24); - minor_cmd = (u8)((val32 >> 16) & 0x00ff); - - extra_arg = *(pdata+1); - - switch (major_cmd) { - case 0x70:/* read_reg */ - switch (minor_cmd) { - case 1: - DBG_88E("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); - break; - case 2: - DBG_88E("rtw_read16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); - break; - case 4: - DBG_88E("rtw_read32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); - break; - } - break; - case 0x71:/* write_reg */ - switch (minor_cmd) { - case 1: - rtw_write8(padapter, arg, extra_arg); - DBG_88E("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); - break; - case 2: - rtw_write16(padapter, arg, extra_arg); - DBG_88E("rtw_write16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); - break; - case 4: - rtw_write32(padapter, arg, extra_arg); - DBG_88E("rtw_write32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); - break; - } - break; - case 0x72:/* read_bb */ - DBG_88E("read_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); - break; - case 0x73:/* write_bb */ - rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg); - DBG_88E("write_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); - break; - case 0x74:/* read_rf */ - DBG_88E("read RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); - break; - case 0x75:/* write_rf */ - rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg); - DBG_88E("write RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); - break; - - case 0x76: - switch (minor_cmd) { - case 0x00: /* normal mode, */ - padapter->recvpriv.is_signal_dbg = 0; - break; - case 0x01: /* dbg mode */ - padapter->recvpriv.is_signal_dbg = 1; - extra_arg = extra_arg > 100 ? 100 : extra_arg; - extra_arg = extra_arg < 0 ? 0 : extra_arg; - padapter->recvpriv.signal_strength_dbg = extra_arg; - break; - } - break; - case 0x78: /* IOL test */ - switch (minor_cmd) { - case 0x04: /* LLT table initialization test */ - { - u8 page_boundary = 0xf9; - struct xmit_frame *xmit_frame; - - xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { - ret = -ENOMEM; - break; - } - - rtw_IOL_append_LLT_cmd(xmit_frame, page_boundary); - - if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 500, 0)) - ret = -EPERM; - } - break; - case 0x05: /* blink LED test */ - { - u16 reg = 0x4c; - u32 blink_num = 50; - u32 blink_delay_ms = 200; - int i; - struct xmit_frame *xmit_frame; - - xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { - ret = -ENOMEM; - break; - } - - for (i = 0; i < blink_num; i++) { - rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x00, 0xff); - rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); - rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08, 0xff); - rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); - } - if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms*blink_num*2)+200, 0)) - ret = -EPERM; - } - break; - - case 0x06: /* continuous write byte test */ - { - u16 reg = arg; - u16 start_value = 0; - u32 write_num = extra_arg; - int i; - u8 final; - struct xmit_frame *xmit_frame; - - xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { - ret = -ENOMEM; - break; - } - - for (i = 0; i < write_num; i++) - rtw_IOL_append_WB_cmd(xmit_frame, reg, i+start_value, 0xFF); - if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) - ret = -EPERM; - - final = rtw_read8(padapter, reg); - if (start_value+write_num-1 == final) - DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); - else - DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); - } - break; - - case 0x07: /* continuous write word test */ - { - u16 reg = arg; - u16 start_value = 200; - u32 write_num = extra_arg; - - int i; - u16 final; - struct xmit_frame *xmit_frame; - - xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { - ret = -ENOMEM; - break; - } - - for (i = 0; i < write_num; i++) - rtw_IOL_append_WW_cmd(xmit_frame, reg, i+start_value, 0xFFFF); - if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) - ret = -EPERM; - - final = rtw_read16(padapter, reg); - if (start_value+write_num-1 == final) - DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); - else - DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); - } - break; - case 0x08: /* continuous write dword test */ - { - u16 reg = arg; - u32 start_value = 0x110000c7; - u32 write_num = extra_arg; - - int i; - u32 final; - struct xmit_frame *xmit_frame; - - xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { - ret = -ENOMEM; - break; - } - - for (i = 0; i < write_num; i++) - rtw_IOL_append_WD_cmd(xmit_frame, reg, i+start_value, 0xFFFFFFFF); - if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) - ret = -EPERM; - - final = rtw_read32(padapter, reg); - if (start_value+write_num-1 == final) - DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Success, start:%u, final:%u\n", - reg, write_num, start_value, final); - else - DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Fail, start:%u, final:%u\n", - reg, write_num, start_value, final); - } - break; - } - break; - case 0x79: - { - /* - * dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15 - * dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15 - */ - u8 value = extra_arg & 0x0f; - u8 sign = minor_cmd; - u16 write_value = 0; - - DBG_88E("%s set RESP_TXAGC to %s %u\n", __func__, sign ? "minus" : "plus", value); - - if (sign) - value = value | 0x10; - - write_value = value | (value << 5); - rtw_write16(padapter, 0x6d9, write_value); - } - break; - case 0x7a: - receive_disconnect(padapter, pmlmeinfo->network.MacAddress - , WLAN_REASON_EXPIRATION_CHK); - break; - case 0x7F: - switch (minor_cmd) { - case 0x0: - DBG_88E("fwstate = 0x%x\n", get_fwstate(pmlmepriv)); - break; - case 0x01: - DBG_88E("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); - break; - case 0x02: - DBG_88E("pmlmeinfo->state = 0x%x\n", pmlmeinfo->state); - break; - case 0x03: - DBG_88E("qos_option =%d\n", pmlmepriv->qospriv.qos_option); - DBG_88E("ht_option =%d\n", pmlmepriv->htpriv.ht_option); - break; - case 0x04: - DBG_88E("cur_ch =%d\n", pmlmeext->cur_channel); - DBG_88E("cur_bw =%d\n", pmlmeext->cur_bwmode); - DBG_88E("cur_ch_off =%d\n", pmlmeext->cur_ch_offset); - break; - case 0x05: - psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); - if (psta) { - int i; - struct recv_reorder_ctrl *preorder_ctrl; - - DBG_88E("SSID =%s\n", cur_network->network.Ssid.Ssid); - DBG_88E("sta's macaddr: %pM\n", psta->hwaddr); - DBG_88E("cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); - DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); - DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); - DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); - DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); - DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); - DBG_88E("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) - DBG_88E("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq); - } - } else { - DBG_88E("can't get sta's macaddr, cur_network's macaddr:%pM\n", (cur_network->network.MacAddress)); - } - break; - case 0x06: - { - u32 ODMFlag; - rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); - DBG_88E("(B)DMFlag = 0x%x, arg = 0x%x\n", ODMFlag, arg); - ODMFlag = (u32)(0x0f&arg); - DBG_88E("(A)DMFlag = 0x%x\n", ODMFlag); - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); - } - break; - case 0x07: - DBG_88E("bSurpriseRemoved =%d, bDriverStopped =%d\n", - padapter->bSurpriseRemoved, padapter->bDriverStopped); - break; - case 0x08: - { - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct recv_priv *precvpriv = &padapter->recvpriv; - - DBG_88E("free_xmitbuf_cnt =%d, free_xmitframe_cnt =%d, free_xmit_extbuf_cnt =%d\n", - pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt); - DBG_88E("rx_urb_pending_cn =%d\n", precvpriv->rx_pending_cnt); - } - break; - case 0x09: - { - int i, j; - struct list_head *plist, *phead; - struct recv_reorder_ctrl *preorder_ctrl; - -#ifdef CONFIG_88EU_AP_MODE - DBG_88E("sta_dz_bitmap = 0x%x, tim_bitmap = 0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); -#endif - _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); - - for (i = 0; i < NUM_STA; i++) { - phead = &(pstapriv->sta_hash[i]); - plist = get_next(phead); - - while ((rtw_end_of_queue_search(phead, plist)) == false) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); - - plist = get_next(plist); - - if (extra_arg == psta->aid) { - DBG_88E("sta's macaddr:%pM\n", (psta->hwaddr)); - DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); - DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); - DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); - DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); - DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); - DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); - -#ifdef CONFIG_88EU_AP_MODE - DBG_88E("capability = 0x%x\n", psta->capability); - DBG_88E("flags = 0x%x\n", psta->flags); - DBG_88E("wpa_psk = 0x%x\n", psta->wpa_psk); - DBG_88E("wpa2_group_cipher = 0x%x\n", psta->wpa2_group_cipher); - DBG_88E("wpa2_pairwise_cipher = 0x%x\n", psta->wpa2_pairwise_cipher); - DBG_88E("qos_info = 0x%x\n", psta->qos_info); -#endif - DBG_88E("dot118021XPrivacy = 0x%x\n", psta->dot118021XPrivacy); - - for (j = 0; j < 16; j++) { - preorder_ctrl = &psta->recvreorder_ctrl[j]; - if (preorder_ctrl->enable) - DBG_88E("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq); - } - } - } - } - _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); - } - break; - case 0x0c:/* dump rx/tx packet */ - if (arg == 0) { - DBG_88E("dump rx packet (%d)\n", extra_arg); - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); - } else if (arg == 1) { - DBG_88E("dump tx packet (%d)\n", extra_arg); - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); - } - break; - case 0x0f: - if (extra_arg == 0) { - DBG_88E("###### silent reset test.......#####\n"); - rtw_hal_sreset_reset(padapter); - } - break; - case 0x15: - { - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - DBG_88E("==>silent resete cnts:%d\n", pwrpriv->ips_enter_cnts); - } - break; - case 0x10:/* driver version display */ - DBG_88E("rtw driver version =%s\n", DRIVERVERSION); - break; - case 0x11: - DBG_88E("turn %s Rx RSSI display function\n", (extra_arg == 1) ? "on" : "off"); - padapter->bRxRSSIDisplay = extra_arg; - rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP, &extra_arg); - break; - case 0x12: /* set rx_stbc */ - { - struct registry_priv *pregpriv = &padapter->registrypriv; - /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ - /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ - if (pregpriv && - (extra_arg == 0 || - extra_arg == 1 || - extra_arg == 2 || - extra_arg == 3)) { - pregpriv->rx_stbc = extra_arg; - DBG_88E("set rx_stbc =%d\n", pregpriv->rx_stbc); - } else { - DBG_88E("get rx_stbc =%d\n", pregpriv->rx_stbc); - } - } - break; - case 0x13: /* set ampdu_enable */ - { - struct registry_priv *pregpriv = &padapter->registrypriv; - /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ - if (pregpriv && extra_arg >= 0 && extra_arg < 3) { - pregpriv->ampdu_enable = extra_arg; - DBG_88E("set ampdu_enable =%d\n", pregpriv->ampdu_enable); - } else { - DBG_88E("get ampdu_enable =%d\n", pregpriv->ampdu_enable); - } - } - break; - case 0x14: /* get wifi_spec */ - { - struct registry_priv *pregpriv = &padapter->registrypriv; - DBG_88E("get wifi_spec =%d\n", pregpriv->wifi_spec); - } - break; - case 0x16: - if (arg == 0xff) { - pr_info("ODM_COMP_DIG\t\tBIT0\n"); - pr_info("ODM_COMP_RA_MASK\t\tBIT1\n"); - pr_info("ODM_COMP_DYNAMIC_TXPWR\tBIT2\n"); - pr_info("ODM_COMP_FA_CNT\t\tBIT3\n"); - pr_info("ODM_COMP_RSSI_MONITOR\tBIT4\n"); - pr_info("ODM_COMP_CCK_PD\t\tBIT5\n"); - pr_info("ODM_COMP_ANT_DIV\t\tBIT6\n"); - pr_info("ODM_COMP_PWR_SAVE\t\tBIT7\n"); - pr_info("ODM_COMP_PWR_TRAIN\tBIT8\n"); - pr_info("ODM_COMP_RATE_ADAPTIVE\tBIT9\n"); - pr_info("ODM_COMP_PATH_DIV\t\tBIT10\n"); - pr_info("ODM_COMP_PSD \tBIT11\n"); - pr_info("ODM_COMP_DYNAMIC_PRICCA\tBIT12\n"); - pr_info("ODM_COMP_RXHP\t\tBIT13\n"); - pr_info("ODM_COMP_EDCA_TURBO\tBIT16\n"); - pr_info("ODM_COMP_EARLY_MODE\tBIT17\n"); - pr_info("ODM_COMP_TX_PWR_TRACK\tBIT24\n"); - pr_info("ODM_COMP_RX_GAIN_TRACK\tBIT25\n"); - pr_info("ODM_COMP_CALIBRATION\tBIT26\n"); - rtw_hal_get_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); - } else { - rtw_hal_set_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); - } - break; - case 0x23: - DBG_88E("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1) ? "on" : "off"); - padapter->bNotifyChannelChange = extra_arg; - break; - case 0x24: -#ifdef CONFIG_88EU_P2P - DBG_88E("turn %s the bShowGetP2PState Variable\n", (extra_arg == 1) ? "on" : "off"); - padapter->bShowGetP2PState = extra_arg; -#endif /* CONFIG_88EU_P2P */ - break; - case 0xaa: - if (extra_arg > 0x13) - extra_arg = 0xFF; - DBG_88E("chang data rate to :0x%02x\n", extra_arg); - padapter->fix_rate = extra_arg; - break; - case 0xdd:/* registers dump, 0 for mac reg, 1 for bb reg, 2 for rf reg */ - if (extra_arg == 0) - mac_reg_dump(padapter); - else if (extra_arg == 1) - bb_reg_dump(padapter); - else if (extra_arg == 2) - rf_reg_dump(padapter); - break; - case 0xee:/* turn on/off dynamic funcs */ - { - u32 odm_flag; - - if (0xf == extra_arg) { - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); - DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); - DBG_88E("extra_arg = 0 - disable all dynamic func\n"); - DBG_88E("extra_arg = 1 - disable DIG- BIT(0)\n"); - DBG_88E("extra_arg = 2 - disable High power - BIT(1)\n"); - DBG_88E("extra_arg = 3 - disable tx power tracking - BIT(2)\n"); - DBG_88E("extra_arg = 4 - disable BT coexistence - BIT(3)\n"); - DBG_88E("extra_arg = 5 - disable antenna diversity - BIT(4)\n"); - DBG_88E("extra_arg = 6 - enable all dynamic func\n"); - } else { - /* extra_arg = 0 - disable all dynamic func - extra_arg = 1 - disable DIG - extra_arg = 2 - disable tx power tracking - extra_arg = 3 - turn on all dynamic func - */ - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg)); - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); - DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); - } - } - break; - - case 0xfd: - rtw_write8(padapter, 0xc50, arg); - DBG_88E("wr(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); - rtw_write8(padapter, 0xc58, arg); - DBG_88E("wr(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); - break; - case 0xfe: - DBG_88E("rd(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); - DBG_88E("rd(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); - break; - case 0xff: - DBG_88E("dbg(0x210) = 0x%x\n", rtw_read32(padapter, 0x210)); - DBG_88E("dbg(0x608) = 0x%x\n", rtw_read32(padapter, 0x608)); - DBG_88E("dbg(0x280) = 0x%x\n", rtw_read32(padapter, 0x280)); - DBG_88E("dbg(0x284) = 0x%x\n", rtw_read32(padapter, 0x284)); - DBG_88E("dbg(0x288) = 0x%x\n", rtw_read32(padapter, 0x288)); - - DBG_88E("dbg(0x664) = 0x%x\n", rtw_read32(padapter, 0x664)); - - DBG_88E("\n"); - - DBG_88E("dbg(0x430) = 0x%x\n", rtw_read32(padapter, 0x430)); - DBG_88E("dbg(0x438) = 0x%x\n", rtw_read32(padapter, 0x438)); - - DBG_88E("dbg(0x440) = 0x%x\n", rtw_read32(padapter, 0x440)); - - DBG_88E("dbg(0x458) = 0x%x\n", rtw_read32(padapter, 0x458)); - - DBG_88E("dbg(0x484) = 0x%x\n", rtw_read32(padapter, 0x484)); - DBG_88E("dbg(0x488) = 0x%x\n", rtw_read32(padapter, 0x488)); - - DBG_88E("dbg(0x444) = 0x%x\n", rtw_read32(padapter, 0x444)); - DBG_88E("dbg(0x448) = 0x%x\n", rtw_read32(padapter, 0x448)); - DBG_88E("dbg(0x44c) = 0x%x\n", rtw_read32(padapter, 0x44c)); - DBG_88E("dbg(0x450) = 0x%x\n", rtw_read32(padapter, 0x450)); - break; - } - break; - default: - DBG_88E("error dbg cmd!\n"); - break; - } - return ret; -} - static int wpa_set_param(struct net_device *dev, u8 name, u32 value) { uint ret = 0; @@ -4816,13 +2117,13 @@ static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { res = _FAIL; goto exit; } - psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); if (psetstakey_para == NULL) { kfree(ph2c); res = _FAIL; @@ -4854,19 +2155,19 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) DBG_88E("%s\n", __func__); - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (pcmd == NULL) { res = _FAIL; goto exit; } - psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); if (psetkeyparm == NULL) { kfree(pcmd); res = _FAIL; goto exit; } - _rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + memset(psetkeyparm, 0, sizeof(struct setkey_parm)); psetkeyparm->keyid = (u8)keyid; @@ -4896,7 +2197,7 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) pcmd->rsp = NULL; pcmd->rspsz = 0; - _rtw_init_listhead(&pcmd->list); + INIT_LIST_HEAD(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); @@ -4981,7 +2282,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, goto exit; } - _rtw_memset(pwep, 0, wep_total_len); + memset(pwep, 0, wep_total_len); pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; @@ -5251,7 +2552,6 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) { - unsigned long irqL; int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); @@ -5271,13 +2571,13 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) psta = rtw_get_stainfo(pstapriv, param->sta_addr); if (psta) { - _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); - if (!rtw_is_list_empty(&psta->asoc_list)) { - rtw_list_delete(&psta->asoc_list); + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + spin_unlock_bh(&pstapriv->asoc_list_lock); associated_clients_update(padapter, updated); psta = NULL; } else { @@ -5398,10 +2698,8 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, ie_len = len-12-2;/* 12 = param header, 2:no packed */ - if (pmlmepriv->wps_beacon_ie) { - kfree(pmlmepriv->wps_beacon_ie); - pmlmepriv->wps_beacon_ie = NULL; - } + kfree(pmlmepriv->wps_beacon_ie); + pmlmepriv->wps_beacon_ie = NULL; if (ie_len > 0) { pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); @@ -5435,10 +2733,8 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par ie_len = len-12-2;/* 12 = param header, 2:no packed */ - if (pmlmepriv->wps_probe_resp_ie) { - kfree(pmlmepriv->wps_probe_resp_ie); - pmlmepriv->wps_probe_resp_ie = NULL; - } + kfree(pmlmepriv->wps_probe_resp_ie); + pmlmepriv->wps_probe_resp_ie = NULL; if (ie_len > 0) { pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); @@ -5467,10 +2763,8 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par ie_len = len-12-2;/* 12 = param header, 2:no packed */ - if (pmlmepriv->wps_assoc_resp_ie) { - kfree(pmlmepriv->wps_assoc_resp_ie); - pmlmepriv->wps_assoc_resp_ie = NULL; - } + kfree(pmlmepriv->wps_assoc_resp_ie); + pmlmepriv->wps_assoc_resp_ie = NULL; if (ie_len > 0) { pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); @@ -5665,12 +2959,12 @@ static int rtw_wx_set_priv(struct net_device *dev, return -EFAULT; len = dwrq->length; - ext = rtw_vmalloc(len); + ext = vmalloc(len); if (!ext) return -ENOMEM; if (copy_from_user(ext, dwrq->pointer, len)) { - rtw_vmfree(ext, len); + vfree(ext); return -EFAULT; } @@ -5710,1896 +3004,11 @@ static int rtw_wx_set_priv(struct net_device *dev, FREE_EXT: - rtw_vmfree(ext, len); + vfree(ext); return ret; } -static int rtw_pm_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - unsigned mode = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - DBG_88E("[%s] extra = %s\n", __func__, extra); - - if (!memcmp(extra, "lps =", 4)) { - sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_lps(padapter, mode); - } else if (!memcmp(extra, "ips =", 4)) { - sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_ips(padapter, mode); - } else { - ret = -EINVAL; - } - - return ret; -} - -static int rtw_mp_efuse_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); - struct efuse_hal *pEfuseHal; - struct iw_point *wrqu; - - u8 *PROMContent = pEEPROM->efuse_eeprom_data; - u8 ips_mode = 0, lps_mode = 0; - struct pwrctrl_priv *pwrctrlpriv; - u8 *data = NULL; - u8 *rawdata = NULL; - char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; - u16 i = 0, j = 0, mapLen = 0, addr = 0, cnts = 0; - u16 max_available_size = 0, raw_cursize = 0, raw_maxsize = 0; - int err; - u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ - - wrqu = (struct iw_point *)wdata; - pwrctrlpriv = &padapter->pwrctrlpriv; - pEfuseHal = &haldata->EfuseHal; - - err = 0; - data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); - if (data == NULL) { - err = -ENOMEM; - goto exit; - } - rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); - if (rawdata == NULL) { - err = -ENOMEM; - goto exit; - } - - if (copy_from_user(extra, wrqu->pointer, wrqu->length)) { - err = -EFAULT; - goto exit; - } - lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ - rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); - - ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ - rtw_pm_set_ips(padapter, IPS_NONE); - - pch = extra; - DBG_88E("%s: in =%s\n", __func__, extra); - - i = 0; - /* mac 16 "00e04c871200" rmap, 00, 2 */ - while ((token = strsep(&pch, ",")) != NULL) { - if (i > 2) - break; - tmp[i] = token; - i++; - } - padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */ - - if (strcmp(tmp[0], "status") == 0) { - sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); - - goto exit; - } else if (strcmp(tmp[0], "filemap") == 0) { - mapLen = EFUSE_MAP_SIZE; - - sprintf(extra, "\n"); - for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { - sprintf(extra, "%s0x%02x\t", extra, i); - for (j = 0; j < 8; j++) - sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); - sprintf(extra, "%s\t", extra); - for (; j < 16; j++) - sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); - sprintf(extra, "%s\n", extra); - } - } else if (strcmp(tmp[0], "realmap") == 0) { - mapLen = EFUSE_MAP_SIZE; - if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) { - DBG_88E("%s: read realmap Fail!!\n", __func__); - err = -EFAULT; - goto exit; - } - - sprintf(extra, "\n"); - for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { - sprintf(extra, "%s0x%02x\t", extra, i); - for (j = 0; j < 8; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); - sprintf(extra, "%s\t", extra); - for (; j < 16; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); - sprintf(extra, "%s\n", extra); - } - } else if (strcmp(tmp[0], "rmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { - DBG_88E("%s: rmap Fail!! Parameters error!\n", __func__); - err = -EINVAL; - goto exit; - } - - /* rmap addr cnts */ - addr = simple_strtoul(tmp[1], &ptmp, 16); - DBG_88E("%s: addr =%x\n", __func__, addr); - - cnts = simple_strtoul(tmp[2], &ptmp, 10); - if (cnts == 0) { - DBG_88E("%s: rmap Fail!! cnts error!\n", __func__); - err = -EINVAL; - goto exit; - } - DBG_88E("%s: cnts =%d\n", __func__, cnts); - - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) { - DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EINVAL; - goto exit; - } - - if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { - DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); - err = -EFAULT; - goto exit; - } - - *extra = 0; - for (i = 0; i < cnts; i++) - sprintf(extra, "%s0x%02X ", extra, data[i]); - } else if (strcmp(tmp[0], "realraw") == 0) { - addr = 0; - mapLen = EFUSE_MAX_SIZE; - if (rtw_efuse_access(padapter, false, addr, mapLen, rawdata) == _FAIL) { - DBG_88E("%s: rtw_efuse_access Fail!!\n", __func__); - err = -EFAULT; - goto exit; - } - - sprintf(extra, "\n"); - for (i = 0; i < mapLen; i++) { - sprintf(extra, "%s%02X", extra, rawdata[i]); - - if ((i & 0xF) == 0xF) - sprintf(extra, "%s\n", extra); - else if ((i & 0x7) == 0x7) - sprintf(extra, "%s\t", extra); - else - sprintf(extra, "%s ", extra); - } - } else if (strcmp(tmp[0], "mac") == 0) { - cnts = 6; - - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) { - DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EFAULT; - goto exit; - } - - if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { - DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); - err = -EFAULT; - goto exit; - } - - *extra = 0; - for (i = 0; i < cnts; i++) { - sprintf(extra, "%s%02X", extra, data[i]); - if (i != (cnts-1)) - sprintf(extra, "%s:", extra); - } - } else if (strcmp(tmp[0], "vidpid") == 0) { - cnts = 4; - - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) { - DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EFAULT; - goto exit; - } - if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { - DBG_88E("%s: rtw_efuse_access error!!\n", __func__); - err = -EFAULT; - goto exit; - } - - *extra = 0; - for (i = 0; i < cnts; i++) { - sprintf(extra, "%s0x%02X", extra, data[i]); - if (i != (cnts-1)) - sprintf(extra, "%s,", extra); - } - } else if (strcmp(tmp[0], "ableraw") == 0) { - efuse_GetCurrentSize(padapter, &raw_cursize); - raw_maxsize = efuse_GetMaxSize(padapter); - sprintf(extra, "[available raw size] = %d bytes", raw_maxsize-raw_cursize); - } else if (strcmp(tmp[0], "btfmap") == 0) { - mapLen = EFUSE_BT_MAX_MAP_LEN; - if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { - DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); - err = -EFAULT; - goto exit; - } - - sprintf(extra, "\n"); - for (i = 0; i < 512; i += 16) { - /* set 512 because the iwpriv's extra size have limit 0x7FF */ - sprintf(extra, "%s0x%03x\t", extra, i); - for (j = 0; j < 8; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - sprintf(extra, "%s\t", extra); - for (; j < 16; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - sprintf(extra, "%s\n", extra); - } - } else if (strcmp(tmp[0], "btbmap") == 0) { - mapLen = EFUSE_BT_MAX_MAP_LEN; - if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { - DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); - err = -EFAULT; - goto exit; - } - - sprintf(extra, "\n"); - for (i = 512; i < 1024; i += 16) { - sprintf(extra, "%s0x%03x\t", extra, i); - for (j = 0; j < 8; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - sprintf(extra, "%s\t", extra); - for (; j < 16; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); - sprintf(extra, "%s\n", extra); - } - } else if (strcmp(tmp[0], "btrmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { - err = -EINVAL; - goto exit; - } - - /* rmap addr cnts */ - addr = simple_strtoul(tmp[1], &ptmp, 16); - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - - cnts = simple_strtoul(tmp[2], &ptmp, 10); - if (cnts == 0) { - DBG_88E("%s: btrmap Fail!! cnts error!\n", __func__); - err = -EINVAL; - goto exit; - } - DBG_88E("%s: cnts =%d\n", __func__, cnts); - - EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) { - DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EFAULT; - goto exit; - } - - if (rtw_BT_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { - DBG_88E("%s: rtw_BT_efuse_map_read error!!\n", __func__); - err = -EFAULT; - goto exit; - } - - *extra = 0; - for (i = 0; i < cnts; i++) - sprintf(extra, "%s 0x%02X ", extra, data[i]); - } else if (strcmp(tmp[0], "btffake") == 0) { - sprintf(extra, "\n"); - for (i = 0; i < 512; i += 16) { - sprintf(extra, "%s0x%03x\t", extra, i); - for (j = 0; j < 8; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - sprintf(extra, "%s\t", extra); - for (; j < 16; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - sprintf(extra, "%s\n", extra); - } - } else if (strcmp(tmp[0], "btbfake") == 0) { - sprintf(extra, "\n"); - for (i = 512; i < 1024; i += 16) { - sprintf(extra, "%s0x%03x\t", extra, i); - for (j = 0; j < 8; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - sprintf(extra, "%s\t", extra); - for (; j < 16; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); - sprintf(extra, "%s\n", extra); - } - } else if (strcmp(tmp[0], "wlrfkmap") == 0) { - sprintf(extra, "\n"); - for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { - sprintf(extra, "%s0x%02x\t", extra, i); - for (j = 0; j < 8; j++) - sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); - sprintf(extra, "%s\t", extra); - for (; j < 16; j++) - sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); - sprintf(extra, "%s\n", extra); - } - } else { - sprintf(extra, "Command not found!"); - } - -exit: - kfree(data); - kfree(rawdata); - if (!err) - wrqu->length = strlen(extra); - - rtw_pm_set_ips(padapter, ips_mode); - rtw_pm_set_lps(padapter, lps_mode); - padapter->registrypriv.fw_iol = org_fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ - return err; -} - -static int rtw_mp_efuse_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - struct adapter *padapter; - struct pwrctrl_priv *pwrctrlpriv; - struct hal_data_8188e *haldata; - struct efuse_hal *pEfuseHal; - - u8 ips_mode = 0, lps_mode = 0; - u32 i, jj, kk; - u8 *setdata = NULL; - u8 *ShadowMapBT = NULL; - u8 *ShadowMapWiFi = NULL; - u8 *setrawdata = NULL; - char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; - u16 addr = 0, cnts = 0, max_available_size = 0; - int err; - - padapter = rtw_netdev_priv(dev); - pwrctrlpriv = &padapter->pwrctrlpriv; - haldata = GET_HAL_DATA(padapter); - pEfuseHal = &haldata->EfuseHal; - err = 0; - setdata = _rtw_zmalloc(1024); - if (setdata == NULL) { - err = -ENOMEM; - goto exit; - } - ShadowMapBT = _rtw_malloc(EFUSE_BT_MAX_MAP_LEN); - if (ShadowMapBT == NULL) { - err = -ENOMEM; - goto exit; - } - ShadowMapWiFi = _rtw_malloc(EFUSE_MAP_SIZE); - if (ShadowMapWiFi == NULL) { - err = -ENOMEM; - goto exit; - } - setrawdata = _rtw_malloc(EFUSE_MAX_SIZE); - if (setrawdata == NULL) { - err = -ENOMEM; - goto exit; - } - - lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ - rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); - - ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ - rtw_pm_set_ips(padapter, IPS_NONE); - - pch = extra; - DBG_88E("%s: in =%s\n", __func__, extra); - - i = 0; - while ((token = strsep(&pch, ",")) != NULL) { - if (i > 2) - break; - tmp[i] = token; - i++; - } - - /* tmp[0],[1],[2] */ - /* wmap, addr, 00e04c871200 */ - if (strcmp(tmp[0], "wmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { - err = -EINVAL; - goto exit; - } - - addr = simple_strtoul(tmp[1], &ptmp, 16); - addr &= 0xFFF; - - cnts = strlen(tmp[2]); - if (cnts%2) { - err = -EINVAL; - goto exit; - } - cnts /= 2; - if (cnts == 0) { - err = -EINVAL; - goto exit; - } - - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - DBG_88E("%s: cnts =%d\n", __func__, cnts); - DBG_88E("%s: map data =%s\n", __func__, tmp[2]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); - /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { - DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EFAULT; - goto exit; - } - - if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { - DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); - err = -EFAULT; - goto exit; - } - } else if (strcmp(tmp[0], "wraw") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { - err = -EINVAL; - goto exit; - } - - addr = simple_strtoul(tmp[1], &ptmp, 16); - addr &= 0xFFF; - - cnts = strlen(tmp[2]); - if (cnts%2) { - err = -EINVAL; - goto exit; - } - cnts /= 2; - if (cnts == 0) { - err = -EINVAL; - goto exit; - } - - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - DBG_88E("%s: cnts =%d\n", __func__, cnts); - DBG_88E("%s: raw data =%s\n", __func__, tmp[2]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - setrawdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); - - if (rtw_efuse_access(padapter, true, addr, cnts, setrawdata) == _FAIL) { - DBG_88E("%s: rtw_efuse_access error!!\n", __func__); - err = -EFAULT; - goto exit; - } - } else if (strcmp(tmp[0], "mac") == 0) { - if (tmp[1] == NULL) { - err = -EINVAL; - goto exit; - } - - /* mac, 00e04c871200 */ - addr = EEPROM_MAC_ADDR_88EU; - cnts = strlen(tmp[1]); - if (cnts%2) { - err = -EINVAL; - goto exit; - } - cnts /= 2; - if (cnts == 0) { - err = -EINVAL; - goto exit; - } - if (cnts > 6) { - DBG_88E("%s: error data for mac addr =\"%s\"\n", __func__, tmp[1]); - err = -EFAULT; - goto exit; - } - - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - DBG_88E("%s: cnts =%d\n", __func__, cnts); - DBG_88E("%s: MAC address =%s\n", __func__, tmp[1]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); - /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { - DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EFAULT; - goto exit; - } - - if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { - DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); - err = -EFAULT; - goto exit; - } - } else if (strcmp(tmp[0], "vidpid") == 0) { - if (tmp[1] == NULL) { - err = -EINVAL; - goto exit; - } - - /* pidvid, da0b7881 */ - addr = EEPROM_VID_88EE; - cnts = strlen(tmp[1]); - if (cnts%2) { - err = -EINVAL; - goto exit; - } - cnts /= 2; - if (cnts == 0) { - err = -EINVAL; - goto exit; - } - - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - DBG_88E("%s: cnts =%d\n", __func__, cnts); - DBG_88E("%s: VID/PID =%s\n", __func__, tmp[1]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); - - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { - DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EFAULT; - goto exit; - } - - if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { - DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); - err = -EFAULT; - goto exit; - } - } else if (strcmp(tmp[0], "btwmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { - err = -EINVAL; - goto exit; - } - - addr = simple_strtoul(tmp[1], &ptmp, 16); - addr &= 0xFFF; - - cnts = strlen(tmp[2]); - if (cnts%2) { - err = -EINVAL; - goto exit; - } - cnts /= 2; - if (cnts == 0) { - err = -EINVAL; - goto exit; - } - - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - DBG_88E("%s: cnts =%d\n", __func__, cnts); - DBG_88E("%s: BT data =%s\n", __func__, tmp[2]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); - - EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { - DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); - err = -EFAULT; - goto exit; - } - - if (rtw_BT_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { - DBG_88E("%s: rtw_BT_efuse_map_write error!!\n", __func__); - err = -EFAULT; - goto exit; - } - } else if (strcmp(tmp[0], "btwfake") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { - err = -EINVAL; - goto exit; - } - - addr = simple_strtoul(tmp[1], &ptmp, 16); - addr &= 0xFFF; - - cnts = strlen(tmp[2]); - if (cnts%2) { - err = -EINVAL; - goto exit; - } - cnts /= 2; - if (cnts == 0) { - err = -EINVAL; - goto exit; - } - - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - DBG_88E("%s: cnts =%d\n", __func__, cnts); - DBG_88E("%s: BT tmp data =%s\n", __func__, tmp[2]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); - } else if (strcmp(tmp[0], "btdumpfake") == 0) { - if (rtw_BT_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _SUCCESS) { - DBG_88E("%s: BT read all map success\n", __func__); - } else { - DBG_88E("%s: BT read all map Fail!\n", __func__); - err = -EFAULT; - } - } else if (strcmp(tmp[0], "wldumpfake") == 0) { - if (rtw_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _SUCCESS) { - DBG_88E("%s: BT read all map success\n", __func__); - } else { - DBG_88E("%s: BT read all map Fail\n", __func__); - err = -EFAULT; - } - } else if (strcmp(tmp[0], "btfk2map") == 0) { - memcpy(pEfuseHal->BTEfuseModifiedMap, pEfuseHal->fakeBTEfuseModifiedMap, EFUSE_BT_MAX_MAP_LEN); - - EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if (max_available_size < 1) { - err = -EFAULT; - goto exit; - } - - if (rtw_BT_efuse_map_write(padapter, 0x00, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _FAIL) { - DBG_88E("%s: rtw_BT_efuse_map_write error!\n", __func__); - err = -EFAULT; - goto exit; - } - } else if (strcmp(tmp[0], "wlfk2map") == 0) { - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if (max_available_size < 1) { - err = -EFAULT; - goto exit; - } - - if (rtw_efuse_map_write(padapter, 0x00, EFUSE_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _FAIL) { - DBG_88E("%s: rtw_efuse_map_write error!\n", __func__); - err = -EFAULT; - goto exit; - } - } else if (strcmp(tmp[0], "wlwfake") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { - err = -EINVAL; - goto exit; - } - - addr = simple_strtoul(tmp[1], &ptmp, 16); - addr &= 0xFFF; - - cnts = strlen(tmp[2]); - if (cnts%2) { - err = -EINVAL; - goto exit; - } - cnts /= 2; - if (cnts == 0) { - err = -EINVAL; - goto exit; - } - - DBG_88E("%s: addr = 0x%X\n", __func__, addr); - DBG_88E("%s: cnts =%d\n", __func__, cnts); - DBG_88E("%s: map tmp data =%s\n", __func__, tmp[2]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); - } - -exit: - kfree(setdata); - kfree(ShadowMapBT); - kfree(ShadowMapWiFi); - kfree(setrawdata); - - rtw_pm_set_ips(padapter, ips_mode); - rtw_pm_set_lps(padapter, lps_mode); - - return err; -} - -/* - * Input Format: %s,%d,%d - * %s is width, could be - * "b" for 1 byte - * "w" for WORD (2 bytes) - * "dw" for DWORD (4 bytes) - * 1st %d is address(offset) - * 2st %d is data to write - */ -static int rtw_mp_write_reg(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - char *pch, *pnext, *ptmp; - char *width_str; - char width; - u32 addr, data; - int ret; - struct adapter *padapter = rtw_netdev_priv(dev); - - pch = extra; - pnext = strpbrk(pch, ",.-"); - if (pnext == NULL) - return -EINVAL; - *pnext = 0; - width_str = pch; - - pch = pnext + 1; - pnext = strpbrk(pch, ",.-"); - if (pnext == NULL) - return -EINVAL; - *pnext = 0; - addr = simple_strtoul(pch, &ptmp, 16); - if (addr > 0x3FFF) - return -EINVAL; - - pch = pnext + 1; - if ((pch - extra) >= wrqu->length) - return -EINVAL; - data = simple_strtoul(pch, &ptmp, 16); - - ret = 0; - width = width_str[0]; - switch (width) { - case 'b': - /* 1 byte */ - if (data > 0xFF) { - ret = -EINVAL; - break; - } - rtw_write8(padapter, addr, data); - break; - case 'w': - /* 2 bytes */ - if (data > 0xFFFF) { - ret = -EINVAL; - break; - } - rtw_write16(padapter, addr, data); - break; - case 'd': - /* 4 bytes */ - rtw_write32(padapter, addr, data); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - -/* - * Input Format: %s,%d - * %s is width, could be - * "b" for 1 byte - * "w" for WORD (2 bytes) - * "dw" for DWORD (4 bytes) - * %d is address(offset) - * - * Return: - * %d for data readed - */ -static int rtw_mp_read_reg(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - char *input = kmalloc(wrqu->length, GFP_KERNEL); - char *pch, *pnext, *ptmp; - char *width_str; - char width; - char data[20], tmp[20]; - u32 addr; - u32 ret, i = 0, j = 0, strtout = 0; - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - _rtw_memset(data, 0, 20); - _rtw_memset(tmp, 0, 20); - _rtw_memset(extra, 0, wrqu->length); - - pch = input; - pnext = strpbrk(pch, ",.-"); - if (pnext == NULL) { - kfree(input); - return -EINVAL; - } - *pnext = 0; - width_str = pch; - - pch = pnext + 1; - if ((pch - input) >= wrqu->length) { - kfree(input); - return -EINVAL; - } - kfree(input); - addr = simple_strtoul(pch, &ptmp, 16); - if (addr > 0x3FFF) - return -EINVAL; - - ret = 0; - width = width_str[0]; - switch (width) { - case 'b': - /* 1 byte */ - sprintf(extra, "%d\n", rtw_read8(padapter, addr)); - wrqu->length = strlen(extra); - break; - case 'w': - /* 2 bytes */ - sprintf(data, "%04x\n", rtw_read16(padapter, addr)); - for (i = 0; i <= strlen(data); i++) { - if (i%2 == 0) { - tmp[j] = ' '; - j++; - } - if (data[i] != '\0') - tmp[j] = data[i]; - j++; - } - pch = tmp; - DBG_88E("pch =%s", pch); - - while (*pch != '\0') { - pnext = strpbrk(pch, " "); - if (!pnext) - break; - - pnext++; - if (*pnext != '\0') { - strtout = simple_strtoul(pnext, &ptmp, 16); - sprintf(extra, "%s %d", extra, strtout); - } else { - break; - } - pch = pnext; - } - wrqu->length = 6; - break; - case 'd': - /* 4 bytes */ - sprintf(data, "%08x", rtw_read32(padapter, addr)); - /* add read data format blank */ - for (i = 0; i <= strlen(data); i++) { - if (i%2 == 0) { - tmp[j] = ' '; - j++; - } - if (data[i] != '\0') - tmp[j] = data[i]; - - j++; - } - pch = tmp; - DBG_88E("pch =%s", pch); - - while (*pch != '\0') { - pnext = strpbrk(pch, " "); - if (!pnext) - break; - pnext++; - if (*pnext != '\0') { - strtout = simple_strtoul(pnext, &ptmp, 16); - sprintf(extra, "%s %d", extra, strtout); - } else { - break; - } - pch = pnext; - } - wrqu->length = strlen(extra); - break; - default: - wrqu->length = 0; - ret = -EINVAL; - break; - } - - return ret; -} - -/* - * Input Format: %d,%x,%x - * %d is RF path, should be smaller than MAX_RF_PATH_NUMS - * 1st %x is address(offset) - * 2st %x is data to write - */ - static int rtw_mp_write_rf(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 path, addr, data; - int ret; - struct adapter *padapter = rtw_netdev_priv(dev); - - ret = sscanf(extra, "%d,%x,%x", &path, &addr, &data); - if (ret < 3) - return -EINVAL; - - if (path >= MAX_RF_PATH_NUMS) - return -EINVAL; - if (addr > 0xFF) - return -EINVAL; - if (data > 0xFFFFF) - return -EINVAL; - - _rtw_memset(extra, 0, wrqu->length); - - write_rfreg(padapter, path, addr, data); - - sprintf(extra, "write_rf completed\n"); - wrqu->length = strlen(extra); - - return 0; -} - -/* - * Input Format: %d,%x - * %d is RF path, should be smaller than MAX_RF_PATH_NUMS - * %x is address(offset) - * - * Return: - * %d for data readed - */ -static int rtw_mp_read_rf(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - char *input = kmalloc(wrqu->length, GFP_KERNEL); - char *pch, *pnext, *ptmp; - char data[20], tmp[20]; - u32 path, addr; - u32 ret, i = 0, j = 0, strtou = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - ret = sscanf(input, "%d,%x", &path, &addr); - kfree(input); - if (ret < 2) - return -EINVAL; - - if (path >= MAX_RF_PATH_NUMS) - return -EINVAL; - if (addr > 0xFF) - return -EINVAL; - - _rtw_memset(extra, 0, wrqu->length); - - sprintf(data, "%08x", read_rfreg(padapter, path, addr)); - /* add read data format blank */ - for (i = 0; i <= strlen(data); i++) { - if (i%2 == 0) { - tmp[j] = ' '; - j++; - } - tmp[j] = data[i]; - j++; - } - pch = tmp; - DBG_88E("pch =%s", pch); - - while (*pch != '\0') { - pnext = strpbrk(pch, " "); - pnext++; - if (*pnext != '\0') { - strtou = simple_strtoul(pnext, &ptmp, 16); - sprintf(extra, "%s %d", extra, strtou); - } else { - break; - } - pch = pnext; - } - wrqu->length = strlen(extra); - return 0; -} - -static int rtw_mp_start(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - if (padapter->registrypriv.mp_mode == 0) { - padapter->registrypriv.mp_mode = 1; - - rtw_pm_set_ips(padapter, IPS_NONE); - LeaveAllPowerSaveMode(padapter); - - MPT_InitializeAdapter(padapter, 1); - } - if (padapter->registrypriv.mp_mode == 0) - return -EPERM; - if (padapter->mppriv.mode == MP_OFF) { - if (mp_start_test(padapter) == _FAIL) - return -EPERM; - padapter->mppriv.mode = MP_ON; - } - return 0; -} - -static int rtw_mp_stop(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - if (padapter->registrypriv.mp_mode == 1) { - MPT_DeInitAdapter(padapter); - padapter->registrypriv.mp_mode = 0; - } - - if (padapter->mppriv.mode != MP_OFF) { - mp_stop_test(padapter); - padapter->mppriv.mode = MP_OFF; - } - - return 0; -} - -extern int wifirate2_ratetbl_inx(unsigned char rate); - -static int rtw_mp_rate(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 rate = MPT_RATE_1M; - char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter *padapter = rtw_netdev_priv(dev); - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - rate = rtw_atoi(input); - sprintf(extra, "Set data rate to %d", rate); - kfree(input); - if (rate <= 0x7f) - rate = wifirate2_ratetbl_inx((u8)rate); - else - rate = (rate-0x80+MPT_RATE_MCS0); - - if (rate >= MPT_RATE_LAST) - return -EINVAL; - - padapter->mppriv.rateidx = rate; - Hal_SetDataRate(padapter); - - wrqu->length = strlen(extra) + 1; - return 0; -} - -static int rtw_mp_channel(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - char *input = kmalloc(wrqu->length, GFP_KERNEL); - u32 channel = 1; - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - channel = rtw_atoi(input); - sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel, channel); - - padapter->mppriv.channel = channel; - Hal_SetChannel(padapter); - - wrqu->length = strlen(extra) + 1; - kfree(input); - return 0; -} - -static int rtw_mp_bandwidth(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 bandwidth = 0, sg = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - - sscanf(extra, "40M =%d, shortGI =%d", &bandwidth, &sg); - - if (bandwidth != HT_CHANNEL_WIDTH_40) - bandwidth = HT_CHANNEL_WIDTH_20; - - padapter->mppriv.bandwidth = (u8)bandwidth; - padapter->mppriv.preamble = sg; - - SetBandwidth(padapter); - - return 0; -} - -static int rtw_mp_txpower(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 idx_a = 0, idx_b = 0; - char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter *padapter = rtw_netdev_priv(dev); - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - sscanf(input, "patha =%d, pathb =%d", &idx_a, &idx_b); - - sprintf(extra, "Set power level path_A:%d path_B:%d", idx_a, idx_b); - padapter->mppriv.txpoweridx = (u8)idx_a; - padapter->mppriv.txpoweridx_b = (u8)idx_b; - padapter->mppriv.bSetTxPower = 1; - Hal_SetAntennaPathPower(padapter); - - wrqu->length = strlen(extra) + 1; - kfree(input); - return 0; -} - -static int rtw_mp_ant_tx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 i; - char *input = kmalloc(wrqu->length, GFP_KERNEL); - u16 antenna = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - - sprintf(extra, "switch Tx antenna to %s", input); - - for (i = 0; i < strlen(input); i++) { - switch (input[i]) { - case 'a': - antenna |= ANTENNA_A; - break; - case 'b': - antenna |= ANTENNA_B; - break; - } - } - padapter->mppriv.antenna_tx = antenna; - - Hal_SetAntenna(padapter); - - wrqu->length = strlen(extra) + 1; - kfree(input); - return 0; -} - -static int rtw_mp_ant_rx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 i; - u16 antenna = 0; - char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter *padapter = rtw_netdev_priv(dev); - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - _rtw_memset(extra, 0, wrqu->length); - - sprintf(extra, "switch Rx antenna to %s", input); - - for (i = 0; i < strlen(input); i++) { - switch (input[i]) { - case 'a': - antenna |= ANTENNA_A; - break; - case 'b': - antenna |= ANTENNA_B; - break; - } - } - - padapter->mppriv.antenna_rx = antenna; - Hal_SetAntenna(padapter); - wrqu->length = strlen(extra); - kfree(input); - return 0; -} - -static int rtw_mp_ctx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 pkTx = 1, countPkTx = 1, cotuTx = 1, CarrSprTx = 1, scTx = 1, sgleTx = 1, stop = 1; - u32 bStartTest = 1; - u32 count = 0; - struct mp_priv *pmp_priv; - struct pkt_attrib *pattrib; - - struct adapter *padapter = rtw_netdev_priv(dev); - - pmp_priv = &padapter->mppriv; - - if (copy_from_user(extra, wrqu->pointer, wrqu->length)) - return -EFAULT; - - DBG_88E("%s: in =%s\n", __func__, extra); - - countPkTx = strncmp(extra, "count =", 5); /* strncmp true is 0 */ - cotuTx = strncmp(extra, "background", 20); - CarrSprTx = strncmp(extra, "background, cs", 20); - scTx = strncmp(extra, "background, sc", 20); - sgleTx = strncmp(extra, "background, stone", 20); - pkTx = strncmp(extra, "background, pkt", 20); - stop = strncmp(extra, "stop", 4); - sscanf(extra, "count =%d, pkt", &count); - - _rtw_memset(extra, '\0', sizeof(*extra)); - - if (stop == 0) { - bStartTest = 0; /* To set Stop */ - pmp_priv->tx.stop = 1; - sprintf(extra, "Stop continuous Tx"); - } else { - bStartTest = 1; - if (pmp_priv->mode != MP_ON) { - if (pmp_priv->tx.stop != 1) { - DBG_88E("%s: MP_MODE != ON %d\n", __func__, pmp_priv->mode); - return -EFAULT; - } - } - } - - if (pkTx == 0 || countPkTx == 0) - pmp_priv->mode = MP_PACKET_TX; - if (sgleTx == 0) - pmp_priv->mode = MP_SINGLE_TONE_TX; - if (cotuTx == 0) - pmp_priv->mode = MP_CONTINUOUS_TX; - if (CarrSprTx == 0) - pmp_priv->mode = MP_CARRIER_SUPPRISSION_TX; - if (scTx == 0) - pmp_priv->mode = MP_SINGLE_CARRIER_TX; - - switch (pmp_priv->mode) { - case MP_PACKET_TX: - if (bStartTest == 0) { - pmp_priv->tx.stop = 1; - pmp_priv->mode = MP_ON; - sprintf(extra, "Stop continuous Tx"); - } else if (pmp_priv->tx.stop == 1) { - sprintf(extra, "Start continuous DA = ffffffffffff len = 1500 count =%u,\n", count); - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = count; - pmp_priv->tx.payload = 2; - pattrib = &pmp_priv->tx.attrib; - pattrib->pktlen = 1500; - _rtw_memset(pattrib->dst, 0xFF, ETH_ALEN); - SetPacketTx(padapter); - } else { - return -EFAULT; - } - wrqu->length = strlen(extra); - return 0; - case MP_SINGLE_TONE_TX: - if (bStartTest != 0) - sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); - Hal_SetSingleToneTx(padapter, (u8)bStartTest); - break; - case MP_CONTINUOUS_TX: - if (bStartTest != 0) - sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); - Hal_SetContinuousTx(padapter, (u8)bStartTest); - break; - case MP_CARRIER_SUPPRISSION_TX: - if (bStartTest != 0) { - if (pmp_priv->rateidx <= MPT_RATE_11M) { - sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); - Hal_SetCarrierSuppressionTx(padapter, (u8)bStartTest); - } else { - sprintf(extra, "Specify carrier suppression but not CCK rate"); - } - } - break; - case MP_SINGLE_CARRIER_TX: - if (bStartTest != 0) - sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); - Hal_SetSingleCarrierTx(padapter, (u8)bStartTest); - break; - default: - sprintf(extra, "Error! Continuous-Tx is not on-going."); - return -EFAULT; - } - - if (bStartTest == 1 && pmp_priv->mode != MP_ON) { - struct mp_priv *pmp_priv = &padapter->mppriv; - if (pmp_priv->tx.stop == 0) { - pmp_priv->tx.stop = 1; - rtw_msleep_os(5); - } - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(padapter); - } else { - pmp_priv->mode = MP_ON; - } - - wrqu->length = strlen(extra); - return 0; -} - -static int rtw_mp_arx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 bStartRx = 0, bStopRx = 0, bQueryPhy; - u32 cckok = 0, cckcrc = 0, ofdmok = 0, ofdmcrc = 0, htok = 0, htcrc = 0, OFDM_FA = 0, CCK_FA = 0; - char *input = kmalloc(wrqu->length, GFP_KERNEL); - struct adapter *padapter = rtw_netdev_priv(dev); - - if (!input) - return -ENOMEM; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - DBG_88E("%s: %s\n", __func__, input); - - bStartRx = (strncmp(input, "start", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ - bStopRx = (strncmp(input, "stop", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ - bQueryPhy = (strncmp(input, "phy", 3) == 0) ? 1 : 0; /* strncmp true is 0 */ - - if (bStartRx) { - sprintf(extra, "start"); - SetPacketRx(padapter, bStartRx); - } else if (bStopRx) { - SetPacketRx(padapter, 0); - sprintf(extra, "Received packet OK:%d CRC error:%d", padapter->mppriv.rx_pktcount, padapter->mppriv.rx_crcerrpktcount); - } else if (bQueryPhy) { - /* - OFDM FA - RegCF0[15:0] - RegCF2[31:16] - RegDA0[31:16] - RegDA4[15:0] - RegDA4[31:16] - RegDA8[15:0] - CCK FA - (RegA5B<<8) | RegA5C - */ - cckok = read_bbreg(padapter, 0xf88, 0xffffffff); - cckcrc = read_bbreg(padapter, 0xf84, 0xffffffff); - ofdmok = read_bbreg(padapter, 0xf94, 0x0000FFFF); - ofdmcrc = read_bbreg(padapter, 0xf94, 0xFFFF0000); - htok = read_bbreg(padapter, 0xf90, 0x0000FFFF); - htcrc = read_bbreg(padapter, 0xf90, 0xFFFF0000); - - OFDM_FA = read_bbreg(padapter, 0xcf0, 0x0000FFFF); - OFDM_FA = read_bbreg(padapter, 0xcf2, 0xFFFF0000); - OFDM_FA = read_bbreg(padapter, 0xda0, 0xFFFF0000); - OFDM_FA = read_bbreg(padapter, 0xda4, 0x0000FFFF); - OFDM_FA = read_bbreg(padapter, 0xda4, 0xFFFF0000); - OFDM_FA = read_bbreg(padapter, 0xda8, 0x0000FFFF); - CCK_FA = (rtw_read8(padapter, 0xa5b)<<8) | (rtw_read8(padapter, 0xa5c)); - - sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", cckok+ofdmok+htok, cckcrc+ofdmcrc+htcrc, OFDM_FA+CCK_FA); - } - wrqu->length = strlen(extra) + 1; - kfree(input); - return 0; -} - -static int rtw_mp_trx_query(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 txok, txfail, rxok, rxfail; - struct adapter *padapter = rtw_netdev_priv(dev); - - txok = padapter->mppriv.tx.sended; - txfail = 0; - rxok = padapter->mppriv.rx_pktcount; - rxfail = padapter->mppriv.rx_crcerrpktcount; - - _rtw_memset(extra, '\0', 128); - - sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ", txok, txfail, rxok, rxfail); - - wrqu->length = strlen(extra)+1; - - return 0; -} - -static int rtw_mp_pwrtrk(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 enable; - u32 thermal; - s32 ret; - struct adapter *padapter = rtw_netdev_priv(dev); - char *input = kmalloc(wrqu->length, GFP_KERNEL); - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - _rtw_memset(extra, 0, wrqu->length); - - enable = 1; - if (wrqu->length > 1) {/* not empty string */ - if (strncmp(input, "stop", 4) == 0) { - enable = 0; - sprintf(extra, "mp tx power tracking stop"); - } else if (sscanf(input, "ther =%d", &thermal)) { - ret = Hal_SetThermalMeter(padapter, (u8)thermal); - if (ret == _FAIL) - return -EPERM; - sprintf(extra, "mp tx power tracking start, target value =%d ok ", thermal); - } else { - kfree(input); - return -EINVAL; - } - } - - kfree(input); - ret = Hal_SetPowerTracking(padapter, enable); - if (ret == _FAIL) - return -EPERM; - - wrqu->length = strlen(extra); - return 0; -} - -static int rtw_mp_psd(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - char *input = kmalloc(wrqu->length, GFP_KERNEL); - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - - strcpy(extra, input); - - wrqu->length = mp_query_psd(padapter, extra); - kfree(input); - return 0; -} - -static int rtw_mp_thermal(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 val; - u16 bwrite = 1; - u16 addr = EEPROM_THERMAL_METER_88E; - - u16 cnt = 1; - u16 max_available_size = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - - if (copy_from_user(extra, wrqu->pointer, wrqu->length)) - return -EFAULT; - - bwrite = strncmp(extra, "write", 6); /* strncmp true is 0 */ - - Hal_GetThermalMeter(padapter, &val); - - if (bwrite == 0) { - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if (2 > max_available_size) { - DBG_88E("no available efuse!\n"); - return -EFAULT; - } - if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { - DBG_88E("rtw_efuse_map_write error\n"); - return -EFAULT; - } else { - sprintf(extra, " efuse write ok :%d", val); - } - } else { - sprintf(extra, "%d", val); - } - wrqu->length = strlen(extra); - - return 0; -} - -static int rtw_mp_reset_stats(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct mp_priv *pmp_priv; - struct adapter *padapter = rtw_netdev_priv(dev); - - pmp_priv = &padapter->mppriv; - - pmp_priv->tx.sended = 0; - pmp_priv->tx_pktcount = 0; - pmp_priv->rx_pktcount = 0; - pmp_priv->rx_crcerrpktcount = 0; - - /* reset phy counter */ - write_bbreg(padapter, 0xf14, BIT16, 0x1); - rtw_msleep_os(10); - write_bbreg(padapter, 0xf14, BIT16, 0x0); - - return 0; -} - -static int rtw_mp_dump(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 value; - u8 rf_type, path_nums = 0; - u32 i, j = 1, path; - struct adapter *padapter = rtw_netdev_priv(dev); - - if (strncmp(extra, "all", 4) == 0) { - DBG_88E("\n ======= MAC REG =======\n"); - for (i = 0x0; i < 0x300; i += 4) { - if (j%4 == 1) - DBG_88E("0x%02x", i); - DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) - DBG_88E("\n"); - } - for (i = 0x400; i < 0x1000; i += 4) { - if (j%4 == 1) - DBG_88E("0x%02x", i); - DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) - DBG_88E("\n"); - } - - j = 1; - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - - DBG_88E("\n ======= RF REG =======\n"); - if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) - path_nums = 1; - else - path_nums = 2; - - for (path = 0; path < path_nums; path++) { - for (i = 0; i < 0x34; i++) { - value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) - DBG_88E("0x%02x ", i); - DBG_88E(" 0x%08x ", value); - if ((j++)%4 == 0) - DBG_88E("\n"); - } - } - } - return 0; -} - -static int rtw_mp_phypara(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - char *input = kmalloc(wrqu->length, GFP_KERNEL); - u32 valxcap; - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; - } - - DBG_88E("%s:iwpriv in =%s\n", __func__, input); - - sscanf(input, "xcap =%d", &valxcap); - - kfree(input); - return 0; -} - -static int rtw_mp_SetRFPath(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - char *input = kmalloc(wrqu->data.length, GFP_KERNEL); - u8 bMain = 1, bTurnoff = 1; - - if (!input) - return -ENOMEM; - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - DBG_88E("%s:iwpriv in =%s\n", __func__, input); - - bMain = strncmp(input, "1", 2); /* strncmp true is 0 */ - bTurnoff = strncmp(input, "0", 3); /* strncmp true is 0 */ - - if (bMain == 0) { - MP_PHY_SetRFPathSwitch(padapter, true); - DBG_88E("%s:PHY_SetRFPathSwitch = true\n", __func__); - } else if (bTurnoff == 0) { - MP_PHY_SetRFPathSwitch(padapter, false); - DBG_88E("%s:PHY_SetRFPathSwitch = false\n", __func__); - } - kfree(input); - return 0; -} - -static int rtw_mp_QueryDrv(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - char *input = kmalloc(wrqu->data.length, GFP_KERNEL); - u8 qAutoLoad = 1; - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - - if (!input) - return -ENOMEM; - - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - DBG_88E("%s:iwpriv in =%s\n", __func__, input); - - qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */ - - if (qAutoLoad == 0) { - DBG_88E("%s:qAutoLoad\n", __func__); - - if (pEEPROM->bautoload_fail_flag) - sprintf(extra, "fail"); - else - sprintf(extra, "ok"); - } - wrqu->data.length = strlen(extra) + 1; - kfree(input); - return 0; -} - -static int rtw_mp_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - struct iw_point *wrqu = (struct iw_point *)wdata; - u32 subcmd = wrqu->flags; - struct adapter *padapter = rtw_netdev_priv(dev); - - if (padapter == NULL) - return -ENETDOWN; - - if (extra == NULL) { - wrqu->length = 0; - return -EIO; - } - - switch (subcmd) { - case MP_START: - DBG_88E("set case mp_start\n"); - rtw_mp_start(dev, info, wrqu, extra); - break; - case MP_STOP: - DBG_88E("set case mp_stop\n"); - rtw_mp_stop(dev, info, wrqu, extra); - break; - case MP_BANDWIDTH: - DBG_88E("set case mp_bandwidth\n"); - rtw_mp_bandwidth(dev, info, wrqu, extra); - break; - case MP_RESET_STATS: - DBG_88E("set case MP_RESET_STATS\n"); - rtw_mp_reset_stats(dev, info, wrqu, extra); - break; - case MP_SetRFPathSwh: - DBG_88E("set MP_SetRFPathSwitch\n"); - rtw_mp_SetRFPath(dev, info, wdata, extra); - break; - case CTA_TEST: - DBG_88E("set CTA_TEST\n"); - rtw_cta_test_start(dev, info, wdata, extra); - break; - } - - return 0; -} - -static int rtw_mp_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - struct iw_point *wrqu = (struct iw_point *)wdata; - u32 subcmd = wrqu->flags; - struct adapter *padapter = rtw_netdev_priv(dev); - - if (padapter == NULL) - return -ENETDOWN; - if (extra == NULL) { - wrqu->length = 0; - return -EIO; - } - - switch (subcmd) { - case WRITE_REG: - rtw_mp_write_reg(dev, info, wrqu, extra); - break; - case WRITE_RF: - rtw_mp_write_rf(dev, info, wrqu, extra); - break; - case MP_PHYPARA: - DBG_88E("mp_get MP_PHYPARA\n"); - rtw_mp_phypara(dev, info, wrqu, extra); - break; - case MP_CHANNEL: - DBG_88E("set case mp_channel\n"); - rtw_mp_channel(dev, info, wrqu, extra); - break; - case READ_REG: - DBG_88E("mp_get READ_REG\n"); - rtw_mp_read_reg(dev, info, wrqu, extra); - break; - case READ_RF: - DBG_88E("mp_get READ_RF\n"); - rtw_mp_read_rf(dev, info, wrqu, extra); - break; - case MP_RATE: - DBG_88E("set case mp_rate\n"); - rtw_mp_rate(dev, info, wrqu, extra); - break; - case MP_TXPOWER: - DBG_88E("set case MP_TXPOWER\n"); - rtw_mp_txpower(dev, info, wrqu, extra); - break; - case MP_ANT_TX: - DBG_88E("set case MP_ANT_TX\n"); - rtw_mp_ant_tx(dev, info, wrqu, extra); - break; - case MP_ANT_RX: - DBG_88E("set case MP_ANT_RX\n"); - rtw_mp_ant_rx(dev, info, wrqu, extra); - break; - case MP_QUERY: - rtw_mp_trx_query(dev, info, wrqu, extra); - break; - case MP_CTX: - DBG_88E("set case MP_CTX\n"); - rtw_mp_ctx(dev, info, wrqu, extra); - break; - case MP_ARX: - DBG_88E("set case MP_ARX\n"); - rtw_mp_arx(dev, info, wrqu, extra); - break; - case EFUSE_GET: - DBG_88E("efuse get EFUSE_GET\n"); - rtw_mp_efuse_get(dev, info, wdata, extra); - break; - case MP_DUMP: - DBG_88E("set case MP_DUMP\n"); - rtw_mp_dump(dev, info, wrqu, extra); - break; - case MP_PSD: - DBG_88E("set case MP_PSD\n"); - rtw_mp_psd(dev, info, wrqu, extra); - break; - case MP_THER: - DBG_88E("set case MP_THER\n"); - rtw_mp_thermal(dev, info, wrqu, extra); - break; - case MP_QueryDrvStats: - DBG_88E("mp_get MP_QueryDrvStats\n"); - rtw_mp_QueryDrv (dev, info, wdata, extra); - break; - case MP_PWRTRK: - DBG_88E("set case MP_PWRTRK\n"); - rtw_mp_pwrtrk(dev, info, wrqu, extra); - break; - case EFUSE_SET: - DBG_88E("set case efuse set\n"); - rtw_mp_efuse_set(dev, info, wdata, extra); - break; - } - - rtw_msleep_os(10); /* delay 5ms for sending pkt before exit adb shell operation */ - return 0; -} - -static int rtw_tdls(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - -static int rtw_tdls_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - -static int rtw_test( - struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - u32 len; - u8 *pbuf, *pch; - char *ptmp; - u8 *delim = ","; - - DBG_88E("+%s\n", __func__); - len = wrqu->data.length; - - pbuf = (u8 *)rtw_zmalloc(len); - if (pbuf == NULL) { - DBG_88E("%s: no memory!\n", __func__); - return -ENOMEM; - } - - if (copy_from_user(pbuf, wrqu->data.pointer, len)) { - kfree(pbuf); - DBG_88E("%s: copy from user fail!\n", __func__); - return -EFAULT; - } - DBG_88E("%s: string =\"%s\"\n", __func__, pbuf); - - ptmp = (char *)pbuf; - pch = strsep(&ptmp, delim); - if ((pch == NULL) || (strlen(pch) == 0)) { - kfree(pbuf); - DBG_88E("%s: parameter error(level 1)!\n", __func__); - return -EFAULT; - } - kfree(pbuf); - return 0; -} - static iw_handler rtw_handlers[] = { NULL, /* SIOCSIWCOMMIT */ rtw_wx_get_name, /* SIOCGIWNAME */ @@ -7659,539 +3068,37 @@ static iw_handler rtw_handlers[] = { NULL, /*---hole---*/ }; -static const struct iw_priv_args rtw_private_args[] = { - { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_CHAR | 0x7FF, 0, "write" - }, - { - SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_CHAR | 0x7FF, - IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "read" - }, - { - SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext" - }, - { - SIOCIWFIRSTPRIV + 0x3, 0, 0, "mp_ioctl" - }, - { - SIOCIWFIRSTPRIV + 0x4, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo" - }, - { - SIOCIWFIRSTPRIV + 0x5, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setpid" - }, - { - SIOCIWFIRSTPRIV + 0x6, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start" - }, - { - SIOCIWFIRSTPRIV + 0x7, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "get_sensitivity" - }, - { - SIOCIWFIRSTPRIV + 0x8, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_prob_req_ie" - }, - { - SIOCIWFIRSTPRIV + 0x9, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_assoc_req_ie" - }, - - { - SIOCIWFIRSTPRIV + 0xA, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "channel_plan" - }, - - { - SIOCIWFIRSTPRIV + 0xB, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "dbg" - }, - { - SIOCIWFIRSTPRIV + 0xC, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "rfw" - }, - { - SIOCIWFIRSTPRIV + 0xD, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "rfr" - }, - { - SIOCIWFIRSTPRIV + 0x10, - IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, 0, "p2p_set" - }, - { - SIOCIWFIRSTPRIV + 0x11, - IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "p2p_get" - }, - { - SIOCIWFIRSTPRIV + 0x12, - IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IFNAMSIZ, "p2p_get2" - }, - {SIOCIWFIRSTPRIV + 0x13, IW_PRIV_TYPE_CHAR | 128, 0, "NULL"}, - { - SIOCIWFIRSTPRIV + 0x14, - IW_PRIV_TYPE_CHAR | 64, 0, "tdls" - }, - { - SIOCIWFIRSTPRIV + 0x15, - IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "tdls_get" - }, - { - SIOCIWFIRSTPRIV + 0x16, - IW_PRIV_TYPE_CHAR | 64, 0, "pm_set" - }, - - {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ, 0, "rereg_nd_name"}, - - {SIOCIWFIRSTPRIV + 0x1A, IW_PRIV_TYPE_CHAR | 1024, 0, "efuse_set"}, - {SIOCIWFIRSTPRIV + 0x1B, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, - {SIOCIWFIRSTPRIV + 0x1D, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test" - }, - - {SIOCIWFIRSTPRIV + 0x0E, IW_PRIV_TYPE_CHAR | 1024, 0, ""}, /* set */ - {SIOCIWFIRSTPRIV + 0x0F, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, ""},/* get */ -/* --- sub-ioctls definitions --- */ - - {MP_START, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_start"}, /* set */ - {MP_PHYPARA, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_phypara"},/* get */ - {MP_STOP, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_stop"}, /* set */ - {MP_CHANNEL, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_channel"},/* get */ - {MP_BANDWIDTH, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_bandwidth"}, /* set */ - {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"},/* get */ - {MP_RESET_STATS, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_reset_stats"}, - {MP_QUERY, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_query"}, /* get */ - {READ_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_reg"}, - {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"}, - {READ_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_rf"}, - {MP_PSD, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_psd"}, - {MP_DUMP, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_dump"}, - {MP_TXPOWER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_txpower"}, - {MP_ANT_TX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_tx"}, - {MP_ANT_RX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_rx"}, - {WRITE_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_reg"}, - {WRITE_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_rf"}, - {MP_CTX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ctx"}, - {MP_ARX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_arx"}, - {MP_THER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ther"}, - {EFUSE_SET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_set"}, - {EFUSE_GET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, - {MP_PWRTRK, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_pwrtrk"}, - {MP_QueryDrvStats, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_drvquery"}, - {MP_IOCTL, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_ioctl"}, /* mp_ioctl */ - {MP_SetRFPathSwh, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_setrfpath"}, - {CTA_TEST, IW_PRIV_TYPE_CHAR | 1024, 0, "cta_test"}, -}; - -static iw_handler rtw_private_handler[] = { -rtw_wx_write32, /* 0x00 */ -rtw_wx_read32, /* 0x01 */ -rtw_drvext_hdl, /* 0x02 */ -rtw_mp_ioctl_hdl, /* 0x03 */ - -/* for MM DTV platform */ - rtw_get_ap_info, /* 0x04 */ - - rtw_set_pid, /* 0x05 */ - rtw_wps_start, /* 0x06 */ - - rtw_wx_get_sensitivity, /* 0x07 */ - rtw_wx_set_mtk_wps_probe_ie, /* 0x08 */ - rtw_wx_set_mtk_wps_ie, /* 0x09 */ - -/* Set Channel depend on the country code */ - rtw_wx_set_channel_plan, /* 0x0A */ - - rtw_dbg_port, /* 0x0B */ - rtw_wx_write_rf, /* 0x0C */ - rtw_wx_read_rf, /* 0x0D */ - - rtw_mp_set, /* 0x0E */ - rtw_mp_get, /* 0x0F */ - rtw_p2p_set, /* 0x10 */ - rtw_p2p_get, /* 0x11 */ - rtw_p2p_get2, /* 0x12 */ - - NULL, /* 0x13 */ - rtw_tdls, /* 0x14 */ - rtw_tdls_get, /* 0x15 */ - - rtw_pm_set, /* 0x16 */ - rtw_wx_priv_null, /* 0x17 */ - rtw_rereg_nd_name, /* 0x18 */ - rtw_wx_priv_null, /* 0x19 */ - - rtw_mp_efuse_set, /* 0x1A */ - rtw_mp_efuse_get, /* 0x1B */ - NULL, /* 0x1C is reserved for hostapd */ - rtw_test, /* 0x1D */ -}; - static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_statistics *piwstats = &padapter->iwstats; + int tmp_level = 0; + int tmp_qual = 0; int tmp_noise = 0; - int tmp; if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { piwstats->qual.qual = 0; piwstats->qual.level = 0; piwstats->qual.noise = 0; } else { + tmp_level = padapter->recvpriv.signal_strength; + tmp_qual = padapter->recvpriv.signal_qual; tmp_noise = padapter->recvpriv.noise; - piwstats->qual.level = padapter->signal_strength; - tmp = 219 + 3 * padapter->signal_strength; - tmp = min(100, tmp); - tmp = max(0, tmp); - piwstats->qual.qual = tmp; + piwstats->qual.level = tmp_level; + piwstats->qual.qual = tmp_qual; piwstats->qual.noise = tmp_noise; } - piwstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; + piwstats->qual.updated = IW_QUAL_ALL_UPDATED;/* IW_QUAL_DBM; */ return &padapter->iwstats; } struct iw_handler_def rtw_handlers_def = { .standard = rtw_handlers, .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), - .private = rtw_private_handler, - .private_args = (struct iw_priv_args *)rtw_private_args, - .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args), .get_wireless_stats = rtw_get_wireless_stats, }; -/* copy from net/wireless/wext.c start */ -/* ---------------------------------------------------------------- */ -/* - * Calculate size of private arguments - */ -static const char iw_priv_type_size[] = { - 0, /* IW_PRIV_TYPE_NONE */ - 1, /* IW_PRIV_TYPE_BYTE */ - 1, /* IW_PRIV_TYPE_CHAR */ - 0, /* Not defined */ - sizeof(__u32), /* IW_PRIV_TYPE_INT */ - sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ - sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ - 0, /* Not defined */ -}; - -static int get_priv_size(__u16 args) -{ - int num = args & IW_PRIV_SIZE_MASK; - int type = (args & IW_PRIV_TYPE_MASK) >> 12; - - return num * iw_priv_type_size[type]; -} -/* copy from net/wireless/wext.c end */ - -static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data) -{ - int err = 0; - u8 *input = NULL; - u32 input_len = 0; - const char delim[] = " "; - u8 *output = NULL; - u32 output_len = 0; - u32 count = 0; - u8 *buffer = NULL; - u32 buffer_len = 0; - char *ptr = NULL; - u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */ - u32 cmdlen; - s32 len; - u8 *extra = NULL; - u32 extra_size = 0; - - s32 k; - const iw_handler *priv; /* Private ioctl */ - const struct iw_priv_args *priv_args; /* Private ioctl description */ - u32 num_priv_args; /* Number of descriptions */ - iw_handler handler; - int temp; - int subcmd = 0; /* sub-ioctl index */ - int offset = 0; /* Space for sub-ioctl index */ - - union iwreq_data wdata; - - memcpy(&wdata, wrq_data, sizeof(wdata)); - - input_len = wdata.data.length; - input = rtw_zmalloc(input_len); - if (NULL == input) - return -ENOMEM; - if (copy_from_user(input, wdata.data.pointer, input_len)) { - err = -EFAULT; - goto exit; - } - ptr = input; - len = input_len; - - sscanf(ptr, "%16s", cmdname); - cmdlen = strlen(cmdname); - DBG_88E("%s: cmd =%s\n", __func__, cmdname); - - /* skip command string */ - if (cmdlen > 0) - cmdlen += 1; /* skip one space */ - ptr += cmdlen; - len -= cmdlen; - DBG_88E("%s: parameters =%s\n", __func__, ptr); - - priv = rtw_private_handler; - priv_args = rtw_private_args; - num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); - - if (num_priv_args == 0) { - err = -EOPNOTSUPP; - goto exit; - } - - /* Search the correct ioctl */ - k = -1; - while ((++k < num_priv_args) && strcmp(priv_args[k].name, cmdname)); - - /* If not found... */ - if (k == num_priv_args) { - err = -EOPNOTSUPP; - goto exit; - } - - /* Watch out for sub-ioctls ! */ - if (priv_args[k].cmd < SIOCDEVPRIVATE) { - int j = -1; - - /* Find the matching *real* ioctl */ - while ((++j < num_priv_args) && ((priv_args[j].name[0] != '\0') || - (priv_args[j].set_args != priv_args[k].set_args) || - (priv_args[j].get_args != priv_args[k].get_args))); - - /* If not found... */ - if (j == num_priv_args) { - err = -EINVAL; - goto exit; - } - - /* Save sub-ioctl number */ - subcmd = priv_args[k].cmd; - /* Reserve one int (simplify alignment issues) */ - offset = sizeof(__u32); - /* Use real ioctl definition from now on */ - k = j; - } - - buffer = rtw_zmalloc(4096); - if (NULL == buffer) { - err = -ENOMEM; - goto exit; - } - - /* If we have to set some data */ - if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) { - u8 *str; - - switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) - break; - sscanf(str, "%i", &temp); - buffer[count++] = (u8)temp; - } while (1); - buffer_len = count; - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - break; - case IW_PRIV_TYPE_INT: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) - break; - sscanf(str, "%i", &temp); - ((s32 *)buffer)[count++] = (s32)temp; - } while (1); - buffer_len = count * sizeof(s32); - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - break; - case IW_PRIV_TYPE_CHAR: - if (len > 0) { - /* Size of the string to fetch */ - wdata.data.length = len; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - /* Fetch string */ - memcpy(buffer, ptr, wdata.data.length); - } else { - wdata.data.length = 1; - buffer[0] = '\0'; - } - buffer_len = wdata.data.length; - break; - default: - DBG_88E("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; - } - - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) { - DBG_88E("%s: The command %s needs exactly %d argument(s)...\n", - __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); - err = -EINVAL; - goto exit; - } - } else { - /* if args to set */ - wdata.data.length = 0L; - } - - /* Those two tests are important. They define how the driver - * will have to handle the data */ - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) { - /* First case : all SET args fit within wrq */ - if (offset) - wdata.mode = subcmd; - memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); - } else { - if ((priv_args[k].set_args == 0) && - (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) { - /* Second case : no SET args, GET args fit within wrq */ - if (offset) - wdata.mode = subcmd; - } else { - /* Third case : args won't fit in wrq, or variable number of args */ - if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { - err = -EFAULT; - goto exit; - } - wdata.data.flags = subcmd; - } - } - - kfree(input); - input = NULL; - - extra_size = 0; - if (IW_IS_SET(priv_args[k].cmd)) { - /* Size of set arguments */ - extra_size = get_priv_size(priv_args[k].set_args); - - /* Does it fits in iwr ? */ - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((extra_size + offset) <= IFNAMSIZ)) - extra_size = 0; - } else { - /* Size of get arguments */ - extra_size = get_priv_size(priv_args[k].get_args); - - /* Does it fits in iwr ? */ - if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (extra_size <= IFNAMSIZ)) - extra_size = 0; - } - - if (extra_size == 0) { - extra = (u8 *)&wdata; - kfree(buffer); - buffer = NULL; - } else { - extra = buffer; - } - - handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV]; - err = handler(dev, NULL, &wdata, extra); - - /* If we have to get some data */ - if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) { - int j; - int n = 0; /* number of args */ - u8 str[20] = {0}; - - /* Check where is the returned data */ - if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) - n = priv_args[k].get_args & IW_PRIV_SIZE_MASK; - else - n = wdata.data.length; - - output = rtw_zmalloc(4096); - if (NULL == output) { - err = -ENOMEM; - goto exit; - } - switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Display args */ - for (j = 0; j < n; j++) { - sprintf(str, "%d ", extra[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); - } - break; - case IW_PRIV_TYPE_INT: - /* Display args */ - for (j = 0; j < n; j++) { - sprintf(str, "%d ", ((__s32 *)extra)[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); - } - break; - case IW_PRIV_TYPE_CHAR: - /* Display args */ - memcpy(output, extra, n); - break; - default: - DBG_88E("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; - } - - output_len = strlen(output) + 1; - wrq_data->data.length = output_len; - if (copy_to_user(wrq_data->data.pointer, output, output_len)) { - err = -EFAULT; - goto exit; - } - } else { - /* if args to set */ - wrq_data->data.length = 0; - } - -exit: - kfree(input); - kfree(buffer); - kfree(output); - return err; -} - #include int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { @@ -8207,9 +3114,6 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ret = rtw_hostapd_ioctl(dev, &wrq->u.data); break; #endif /* CONFIG_88EU_AP_MODE */ - case SIOCDEVPRIVATE: - ret = rtw_ioctl_wext_private(dev, &wrq->u); - break; case (SIOCDEVPRIVATE+1): ret = rtw_android_priv_cmd(dev, rq, cmd); break; diff --git a/os_dep/mlme_linux.c b/os_dep/mlme_linux.c index 57d1ff7..1b892c4 100644 --- a/os_dep/mlme_linux.c +++ b/os_dep/mlme_linux.c @@ -25,48 +25,21 @@ #include #include -void rtw_join_timeout_handler (void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - - _rtw_join_timeout_handler(adapter); -} - - -void _rtw_scan_timeout_handler (void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - - rtw_scan_timeout_handler(adapter); -} - -static void _dynamic_check_timer_handlder(void *FunctionContext) -{ - struct adapter *adapter = (struct adapter *)FunctionContext; - - if (adapter->registrypriv.mp_mode == 1) - return; - rtw_dynamic_check_timer_handlder(adapter); - _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); -} - void rtw_init_mlme_timer(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, rtw_join_timeout_handler, padapter); - _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, _rtw_scan_timeout_handler, padapter); - _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter); + _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, _rtw_join_timeout_handler, padapter); + _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, rtw_scan_timeout_handler, padapter); + _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, rtw_dynamic_check_timer_handlder, padapter); } void rtw_os_indicate_connect(struct adapter *adapter) { -_func_enter_; rtw_indicate_wx_assoc_event(adapter); netif_carrier_on(adapter->pnetdev); if (adapter->pid[2] != 0) rtw_signal_process(adapter->pid[2], SIGALRM); -_func_exit_; } void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted) @@ -87,12 +60,12 @@ void rtw_reset_securitypriv(struct adapter *adapter) /* We have to backup the PMK information for WiFi PMK Caching test item. */ /* Backup the btkip_countermeasure information. */ /* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */ - _rtw_memset(&backup_pmkid[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + memset(&backup_pmkid[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); backup_index = adapter->securitypriv.PMKIDIndex; backup_counter = adapter->securitypriv.btkip_countermeasure; backup_time = adapter->securitypriv.btkip_countermeasure_time; - _rtw_memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv)); + memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv)); /* Restore the PMK information to securitypriv structure for the following connection. */ memcpy(&adapter->securitypriv.PMKIDList[0], @@ -119,11 +92,9 @@ void rtw_reset_securitypriv(struct adapter *adapter) void rtw_os_indicate_disconnect(struct adapter *adapter) { -_func_enter_; netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */ rtw_indicate_wx_disassoc_event(adapter); rtw_reset_securitypriv(adapter); -_func_exit_; } void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) @@ -132,7 +103,6 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) u8 *buff, *p, i; union iwreq_data wrqu; -_func_enter_; RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode=%d\n", authmode)); buff = NULL; @@ -141,8 +111,8 @@ _func_enter_; ("rtw_report_sec_ie, authmode=%d\n", authmode)); buff = rtw_malloc(IW_CUSTOM_MAX); if (!buff) - goto exit; - _rtw_memset(buff, 0, IW_CUSTOM_MAX); + return; + memset(buff, 0, IW_CUSTOM_MAX); p = buff; p += sprintf(p, "ASSOCINFO(ReqIEs ="); len = sec_ie[1]+2; @@ -150,47 +120,26 @@ _func_enter_; for (i = 0; i < len; i++) p += sprintf(p, "%02x", sec_ie[i]); p += sprintf(p, ")"); - _rtw_memset(&wrqu, 0, sizeof(wrqu)); + memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = p-buff; wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? wrqu.data.length : IW_CUSTOM_MAX; wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); kfree(buff); } -exit: -_func_exit_; -} - -static void _survey_timer_hdl(void *FunctionContext) -{ - struct adapter *padapter = (struct adapter *)FunctionContext; - - survey_timer_hdl(padapter); -} - -static void _link_timer_hdl(void *FunctionContext) -{ - struct adapter *padapter = (struct adapter *)FunctionContext; - link_timer_hdl(padapter); -} - -static void _addba_timer_hdl(void *FunctionContext) -{ - struct sta_info *psta = (struct sta_info *)FunctionContext; - addba_timer_hdl(psta); } void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) { - _init_timer(&psta->addba_retry_timer, padapter->pnetdev, _addba_timer_hdl, psta); + _init_timer(&psta->addba_retry_timer, padapter->pnetdev, addba_timer_hdl, psta); } void init_mlme_ext_timer(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, _survey_timer_hdl, padapter); - _init_timer(&pmlmeext->link_timer, padapter->pnetdev, _link_timer_hdl, padapter); + _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, survey_timer_hdl, padapter); + _init_timer(&pmlmeext->link_timer, padapter->pnetdev, link_timer_hdl, padapter); } #ifdef CONFIG_88EU_AP_MODE diff --git a/os_dep/os_intfs.c b/os_dep/os_intfs.c index 4e0b052..88a909c 100644 --- a/os_dep/os_intfs.c +++ b/os_dep/os_intfs.c @@ -19,26 +19,22 @@ ******************************************************************************/ #define _OS_INTFS_C_ -#include #include +#include #include #include #include #include #include -#include +#include -#include #include -#include -#include MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); MODULE_VERSION(DRIVERVERSION); -#define CONFIG_BR_EXT_BRNAME "br0" #define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ /* module param defaults */ @@ -71,8 +67,6 @@ static int rtw_short_retry_lmt = 7; static int rtw_busy_thresh = 40; static int rtw_ack_policy = NORMAL_ACK; -static int rtw_mp_mode; - static int rtw_software_encrypt; static int rtw_software_decrypt; @@ -86,9 +80,9 @@ static int rtw_uapsd_acbe_en; static int rtw_uapsd_acvi_en; static int rtw_uapsd_acvo_en; -int rtw_ht_enable = 1; -int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ -int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ +static int rtw_ht_enable = 1; +static int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ +static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ @@ -132,7 +126,6 @@ module_param(rtw_rfintfs, int, 0644); module_param(rtw_lbkmode, int, 0644); module_param(rtw_network_mode, int, 0644); module_param(rtw_channel, int, 0644); -module_param(rtw_mp_mode, int, 0644); module_param(rtw_wmm_enable, int, 0644); module_param(rtw_vrtl_carrier_sense, int, 0644); module_param(rtw_vcs_type, int, 0644); @@ -519,10 +512,8 @@ void rtw_proc_remove_one(struct net_device *dev) static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) { - uint status = _SUCCESS; struct registry_priv *registry_par = &padapter->registrypriv; -_func_enter_; GlobalDebugLevel = rtw_debug; registry_par->chip_version = (u8)rtw_chip_version; @@ -535,7 +526,7 @@ _func_enter_; registry_par->channel = (u8)rtw_channel; registry_par->wireless_mode = (u8)rtw_wireless_mode; - registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ; + registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense; registry_par->vcs_type = (u8)rtw_vcs_type; registry_par->rts_thresh = (u16)rtw_rts_thresh; registry_par->frag_thresh = (u16)rtw_frag_thresh; @@ -551,7 +542,7 @@ _func_enter_; registry_par->short_retry_lmt = (u8)rtw_short_retry_lmt; registry_par->busy_thresh = (u16)rtw_busy_thresh; registry_par->ack_policy = (u8)rtw_ack_policy; - registry_par->mp_mode = (u8)rtw_mp_mode; + registry_par->mp_mode = 0; registry_par->software_encrypt = (u8)rtw_software_encrypt; registry_par->software_decrypt = (u8)rtw_software_decrypt; registry_par->acm_method = (u8)rtw_acm_method; @@ -590,8 +581,7 @@ _func_enter_; snprintf(registry_par->ifname, 16, "%s", ifname); snprintf(registry_par->if2name, 16, "%s", if2name); registry_par->notch_filter = (u8)rtw_notch_filter; -_func_exit_; - return status; + return _SUCCESS; } static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) @@ -654,12 +644,8 @@ static unsigned int rtw_classify8021d(struct sk_buff *skb) return dscp >> 5; } -static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) - ,void *unused - ,select_queue_fallback_t fallback -#endif -) +static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, + void *accel_priv, select_queue_fallback_t fallback) { struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -714,27 +700,19 @@ int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname) return 0; } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,39) static const struct device_type wlan_type = { .name = "wlan", }; -#else -static struct device_type wlan_type = { - .name = "wlan", -}; -#endif struct net_device *rtw_init_netdev(struct adapter *old_padapter) { struct adapter *padapter; - struct net_device *pnetdev; + struct net_device *pnetdev = NULL; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); if (old_padapter != NULL) pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter); - else - pnetdev = rtw_alloc_etherdev(sizeof(struct adapter)); if (!pnetdev) return NULL; @@ -765,7 +743,6 @@ u32 rtw_start_drv_threads(struct adapter *padapter) else _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */ - rtw_hal_start_thread(padapter); return _status; } @@ -774,16 +751,14 @@ void rtw_stop_drv_threads(struct adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n")); /* Below is to termindate rtw_cmd_thread & event_thread... */ - _rtw_up_sema(&padapter->cmdpriv.cmd_queue_sema); + up(&padapter->cmdpriv.cmd_queue_sema); if (padapter->cmdThread) _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); - rtw_hal_stop_thread(padapter); } static u8 rtw_init_default_value(struct adapter *padapter) { - u8 ret = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -826,15 +801,11 @@ static u8 rtw_init_default_value(struct adapter *padapter) padapter->bWritePortCancel = false; padapter->bRxRSSIDisplay = 0; padapter->bNotifyChannelChange = 0; -#ifdef CONFIG_88EU_P2P - padapter->bShowGetP2PState = 1; -#endif - return ret; + return _SUCCESS; } u8 rtw_reset_drv_sw(struct adapter *padapter) { - u8 ret8 = _SUCCESS; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; @@ -851,8 +822,7 @@ u8 rtw_reset_drv_sw(struct adapter *padapter) pmlmepriv->LinkDetectInfo.bBusyTraffic = false; _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING); - - rtw_hal_sreset_reset_value(padapter); + rtw_hal_sreset_init(padapter); pwrctrlpriv->pwr_state_check_cnts = 0; /* mlmeextpriv */ @@ -860,14 +830,13 @@ u8 rtw_reset_drv_sw(struct adapter *padapter) rtw_set_signal_stat_timer(&padapter->recvpriv); - return ret8; + return _SUCCESS; } u8 rtw_init_drv_sw(struct adapter *padapter) { u8 ret8 = _SUCCESS; -_func_enter_; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n")); @@ -879,24 +848,12 @@ _func_enter_; padapter->cmdpriv.padapter = padapter; - if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n")); - ret8 = _FAIL; - goto exit; - } - if (rtw_init_mlme_priv(padapter) == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_priv\n")); ret8 = _FAIL; goto exit; } -#ifdef CONFIG_88EU_P2P - rtw_init_wifidirect_timers(padapter); - init_wifidirect_info(padapter, P2P_ROLE_DISABLE); - reset_global_wifidirect_info(padapter); -#endif /* CONFIG_88EU_P2P */ - if (init_mlme_ext_priv(padapter) == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_ext_priv\n")); ret8 = _FAIL; @@ -927,9 +884,6 @@ _func_enter_; rtw_init_pwrctrl_priv(padapter); - if (init_mp_priv(padapter) == _FAIL) - DBG_88E("%s: initialize MP private data Fail!\n", __func__); - ret8 = rtw_init_default_value(padapter); rtw_hal_dm_init(padapter); @@ -937,12 +891,11 @@ _func_enter_; rtw_hal_sreset_init(padapter); - _rtw_spinlock_init(&padapter->br_ext_lock); + spin_lock_init(&padapter->br_ext_lock); exit: RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n")); - _func_exit_; return ret8; } @@ -951,54 +904,30 @@ void rtw_cancel_all_timer(struct adapter *padapter) { RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_cancel_all_timer\n")); - _cancel_timer_ex(&padapter->mlmepriv.assoc_timer); + del_timer_sync(&padapter->mlmepriv.assoc_timer); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel association timer complete!\n")); - _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer); + del_timer_sync(&padapter->mlmepriv.scan_to_timer); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel scan_to_timer!\n")); - _cancel_timer_ex(&padapter->mlmepriv.dynamic_chk_timer); + del_timer_sync(&padapter->mlmepriv.dynamic_chk_timer); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel dynamic_chk_timer!\n")); /* cancel sw led timer */ rtw_hal_sw_led_deinit(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel DeInitSwLeds!\n")); - _cancel_timer_ex(&padapter->pwrctrlpriv.pwr_state_check_timer); + del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer); - _cancel_timer_ex(&padapter->recvpriv.signal_stat_timer); - /* cancel dm timer */ - rtw_hal_dm_deinit(padapter); + del_timer_sync(&padapter->recvpriv.signal_stat_timer); } u8 rtw_free_drv_sw(struct adapter *padapter) { RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw")); - /* we can call rtw_p2p_enable here, but: */ - /* 1. rtw_p2p_enable may have IO operation */ - /* 2. rtw_p2p_enable is bundled with wext interface */ - #ifdef CONFIG_88EU_P2P - { - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - _cancel_timer_ex(&pwdinfo->find_phase_timer); - _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); - _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); - rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); - } - } - #endif - - - _rtw_spinlock_free(&padapter->br_ext_lock); - free_mlme_ext_priv(&padapter->mlmeextpriv); - rtw_free_cmd_priv(&padapter->cmdpriv); - - rtw_free_evt_priv(&padapter->evtpriv); - rtw_free_mlme_priv(&padapter->mlmepriv); _rtw_free_xmit_priv(&padapter->xmitpriv); @@ -1006,8 +935,6 @@ u8 rtw_free_drv_sw(struct adapter *padapter) _rtw_free_recv_priv(&padapter->recvpriv); - rtw_free_pwrctrl_priv(padapter); - rtw_hal_free_data(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw\n")); @@ -1018,44 +945,13 @@ u8 rtw_free_drv_sw(struct adapter *padapter) padapter->rereg_nd_name_priv.old_pnetdev = NULL; } - /* clear pbuddystruct adapter to avoid access wrong pointer. */ - if (padapter->pbuddy_adapter != NULL) - padapter->pbuddy_adapter->pbuddy_adapter = NULL; + mutex_destroy(&padapter->hw_init_mutex); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n")); return _SUCCESS; } -void netdev_br_init(struct net_device *netdev) -{ - struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); - - rcu_read_lock(); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) - if (rcu_dereference(adapter->pnetdev->rx_handler_data)) { -#else - if (rcu_dereference(adapter->pnetdev->br_port)) { -#endif - struct net_device *br_netdev; - struct net *devnet = NULL; - - devnet = dev_net(netdev); - br_netdev = dev_get_by_name(devnet, CONFIG_BR_EXT_BRNAME); - if (br_netdev) { - memcpy(adapter->br_mac, br_netdev->dev_addr, ETH_ALEN); - dev_put(br_netdev); - } else { - pr_info("%s()-%d: dev_get_by_name(%s) failed!", - __func__, __LINE__, CONFIG_BR_EXT_BRNAME); - } - } - adapter->ethBrExtInfo.addPPPoETag = 1; - - rcu_read_unlock(); -} - int _netdev_open(struct net_device *pnetdev) { uint status; @@ -1073,7 +969,6 @@ int _netdev_open(struct net_device *pnetdev) if (!padapter->bup) { padapter->bDriverStopped = false; padapter->bSurpriseRemoved = false; - padapter->bCardDisableWOHSM = false; status = rtw_hal_init(padapter); if (status == _FAIL) { @@ -1109,11 +1004,9 @@ int _netdev_open(struct net_device *pnetdev) rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); if (!rtw_netif_queue_stopped(pnetdev)) - rtw_netif_start_queue(pnetdev); + netif_tx_start_all_queues(pnetdev); else - rtw_netif_wake_queue(pnetdev); - - netdev_br_init(pnetdev); + netif_tx_wake_all_queues(pnetdev); netdev_open_normal_process: RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - dev_open\n")); @@ -1123,7 +1016,7 @@ netdev_open_normal_process: netdev_open_error: padapter->bup = false; netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); + netif_tx_stop_all_queues(pnetdev); RT_TRACE(_module_os_intfs_c_, _drv_err_, ("-88eu_drv - dev_open, fail!\n")); DBG_88E("-88eu_drv - drv_open fail, bup =%d\n", padapter->bup); return -1; @@ -1134,9 +1027,9 @@ int netdev_open(struct net_device *pnetdev) int ret; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); - _enter_critical_mutex(padapter->hw_init_mutex, NULL); + _enter_critical_mutex(&padapter->hw_init_mutex, NULL); ret = _netdev_open(pnetdev); - _exit_critical_mutex(padapter->hw_init_mutex, NULL); + mutex_unlock(&padapter->hw_init_mutex); return ret; } @@ -1148,7 +1041,6 @@ static int ips_netdrv_open(struct adapter *padapter) padapter->bDriverStopped = false; padapter->bSurpriseRemoved = false; - padapter->bCardDisableWOHSM = false; status = rtw_hal_init(padapter); if (status == _FAIL) { @@ -1174,7 +1066,7 @@ netdev_open_error: int rtw_ips_pwr_up(struct adapter *padapter) { int result; - u32 start_time = rtw_get_current_time(); + u32 start_time = jiffies; DBG_88E("===> rtw_ips_pwr_up..............\n"); rtw_reset_drv_sw(padapter); @@ -1188,16 +1080,14 @@ int rtw_ips_pwr_up(struct adapter *padapter) void rtw_ips_pwr_down(struct adapter *padapter) { - u32 start_time = rtw_get_current_time(); + u32 start_time = jiffies; DBG_88E("===> rtw_ips_pwr_down...................\n"); - padapter->bCardDisableWOHSM = true; padapter->net_closed = true; rtw_led_control(padapter, LED_CTL_POWER_OFF); rtw_ips_dev_unload(padapter); - padapter->bCardDisableWOHSM = false; DBG_88E("<=== rtw_ips_pwr_down..................... in %dms\n", rtw_get_passing_time_ms(start_time)); } @@ -1229,7 +1119,7 @@ int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) int netdev_close(struct net_device *pnetdev) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); - struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); + struct hal_data_8188e *rtlhal = GET_HAL_DATA(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n")); @@ -1246,7 +1136,7 @@ int netdev_close(struct net_device *pnetdev) /* s1. */ if (pnetdev) { if (!rtw_netif_queue_stopped(pnetdev)) - rtw_netif_stop_queue(pnetdev); + netif_tx_stop_all_queues(pnetdev); } /* s2. */ @@ -1262,14 +1152,8 @@ int netdev_close(struct net_device *pnetdev) rtw_led_control(padapter, LED_CTL_POWER_OFF); } - nat25_db_cleanup(padapter); - -#ifdef CONFIG_88EU_P2P - rtw_p2p_enable(padapter, P2P_ROLE_DISABLE); -#endif /* CONFIG_88EU_P2P */ - - kfree(dvobj->firmware.szFwBuffer); - dvobj->firmware.szFwBuffer = NULL; + kfree(rtlhal->pfirmware); + rtlhal->pfirmware = NULL; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n")); DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup); diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index a319df6..abcb3a8 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -22,6 +22,7 @@ #define _OSDEP_SERVICE_C_ #include +#include #include #include #include @@ -38,44 +39,6 @@ inline int RTW_STATUS_CODE(int error_code) return _FAIL; } -u32 rtw_atoi(u8 *s) -{ - int num = 0, flag = 0; - int i; - for (i = 0; i <= strlen(s); i++) { - if (s[i] >= '0' && s[i] <= '9') - num = num * 10 + s[i] - '0'; - else if (s[0] == '-' && i == 0) - flag = 1; - else - break; - } - if (flag == 1) - num = num * -1; - return num; -} - -inline u8 *_rtw_vmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = vmalloc(sz); - return pbuf; -} - -inline u8 *_rtw_zvmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = _rtw_vmalloc(sz); - if (pbuf != NULL) - memset(pbuf, 0, sz); - return pbuf; -} - -inline void _rtw_vmfree(u8 *pbuf, u32 sz) -{ - vfree(pbuf); -} - u8 *_rtw_malloc(u32 sz) { u8 *pbuf = NULL; @@ -84,20 +47,11 @@ u8 *_rtw_malloc(u32 sz) return pbuf; } -u8 *_rtw_zmalloc(u32 sz) -{ - u8 *pbuf = _rtw_malloc(sz); - - if (pbuf != NULL) - memset(pbuf, 0, sz); - return pbuf; -} - void *rtw_malloc2d(int h, int w, int size) { int j; - void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size); + void **a = kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL); if (a == NULL) { pr_info("%s: alloc memory fail!\n", __func__); return NULL; @@ -109,72 +63,6 @@ void *rtw_malloc2d(int h, int w, int size) return a; } -void rtw_mfree2d(void *pbuf, int h, int w, int size) -{ - kfree(pbuf); -} - -int _rtw_memcmp(void *dst, void *src, u32 sz) -{ -/* under Linux/GNU/GLibc, the return value of memcmp for two same - * mem. chunk is 0 */ - if (!(memcmp(dst, src, sz))) - return true; - else - return false; -} - -void _rtw_memset(void *pbuf, int c, u32 sz) -{ - memset(pbuf, c, sz); -} - -void _rtw_init_listhead(struct list_head *list) -{ - INIT_LIST_HEAD(list); -} - -/* -For the following list_xxx operations, -caller must guarantee the atomic context. -Otherwise, there will be racing condition. -*/ -u32 rtw_is_list_empty(struct list_head *phead) -{ - if (list_empty(phead)) - return true; - else - return false; -} - -void rtw_list_insert_head(struct list_head *plist, struct list_head *phead) -{ - list_add(plist, phead); -} - -void rtw_list_insert_tail(struct list_head *plist, struct list_head *phead) -{ - list_add_tail(plist, phead); -} - -/* -Caller must check if the list is empty before calling rtw_list_delete -*/ - -void _rtw_init_sema(struct semaphore *sema, int init_val) -{ - sema_init(sema, init_val); -} - -void _rtw_free_sema(struct semaphore *sema) -{ -} - -void _rtw_up_sema(struct semaphore *sema) -{ - up(sema); -} - u32 _rtw_down_sema(struct semaphore *sema) { if (down_interruptible(sema)) @@ -183,183 +71,18 @@ u32 _rtw_down_sema(struct semaphore *sema) return _SUCCESS; } -void _rtw_mutex_init(struct mutex *pmutex) -{ - mutex_init(pmutex); -} - -void _rtw_mutex_free(struct mutex *pmutex) -{ - mutex_destroy(pmutex); -} - -void _rtw_spinlock_init(spinlock_t *plock) -{ - spin_lock_init(plock); -} - -void _rtw_spinlock_free(spinlock_t *plock) -{ -} - void _rtw_init_queue(struct __queue *pqueue) { - _rtw_init_listhead(&(pqueue->queue)); - _rtw_spinlock_init(&(pqueue->lock)); + INIT_LIST_HEAD(&(pqueue->queue)); + spin_lock_init(&(pqueue->lock)); } -u32 _rtw_queue_empty(struct __queue *pqueue) -{ - return rtw_is_list_empty(&(pqueue->queue)); -} - -u32 rtw_end_of_queue_search(struct list_head *head, struct list_head *plist) -{ - if (head == plist) - return true; - else - return false; -} - -u32 rtw_get_current_time(void) -{ - return jiffies; -} - -inline u32 rtw_systime_to_ms(u32 systime) -{ - return systime * 1000 / HZ; -} - -inline u32 rtw_ms_to_systime(u32 ms) -{ - return ms * HZ / 1000; -} - -/* the input parameter start use the same unit as returned by - * rtw_get_current_time */ +/* the input parameter start must be in jiffies */ inline s32 rtw_get_passing_time_ms(u32 start) { - return rtw_systime_to_ms(jiffies-start); + return jiffies_to_msecs(jiffies-start); } -inline s32 rtw_get_time_interval_ms(u32 start, u32 end) -{ - return rtw_systime_to_ms(end-start); -} - -void rtw_sleep_schedulable(int ms) -{ - u32 delta; - - delta = (ms * HZ)/1000;/* ms) */ - if (delta == 0) - delta = 1;/* 1 ms */ - set_current_state(TASK_INTERRUPTIBLE); - if (schedule_timeout(delta) != 0) - return; -} - -void rtw_msleep_os(int ms) -{ - msleep((unsigned int)ms); -} - -void rtw_usleep_os(int us) -{ - if (1 < (us/1000)) - msleep(1); - else - msleep((us/1000) + 1); -} - -void rtw_mdelay_os(int ms) -{ - mdelay((unsigned long)ms); -} - -void rtw_udelay_os(int us) -{ - udelay((unsigned long)us); -} - -void rtw_yield_os(void) -{ - yield(); -} - -#define RTW_SUSPEND_LOCK_NAME "rtw_wifi" - -inline void rtw_suspend_lock_init(void) -{ -} - -inline void rtw_suspend_lock_uninit(void) -{ -} - -inline void rtw_lock_suspend(void) -{ -} - -inline void rtw_unlock_suspend(void) -{ -} - -inline void ATOMIC_SET(ATOMIC_T *v, int i) -{ - atomic_set(v, i); -} - -inline int ATOMIC_READ(ATOMIC_T *v) -{ - return atomic_read(v); -} - -inline void ATOMIC_ADD(ATOMIC_T *v, int i) -{ - atomic_add(i, v); -} - -inline void ATOMIC_SUB(ATOMIC_T *v, int i) -{ - atomic_sub(i, v); -} - -inline void ATOMIC_INC(ATOMIC_T *v) -{ - atomic_inc(v); -} - -inline void ATOMIC_DEC(ATOMIC_T *v) -{ - atomic_dec(v); -} - -inline int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i) -{ - return atomic_add_return(i, v); -} - -inline int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i) -{ - return atomic_sub_return(i, v); -} - -inline int ATOMIC_INC_RETURN(ATOMIC_T *v) -{ - return atomic_inc_return(v); -} - -inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) -{ - return atomic_dec_return(v); -} - -static const struct device_type wlan_type = { - .name = "wlan", -}; - struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv) { @@ -370,7 +93,6 @@ struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, if (!pnetdev) goto RETURN; - pnetdev->dev.type = &wlan_type; pnpi = netdev_priv(pnetdev); pnpi->priv = old_priv; pnpi->sizeof_priv = sizeof_priv; @@ -379,29 +101,6 @@ RETURN: return pnetdev; } -struct net_device *rtw_alloc_etherdev(int sizeof_priv) -{ - struct net_device *pnetdev; - struct rtw_netdev_priv_indicator *pnpi; - - pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); - if (!pnetdev) - goto RETURN; - - pnpi = netdev_priv(pnetdev); - - pnpi->priv = rtw_zvmalloc(sizeof_priv); - if (!pnpi->priv) { - free_netdev(pnetdev); - pnetdev = NULL; - goto RETURN; - } - - pnpi->sizeof_priv = sizeof_priv; -RETURN: - return pnetdev; -} - void rtw_free_netdev(struct net_device *netdev) { struct rtw_netdev_priv_indicator *pnpi; @@ -414,79 +113,18 @@ void rtw_free_netdev(struct net_device *netdev) if (!pnpi->priv) goto RETURN; - rtw_vmfree(pnpi->priv, pnpi->sizeof_priv); + vfree(pnpi->priv); free_netdev(netdev); RETURN: return; } -int rtw_change_ifname(struct adapter *padapter, const char *ifname) -{ - struct net_device *pnetdev; - struct net_device *cur_pnetdev; - struct rereg_nd_name_data *rereg_priv; - int ret; - - if (!padapter) - goto error; - - cur_pnetdev = padapter->pnetdev; - rereg_priv = &padapter->rereg_nd_name_priv; - - /* free the old_pnetdev */ - if (rereg_priv->old_pnetdev) { - free_netdev(rereg_priv->old_pnetdev); - rereg_priv->old_pnetdev = NULL; - } - - if (!rtnl_is_locked()) - unregister_netdev(cur_pnetdev); - else - unregister_netdevice(cur_pnetdev); - - rtw_proc_remove_one(cur_pnetdev); - - rereg_priv->old_pnetdev = cur_pnetdev; - - pnetdev = rtw_init_netdev(padapter); - if (!pnetdev) { - ret = -1; - goto error; - } - - SET_NETDEV_DEV(pnetdev, dvobj_to_dev(adapter_to_dvobj(padapter))); - - rtw_init_netdev_name(pnetdev, ifname); - - memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - - if (!rtnl_is_locked()) - ret = register_netdev(pnetdev); - else - ret = register_netdevice(pnetdev); - if (ret != 0) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, - ("register_netdev() failed\n")); - goto error; - } - rtw_proc_init_one(pnetdev); - return 0; -error: - return -1; -} - u64 rtw_modular64(u64 x, u64 y) { return do_div(x, y); } -u64 rtw_division64(u64 x, u64 y) -{ - do_div(x, y); - return x; -} - void rtw_buf_free(u8 **buf, u32 *buf_len) { *buf_len = 0; @@ -525,89 +163,3 @@ keep_ori: /* free ori */ kfree(ori); } - - -/** - * rtw_cbuf_full - test if cbuf is full - * @cbuf: pointer of struct rtw_cbuf - * - * Returns: true if cbuf is full - */ -inline bool rtw_cbuf_full(struct rtw_cbuf *cbuf) -{ - return (cbuf->write == cbuf->read-1) ? true : false; -} - -/** - * rtw_cbuf_empty - test if cbuf is empty - * @cbuf: pointer of struct rtw_cbuf - * - * Returns: true if cbuf is empty - */ -inline bool rtw_cbuf_empty(struct rtw_cbuf *cbuf) -{ - return (cbuf->write == cbuf->read) ? true : false; -} - -/** - * rtw_cbuf_push - push a pointer into cbuf - * @cbuf: pointer of struct rtw_cbuf - * @buf: pointer to push in - * - * Lock free operation, be careful of the use scheme - * Returns: true push success - */ -bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf) -{ - if (rtw_cbuf_full(cbuf)) - return _FAIL; - - if (0) - DBG_88E("%s on %u\n", __func__, cbuf->write); - cbuf->bufs[cbuf->write] = buf; - cbuf->write = (cbuf->write+1)%cbuf->size; - - return _SUCCESS; -} - -/** - * rtw_cbuf_pop - pop a pointer from cbuf - * @cbuf: pointer of struct rtw_cbuf - * - * Lock free operation, be careful of the use scheme - * Returns: pointer popped out - */ -void *rtw_cbuf_pop(struct rtw_cbuf *cbuf) -{ - void *buf; - if (rtw_cbuf_empty(cbuf)) - return NULL; - - if (0) - DBG_88E("%s on %u\n", __func__, cbuf->read); - buf = cbuf->bufs[cbuf->read]; - cbuf->read = (cbuf->read+1)%cbuf->size; - - return buf; -} - -/** - * rtw_cbuf_alloc - allocate a rtw_cbuf with given size and do initialization - * @size: size of pointer - * - * Returns: pointer of srtuct rtw_cbuf, NULL for allocation failure - */ -struct rtw_cbuf *rtw_cbuf_alloc(u32 size) -{ - struct rtw_cbuf *cbuf; - - cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + - sizeof(void *)*size); - - if (cbuf) { - cbuf->write = 0; - cbuf->read = 0; - cbuf->size = size; - } - return cbuf; -} diff --git a/os_dep/recv_linux.c b/os_dep/recv_linux.c index e8ad0b0..05427c4 100644 --- a/os_dep/recv_linux.c +++ b/os_dep/recv_linux.c @@ -26,61 +26,31 @@ #include #include -#include -#include +#include -/* init os related resource in struct recv_priv */ -int rtw_os_recv_resource_init(struct recv_priv *precvpriv, - struct adapter *padapter) -{ - return _SUCCESS; -} - -/* alloc os related resource in union recv_frame */ +/* alloc os related resource in struct recv_frame */ int rtw_os_recv_resource_alloc(struct adapter *padapter, - union recv_frame *precvframe) + struct recv_frame *precvframe) { - precvframe->u.hdr.pkt_newalloc = NULL; - precvframe->u.hdr.pkt = NULL; + precvframe->pkt_newalloc = NULL; + precvframe->pkt = NULL; return _SUCCESS; } -/* free os related resource in union recv_frame */ -void rtw_os_recv_resource_free(struct recv_priv *precvpriv) -{ -} - /* alloc os related resource in struct recv_buf */ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, struct recv_buf *precvbuf) { int res = _SUCCESS; - precvbuf->irp_pending = false; precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); if (precvbuf->purb == NULL) res = _FAIL; precvbuf->pskb = NULL; precvbuf->reuse = false; - precvbuf->pallocated_buf = NULL; - precvbuf->pbuf = NULL; - precvbuf->pdata = NULL; - precvbuf->phead = NULL; - precvbuf->ptail = NULL; - precvbuf->pend = NULL; - precvbuf->transfer_len = 0; - precvbuf->len = 0; return res; } -/* free os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_free(struct adapter *padapter, - struct recv_buf *precvbuf) -{ - usb_free_urb(precvbuf->purb); - return _SUCCESS; -} - void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) { union iwreq_data wrqu; @@ -90,20 +60,20 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) u32 cur_time = 0; if (psecuritypriv->last_mic_err_time == 0) { - psecuritypriv->last_mic_err_time = rtw_get_current_time(); + psecuritypriv->last_mic_err_time = jiffies; } else { - cur_time = rtw_get_current_time(); + cur_time = jiffies; if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) { psecuritypriv->btkip_countermeasure = true; psecuritypriv->last_mic_err_time = 0; psecuritypriv->btkip_countermeasure_time = cur_time; } else { - psecuritypriv->last_mic_err_time = rtw_get_current_time(); + psecuritypriv->last_mic_err_time = jiffies; } } - _rtw_memset(&ev, 0x00, sizeof(ev)); + memset(&ev, 0x00, sizeof(ev)); if (bgroup) ev.flags |= IW_MICFAILURE_GROUP; else @@ -111,31 +81,25 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) ev.src_addr.sa_family = ARPHRD_ETHER; memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN); - _rtw_memset(&wrqu, 0x00, sizeof(wrqu)); + memset(&wrqu, 0x00, sizeof(wrqu)); wrqu.data.length = sizeof(ev); wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); } -void rtw_hostapd_mlme_rx(struct adapter *padapter, - union recv_frame *precv_frame) -{ -} - int rtw_recv_indicatepkt(struct adapter *padapter, - union recv_frame *precv_frame) + struct recv_frame *precv_frame) { struct recv_priv *precvpriv; struct __queue *pfree_recv_queue; struct sk_buff *skb; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -_func_enter_; precvpriv = &(padapter->recvpriv); pfree_recv_queue = &(precvpriv->free_recv_queue); - skb = precv_frame->u.hdr.pkt; + skb = precv_frame->pkt; if (skb == NULL) { RT_TRACE(_module_recv_osdep_c_, _drv_err_, ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); @@ -145,18 +109,18 @@ _func_enter_; RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("rtw_recv_indicatepkt():skb != NULL !!!\n")); RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("rtw_recv_indicatepkt():precv_frame->u.hdr.rx_head =%p precv_frame->hdr.rx_data =%p\n", - precv_frame->u.hdr.rx_head, precv_frame->u.hdr.rx_data)); + ("rtw_recv_indicatepkt():precv_frame->rx_head =%p precv_frame->hdr.rx_data =%p\n", + precv_frame->rx_head, precv_frame->rx_data)); RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("precv_frame->hdr.rx_tail =%p precv_frame->u.hdr.rx_end =%p precv_frame->hdr.len =%d\n", - precv_frame->u.hdr.rx_tail, precv_frame->u.hdr.rx_end, - precv_frame->u.hdr.len)); + ("precv_frame->hdr.rx_tail =%p precv_frame->rx_end =%p precv_frame->hdr.len =%d\n", + precv_frame->rx_tail, precv_frame->rx_end, + precv_frame->len)); - skb->data = precv_frame->u.hdr.rx_data; + skb->data = precv_frame->rx_data; - skb_set_tail_pointer(skb, precv_frame->u.hdr.len); + skb_set_tail_pointer(skb, precv_frame->len); - skb->len = precv_frame->u.hdr.len; + skb->len = precv_frame->len; RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", @@ -167,11 +131,11 @@ _func_enter_; struct sk_buff *pskb2 = NULL; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; int bmcast = IS_MCAST(pattrib->dst); - if (!_rtw_memcmp(pattrib->dst, myid(&padapter->eeprompriv), - ETH_ALEN)) { + if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), + ETH_ALEN)) { if (bmcast) { psta = rtw_get_bcmc_stainfo(padapter); pskb2 = skb_clone(skb, GFP_ATOMIC); @@ -197,11 +161,7 @@ _func_enter_; } rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) rcu_dereference(padapter->pnetdev->rx_handler_data); -#else - rcu_dereference(padapter->pnetdev->br_port); -#endif rcu_read_unlock(); skb->ip_summed = CHECKSUM_NONE; @@ -213,51 +173,27 @@ _func_enter_; _recv_indicatepkt_end: /* pointers to NULL before rtw_free_recvframe() */ - precv_frame->u.hdr.pkt = NULL; + precv_frame->pkt = NULL; rtw_free_recvframe(precv_frame, pfree_recv_queue); RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt :after netif_rx!!!!\n")); -_func_exit_; return _SUCCESS; _recv_indicatepkt_drop: /* enqueue back to free_recv_queue */ - rtw_free_recvframe(precv_frame, pfree_recv_queue); + rtw_free_recvframe(precv_frame, pfree_recv_queue); -_func_exit_; return _FAIL; } -void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf) -{ - struct recv_priv *precvpriv = &padapter->recvpriv; - - precvbuf->ref_cnt--; - /* free skb in recv_buf */ - dev_kfree_skb_any(precvbuf->pskb); - precvbuf->pskb = NULL; - precvbuf->reuse = false; - if (!precvbuf->irp_pending) - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, - (unsigned char *)precvbuf); -} - -static void _rtw_reordering_ctrl_timeout_handler(void *func_context) -{ - struct recv_reorder_ctrl *preorder_ctrl; - - preorder_ctrl = (struct recv_reorder_ctrl *)func_context; - rtw_reordering_ctrl_timeout_handler(preorder_ctrl); -} - void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) { struct adapter *padapter = preorder_ctrl->padapter; - _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, _rtw_reordering_ctrl_timeout_handler, preorder_ctrl); + _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, rtw_reordering_ctrl_timeout_handler, preorder_ctrl); } diff --git a/os_dep/rtw_android.c b/os_dep/rtw_android.c index 6cf71cc..99ce077 100644 --- a/os_dep/rtw_android.c +++ b/os_dep/rtw_android.c @@ -24,7 +24,6 @@ #include #include #include -#include #include static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { @@ -80,7 +79,7 @@ int rtw_android_cmdstr_to_num(char *cmdstr) { int cmd_num; for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) - if (0 == strnicmp(cmdstr , android_wifi_cmd_str[cmd_num], + if (0 == strncasecmp(cmdstr , android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num]))) break; return cmd_num; @@ -107,23 +106,18 @@ static int rtw_android_get_link_speed(struct net_device *net, char *command, int total_len) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); - int bytes_written; u16 link_speed; link_speed = rtw_get_cur_max_rate(padapter) / 10; - bytes_written = snprintf(command, total_len, "LinkSpeed %d", + return snprintf(command, total_len, "LinkSpeed %d", link_speed); - return bytes_written; } static int rtw_android_get_macaddr(struct net_device *net, char *command, int total_len) { - int bytes_written; - - bytes_written = snprintf(command, total_len, "Macaddr = %pM", + return snprintf(command, total_len, "Macaddr = %pM", net->dev_addr); - return bytes_written; } static int android_set_cntry(struct net_device *net, char *command, @@ -154,37 +148,21 @@ static int rtw_android_set_block(struct net_device *net, char *command, int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) { int ret = 0; - char *command = NULL; + char *command; int cmd_num; int bytes_written = 0; struct android_wifi_priv_cmd priv_cmd; - rtw_lock_suspend(); - if (!ifr->ifr_data) { - ret = -EINVAL; - goto exit; - } - if (copy_from_user(&priv_cmd, ifr->ifr_data, - sizeof(struct android_wifi_priv_cmd))) { - ret = -EFAULT; - goto exit; - } - command = kmalloc(priv_cmd.total_len, GFP_KERNEL); - if (!command) { - DBG_88E("%s: failed to allocate memory\n", __func__); - ret = -ENOMEM; - goto exit; - } - if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) { - DBG_88E("%s: failed to access memory\n", __func__); - ret = -EFAULT; - goto exit; - } - if (copy_from_user(command, (char __user *)priv_cmd.buf, - priv_cmd.total_len)) { - ret = -EFAULT; - goto exit; - } + if (!ifr->ifr_data) + return -EINVAL; + if (copy_from_user(&priv_cmd, ifr->ifr_data, sizeof(priv_cmd))) + return -EFAULT; + if (priv_cmd.total_len < 1) + return -EINVAL; + command = memdup_user(priv_cmd.buf, priv_cmd.total_len); + if (IS_ERR(command)) + return PTR_ERR(command); + command[priv_cmd.total_len - 1] = 0; DBG_88E("%s: Android private cmd \"%s\" on %s\n", __func__, command, ifr->ifr_name); cmd_num = rtw_android_cmdstr_to_num(command); @@ -198,7 +176,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n", __func__, command, ifr->ifr_name); ret = 0; - goto exit; + goto free; } switch (cmd_num) { case ANDROID_WIFI_CMD_STOP: @@ -286,8 +264,7 @@ response: } else { ret = bytes_written; } -exit: - rtw_unlock_suspend(); +free: kfree(command); return ret; } diff --git a/os_dep/usb_intf.c b/os_dep/usb_intf.c index 0811b56..65a257f 100644 --- a/os_dep/usb_intf.c +++ b/os_dep/usb_intf.c @@ -24,26 +24,16 @@ #include #include #include -#include #include +#include #include -#include -#include -#include +#include #include #include int ui_pid[3] = {0, 0, 0}; -static int rtw_suspend(struct usb_interface *intf, pm_message_t message); -static int rtw_resume(struct usb_interface *intf); - - -static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid); -static void rtw_dev_remove(struct usb_interface *pusb_intf); - - #define USB_VENDER_ID_REALTEK 0x0bda /* DID_USB_v916_20130116 */ @@ -53,105 +43,16 @@ static struct usb_device_id rtw_usb_id_tbl[] = { {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */ /*=== Customer ID ===*/ /****** 8188EUS ********/ - {USB_DEVICE(0x07B8, 0x8179)}, /* Abocom - Abocom */ - {USB_DEVICE(0x0DF6, 0x0076)}, /* Sitecom N150 v2 */ + {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */ + {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ - {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ - {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ - {USB_DEVICE(0x056E, 0x4008)}, /* Elecom WDC-150SU2M */ + {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ + {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ {} /* Terminating entry */ }; MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl); -static struct specific_device_id specific_device_id_tbl[] = { - {} /* empty table for now */ -}; - -struct rtw_usb_drv { - struct usb_driver usbdrv; - int drv_registered; - struct mutex hw_init_mutex; -}; - -static struct rtw_usb_drv rtl8188e_usb_drv = { - .usbdrv.name = (char *)"r8188eu", - .usbdrv.probe = rtw_drv_init, - .usbdrv.disconnect = rtw_dev_remove, - .usbdrv.id_table = rtw_usb_id_tbl, - .usbdrv.suspend = rtw_suspend, - .usbdrv.resume = rtw_resume, - .usbdrv.reset_resume = rtw_resume, -}; - -static struct rtw_usb_drv *usb_drv = &rtl8188e_usb_drv; - -static inline int RT_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN; -} - -static inline int RT_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT; -} - -static inline int RT_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT; -} - -static inline int RT_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK; -} - -static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) -{ - return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_in(epd); -} - -static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) -{ - return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_out(epd); -} - -static inline int usb_endpoint_is_int(const struct usb_endpoint_descriptor *epd) -{ - return RT_usb_endpoint_xfer_int(epd) && RT_usb_endpoint_dir_in(epd); -} - -static inline int RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) -{ - return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; -} - -static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) -{ - u8 rst = _SUCCESS; - - _rtw_mutex_init(&dvobj->usb_vendor_req_mutex); - - dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE); - if (dvobj->usb_alloc_vendor_req_buf == NULL) { - DBG_88E("alloc usb_vendor_req_buf failed... /n"); - rst = _FAIL; - goto exit; - } - dvobj->usb_vendor_req_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(dvobj->usb_alloc_vendor_req_buf), ALIGNMENT_UNIT); -exit: - return rst; -} - -static u8 rtw_deinit_intf_priv(struct dvobj_priv *dvobj) -{ - u8 rst = _SUCCESS; - - kfree(dvobj->usb_alloc_vendor_req_buf); - _rtw_mutex_free(&dvobj->usb_vendor_req_mutex); - return rst; -} - static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) { int i; @@ -165,9 +66,8 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; -_func_enter_; - pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv)); + pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL); if (pdvobjpriv == NULL) goto exit; @@ -190,62 +90,37 @@ _func_enter_; pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { + int ep_num; phost_endp = phost_iface->endpoint + i; + if (phost_endp) { pendp_desc = &phost_endp->desc; + ep_num = usb_endpoint_num(pendp_desc); - DBG_88E("\nusb_endpoint_descriptor(%d):\n", i); - DBG_88E("bLength=%x\n", pendp_desc->bLength); - DBG_88E("bDescriptorType=%x\n", - pendp_desc->bDescriptorType); - DBG_88E("bEndpointAddress=%x\n", - pendp_desc->bEndpointAddress); - DBG_88E("wMaxPacketSize=%d\n", - le16_to_cpu(pendp_desc->wMaxPacketSize)); - DBG_88E("bInterval=%x\n", pendp_desc->bInterval); - - if (RT_usb_endpoint_is_bulk_in(pendp_desc)) { - DBG_88E("RT_usb_endpoint_is_bulk_in = %x\n", - RT_usb_endpoint_num(pendp_desc)); - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); + if (usb_endpoint_is_bulk_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_int(pendp_desc)) { - DBG_88E("usb_endpoint_is_int = %x, Interval = %x\n", - RT_usb_endpoint_num(pendp_desc), - pendp_desc->bInterval); - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); + } else if (usb_endpoint_is_int_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; - } else if (RT_usb_endpoint_is_bulk_out(pendp_desc)) { - DBG_88E("RT_usb_endpoint_is_bulk_out = %x\n", - RT_usb_endpoint_num(pendp_desc)); - pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = RT_usb_endpoint_num(pendp_desc); + } else if (usb_endpoint_is_bulk_out(pendp_desc)) { + pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num; pdvobjpriv->RtNumOutPipes++; } - pdvobjpriv->ep_num[i] = RT_usb_endpoint_num(pendp_desc); + pdvobjpriv->ep_num[i] = ep_num; } } - DBG_88E("nr_endpoint=%d, in_num=%d, out_num=%d\n\n", - pdvobjpriv->nr_endpoint, pdvobjpriv->RtNumInPipes, - pdvobjpriv->RtNumOutPipes); - - if (pusbd->speed == USB_SPEED_HIGH) { + if (pusbd->speed == USB_SPEED_HIGH) pdvobjpriv->ishighspeed = true; - DBG_88E("USB_SPEED_HIGH\n"); - } else { + else pdvobjpriv->ishighspeed = false; - DBG_88E("NON USB_SPEED_HIGH\n"); - } - if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, - ("\n Can't INIT rtw_init_intf_priv\n")); + mutex_init(&pdvobjpriv->usb_vendor_req_mutex); + pdvobjpriv->usb_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL); + + if (!pdvobjpriv->usb_vendor_req_buf) goto free_dvobj; - } - - /* 3 misc */ - _rtw_init_sema(&(pdvobjpriv->usb_suspend_sema), 0); - rtw_reset_continual_urb_error(pdvobjpriv); usb_get_dev(pusbd); @@ -258,7 +133,6 @@ free_dvobj: pdvobjpriv = NULL; } exit: -_func_exit_; return pdvobjpriv; } @@ -266,7 +140,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) { struct dvobj_priv *dvobj = usb_get_intfdata(usb_intf); -_func_enter_; usb_set_intfdata(usb_intf, NULL); if (dvobj) { @@ -285,20 +158,14 @@ _func_enter_; usb_reset_device(interface_to_usbdev(usb_intf)); } } - rtw_deinit_intf_priv(dvobj); + + kfree(dvobj->usb_vendor_req_buf); + mutex_destroy(&dvobj->usb_vendor_req_mutex); kfree(dvobj); } usb_put_dev(interface_to_usbdev(usb_intf)); -_func_exit_; -} - -static void chip_by_usb_id(struct adapter *padapter, - const struct usb_device_id *pdid) -{ - padapter->chip_type = NULL_CHIP_TYPE; - hal_set_hw_type(padapter); } static void usb_intf_start(struct adapter *padapter) @@ -326,7 +193,7 @@ static void usb_intf_stop(struct adapter *padapter) rtw_hal_inirp_deinit(padapter); /* cancel out irp */ - rtw_write_port_cancel(padapter); + usb_write_port_cancel(padapter); /* todo:cancel other irps */ @@ -366,139 +233,6 @@ static void rtw_dev_unload(struct adapter *padapter) RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n")); } -static void process_spec_devid(const struct usb_device_id *pdid) -{ - u16 vid, pid; - u32 flags; - int i; - int num = sizeof(specific_device_id_tbl) / - sizeof(struct specific_device_id); - - for (i = 0; i < num; i++) { - vid = specific_device_id_tbl[i].idVendor; - pid = specific_device_id_tbl[i].idProduct; - flags = specific_device_id_tbl[i].flags; - - if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && - (flags&SPEC_DEV_ID_DISABLE_HT)) { - rtw_ht_enable = 0; - rtw_cbw40_enable = 0; - rtw_ampdu_enable = 0; - } - } -} - -int rtw_hw_suspend(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct net_device *pnetdev = padapter->pnetdev; - - _func_enter_; - - if ((!padapter->bup) || (padapter->bDriverStopped) || - (padapter->bSurpriseRemoved)) { - DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", - padapter->bup, padapter->bDriverStopped, - padapter->bSurpriseRemoved); - goto error_exit; - } - - if (padapter) { /* system suspend */ - LeaveAllPowerSaveMode(padapter); - - DBG_88E("==> rtw_hw_suspend\n"); - _enter_pwrlock(&pwrpriv->lock); - pwrpriv->bips_processing = true; - /* s1. */ - if (pnetdev) { - netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); - } - - /* s2. */ - rtw_disassoc_cmd(padapter, 500, false); - - /* s2-2. indicate disconnect to os */ - { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - _clr_fwstate_(pmlmepriv, _FW_LINKED); - - rtw_led_control(padapter, LED_CTL_NO_LINK); - - rtw_os_indicate_disconnect(padapter); - - /* donnot enqueue cmd */ - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); - } - } - /* s2-3. */ - rtw_free_assoc_resources(padapter, 1); - - /* s2-4. */ - rtw_free_network_queue(padapter, true); - rtw_ips_dev_unload(padapter); - pwrpriv->rf_pwrstate = rf_off; - pwrpriv->bips_processing = false; - - _exit_pwrlock(&pwrpriv->lock); - } else { - goto error_exit; - } - _func_exit_; - return 0; - -error_exit: - DBG_88E("%s, failed\n", __func__); - return -1; -} - -int rtw_hw_resume(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct net_device *pnetdev = padapter->pnetdev; - - _func_enter_; - - if (padapter) { /* system resume */ - DBG_88E("==> rtw_hw_resume\n"); - _enter_pwrlock(&pwrpriv->lock); - pwrpriv->bips_processing = true; - rtw_reset_drv_sw(padapter); - - if (pm_netdev_open(pnetdev, false) != 0) { - _exit_pwrlock(&pwrpriv->lock); - goto error_exit; - } - - netif_device_attach(pnetdev); - netif_carrier_on(pnetdev); - - if (!netif_queue_stopped(pnetdev)) - netif_start_queue(pnetdev); - else - netif_wake_queue(pnetdev); - - pwrpriv->bkeepfwalive = false; - pwrpriv->brfoffbyhw = false; - - pwrpriv->rf_pwrstate = rf_on; - pwrpriv->bips_processing = false; - - _exit_pwrlock(&pwrpriv->lock); - } else { - goto error_exit; - } - - _func_exit_; - - return 0; -error_exit: - DBG_88E("%s, Open net dev failed\n", __func__); - return -1; -} - static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) { struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); @@ -508,9 +242,8 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; int ret = 0; - u32 start_time = rtw_get_current_time(); + u32 start_time = jiffies; - _func_enter_; DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); @@ -530,7 +263,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) /* s1. */ if (pnetdev) { netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); + netif_tx_stop_all_queues(pnetdev); } /* s2. */ @@ -567,31 +300,15 @@ exit: DBG_88E("<=== %s return %d.............. in %dms\n", __func__ , ret, rtw_get_passing_time_ms(start_time)); - _func_exit_; return ret; } -static int rtw_resume(struct usb_interface *pusb_intf) -{ - struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); - struct adapter *padapter = dvobj->if1; - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - int ret = 0; - - if (pwrpriv->bInternalAutoSuspend) - ret = rtw_resume_process(padapter); - else - ret = rtw_resume_process(padapter); - return ret; -} - -int rtw_resume_process(struct adapter *padapter) +static int rtw_resume_process(struct adapter *padapter) { struct net_device *pnetdev; struct pwrctrl_priv *pwrpriv = NULL; int ret = -1; - u32 start_time = rtw_get_current_time(); - _func_enter_; + u32 start_time = jiffies; DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); @@ -604,8 +321,7 @@ int rtw_resume_process(struct adapter *padapter) _enter_pwrlock(&pwrpriv->lock); rtw_reset_drv_sw(padapter); - if (pwrpriv) - pwrpriv->bkeepfwalive = false; + pwrpriv->bkeepfwalive = false; DBG_88E("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive); if (pm_netdev_open(pnetdev, true) != 0) @@ -630,11 +346,18 @@ exit: DBG_88E("<=== %s return %d.............. in %dms\n", __func__, ret, rtw_get_passing_time_ms(start_time)); - _func_exit_; return ret; } +static int rtw_resume(struct usb_interface *pusb_intf) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); + struct adapter *padapter = dvobj->if1; + + return rtw_resume_process(padapter); +} + /* * drv_init() - a device potentially for us * @@ -650,26 +373,19 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, struct net_device *pnetdev = NULL; int status = _FAIL; - padapter = (struct adapter *)rtw_zvmalloc(sizeof(*padapter)); + padapter = (struct adapter *)vzalloc(sizeof(*padapter)); if (padapter == NULL) goto exit; padapter->dvobj = dvobj; dvobj->if1 = padapter; padapter->bDriverStopped = true; - - padapter->hw_init_mutex = &usb_drv->hw_init_mutex; - - /* step 1-1., decide the chip_type via vid/pid */ - padapter->interface_type = RTW_USB; - chip_by_usb_id(padapter, pdid); - - if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) - goto free_adapter; + mutex_init(&padapter->hw_init_mutex); + padapter->chip_type = RTL8188E; pnetdev = rtw_init_netdev(padapter); if (pnetdev == NULL) - goto handle_dualmac; + goto free_adapter; SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); padapter = rtw_netdev_priv(pnetdev); @@ -679,9 +395,6 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter->intf_start = &usb_intf_start; padapter->intf_stop = &usb_intf_stop; - /* step init_io_priv */ - rtw_init_io_priv(padapter, usb_set_intf_ops); - /* step read_chip_version */ rtw_hal_read_chip_version(padapter); @@ -717,10 +430,6 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, /* alloc dev name after read efuse. */ rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname); rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); -#ifdef CONFIG_88EU_P2P - rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, - padapter->eeprompriv.mac_addr); -#endif memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); DBG_88E("MAC Address from pnetdev->dev_addr = %pM\n", pnetdev->dev_addr); @@ -743,15 +452,12 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, free_hal_data: if (status != _SUCCESS) kfree(padapter->HalData); -handle_dualmac: - if (status != _SUCCESS) - rtw_handle_dualmac(padapter, 0); free_adapter: if (status != _SUCCESS) { if (pnetdev) rtw_free_netdev(pnetdev); else if (padapter) - rtw_vmfree((u8 *)padapter, sizeof(*padapter)); + vfree(padapter); padapter = NULL; } exit: @@ -770,19 +476,16 @@ static void rtw_usb_if1_deinit(struct adapter *if1) free_mlme_ap_info(if1); #endif - if (if1->DriverState != DRIVER_DISAPPEAR) { - if (pnetdev) { - /* will call netdev_close() */ - unregister_netdev(pnetdev); - rtw_proc_remove_one(pnetdev); - } + if (pnetdev) { + /* will call netdev_close() */ + unregister_netdev(pnetdev); + rtw_proc_remove_one(pnetdev); } rtw_cancel_all_timer(if1); rtw_dev_unload(if1); DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n", if1->hw_init_completed); - rtw_handle_dualmac(if1, 0); rtw_free_drv_sw(if1); if (pnetdev) rtw_free_netdev(pnetdev); @@ -791,14 +494,11 @@ static void rtw_usb_if1_deinit(struct adapter *if1) static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) { struct adapter *if1 = NULL; - int status; + int status = _FAIL; struct dvobj_priv *dvobj; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n")); - /* step 0. */ - process_spec_devid(pdid); - /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); if (dvobj == NULL) { @@ -822,8 +522,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device status = _SUCCESS; - if (status != _SUCCESS && if1) - rtw_usb_if1_deinit(if1); free_dvobj: if (status != _SUCCESS) usb_dvobj_deinit(pusb_intf); @@ -840,12 +538,11 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf) struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); struct adapter *padapter = dvobj->if1; -_func_enter_; DBG_88E("+rtw_dev_remove\n"); RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n")); - if (usb_drv->drv_registered) + if (!pusb_intf->unregistering) padapter->bSurpriseRemoved = true; rtw_pm_set_ips(padapter, IPS_NONE); @@ -859,38 +556,16 @@ _func_enter_; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n")); DBG_88E("-r871xu_dev_remove, done\n"); -_func_exit_; - - return; } -static int __init rtw_drv_entry(void) -{ - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_entry\n")); +static struct usb_driver rtl8188e_usb_drv = { + .name = "r8188eu", + .probe = rtw_drv_init, + .disconnect = rtw_dev_remove, + .id_table = rtw_usb_id_tbl, + .suspend = rtw_suspend, + .resume = rtw_resume, + .reset_resume = rtw_resume, +}; - DBG_88E(DRV_NAME " driver version=%s\n", DRIVERVERSION); - - rtw_suspend_lock_init(); - - _rtw_mutex_init(&usb_drv->hw_init_mutex); - - usb_drv->drv_registered = true; - return usb_register(&usb_drv->usbdrv); -} - -static void __exit rtw_drv_halt(void) -{ - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n")); - DBG_88E("+rtw_drv_halt\n"); - - rtw_suspend_lock_uninit(); - - usb_drv->drv_registered = false; - usb_deregister(&usb_drv->usbdrv); - - _rtw_mutex_free(&usb_drv->hw_init_mutex); - DBG_88E("-rtw_drv_halt\n"); -} - -module_init(rtw_drv_entry); -module_exit(rtw_drv_halt); +module_usb_driver(rtl8188e_usb_drv) diff --git a/os_dep/usb_ops_linux.c b/os_dep/usb_ops_linux.c index 4c71e3b..d2efa9d 100644 --- a/os_dep/usb_ops_linux.c +++ b/os_dep/usb_ops_linux.c @@ -19,9 +19,197 @@ #define _USB_OPS_LINUX_C_ #include -#include +#include #include +static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) { + DBG_88E("%s Invalid interrupt content length (%d)!\n", __func__, pkt_len); + return; + } + + /* HISR */ + memcpy(&(haldata->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); + memcpy(&(haldata->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); + + /* C2H Event */ + if (pbuf[0] != 0) + memcpy(&(haldata->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); +} + +static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) +{ + u8 *pbuf; + u8 shift_sz = 0; + u16 pkt_cnt; + u32 pkt_offset, skb_len, alloc_sz; + s32 transfer_len; + struct recv_stat *prxstat; + struct phy_stat *pphy_status = NULL; + struct sk_buff *pkt_copy = NULL; + struct recv_frame *precvframe = NULL; + struct rx_pkt_attrib *pattrib = NULL; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct recv_priv *precvpriv = &adapt->recvpriv; + struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; + + transfer_len = (s32)pskb->len; + pbuf = pskb->data; + + prxstat = (struct recv_stat *)pbuf; + pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; + + do { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", + prxstat->rxdw0, prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4)); + + prxstat = (struct recv_stat *)pbuf; + + precvframe = rtw_alloc_recvframe(pfree_recv_queue); + if (precvframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); + DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); + goto _exit_recvbuf2recvframe; + } + + INIT_LIST_HEAD(&precvframe->list); + precvframe->len = 0; + + update_recvframe_attrib_88e(precvframe, prxstat); + + pattrib = &precvframe->attrib; + + if ((pattrib->crc_err) || (pattrib->icv_err)) { + DBG_88E("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); + + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + + if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX)) + pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET); + + pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; + + if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<=0\n")); + DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len\n", __func__, __LINE__); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + + /* Modified by Albert 20101213 */ + /* For 8 bytes IP header alignment. */ + if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ + shift_sz = 6; + else + shift_sz = 0; + + skb_len = pattrib->pkt_len; + + /* for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */ + /* modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */ + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + if (skb_len <= 1650) + alloc_sz = 1664; + else + alloc_sz = skb_len + 14; + } else { + alloc_sz = skb_len; + /* 6 is for IP header 8 bytes alignment in QoS packet case. */ + /* 8 is for skb->data 4 bytes alignment. */ + alloc_sz += 14; + } + + pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz); + if (pkt_copy) { + pkt_copy->dev = adapt->pnetdev; + precvframe->pkt = pkt_copy; + precvframe->rx_head = pkt_copy->data; + precvframe->rx_end = pkt_copy->data + alloc_sz; + skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ + skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */ + memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); + precvframe->rx_tail = pkt_copy->data; + precvframe->rx_data = pkt_copy->data; + } else { + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n"); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + precvframe->pkt = skb_clone(pskb, GFP_ATOMIC); + if (precvframe->pkt) { + precvframe->rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE; + precvframe->rx_head = precvframe->rx_tail; + precvframe->rx_data = precvframe->rx_tail; + precvframe->rx_end = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz; + } else { + DBG_88E("recvbuf2recvframe: skb_clone fail\n"); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + } + + recvframe_put(precvframe, skb_len); + + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + case USB_RX_AGG_MIX: + pkt_offset = (u16)round_up(pkt_offset, 128); + break; + case USB_RX_AGG_USB: + pkt_offset = (u16)round_up(pkt_offset, 4); + break; + case USB_RX_AGG_DISABLE: + default: + break; + } + if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ + if (pattrib->physt) + update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status); + if (rtw_recv_entry(precvframe) != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); + } + } else { + /* enqueue recvframe to txrtp queue */ + if (pattrib->pkt_rpt_type == TX_REPORT1) { + /* CCX-TXRPT ack for xmit mgmt frames. */ + handle_txrpt_ccx_88e(adapt, precvframe->rx_data); + } else if (pattrib->pkt_rpt_type == TX_REPORT2) { + ODM_RA_TxRPT2Handle_8188E( + &haldata->odmpriv, + precvframe->rx_data, + pattrib->pkt_len, + pattrib->MacIDValidEntry[0], + pattrib->MacIDValidEntry[1] + ); + } else if (pattrib->pkt_rpt_type == HIS_REPORT) { + interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->rx_data); + } + rtw_free_recvframe(precvframe, pfree_recv_queue); + } + pkt_cnt--; + transfer_len -= pkt_offset; + pbuf += pkt_offset; + precvframe = NULL; + pkt_copy = NULL; + + if (transfer_len > 0 && pkt_cnt == 0) + pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; + + } while ((transfer_len > 0) && (pkt_cnt > 0)); + +_exit_recvbuf2recvframe: + + return _SUCCESS; +} + unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) { unsigned int pipe = 0, ep_num = 0; @@ -39,26 +227,309 @@ unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) return pipe; } -struct zero_bulkout_context { - void *pbuf; - void *purb; - void *pirp; - void *padapter; -}; - -void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) +static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) { + struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); + struct usb_device *udev = dvobjpriv->pusbdev; + unsigned int pipe; + int status = 0; + u8 reqtype; + u8 *pIo_buf; + int vendorreq_times = 0; + + if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usbctrl_vendorreq:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + status = -EPERM; + goto exit; + } + + if (len > MAX_VENDOR_REQ_CMD_SIZE) { + DBG_88E("[%s] Buffer len error ,vendor request failed\n", __func__); + status = -EINVAL; + goto exit; + } + + _enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); + + /* Acquire IO memory for vendorreq */ + pIo_buf = dvobjpriv->usb_vendor_req_buf; + + if (pIo_buf == NULL) { + DBG_88E("[%s] pIo_buf == NULL\n", __func__); + status = -ENOMEM; + goto release_mutex; + } + + while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { + memset(pIo_buf, 0, len); + + if (requesttype == 0x01) { + pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ + reqtype = REALTEK_USB_VENQT_READ; + } else { + pipe = usb_sndctrlpipe(udev, 0);/* write_out */ + reqtype = REALTEK_USB_VENQT_WRITE; + memcpy(pIo_buf, pdata, len); + } + + status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + + if (status == len) { /* Success this control transfer. */ + if (requesttype == 0x01) + memcpy(pdata, pIo_buf, len); + } else { /* error cases */ + DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n", + value, (requesttype == 0x01) ? "read" : "write", + len, status, *(u32 *)pdata, vendorreq_times); + + if (status < 0) { + if (status == (-ESHUTDOWN) || status == -ENODEV) { + adapt->bSurpriseRemoved = true; + } else { + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; + } + } else { /* status != len && status >= 0 */ + if (status > 0) { + if (requesttype == 0x01) { + /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ + memcpy(pdata, pIo_buf, len); + } + } + } + + } + + /* firmware download is checksumed, don't retry */ + if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len) + break; + } +release_mutex: + mutex_unlock(&dvobjpriv->usb_vendor_req_mutex); +exit: + return status; } -void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +u8 usb_read8(struct adapter *adapter, u32 addr) { + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 data = 0; + + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 1; + + usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); + + + return data; + } -void usb_read_port_cancel(struct intf_hdl *pintfhdl) +u16 usb_read16(struct adapter *adapter, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + wvalue = (u16)(addr&0x0000ffff); + len = 2; + usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); + + return (u16)(le32_to_cpu(data)&0xffff); +} + +u32 usb_read32(struct adapter *adapter, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 4; + + usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); + + + return le32_to_cpu(data); +} + +static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) +{ + struct recv_buf *precvbuf = (struct recv_buf *)purb->context; + struct adapter *adapt = (struct adapter *)precvbuf->adapter; + struct recv_priv *precvpriv = &adapt->recvpriv; + + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete!!!\n")); + + precvpriv->rx_pending_cnt--; + + if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", + adapt->bDriverStopped, adapt->bSurpriseRemoved)); + + precvbuf->reuse = true; + DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", + __func__, adapt->bDriverStopped, + adapt->bSurpriseRemoved, adapt->bReadPortCancel); + return; + } + + if (purb->status == 0) { /* SUCCESS */ + if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); + precvbuf->reuse = true; + usb_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__); + } else { + skb_put(precvbuf->pskb, purb->actual_length); + skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb); + + if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1) + tasklet_schedule(&precvpriv->recv_tasklet); + + precvbuf->pskb = NULL; + precvbuf->reuse = false; + usb_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + } + } else { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); + + DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status); + skb_put(precvbuf->pskb, purb->actual_length); + precvbuf->pskb = NULL; + + switch (purb->status) { + case -EINVAL: + case -EPIPE: + case -ENODEV: + case -ESHUTDOWN: + adapt->bSurpriseRemoved = true; + case -ENOENT: + adapt->bDriverStopped = true; + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); + break; + case -EPROTO: + case -EOVERFLOW: + { + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; + } + precvbuf->reuse = true; + usb_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + break; + case -EINPROGRESS: + DBG_88E("ERROR: URB IS IN PROGRESS!\n"); + break; + default: + break; + } + } +} + +u32 usb_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *rmem) +{ + struct urb *purb = NULL; + struct recv_buf *precvbuf = (struct recv_buf *)rmem; + struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); + struct recv_priv *precvpriv = &adapter->recvpriv; + struct usb_device *pusbd = pdvobj->pusbdev; + int err; + unsigned int pipe; + size_t tmpaddr = 0; + size_t alignment = 0; + u32 ret = _SUCCESS; + + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved || + adapter->pwrctrlpriv.pnp_bstop_trx) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + return _FAIL; + } + + if (!precvbuf) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port:precvbuf==NULL\n")); + return _FAIL; + } + + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); + if (NULL != precvbuf->pskb) + precvbuf->reuse = true; + } + + /* re-assign for linux based on skb */ + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); + if (precvbuf->pskb == NULL) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); + DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); + return _FAIL; + } + + tmpaddr = (size_t)precvbuf->pskb->data; + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); + } else { /* reuse skb */ + precvbuf->reuse = false; + } + + precvpriv->rx_pending_cnt++; + + purb = precvbuf->purb; + + /* translate DMA FIFO addr to pipehandle */ + pipe = ffaddr2pipehdl(pdvobj, addr); + + usb_fill_bulk_urb(purb, pusbd, pipe, + precvbuf->pskb->data, + MAX_RECVBUF_SZ, + usb_read_port_complete, + precvbuf);/* context is precvbuf */ + + err = usb_submit_urb(purb, GFP_ATOMIC); + if ((err) && (err != (-EPERM))) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x", + err, purb->status)); + DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n", + err, purb->status); + ret = _FAIL; + } + + return ret; +} + +void usb_read_port_cancel(struct adapter *padapter) { int i; struct recv_buf *precvbuf; - struct adapter *padapter = pintfhdl->padapter; precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf; DBG_88E("%s\n", __func__); @@ -73,14 +544,109 @@ void usb_read_port_cancel(struct intf_hdl *pintfhdl) } } +int usb_write8(struct adapter *adapter, u32 addr, u8 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 data; + int ret; + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + wvalue = (u16)(addr&0x0000ffff); + len = 1; + data = val; + ret = usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); + return ret; +} + +int usb_write16(struct adapter *adapter, u32 addr, u16 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + int ret; + + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 2; + + data = cpu_to_le32(val & 0x0000ffff); + + ret = usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); + + + return ret; +} + +int usb_write32(struct adapter *adapter, u32 addr, u32 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + int ret; + + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 4; + data = cpu_to_le32(val); + + ret = usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); + + + return ret; +} + +int usb_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; + int ret; + + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = length; + memcpy(buf, pdata, len); + + ret = usbctrl_vendorreq(adapter, request, wvalue, index, buf, len, requesttype); + + + return RTW_STATUS_CODE(ret); +} + + + static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) { struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; struct adapter *padapter = pxmitbuf->padapter; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct hal_data_8188e *haldata; - -_func_enter_; switch (pxmitbuf->flags) { case VO_QUEUE_INX: @@ -145,9 +711,6 @@ _func_enter_; } } - haldata = GET_HAL_DATA(padapter); - haldata->srestpriv.last_tx_complete_time = rtw_get_current_time(); - check_completion: rtw_sctx_done_err(&pxmitbuf->sctx, purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : @@ -156,25 +719,21 @@ check_completion: rtw_free_xmitbuf(pxmitpriv, pxmitbuf); tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); - -_func_exit_; } -u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, u8 *wmem) { unsigned long irqL; unsigned int pipe; int status; u32 ret = _FAIL; struct urb *purb = NULL; - struct adapter *padapter = (struct adapter *)pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_buf *pxmitbuf = (struct xmit_buf *)wmem; struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; -_func_enter_; RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n")); @@ -186,7 +745,7 @@ _func_enter_; goto exit; } - _enter_critical(&pxmitpriv->lock, &irqL); + spin_lock_irqsave(&pxmitpriv->lock, irqL); switch (addr) { case VO_QUEUE_INX: @@ -213,7 +772,7 @@ _func_enter_; break; } - _exit_critical(&pxmitpriv->lock, &irqL); + spin_unlock_irqrestore(&pxmitpriv->lock, irqL); purb = pxmitbuf->pxmit_urb[0]; @@ -227,11 +786,7 @@ _func_enter_; pxmitbuf);/* context is pxmitbuf */ status = usb_submit_urb(purb, GFP_ATOMIC); - if (!status) { - struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); - - haldata->srestpriv.last_tx_time = rtw_get_current_time(); - } else { + if (status) { rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); DBG_88E("usb_write_port, status =%d\n", status); RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port(): usb_submit_urb, status =%x\n", status)); @@ -255,14 +810,12 @@ _func_enter_; exit: if (ret != _SUCCESS) rtw_free_xmitbuf(pxmitpriv, pxmitbuf); -_func_exit_; return ret; } -void usb_write_port_cancel(struct intf_hdl *pintfhdl) +void usb_write_port_cancel(struct adapter *padapter) { int i, j; - struct adapter *padapter = pintfhdl->padapter; struct xmit_buf *pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmitbuf; DBG_88E("%s\n", __func__); @@ -286,3 +839,46 @@ void usb_write_port_cancel(struct intf_hdl *pintfhdl) pxmitbuf++; } } + +void rtl8188eu_recv_tasklet(void *priv) +{ + struct sk_buff *pskb; + struct adapter *adapt = priv; + struct recv_priv *precvpriv = &adapt->recvpriv; + + while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { + if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) { + DBG_88E("recv_tasklet => bDriverStopped or bSurpriseRemoved\n"); + dev_kfree_skb_any(pskb); + break; + } + recvbuf2recvframe(adapt, pskb); + skb_reset_tail_pointer(pskb); + pskb->len = 0; + skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); + } +} + +void rtl8188eu_xmit_tasklet(void *priv) +{ + int ret = false; + struct adapter *adapt = priv; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + + if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) + return; + + while (1) { + if ((adapt->bDriverStopped) || + (adapt->bSurpriseRemoved) || + (adapt->bWritePortCancel)) { + DBG_88E("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n"); + break; + } + + ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv, NULL); + + if (!ret) + break; + } +} diff --git a/os_dep/xmit_linux.c b/os_dep/xmit_linux.c index 2e586c0..d5e41a5 100644 --- a/os_dep/xmit_linux.c +++ b/os_dep/xmit_linux.c @@ -19,17 +19,13 @@ ******************************************************************************/ #define _XMIT_OSDEP_C_ -#include #include #include -#include -#include #include #include #include #include -#include uint rtw_remainder_len(struct pkt_file *pfile) { @@ -39,7 +35,6 @@ uint rtw_remainder_len(struct pkt_file *pfile) void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) { -_func_enter_; pfile->pkt = pktptr; pfile->cur_addr = pktptr->data; @@ -49,14 +44,12 @@ _func_enter_; pfile->cur_buffer = pfile->buf_start; -_func_exit_; } -uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) +uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen) { uint len = 0; -_func_enter_; len = rtw_remainder_len(pfile); len = (rlen > len) ? len : rlen; @@ -67,34 +60,26 @@ _func_enter_; pfile->cur_addr += len; pfile->pkt_len -= len; -_func_exit_; return len; } int rtw_endofpktfile(struct pkt_file *pfile) { -_func_enter_; if (pfile->pkt_len == 0) { - _func_exit_; return true; } -_func_exit_; return false; } -void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib) -{ -} - int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) { int i; - pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); + pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL); if (pxmitbuf->pallocated_buf == NULL) return _FAIL; @@ -126,7 +111,6 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) u16 queue; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -139,10 +123,6 @@ void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) if (__netif_subqueue_stopped(padapter->pnetdev, queue)) netif_wake_subqueue(padapter->pnetdev, queue); } -#else - if (netif_queue_stopped(padapter->pnetdev)) - netif_wake_queue(padapter->pnetdev); -#endif dev_kfree_skb_any(pkt); } @@ -156,7 +136,6 @@ void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe) void rtw_os_xmit_schedule(struct adapter *padapter) { - unsigned long irql; struct xmit_priv *pxmitpriv; if (!padapter) @@ -164,12 +143,12 @@ void rtw_os_xmit_schedule(struct adapter *padapter) pxmitpriv = &padapter->xmitpriv; - _enter_critical_bh(&pxmitpriv->lock, &irql); + spin_lock_bh(&pxmitpriv->lock); if (rtw_txframes_pending(padapter)) tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); - _exit_critical_bh(&pxmitpriv->lock, &irql); + spin_unlock_bh(&pxmitpriv->lock); } static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt) @@ -194,21 +173,20 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) { struct sta_priv *pstapriv = &padapter->stapriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - unsigned long irql; struct list_head *phead, *plist; struct sk_buff *newskb; struct sta_info *psta = NULL; s32 res; - _enter_critical_bh(&pstapriv->asoc_list_lock, &irql); + spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; - plist = get_next(phead); + plist = phead->next; /* free sta asoc_queue */ - while (!rtw_end_of_queue_search(phead, plist)) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); - plist = get_next(plist); + plist = plist->next; /* avoid come from STA1 and send back STA1 */ if (!memcmp(psta->hwaddr, &skb->data[6], 6)) @@ -230,12 +208,12 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) DBG_88E("%s-%d: skb_copy() failed!\n", __func__, __LINE__); pxmitpriv->tx_drop++; - _exit_critical_bh(&pstapriv->asoc_list_lock, &irql); + spin_unlock_bh(&pstapriv->asoc_list_lock); return false; /* Caller shall tx this multicast frame via normal way. */ } } - _exit_critical_bh(&pstapriv->asoc_list_lock, &irql); + spin_unlock_bh(&pstapriv->asoc_list_lock); dev_kfree_skb_any(skb); return true; } @@ -248,7 +226,6 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; s32 res = 0; -_func_enter_; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); @@ -284,7 +261,6 @@ drop_packet: exit: -_func_exit_; return 0; }