void dot11d_init(struct rtllib_device *ieee)
 {
        struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee);
+
        pDot11dInfo->bEnabled = false;
 
        pDot11dInfo->State = DOT11D_STATE_NONE;
 
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        bool rtStatus = true;
+
        priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH;
        rtStatus = phy_RF8256_Config_ParaFile(dev);
 
 
        struct r8192_priv *priv = rtllib_priv(dev);
        u8 msr;
        enum led_ctl_mode LedAction = LED_CTL_NO_LINK;
+
        msr  = read_nic_byte(dev, MSR);
        msr &= ~MSR_LINK_MASK;
 
        case HW_VAR_ACK_PREAMBLE:
        {
                u32 regTmp;
+
                priv->short_preamble = (bool)(*(u8 *)val);
                regTmp = priv->basic_rate;
                if (priv->short_preamble)
        case HW_VAR_RF_TIMING:
        {
                u8 Rf_Timing = *((u8 *)val);
+
                write_nic_byte(dev, rFPGA0_RFTiming1, Rf_Timing);
                break;
        }
        u16 i, usValue, IC_Version;
        u16 EEPROMId;
        u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
+
        RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n");
 
        EEPROMId = eprom_read(dev, 0);
        write_nic_byte(dev, BW_OPMODE, regBwOpMode);
        {
                u32 ratr_value = 0;
+
                ratr_value = regRATR;
                if (priv->rf_type == RF_1T2R)
                        ratr_value &= ~(RATE_ALL_OFDM_2SS);
        CamResetAllEntry(dev);
        {
                u8 SECR_value = 0x0;
+
                SECR_value |= SCR_TxEncEnable;
                SECR_value |= SCR_RxDecEnable;
                SECR_value |= SCR_NoSKMC;
        write_nic_word(dev, BCN_INTERVAL, 100);
        {
                int i;
+
                for (i = 0; i < QOS_QUEUE_NUM; i++)
                        write_nic_dword(dev, WDCAPARA_ADD[i], 0x005e4332);
        }
 
        if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) {
                u32 reg = 0;
+
                reg = read_nic_dword(dev, RCR);
                if (priv->rtllib->state == RTLLIB_LINKED) {
                        if (ieee->IntelPromiscuousModeInfo.bPromiscuousOn)
        dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len,
                         PCI_DMA_TODEVICE);
        struct tx_fwinfo_8190pci *pTxFwInfo = NULL;
+
        pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data;
        memset(pTxFwInfo, 0, sizeof(struct tx_fwinfo_8190pci));
        pTxFwInfo->TxHT = (cb_desc->data_rate & 0x80) ? 1 : 0;
        pdesc->SecType = 0x0;
        if (cb_desc->bHwSec) {
                static u8 tmp;
+
                if (!tmp) {
                        RT_TRACE(COMP_DBG, "==>================hw sec\n");
                        tmp = 1;
                entry->CmdInit = DESC_PACKET_TYPE_INIT;
        } else {
                struct tx_desc * entry_tmp = (struct tx_desc *)entry;
+
                entry_tmp->CmdInit = DESC_PACKET_TYPE_NORMAL;
                entry_tmp->Offset = sizeof(struct tx_fwinfo_8190pci) + 8;
                entry_tmp->PktSize = (u16)(cb_desc->pkt_size +
                return false;
        } else {
                struct rx_fwinfo *pDrvInfo = NULL;
+
                stats->RxDrvInfoSize = pdesc->RxDrvInfoSize;
                stats->RxBufShift = ((pdesc->Shift)&0x03);
                stats->Decrypted = !pdesc->SWDec;
 void rtl8192_EnableInterrupt(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
+
        priv->irq_enabled = 1;
 
        write_nic_dword(dev, INTA_MASK, priv->irq_mask[0]);
 void rtl8192_ClearInterrupt(struct net_device *dev)
 {
        u32 tmp = 0;
+
        tmp = read_nic_dword(dev, ISR);
        write_nic_dword(dev, ISR, tmp);
 }
 void rtl8192_enable_rx(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
+
        write_nic_dword(dev, RDQDA, priv->rx_ring_dma[RX_MPDU_QUEUE]);
 }
 
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
+
        if (ieee->rtllib_ap_sec_type &&
           (ieee->rtllib_ap_sec_type(priv->rtllib)&(SEC_ALG_WEP |
                                     SEC_ALG_TKIP))) {
 
                                };
                                const struct firmware *fw_entry;
                                int rc;
+
                                rc = request_firmware(&fw_entry,
                                                      fw_name[init_step],
                                                      &priv->pdev->dev);
 
 static u32 rtl8192_CalculateBitShift(u32 dwBitMask)
 {
        u32 i;
+
        for (i = 0; i <= 31; i++) {
                if (((dwBitMask >> i) & 0x1) == 1)
                        break;
 {
        u8 ret = 1;
        struct r8192_priv *priv = rtllib_priv(dev);
+
        if (priv->rf_type == RF_2T4R)
                ret = 0;
        else if (priv->rf_type == RF_1T2R) {
        u32 ret = 0;
        u32 NewOffset = 0;
        struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath];
+
        Offset &= 0x3f;
 
        if (priv->rf_chip == RF_8256) {
 {
        u32 Original_Value, Readback_Value, BitShift;
        struct r8192_priv *priv = rtllib_priv(dev);
+
        if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
                return 0;
        if (priv->rtllib->eRFPowerState != eRfOn && !priv->being_init_adapter)
        u32             retValue = 0;
        u32             Data = 0;
        u8              time = 0;
+
        Data |= ((Offset & 0xFF) << 12);
        Data |= ((eRFPath & 0x3) << 20);
        Data |= 0x80000000;
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        bool rtStatus = true;
+
        switch (priv->rf_chip) {
        case RF_8225:
                break;
 u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        RT_TRACE(COMP_PHY, "=====>%s()\n", __func__);
        if (IS_NIC_DOWN(priv)) {
                RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n", __func__);
                             RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) {
                                bool rtstatus = true;
                                u32 InitilizeCount = 3;
+
                                do {
                                        InitilizeCount--;
                                        priv->RegRfOff = false;
 
        u8 SECR_value = 0x0;
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
+
        SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
        if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
             (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) &&
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
+
        RT_TRACE(COMP_DBG, "===========>%s():EntryNo is %d,KeyIndex is "
                 "%d,KeyType is %d,is_mesh is %d\n", __func__, EntryNo,
                 KeyIndex, KeyType, is_mesh);
        u8 i;
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
        enum rt_rf_power_state rtState;
+
        rtState = priv->rtllib->eRFPowerState;
        if (priv->rtllib->PowerSaveControl.bInactivePs) {
                if (rtState == eRfOff) {
        u8 entry_i = 0;
        u32 ulStatus;
        s32 i = 100;
+
        for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) {
                target_command = entry_i+CAM_CONTENT_COUNT*iIndex;
                target_command = target_command | BIT31;
 
        enum rt_rf_power_state rtState;
        u16                     RFWaitCounter = 0;
        unsigned long flag;
+
        RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): "
                 "StateToSet(%d)\n", StateToSet);
 
 void rtl8192_irq_enable(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
+
        priv->irq_enabled = 1;
 
        priv->ops->irq_enable(dev);
                                 struct rtllib_network *network)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        rtl8192_qos_association_resp(priv, network);
        return 0;
 }
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_network *net;
        u8 i = 0, basic_rate = 0;
+
        net = &priv->rtllib->current_network;
 
        for (i = 0; i < net->rates_len; i++) {
 static void rtl8192_refresh_supportrate(struct r8192_priv *priv)
 {
        struct rtllib_device *ieee = priv->rtllib;
+
        if (ieee->mode == WIRELESS_MODE_N_24G ||
            ieee->mode == WIRELESS_MODE_N_5G) {
                memcpy(ieee->Regdot11HTOperationalRateSet,
        struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
                                        (&(priv->rtllib->PowerSaveControl));
        bool init_status = true;
+
        priv->bDriverIsGoingToUnload = false;
        priv->bdisable_nic = false;
 
        int i;
 
        struct r8192_priv *priv = rtllib_priv(dev);
+
        if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256)
                        && (priv->rf_chip != RF_6052)) {
                RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel "
 {
        int i = 0;
        struct r8192_priv *priv = rtllib_priv(dev);
+
        for (i = 0; i <= MGNT_QUEUE; i++) {
                if ((i == TXCMD_QUEUE) || (i == HCCA_QUEUE))
                        continue;
 void watch_dog_timer_callback(unsigned long data)
 {
        struct r8192_priv *priv = rtllib_priv((struct net_device *)data);
+
        queue_delayed_work_rsl(priv->priv_wq, &priv->watch_dog_wq, 0);
        mod_timer(&priv->watch_dog_timer, jiffies +
                  MSECS(RTLLIB_WATCH_DOG_TIME));
 void rtl8192_rx_enable(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
+
        priv->ops->rx_enable(dev);
 }
 
             rx_queue_idx++) {
                for (i = 0; i < priv->rxringcount; i++) {
                        struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
+
                        if (!skb)
                                continue;
 
                for (i = 0; i < priv->rxringcount; i++) {
                        struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
                        dma_addr_t *mapping;
+
                        entry = &priv->rx_ring[rx_queue_idx][i];
                        if (!skb)
                                return 0;
        for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
                if (priv->rx_ring[rx_queue_idx]) {
                        struct rx_desc *entry = NULL;
+
                        for (i = 0; i < priv->rxringcount; i++) {
                                entry = &priv->rx_ring[rx_queue_idx][i];
                                entry->OWN = 1;
        unsigned long flags;
        u32 inta;
        u32 intb;
+
        intb = 0;
 
        if (priv->irq_enabled == 0)
        bool    status = true;
        struct r8192_priv *priv = rtllib_priv(dev);
        u8 tmp_state = 0;
+
        RT_TRACE(COMP_PS, "=========>%s()\n", __func__);
        priv->bdisable_nic = true;
        tmp_state = priv->rtllib->state;
 
 void init_hal_dm(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        priv->DM_Type = DM_Type_ByDriver;
 
        priv->undecorated_smoothed_pwdb = -1;
 void hal_dm_watchdog(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        if (priv->being_init_adapter)
                return;
 
                currentRATR = read_nic_dword(dev, RATR0);
                if (targetRATR !=  currentRATR) {
                        u32 ratr_value;
+
                        ratr_value = targetRATR;
                        RT_TRACE(COMP_RATE,
                                 "currentRATR = %x, targetRATR = %x\n",
 void dm_initialize_txpower_tracking(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        if (priv->IC_Cut >= IC_VersionCut_D)
                dm_InitializeTXPowerTracking_TSSI(dev);
        else
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        static u32 tx_power_track_counter;
+
        RT_TRACE(COMP_POWER_TRACKING, "%s()\n", __func__);
        if (read_nic_byte(dev, 0x11e) == 1)
                return;
 {
        u32 TempVal;
        struct r8192_priv *priv = rtllib_priv(dev);
+
        TempVal = 0;
        if (!bInCH14) {
                TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] +
 void dm_cck_txpower_adjust(struct net_device *dev, bool  binch14)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        if (priv->IC_Cut >= IC_VersionCut_D)
                dm_CCKTxPowerAdjust_TSSI(dev, binch14);
        else
 static void dm_dig_init(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        dm_digtable.dig_enable_flag     = true;
        dm_digtable.Backoff_Enable_Flag = true;
 
                        "self_softap"
                };
                static int wb_tmp;
+
                if (wb_tmp == 0) {
                        printk(KERN_INFO "%s():iot peer is %s, bssid:"
                               " %pM\n", __func__,
        } else {
                 if (priv->bcurrent_turbo_EDCA) {
                        u8 tmp = AC0_BE;
+
                        priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&tmp));
                        priv->bcurrent_turbo_EDCA = false;
                }
 static void dm_deInit_fsync(struct net_device *dev)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        del_timer_sync(&priv->fsync_timer);
 }
 
            priv->rtllib->bfsync_enable &&
            (priv->rtllib->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC)) {
                u32 rate_bitmap;
+
                for (rate_index = 0; rate_index <= 27; rate_index++) {
                        rate_bitmap  = 1 << rate_index;
                        if (priv->rtllib->fsync_rate_bitmap &  rate_bitmap)
 {
        u8 rf_timing = 0x77;
        struct r8192_priv *priv = rtllib_priv(dev);
+
        RT_TRACE(COMP_HALDM, "%s\n", __func__);
        write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf);
        priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING,
 {
        u8 rf_timing = 0xaa;
        struct r8192_priv *priv = rtllib_priv(dev);
+
        RT_TRACE(COMP_HALDM, "%s\n", __func__);
        write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
        priv->rtllib->SetHwRegHandler(dev, HW_VAR_RF_TIMING, (u8 *)
        struct r8192_priv *priv = rtllib_priv(dev);
        unsigned int txhipower_threshhold = 0;
        unsigned int txlowpower_threshold = 0;
+
        if (priv->rtllib->bdynamic_txpower_enable != true) {
                priv->bDynamicTxHighPower = false;
                priv->bDynamicTxLowPower = false;
 
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        unsigned long flags = 0;
+
        spin_lock_irqsave(&priv->rf_ps_lock, flags);
        if (priv->RFChangeInProgress) {
                spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
        struct rtllib_device *ieee = container_of_dwork_rsl(data,
                                     struct rtllib_device, hw_sleep_wq);
        struct net_device *dev = ieee->dev;
+
        rtl8192_hw_sleep_down(dev);
 }
 
 {
        struct r8192_priv *priv = rtllib_priv(dev);
        unsigned long flags = 0;
+
        spin_lock_irqsave(&priv->rf_ps_lock, flags);
        if (priv->RFChangeInProgress) {
                spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
        struct rtllib_device *ieee = container_of_dwork_rsl(data,
                                     struct rtllib_device, hw_wakeup_wq);
        struct net_device *dev = ieee->dev;
-       rtl8192_hw_wakeup(dev);
 
+       rtl8192_hw_wakeup(dev);
 }
 
 #define MIN_SLEEP_TIME 50
                                     struct rtllib_device, ips_leave_wq);
        struct net_device *dev = ieee->dev;
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
+
        down(&priv->rtllib->ips_sem);
        IPSLeave(dev);
        up(&priv->rtllib->ips_sem);
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
        enum rt_rf_power_state rtState;
+
        rtState = priv->rtllib->eRFPowerState;
 
        if (priv->rtllib->PowerSaveControl.bInactivePs) {
 void rtllib_ips_leave(struct net_device *dev)
 {
        struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev);
+
        down(&priv->rtllib->ips_sem);
        IPSLeave(dev);
        up(&priv->rtllib->ips_sem);
 
                             union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        return rtllib_wx_get_rate(priv->rtllib, info, wrqu, extra);
 }
 
                             union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        return rtllib_wx_get_rts(priv->rtllib, info, wrqu, extra);
 }
 
                             union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        return rtllib_wx_get_power(priv->rtllib, info, wrqu, extra);
 }
 
 
        if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                struct iw_scan_req *req = (struct iw_scan_req *)b;
+
                if (req->essid_len) {
                        ieee->current_network.ssid_len = req->essid_len;
                        memcpy(ieee->current_network.ssid, req->essid,
                             union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        return rtllib_wx_get_name(priv->rtllib, info, wrqu, extra);
 }
 
                             union iwreq_data *wrqu, char *extra)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+
        if (priv->rf_set_sens == NULL)
                return -1; /* we have not this support for this radio */
        wrqu->sens.value = priv->sens;
                struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
                struct iw_point *encoding = &wrqu->encoding;
                u8 idx = 0, alg = 0, group = 0;
+
                if ((encoding->flags & IW_ENCODE_DISABLED) ||
                     ext->alg == IW_ENCODE_ALG_NONE) {
                        ieee->pairwise_key_type = ieee->group_key_type
        int tmp_level = 0;
        int tmp_qual = 0;
        int tmp_noise = 0;
+
        if (ieee->state < RTLLIB_LINKED) {
                wstats->qual.qual = 10;
                wstats->qual.level = 0;
 
                                 struct ba_record *pBA)
 {
        struct sk_buff *skb = NULL;
+
        skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ);
 
        if (skb) {
                                 struct ba_record *pBA, u16 StatusCode)
 {
        struct sk_buff *skb = NULL;
+
        skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP);
        if (skb)
                softmac_mgmt_xmit(skb, ieee);
                              u16 ReasonCode)
 {
        struct sk_buff *skb = NULL;
+
        skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode);
        if (skb)
                softmac_mgmt_xmit(skb, ieee);
 OnADDBAReq_Fail:
        {
                struct ba_record BA;
+
                BA.BaParamSet = *pBaParamSet;
                BA.BaTimeoutValue = *pBaTimeoutVal;
                BA.DialogToken = *pDialogToken;
 OnADDBARsp_Reject:
        {
                struct ba_record BA;
+
                BA.BaParamSet = *pBaParamSet;
                rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
                return 0;
 
 {
        struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
        struct rtllib_network *net = &ieee->current_network;
+
        if (net->bssht.bdRT2RTAggregation) {
                pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
                if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE)
 static void HTIOTActDetermineRaFunc(struct rtllib_device *ieee, bool bPeerRx2ss)
 {
        struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
+
        pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL;
 
        if (pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss)
 
        if ((bAssoc) && (pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)) {
                u8      EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
+
                memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
                pCapELE = (struct ht_capab_ele *)&(posHTCap[4]);
                *len = 30 + 2;
 {
        struct rt_hi_throughput *pHT = ieee->pHTInfo;
        struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo;
+
        if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) {
                RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be "
                             "null in HTConstructInfoElement()\n");
 static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS)
 {
        u8 i;
+
        if (pOperateMCS == NULL) {
                RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null"
                             " in HT_PickMCSRate()\n");
        u8              bitMap;
        u8              mcsRate = 0;
        u8              availableMcsRate[16];
+
        if (pMCSRateSet == NULL || pMCSFilter == NULL) {
                RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't "
                             "be null in HTGetHighestMCSRate()\n");
 
        {
                u8 *RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
+
                RegHTSuppRateSets[0] = 0xFF;
                RegHTSuppRateSets[1] = 0xFF;
                RegHTSuppRateSets[4] = 0x01;
 
        struct rx_ts_record *pRxTS  = ieee->RxTsRecord;
        struct rx_reorder_entry *pRxReorderEntry = ieee->RxReorderEntry;
        u8                              count = 0;
+
        RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __func__);
        INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
        INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
        bool    search_dir[4] = {0};
        struct list_head *psearch_list;
        struct ts_common_info *pRet = NULL;
+
        if (ieee->iw_mode == IW_MODE_MASTER) {
                if (TxRxSelect == TX_DIR) {
                        search_dir[DIR_DOWN] = true;
           u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs)
 {
        u8      UP = 0;
+
        if (is_multicast_ether_addr(Addr)) {
                RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or "
                             "Multicast\n");
                        {
                                int i = 0;
                                struct rtllib_rxb *prxb = pRxReorderEntry->prxb;
+
                                if (unlikely(!prxb))
                                        return;
                                for (i = 0; i < prxb->nr_subframes; i++)
                }
        } else {
                struct tx_ts_record *pTxTS = (struct tx_ts_record *)pTs;
+
                del_timer_sync(&pTxTS->TsAddBaTimer);
        }
 }
 void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr)
 {
        struct ts_common_info *pTS, *pTmpTS;
+
        printk(KERN_INFO "===========>RemovePeerTS, %pM\n", Addr);
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) {
 
 {
        struct rtllib_hdr_3addr *hdr;
        u16 fc;
+
        hdr = (struct rtllib_hdr_3addr *)buf;
        fc = le16_to_cpu(hdr->frame_ctl);
        return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) &&
 
 static void rtllib_ccmp_deinit(void *priv)
 {
        struct rtllib_ccmp_data *_priv = priv;
+
        if (_priv && _priv->tfm)
                crypto_free_cipher((void *)_priv->tfm);
        kfree(priv);
 static inline void xor_block(u8 *b, u8 *a, size_t len)
 {
        int i;
+
        for (i = 0; i < len; i++)
                b[i] ^= a[i];
 }
 static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv)
 {
        struct rtllib_ccmp_data *ccmp = priv;
+
        seq_printf(m,
                   "key[%d] alg=CCMP key_set=%d "
                   "tx_pn=%pM rx_pn=%pM "
 
 #ifdef __BIG_ENDIAN
        {
                int i;
+
                for (i = 0; i < 6; i++)
                        PPK[i] = (PPK[i] << 8) | (PPK[i] >> 8);
        }
        u32 crc;
        struct scatterlist sg;
        int plen;
+
        if (skb->len < hdr_len + 8 + 4)
                return -1;
 
 
        if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
                struct rtllib_hdr_4addr *hdr;
+
                hdr = (struct rtllib_hdr_4addr *) skb->data;
                printk(KERN_DEBUG "%s: Michael MIC verification failed for "
                       "MSDU from %pM keyidx=%d\n",
                /* Return the sequence number of the last transmitted frame. */
                u16 iv16 = tkey->tx_iv16;
                u32 iv32 = tkey->tx_iv32;
+
                if (iv16 == 0)
                        iv32--;
                iv16--;
 static void rtllib_tkip_print_stats(struct seq_file *m, void *priv)
 {
        struct rtllib_tkip_data *tkip = priv;
+
        seq_printf(m,
                   "key[%d] alg=TKIP key_set=%d "
                   "tx_pn=%02x%02x%02x%02x%02x%02x "
 
        u32 crc;
        u8 *icv;
        struct scatterlist sg;
+
        if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
            skb->len < hdr_len){
                printk(KERN_ERR "Error!!! headroom=%d tailroom=%d skblen=%d"
         * can be used to speedup attacks, so avoid using them. */
        if ((wep->iv & 0xff00) == 0xff00) {
                u8 B = (wep->iv >> 16) & 0xff;
+
                if (B >= 3 && B < klen)
                        wep->iv += 0x0100;
        }
        u32 crc;
        u8 icv[4];
        struct scatterlist sg;
+
        if (skb->len < hdr_len + 8)
                return -1;
 
 static void prism2_wep_print_stats(struct seq_file *m, void *priv)
 {
        struct prism2_wep_data *wep = priv;
+
        seq_printf(m, "key[%d] alg=WEP len=%d\n", wep->key_idx, wep->key_len);
 }
 
 
 {
        unsigned long val;
        int err = kstrtoul_from_user(buffer, count, 0, &val);
+
        if (err)
                return err;
        rtllib_debug_level = val;
 
 
        if (ieee->hwsec_active) {
                struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+
                tcb_desc->bHwSec = 1;
 
                if (ieee->need_sw_enc)
                return 0;
        if (ieee->hwsec_active) {
                struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+
                tcb_desc->bHwSec = 1;
 
                if (ieee->need_sw_enc)
                struct ieee_ibss_seq *entry = NULL;
                u8 *mac = header->addr2;
                int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE;
+
                list_for_each(p, &ieee->ibss_mac_hash[index]) {
                        entry = list_entry(p, struct ieee_ibss_seq, list);
                        if (!memcmp(entry->mac, mac, ETH_ALEN))
        struct net_device_stats *stats = &ieee->stats;
        u8 i = 0 , j = 0;
        u16 ethertype;
+
        for (j = 0; j < index; j++) {
                struct rtllib_rxb *prxb = prxbIndicateArray[j];
+
                for (i = 0; i < prxb->nr_subframes; i++) {
                        struct sk_buff *sub_skb = prxb->subframes[i];
 
                pHTInfo->RxReorderDropCounter++;
                {
                        int i;
+
                        for (i = 0; i < prxb->nr_subframes; i++)
                                dev_kfree_skb(prxb->subframes[i]);
                        kfree(prxb);
                                list_add_tail(&pReorderEntry->List,
                                              &ieee->RxReorder_Unused_List); {
                                        int i;
+
                                        for (i = 0; i < prxb->nr_subframes; i++)
                                                dev_kfree_skb(prxb->subframes[i]);
                                        kfree(prxb);
                                     "dropped!!\n");
                        {
                                int i;
+
                                for (i = 0; i < prxb->nr_subframes; i++)
                                        dev_kfree_skb(prxb->subframes[i]);
                                kfree(prxb);
                }
        } else {
                struct rx_ts_record *pRxTS = NULL;
+
                if (GetTs(ieee, (struct ts_common_info **) &pRxTS, hdr->addr2,
                        (u8)Frame_QoSTID((u8 *)(skb->data)), RX_DIR, true)) {
                        if ((fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) &&
        if ((frag != 0 || (fc & RTLLIB_FCTL_MOREFRAGS))) {
                int flen;
                struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr);
+
                RTLLIB_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
 
                if (!frag_skb) {
 
 static void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb)
 {
        int nh;
+
        nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM;
 
 /*
                (struct rtllib_hdr_3addr  *) skb->data;
 
        struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + 8);
+
        spin_lock_irqsave(&ieee->lock, flags);
 
        /* called with 2nd param 0, no mgmt lock required */
 static void rtllib_send_beacon(struct rtllib_device *ieee)
 {
        struct sk_buff *skb;
+
        if (!ieee->ieee_up)
                return;
        skb = rtllib_get_beacon_(ieee);
 static void rtllib_send_probe(struct rtllib_device *ieee, u8 is_mesh)
 {
        struct sk_buff *skb;
+
        skb = rtllib_probe_req(ieee);
        if (skb) {
                softmac_mgmt_xmit(skb, ieee);
 static void rtllib_beacons_start(struct rtllib_device *ieee)
 {
        unsigned long flags;
+
        spin_lock_irqsave(&ieee->beacon_lock, flags);
 
        ieee->beacon_txing = 1;
        struct sk_buff *skb;
        struct rtllib_authentication *auth;
        int  len = 0;
+
        len = sizeof(struct rtllib_authentication) + challengelen +
                     ieee->tx_headroom + 4;
        skb = dev_alloc_skb(len);
        struct sk_buff *skb = NULL;
        struct rtllib_authentication *auth;
        int len = ieee->tx_headroom + sizeof(struct rtllib_authentication) + 1;
+
        skb = dev_alloc_skb(len);
        if (!skb)
                return NULL;
 
 static void rtllib_resp_to_probe(struct rtllib_device *ieee, u8 *dest)
 {
-
        struct sk_buff *buf = rtllib_probe_resp(ieee, dest);
+
        if (buf)
                softmac_mgmt_xmit(buf, ieee);
 }
        unsigned int turbo_info_len = beacon->Turbo_Enable ? 9 : 0;
 
        int len = 0;
+
        crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx];
        if (crypt != NULL)
                encrypt = ieee->host_encrypt && crypt && crypt->ops &&
        if (beacon->BssCcxVerNumber >= 2) {
                u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00};
                struct octet_string osCcxVerNum;
+
                CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
                osCcxVerNum.Octet = CcxVerNumBuf;
                osCcxVerNum.Length = sizeof(CcxVerNumBuf);
 
 void rtllib_associate_abort(struct rtllib_device *ieee)
 {
-
        unsigned long flags;
+
        spin_lock_irqsave(&ieee->lock, flags);
 
        ieee->associate_seq++;
 {
        struct rtllib_authentication *a;
        u8 *t;
+
        if (skb->len <  (sizeof(struct rtllib_authentication) -
            sizeof(struct rtllib_info_element))) {
                RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
 void rtllib_rx_probe_rq(struct rtllib_device *ieee, struct sk_buff *skb)
 {
        u8 dest[ETH_ALEN];
+
        ieee->softmac_stats.rx_probe_rq++;
        if (probe_rq_parse(ieee, skb, dest) > 0) {
                ieee->softmac_stats.tx_probe_rs++;
 {
        u8 dest[ETH_ALEN];
        int status;
+
        ieee->softmac_stats.rx_auth_rq++;
 
        status = auth_rq_parse(skb, dest);
                        u8 LPSAwakeIntvl_tmp = 0;
                        u8 period = ieee->current_network.dtim_period;
                        u8 count = ieee->current_network.tim.tim_count;
+
                        if (count == 0) {
                                if (pPSC->LPSAwakeIntvl > period)
                                        LPSAwakeIntvl_tmp = period +
 static void rtllib_resume_tx(struct rtllib_device *ieee)
 {
        int i;
+
        for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags;
             i++) {
 
 void rtllib_stop_all_queues(struct rtllib_device *ieee)
 {
        unsigned int i;
+
        for (i = 0; i < ieee->dev->num_tx_queues; i++)
                netdev_get_tx_queue(ieee->dev, i)->trans_start = jiffies;
 
 void rtllib_start_bss(struct rtllib_device *ieee)
 {
        unsigned long flags;
+
        if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) {
                if (!ieee->bGlobalDomain)
                        return;
 
        struct sk_buff *skb;
        struct rtllib_probe_response *b;
+
        skb = rtllib_probe_resp(ieee, broadcast_addr);
 
        if (!skb)
 void rtllib_softmac_init(struct rtllib_device *ieee)
 {
        int i;
+
        memset(&ieee->current_network, 0, sizeof(struct rtllib_network));
 
        ieee->state = RTLLIB_NOLINK;
        struct sk_buff *skb;
        struct rtllib_disassoc *disass;
        int len = sizeof(struct rtllib_disassoc) + ieee->tx_headroom;
+
        skb = dev_alloc_skb(len);
 
        if (!skb)
 
                             union iwreq_data *wrqu, char *extra)
 {
        u32 tmp_rate = 0;
+
        tmp_rate = TxCountToDataRate(ieee,
                                     ieee->softmac_stats.CurrentShowTxate);
        wrqu->bitrate.value = tmp_rate * 500000;
 
 {
        struct rtllib_txb *txb;
        int i;
+
        txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags),
                      gfp_mask);
        if (!txb)
                return;
        } else {
                struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
+
                while (true) {
                        if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) {
                                tcb_desc->bCTSEnable    = true;
                        }
                        if (pHTInfo->bCurrentHTSupport  && pHTInfo->bEnableHT) {
                                u8 HTOpMode = pHTInfo->CurrentOpMode;
+
                                if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 ||
                                     HTOpMode == 3)) ||
                                     (!pHTInfo->bCurBW40MHz && HTOpMode == 3)) {
                return 0;
        if (IsQoSDataFrame(skb->data)) {
                struct tx_ts_record *pTS = NULL;
+
                if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
                    skb->priority, TX_DIR, true))
                        return 0;
 
                struct ht_capab_ele *ht_cap = NULL;
                bool is40M = false, isShortGI = false;
                u8 max_mcs = 0;
+
                if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4))
                        ht_cap = (struct ht_capab_ele *)
                                 &network->bssht.bdHTCapBuf[4];
        memset(&iwe, 0, sizeof(iwe));
        if (network->wpa_ie_len) {
                char buf[MAX_WPA_IE_LEN];
+
                memcpy(buf, network->wpa_ie, network->wpa_ie_len);
                iwe.cmd = IWEVGENIE;
                iwe.u.data.length = network->wpa_ie_len;
        memset(&iwe, 0, sizeof(iwe));
        if (network->rsn_ie_len) {
                char buf[MAX_WPA_IE_LEN];
+
                memcpy(buf, network->rsn_ie, network->rsn_ie_len);
                iwe.cmd = IWEVGENIE;
                iwe.u.data.length = network->rsn_ie_len;
        memset(&iwe, 0, sizeof(iwe));
        if (network->wzc_ie_len) {
                char buf[MAX_WZC_IE_LEN];
+
                memcpy(buf, network->wzc_ie, network->wzc_ie_len);
                iwe.cmd = IWEVGENIE;
                iwe.u.data.length = network->wzc_ie_len;
        char *stop = ev + wrqu->data.length;
        int i = 0;
        int err = 0;
+
        RTLLIB_DEBUG_WX("Getting scan\n");
        down(&ieee->wx_sem);
        spin_lock_irqsave(&ieee->lock, flags);