hdr = (struct ieee80211_hdr_4addr *) skb->data;
 
-#if 0
-printk("@@ tkey\n");
-printk("%x|", ((u32*)tkey->key)[0]);
-printk("%x|", ((u32*)tkey->key)[1]);
-printk("%x|", ((u32*)tkey->key)[2]);
-printk("%x|", ((u32*)tkey->key)[3]);
-printk("%x|", ((u32*)tkey->key)[4]);
-printk("%x|", ((u32*)tkey->key)[5]);
-printk("%x|", ((u32*)tkey->key)[6]);
-printk("%x\n", ((u32*)tkey->key)[7]);
-#endif
-
        if (!tcb_desc->bHwSec)
        {
                if (!tkey->tx_phase1_done) {
        skb_pull(skb, 8);
        skb_trim(skb, skb->len - 4);
 
-//john's test
-#ifdef JOHN_DUMP
-if( ((u16*)skb->data)[0] & 0x4000){
-        printk("@@ rx decrypted skb->data");
-        int i;
-        for(i=0;i<skb->len;i++){
-                if( (i%24)==0 ) printk("\n");
-                printk("%2x ", ((u8*)skb->data)[i]);
-        }
-        printk("\n");
-}
-#endif /*JOHN_DUMP*/
        return keyidx;
 }
 
 
  * more details.
  */
 
-//#include <linux/config.h>
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/init.h>
 
 #ifdef CONFIG_IEEE80211_DEBUG
 
 u32 ieee80211_debug_level = 0;
-static int debug = \
+static int debug =
        /* IEEE80211_DL_INFO    | */
        /* IEEE80211_DL_WX      | */
        /* IEEE80211_DL_SCAN    | */
 
 
 
 #include <linux/compiler.h>
-//#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
 
        rx_stats->len = skb->len;
        ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats);
-        //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)))
         if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames
         {
                 dev_kfree_skb_any(skb);
                printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
                       ieee->dev->name);
                return 0;
-/*
-  hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
-  skb->data);*/
        }
 
        if (ieee->hostapd && type == IEEE80211_TYPE_MGMT) {
        if (skb->len < 24)
                return 0;
 
-#if 1
         if (ieee->hwsec_active)
         {
                 cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
                 if(ieee->need_sw_enc)
                         tcb_desc->bHwSec = 0;
         }
-#endif
 
        hdr = (struct ieee80211_hdr_4addr *) skb->data;
        fc = le16_to_cpu(hdr->frame_ctl);
                return 0;
 
        /* check for port access entity Ethernet type */
-//     pos = skb->data + 24;
        pos = skb->data + hdrlen;
        ethertype = (pos[6] << 8) | pos[7];
        if (ethertype == ETH_P_PAE)
 
        if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
                return 0;
-#if 1
+
        if (ieee->hwsec_active)
        {
                cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
                tcb_desc->bHwSec = 1;
        }
-#endif
+
        hdr = (struct ieee80211_hdr_4addr *) skb->data;
        hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
 
                struct ieee_ibss_seq *entry = NULL;
                u8 *mac = header->addr2;
                int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE;
-               //for (pos = (head)->next; pos != (head); pos = pos->next)
-               //__list_for_each(p, &ieee->ibss_mac_hash[index]) {
+
                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))
                                break;
                }
-       //      if (memcmp(entry->mac, mac, ETH_ALEN)){
+
                if (p == &ieee->ibss_mac_hash[index]) {
                        entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
                        if (!entry) {
        )
 {
        struct list_head *pList = &pTS->RxPendingPktList;
-#if  1
+
        while(pList->next != &pTS->RxPendingPktList)
        {
                if( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) )
                        break;
                }
        }
-#endif
+
        pReorderEntry->List.next = pList->next;
        pReorderEntry->List.next->prev = &pReorderEntry->List;
        pReorderEntry->List.prev = pList;
 {
        u8 i = 0 , j=0;
        u16 ethertype;
-//     if(index > 1)
-//             IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__FUNCTION__,index);
+
        for(j = 0; j<index; j++)
        {
 //added by amy for reorder
                                memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
                                memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
                        }
-                       //stats->rx_packets++;
-                       //stats->rx_bytes += sub_skb->len;
 
                /* Indicat the packets to upper layer */
                        if (sub_skb) {
                                memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
                                sub_skb->dev = ieee->dev;
                                sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
-                               //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
                                ieee->last_rx_ps_time = jiffies;
                                netif_rx(sub_skb);
                        }
        u8                      index = 0;
        bool                    bMatchWinStart = false, bPktInBuf = false;
        IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__,SeqNum,pTS->RxIndicateSeq,WinSize);
-#if 0
-       if(!list_empty(&ieee->RxReorder_Unused_List))
-               IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): ieee->RxReorder_Unused_List is nut NULL\n");
-#endif
+
        /* Rx Reorder initialize condition.*/
        if(pTS->RxIndicateSeq == 0xffff) {
                pTS->RxIndicateSeq = SeqNum;
                index = 1;
        } else {
                /* Current packet is going to be inserted into pending list.*/
-               //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to orderd list\n",__FUNCTION__);
                if(!list_empty(&ieee->RxReorder_Unused_List)) {
                        pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List);
                        list_del_init(&pReorderEntry->List);
                        /* Make a reorder entry and insert into a the packet list.*/
                        pReorderEntry->SeqNum = SeqNum;
                        pReorderEntry->prxb = prxb;
-       //              IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
 
-#if 1
                        if(!AddReorderEntry(pTS, pReorderEntry)) {
                                IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
                                        __FUNCTION__, pTS->RxIndicateSeq, SeqNum);
                                IEEE80211_DEBUG(IEEE80211_DL_REORDER,
                                         "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
                        }
-#endif
                }
                else {
                        /*
                bPktInBuf = false;
        }
 
-#if 1
        if(bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) {
                // Set new pending timer.
                IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __FUNCTION__);
                pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
-#if 0
-               if(timer_pending(&pTS->RxPktPendingTimer))
-                       del_timer_sync(&pTS->RxPktPendingTimer);
-               pTS->RxPktPendingTimer.expires = jiffies + MSECS(pHTInfo->RxReorderPendingTime);
-               add_timer(&pTS->RxPktPendingTimer);
-#else
+
                mod_timer(&pTS->RxPktPendingTimer,  jiffies + MSECS(pHTInfo->RxReorderPendingTime));
-#endif
        }
-#endif
 }
 
 u8 parse_subframe(struct ieee80211_device* ieee,struct sk_buff *skb,
                        nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8);
 
                        if(skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) {
-#if 0//cosa
-                               RT_ASSERT(
-                                               (nRemain_Length>=(ETHERNET_HEADER_SIZE + nSubframe_Length)),
-                                               ("ParseSubframe(): A-MSDU subframe parse error!! Subframe Length: %d\n", nSubframe_Length) );
-#endif
                                printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
                                                __FUNCTION__,rxb->nr_subframes);
                                printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__, nSubframe_Length);
 {
        struct net_device *dev = ieee->dev;
        struct ieee80211_hdr_4addr *hdr;
-       //struct ieee80211_hdr_3addrqos *hdr;
 
        size_t hdrlen;
        u16 fc, type, stype, sc;
        u16     SeqNum = 0;
        PRX_TS_RECORD pTS = NULL;
        bool unicast_packet = false;
-       //bool bIsAggregateFrame = false;
        //added by amy for reorder
 #ifdef NOT_YET
        struct net_device *wds = NULL;
        int from_assoc_ap = 0;
        void *sta = NULL;
 #endif
-//     u16 qos_ctl = 0;
        u8 dst[ETH_ALEN];
        u8 src[ETH_ALEN];
        u8 bssid[ETH_ALEN];
                rx_stats->bContainHTC = 1;
        }
 
-       //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
 #ifdef NOT_YET
 #if WIRELESS_EXT > 15
        /* Put this code here so that we avoid duplicating it in all
        else
        {
                PRX_TS_RECORD pRxTS = NULL;
-       #if 0
-               struct ieee80211_hdr_3addr *hdr;
-               u16 fc;
-               hdr = (struct ieee80211_hdr_3addr *)skb->data;
-               fc = le16_to_cpu(hdr->frame_ctl);
-               u8 tmp = (fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS);
-
-               u8 tid = (*((u8*)skb->data + (((fc& IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))?30:24)))&0xf;
-               printk("====================>fc:%x, tid:%d, tmp:%d\n", fc, tid, tmp);
-               //u8 tid =  (u8)((frameqos*)(buf + ((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24))->field.tid;
-       #endif
-                       //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__FUNCTION__, tid);
-#if 1
+
                if(GetTs(
                                ieee,
                                (PTS_COMMON_INFO*) &pRxTS,
                                true))
                {
 
-               //      IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
                        if(     (fc & (1<<11))  &&
                                        (frag == pRxTS->RxLastFragNum) &&
                                        (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)   )
                        goto rx_dropped;
                }
        }
-#endif
-       if (type == IEEE80211_FTYPE_MGMT) {
 
-       #if 0
-               if ( stype == IEEE80211_STYPE_AUTH &&
-                   fc & IEEE80211_FCTL_WEP && ieee->host_decrypt &&
-                   (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0)
-               {
-                       printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
-                              "from %pM\n", dev->name,
-                              hdr->addr2);
-                       /* TODO: could inform hostapd about this so that it
-                        * could send auth failure report */
-                       goto rx_dropped;
-               }
-       #endif
+       if (type == IEEE80211_FTYPE_MGMT) {
 
-       //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
                if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
                        goto rx_dropped;
                else
                }
        }
 #endif
-       //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
        /* Nullfunc frames may have PS-bit set, so they must be passed to
         * hostap_handle_sta_rx() before being dropped here. */
        if (stype != IEEE80211_STYPE_DATA &&
                        hdr->addr2);
                goto rx_dropped;
        }
-/*
-       if(ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
-               printk(KERN_WARNING "RX: IEEE802.1X EPAOL frame!\n");
-       }
-*/
 //added by amy for reorder
-#if 1
        if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
                && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1))
        {
                        ieee->bis_any_nonbepkts = true;
                }
        }
-#endif
+
 //added by amy for reorder
        /* skb: hdr + (possible reassembled) full plaintext payload */
        payload = skb->data + hdrlen;
-       //ethertype = (payload[6] << 8) | payload[7];
+
        rxb = kmalloc(sizeof(struct ieee80211_rxb), GFP_ATOMIC);
        if(rxb == NULL)
        {
                                        ieee->LinkDetectInfo.NumRxUnicastOkInPeriod++;
 
                                // 2009.03.03 Leave DC mode immediately when detect high traffic
-                               // DbgPrint("ending Seq %d\n", Frame_SeqNum(pduOS));
                                if((ieee->state == IEEE80211_LINKED) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/)
                                {
                                        if(     ((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +ieee->LinkDetectInfo.NumTxOkInPeriod) > 8 ) ||
                                memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
                                sub_skb->dev = dev;
                                sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
-                               //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
                                netif_rx(sub_skb);
                        }
                }
         int i;
         struct ieee80211_qos_ac_parameter *ac_params;
        u8 aci;
-        //u8 cw_min;
-        //u8 cw_max;
 
         for (i = 0; i < QOS_QUEUE_NUM; i++) {
                 ac_params = &(param_elm->ac_params_record[i]);
        u16     tmp_htinfo_len=0;
        u16 ht_realtek_agg_len=0;
        u8  ht_realtek_agg_buf[MAX_IE_LEN];
-//     u16 broadcom_len = 0;
 #ifdef CONFIG_IEEE80211_DEBUG
        char rates_str[64];
        char *p;
                         network->dtim_period = info_element->data[1];
                         if(ieee->state != IEEE80211_LINKED)
                                 break;
-#if 0
-                        network->last_dtim_sta_time[0] = stats->mac_time[0];
-#else
                        //we use jiffies for legacy Power save
                        network->last_dtim_sta_time[0] = jiffies;
-#endif
                         network->last_dtim_sta_time[1] = stats->mac_time[1];
 
                         network->dtim_data = IEEE80211_DTIM_VALID;
 
                        }
 
-                       //if(tmp_htcap_len !=0  ||  tmp_htinfo_len != 0)
-                       {
                                if((info_element->len >= 3 &&
                                         info_element->data[0] == 0x00 &&
                                         info_element->data[1] == 0x05 &&
                                                network->broadcom_cap_exist = true;
 
                                }
-                       }
-#if 0
-                       if (tmp_htcap_len !=0)
-                               {
-                                       u16 cap_ext = ((PHT_CAPABILITY_ELE)&info_element->data[0])->ExtHTCapInfo;
-                                       if ((cap_ext & 0x0c00) == 0x0c00)
-                                               {
-                                                       network->ralink_cap_exist = true;
-                                               }
-                               }
-#endif
+
                        if(info_element->len >= 3 &&
                                info_element->data[0] == 0x00 &&
                                info_element->data[1] == 0x0c &&
                        ieee80211_extract_country_ie(ieee, info_element, network, network->bssid);//addr2 is same as addr3 when from an AP
                        break;
 #endif
-/* TODO */
-#if 0
-                       /* 802.11h */
-               case MFIE_TYPE_POWER_CONSTRAINT:
-                       network->power_constraint = info_element->data[0];
-                       network->flags |= NETWORK_HAS_POWER_CONSTRAINT;
-                       break;
 
-               case MFIE_TYPE_CSA:
-                       network->power_constraint = info_element->data[0];
-                       network->flags |= NETWORK_HAS_CSA;
-                       break;
-
-               case MFIE_TYPE_QUIET:
-                       network->quiet.count = info_element->data[0];
-                       network->quiet.period = info_element->data[1];
-                       network->quiet.duration = info_element->data[2];
-                       network->quiet.offset = info_element->data[3];
-                       network->flags |= NETWORK_HAS_QUIET;
-                       break;
-
-               case MFIE_TYPE_IBSS_DFS:
-                       if (network->ibss_dfs)
-                               break;
-                       network->ibss_dfs = kmemdup(info_element->data,
-                                                   info_element->len,
-                                                   GFP_ATOMIC);
-                       if (!network->ibss_dfs)
-                               return 1;
-                       network->flags |= NETWORK_HAS_IBSS_DFS;
-                       break;
-
-               case MFIE_TYPE_TPC_REPORT:
-                       network->tpc_report.transmit_power =
-                           info_element->data[0];
-                       network->tpc_report.link_margin = info_element->data[1];
-                       network->flags |= NETWORK_HAS_TPC_REPORT;
-                       break;
-#endif
                default:
                        IEEE80211_DEBUG_MGMT
                            ("Unsupported info element: %s (%d)\n",
        {
                RetSS = CurrSS;
        }
-       //RT_TRACE(COMP_DBG, DBG_LOUD, ("##### After Mapping:  LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
-
-       // Step 2. Smoothing.
-
-       //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing:  LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
 
        return RetSS;
 }
        struct ieee80211_network *network,
        struct ieee80211_rx_stats *stats)
 {
-#ifdef CONFIG_IEEE80211_DEBUG
-       //char rates_str[64];
-       //char *p;
-#endif
-
         network->qos_data.active = 0;
         network->qos_data.supported = 0;
         network->qos_data.param_count = 0;
        memset(network->CountryIeBuf, 0, MAX_IE_LEN);
 #endif
 //Initialize HT parameters
-       //ieee80211_ht_initialize(&network->bssht);
        HTInitializeBssDesc(&network->bssht);
        if (stats->freq == IEEE80211_52GHZ_BAND) {
                /* for A band (No DS info) */
        if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
                network->flags |= NETWORK_EMPTY_ESSID;
 
-#if 1
        stats->signal = 30 + (stats->SignalStrength * 70) / 100;
-       //stats->signal = ieee80211_SignalStrengthTranslate(stats->signal);
        stats->noise = ieee80211_translate_todbm((u8)(100-stats->signal)) -25;
-#endif
 
        memcpy(&network->stats, stats, sizeof(network->stats));
 
         * and the capability field (in particular IBSS and BSS) all match.
         * We treat all <hidden> with the same BSSID and channel
         * as one network */
-       return //((src->ssid_len == dst->ssid_len) &&
-               (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
+       return (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
                (src->channel == dst->channel) &&
                !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
-               //!memcmp(src->ssid, dst->ssid, src->ssid_len) &&
                (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
                ((src->capability & WLAN_CAPABILITY_IBSS) ==
                (dst->capability & WLAN_CAPABILITY_IBSS)) &&
 
        dst->last_scanned = jiffies;
        /* qos related parameters */
-       //qos_active = src->qos_data.active;
        qos_active = dst->qos_data.active;
-       //old_param = dst->qos_data.old_param_count;
        old_param = dst->qos_data.param_count;
        if(dst->flags & NETWORK_HAS_QOS_MASK){
         //not update QOS paramter in beacon, as most AP will set all these parameter to 0.//WB
        dst->qos_data.old_param_count = old_param;
 
        /* dst->last_associate is not overwritten */
-#if 1
        dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame.
        if(src->wmm_param[0].ac_aci_acm_aifsn|| \
           src->wmm_param[1].ac_aci_acm_aifsn|| \
           src->wmm_param[3].ac_aci_acm_aifsn) {
          memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
        }
-       //dst->QoS_Enable = src->QoS_Enable;
-#else
-       dst->QoS_Enable = 1;//for Rtl8187 simulation
-#endif
 #ifdef THOMAS_TURBO
        dst->Turbo_Enable = src->Turbo_Enable;
 #endif
 #endif
        unsigned long flags;
        short renew;
-       //u8 wmm_info;
 
        memset(&network, 0, sizeof(struct ieee80211_network));
        IEEE80211_DEBUG_SCAN(
                      struct ieee80211_hdr_4addr *header,
                      struct ieee80211_rx_stats *stats)
 {
-#if 0
-       if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
-                               ieee->iw_mode == IW_MODE_INFRA &&
-                               ieee->state == IEEE80211_LINKED))
-       {
-               tasklet_schedule(&ieee->ps_task);
-       }
-#endif
-
        if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
                WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
                ieee->last_rx_ps_time = jiffies;
 
  */
        ieee->mgmt_queue_head = nh;
        ieee->mgmt_queue_ring[nh] = skb;
-
-       //return 0;
 }
 
 struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
                        rate = 0x02;
        }
 
-       /*
-       // Data rate of ProbeReq is already decided. Annie, 2005-03-31
-       if( pMgntInfo->bScanInProgress || (pMgntInfo->bDualModeScanStep!=0) )
-       {
-       if(pMgntInfo->dot11CurrentWirelessMode==WIRELESS_MODE_A)
-       rate = 0x0c;
-       else
-       rate = 0x02;
-       }
-        */
        return rate;
 }
 
                                ieee->seq_ctrl[0]++;
 
                        /* avoid watchdog triggers */
-       //              ieee->dev->trans_start = jiffies;
                        ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
-                       //dev_kfree_skb_any(skb);//edit by thomas
                }
 
                spin_unlock_irqrestore(&ieee->lock, flags);
                        skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb);
                } else {
                        ieee->softmac_hard_start_xmit(skb,ieee->dev);
-                       //dev_kfree_skb_any(skb);//edit by thomas
                }
                spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
        }
                        ieee->seq_ctrl[0]++;
 
                /* avoid watchdog triggers */
-       //      ieee->dev->trans_start = jiffies;
                ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
 
        }else{
                ieee->softmac_hard_start_xmit(skb,ieee->dev);
 
        }
-       //dev_kfree_skb_any(skb);//edit by thomas
 }
 
 inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
        struct sk_buff *skb;
        if(!ieee->ieee_up)
                return;
-       //unsigned long flags;
+
        skb = ieee80211_get_beacon_(ieee);
 
        if (skb){
                softmac_mgmt_xmit(skb, ieee);
                ieee->softmac_stats.tx_beacons++;
-               //dev_kfree_skb_any(skb);//edit by thomas
        }
-//     ieee->beacon_timer.expires = jiffies +
-//             (MSECS( ieee->current_network.beacon_interval -5));
 
-       //spin_lock_irqsave(&ieee->beacon_lock,flags);
        if(ieee->beacon_txing && ieee->ieee_up){
-//             if(!timer_pending(&ieee->beacon_timer))
-//                     add_timer(&ieee->beacon_timer);
                mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5)));
        }
-       //spin_unlock_irqrestore(&ieee->beacon_lock,flags);
 }
 
 
        if (skb){
                softmac_mgmt_xmit(skb, ieee);
                ieee->softmac_stats.tx_probe_rq++;
-               //dev_kfree_skb_any(skb);//edit by thomas
        }
 }
 
 
 void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
 {
-//     unsigned long flags;
-
-       //ieee->sync_scan_hurryup = 1;
-
        down(&ieee->scan_sem);
-//     spin_lock_irqsave(&ieee->lock, flags);
 
        if (ieee->scanning == 1){
                ieee->scanning = 0;
                cancel_delayed_work(&ieee->softmac_scan_wq);
        }
 
-//     spin_unlock_irqrestore(&ieee->lock, flags);
        up(&ieee->scan_sem);
 }
 
        memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
        memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
 
-       //auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
        if(ieee->auth_mode == 0)
                auth->algorithm = WLAN_AUTH_OPEN;
        else if(ieee->auth_mode == 1)
        else
                atim_len = 0;
 
-#if 1
        if(ieee80211_is_54g(ieee->current_network))
                erp_len = 3;
        else
                erp_len = 0;
-#else
-      if((ieee->current_network.mode == IEEE_G)
-               ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) {
-               erp_len = 3;
-               erpinfo_content = 0;
-               if(ieee->current_network.buseprotection)
-                       erpinfo_content |= ERP_UseProtection;
-       }
-       else
-               erp_len = 0;
-#endif
-
 
        crypt = ieee->crypt[ieee->tx_keyidx];
 
        encrypt = ieee->host_encrypt && crypt && crypt->ops &&
                ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len));
        //HT ralated element
-#if 1
+
        tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap);
        tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
        tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo);
                tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer);
                HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len);
         }
-#endif
+
        beacon_size = sizeof(struct ieee80211_probe_response)+2+
                ssid_len
                +3 //channel
                +atim_len
                +erp_len
                 +wpa_ie_len
-       //      +tmp_ht_cap_len
-       //      +tmp_ht_info_len
-       //      +tmp_generic_ie_len
-//             +wmm_len+2
                +ieee->tx_headroom;
        skb = dev_alloc_skb(beacon_size);
        if (!skb)
                cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
 
        crypt = ieee->crypt[ieee->tx_keyidx];
-#if 0
-       encrypt = ieee->host_encrypt && crypt && crypt->ops &&
-               (0 == strcmp(crypt->ops->name, "WEP"));
-#endif
        if (encrypt)
                beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
 
        u16 val16;
                *(tag++) = MFIE_TYPE_IBSS_SET;
                *(tag++) = 2;
-               //*((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
                 val16 = cpu_to_le16(ieee->current_network.atim_window);
                memcpy((u8 *)tag, (u8 *)&val16, 2);
                tag+=2;
                *(tag++) = 1;
                *(tag++) = erpinfo_content;
        }
-#if 0
-       //Include High Throuput capability
-
-       *(tag++) = MFIE_TYPE_HT_CAP;
-       *(tag++) = tmp_ht_cap_len - 2;
-       memcpy(tag, tmp_ht_cap_buf, tmp_ht_cap_len - 2);
-       tag += tmp_ht_cap_len - 2;
-#endif
        if(rate_ex_len){
                *(tag++) = MFIE_TYPE_RATES_EX;
                *(tag++) = rate_ex_len-2;
                tag+=rate_ex_len-2;
        }
 
-#if 0
-       //Include High Throuput info
-
-       *(tag++) = MFIE_TYPE_HT_INFO;
-       *(tag++) = tmp_ht_info_len - 2;
-       memcpy(tag, tmp_ht_info_buf, tmp_ht_info_len -2);
-       tag += tmp_ht_info_len - 2;
-#endif
        if (wpa_ie_len)
        {
                if (ieee->iw_mode == IW_MODE_ADHOC)
                tag += wpa_ie_len;
        }
 
-#if 0
-       //
-       // Construct Realtek Proprietary Aggregation mode (Set AMPDU Factor to 2, 32k)
-       //
-       if(pHTInfo->bRegRT2RTAggregation)
-       {
-               (*tag++) = 0xdd;
-               (*tag++) = tmp_generic_ie_len - 2;
-               memcpy(tag,tmp_generic_ie_buf,tmp_generic_ie_len -2);
-               tag += tmp_generic_ie_len -2;
-
-       }
-#endif
-#if 0
-       if(ieee->qos_support)
-       {
-               (*tag++) = 0xdd;
-               (*tag++) = wmm_len;
-               memcpy(tag,QosOui,wmm_len);
-               tag += wmm_len;
-       }
-#endif
-       //skb->dev = ieee->dev;
        return skb;
 }
 
 inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
 {
        struct sk_buff *skb;
-       //unsigned long flags;
-
        struct ieee80211_assoc_request_frame *hdr;
-       u8 *tag;//,*rsn_ie;
-       //short info_addr = 0;
-       //int i;
-       //u16 suite_count = 0;
-       //u8 suit_select = 0;
-       //unsigned int wpa_len = beacon->wpa_ie_len;
-       //for HT
+       u8 *tag;
        u8* ht_cap_buf = NULL;
        u8 ht_cap_len=0;
        u8* realtek_ie_buf=NULL;
                        ieee->associate_timer.expires = jiffies + (HZ / 2);
                        add_timer(&ieee->associate_timer);
                }
-               //dev_kfree_skb_any(skb);//edit by thomas
        }
 }
 
        u8 *c;
        struct sk_buff *skb;
        struct ieee80211_network *beacon = &ieee->current_network;
-//     int hlen = sizeof(struct ieee80211_authentication);
 
        ieee->associate_seq++;
        ieee->softmac_stats.tx_auth_rq++;
 
                softmac_mgmt_xmit(skb, ieee);
                mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
-#if 0
-               ieee->associate_timer.expires = jiffies + (HZ / 2);
-               add_timer(&ieee->associate_timer);
-#endif
-               //dev_kfree_skb_any(skb);//edit by thomas
        }
        kfree(challenge);
 }
        else{
                softmac_mgmt_xmit(skb, ieee);
                mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
-#if 0
-               ieee->associate_timer.expires = jiffies + (HZ / 2);
-               add_timer(&ieee->associate_timer);
-#endif
-               //dev_kfree_skb_any(skb);//edit by thomas
        }
 }
 void ieee80211_associate_complete_wq(struct work_struct *work)
        {
                printk("Successfully associated, ht not enabled(%d, %d)\n", ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT);
                memset(ieee->dot11HTOperationalRateSet, 0, 16);
-               //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
        }
        ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500);
        // To prevent the immediately calling watch_dog after association.
 
 void ieee80211_associate_complete(struct ieee80211_device *ieee)
 {
-//     int i;
-//     struct net_device* dev = ieee->dev;
        del_timer_sync(&ieee->associate_timer);
 
-#if 0
-       for(i = 0; i < 6; i++) {
-         ieee->seq_ctrl[i] = 0;
-       }
-#endif
        ieee->state = IEEE80211_LINKED;
-#if 0
-       if (ieee->pHTInfo->bCurrentHTSupport)
-       {
-               printk("Successfully associated, ht enabled\n");
-               queue_work(ieee->wq, &ieee->ht_onAssRsp);
-       }
-       else
-       {
-               printk("Successfully associated, ht not enabled\n");
-               memset(ieee->dot11HTOperationalRateSet, 0, 16);
-               HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
-       }
-#endif
-       //ieee->UpdateHalRATRTableHandler(dev, ieee->dot11HTOperationalRateSet);
        queue_work(ieee->wq, &ieee->associate_complete_wq);
 }
 
 
        ieee80211_stop_scan(ieee);
        printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel);
-       //ieee->set_chan(ieee->dev, ieee->current_network.channel);
        HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
 
 #ifdef ENABLE_IPS
                 * This could be obtained by beacons or, if the network does not
                 * broadcast it, it can be put manually.
                 */
-               apset = ieee->wap_set;//(memcmp(ieee->current_network.bssid, zero,ETH_ALEN)!=0 );
-               ssidset = ieee->ssid_set;//ieee->current_network.ssid[0] != '\0';
+               apset = ieee->wap_set;
+               ssidset = ieee->ssid_set;
                ssidbroad =  !(net->ssid_len == 0 || net->ssid[0]== '\0');
                apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
                ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\
                                }
                                printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT);
 
-                               //ieee->pHTInfo->IOTAction = 0;
                                HTResetIOTSetting(ieee->pHTInfo);
                                if (ieee->iw_mode == IW_MODE_INFRA){
                                        /* Join the network for the first time */
                                        ieee->AsocRetryCount = 0;
                                        //for HT by amy 080514
                                        if((ieee->current_network.qos_data.supported == 1) &&
-                                         // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT))
                                           ieee->current_network.bssht.bdSupportHT)
 /*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/
                                        {
-                                       //      ieee->pHTInfo->bCurrentHTSupport = true;
                                                HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network));
                                        }
                                        else
                                                printk(KERN_INFO"Using B rates\n");
                                        }
                                        memset(ieee->dot11HTOperationalRateSet, 0, 16);
-                                       //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
                                        ieee->state = IEEE80211_LINKED;
                                }
 
                tag++; /* point to the next tag */
        }
 
-       //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
        if (ssidlen == 0) return 1;
 
        if (!ssid) return 1; /* ssid not found in tagged param */
 {
        u8 dest[ETH_ALEN];
 
-       //IEEE80211DMESG("Rx probe");
        ieee->softmac_stats.rx_probe_rq++;
-       //DMESG("Dest is "MACSTR, MAC2STR(dest));
        if (probe_rq_parse(ieee, skb, dest)){
-               //IEEE80211DMESG("Was for me!");
                ieee->softmac_stats.tx_probe_rs++;
                ieee80211_resp_to_probe(ieee, dest);
        }
 {
        u8 dest[ETH_ALEN];
        int status;
-       //IEEE80211DMESG("Rx probe");
        ieee->softmac_stats.rx_auth_rq++;
 
        status = auth_rq_parse(skb, dest);
        if (status != -1) {
                ieee80211_resp_to_auth(ieee, status, dest);
        }
-       //DMESG("Dest is "MACSTR, MAC2STR(dest));
-
 }
 
 static inline void
 ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
 {
-
        u8 dest[ETH_ALEN];
-       //unsigned long flags;
 
        ieee->softmac_stats.rx_ass_rq++;
        if (assoc_rq_parse(skb,dest) != -1){
        }
 
        printk(KERN_INFO"New client associated: %pM\n", dest);
-       //FIXME
-       #if 0
-       spin_lock_irqsave(&ieee->lock,flags);
-       add_associate(ieee,dest);
-       spin_unlock_irqrestore(&ieee->lock,flags);
-       #endif
 }
 
 
 
                        if(pPSC->LPSAwakeIntvl == 0)
                                pPSC->LPSAwakeIntvl = 1;
-                       //pNdisCommon->RegLPSMaxIntvl /// 0x0 - eFastPs, 0xFF -DTIM, 0xNN - 0xNN * BeaconIntvl
                        if(pPSC->RegMaxLPSAwakeIntvl == 0) // Default (0x0 - eFastPs, 0xFF -DTIM, 0xNN - 0xNN * BeaconIntvl)
                                MaxPeriod = 1; // 1 Beacon interval
                        else if(pPSC->RegMaxLPSAwakeIntvl == 0xFF) // DTIM
                                if(pPSC->LPSAwakeIntvl > ieee->current_network.tim.tim_count)
                                        LPSAwakeIntvl_tmp = count + (pPSC->LPSAwakeIntvl - count) -((pPSC->LPSAwakeIntvl-count)%period);
                                else
-                                       LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;//ieee->current_network.tim.tim_count;//pPSC->LPSAwakeIntvl;
+                                       LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;
                        }
 
                *time_l = ieee->current_network.last_dtim_sta_time[0]
                        + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp);
-               //      * ieee->current_network.dtim_period) * 1000;
        }
        }
 
        struct ieee80211_hdr* header = (struct ieee80211_hdr*)skb->data;
        u8* act = ieee80211_get_payload(header);
        u8 tmp = 0;
-//     IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
+
        if (act == NULL)
        {
                IEEE80211_DEBUG(IEEE80211_DL_ERR, "error to get payload of action frame\n");
                        ieee80211_rx_DELBA(ieee, skb);
                        break;
                default:
-//                     if (net_ratelimit())
-//                     IEEE80211_DEBUG(IEEE80211_DL_BA, "unknown action frame(%d)\n", tmp);
                        break;
        }
        return;
        int chlen=0;
        int aid;
        struct ieee80211_assoc_response_frame *assoc_resp;
-//     struct ieee80211_info_element *info_element;
        bool bSupportNmode = true, bHalfSupportNmode = false; //default support N mode, disable halfNmode
 
        if(!ieee->proto_started)
                return 0;
-#if 0
-       printk("%d, %d, %d, %d\n", ieee->sta_sleep, ieee->ps, ieee->iw_mode, ieee->state);
-       if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
-               ieee->iw_mode == IW_MODE_INFRA &&
-               ieee->state == IEEE80211_LINKED))
-
-               tasklet_schedule(&ieee->ps_task);
-
-       if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
-               WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
-               ieee->last_rx_ps_time = jiffies;
-#endif
 
        switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
 
                                ieee->softmac_stats.reassoc++;
                                ieee->is_roaming = true;
                                ieee80211_disassociate(ieee);
-                       //      notify_wx_assoc_event(ieee);
-                               //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
                                RemovePeerTS(ieee, header->addr2);
                                queue_work(ieee->wq, &ieee->associate_procedure_wq);
                        }
                        break;
        }
 
-       //dev_kfree_skb_any(skb);
        return 0;
 }
 
        ieee80211_sta_wakeup(ieee,0);
 
        /* update the tx status */
-//     ieee->stats.tx_bytes += txb->payload_size;
-//     ieee->stats.tx_packets++;
        tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
        if(tcb_desc->bMulticast) {
                ieee->stats.multicast++;
        }
-#if 1
+
        /* if xmit available, just xmit it immediately, else just insert it to the wait queue */
        for(i = 0; i < txb->nr_frags; i++) {
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
                        /* as for the completion function, it does not need
                         * to check it any more.
                         * */
-                       //ieee80211_rtl_stop_queue(ieee);
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
                        skb_queue_tail(&ieee->skb_drv_aggQ[queue_index], txb->fragments[i]);
 #else
                        ieee->softmac_data_hard_start_xmit(
                                        txb->fragments[i],
                                        ieee->dev,ieee->rate);
-                       //ieee->stats.tx_packets++;
-                       //ieee->stats.tx_bytes += txb->fragments[i]->len;
-                       //ieee->dev->trans_start = jiffies;
                }
        }
-#endif
+
        ieee80211_txb_free(txb);
 
-//exit:
        spin_unlock_irqrestore(&ieee->lock,flags);
 
 }
                        ieee->softmac_data_hard_start_xmit(
                                ieee->tx_pending.txb->fragments[i],
                                ieee->dev,ieee->rate);
-                               //(i+1)<ieee->tx_pending.txb->nr_frags);
                        ieee->stats.tx_packets++;
-               //      ieee->dev->trans_start = jiffies;
                }
        }
 
                                ieee->seq_ctrl[0]++;
 
                        ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
-                       //dev_kfree_skb_any(skb);//edit by thomas
                }
        }
        if (!ieee->queue_stop && ieee->tx_pending.txb)
 
 void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee)
 {
-       //unsigned long flags;
-       //spin_lock_irqsave(&ieee->lock,flags);
-
        if (! netif_queue_stopped(ieee->dev)){
                netif_stop_queue(ieee->dev);
                ieee->softmac_stats.swtxstop++;
        }
        ieee->queue_stop = 1;
-       //spin_unlock_irqrestore(&ieee->lock,flags);
-
 }
 
 
 
 
 #ifdef ENABLE_DOT11D //if creating an ad-hoc, set its channel to 10 temporarily--this is the requirement for ASUS, not 11D, so disable 11d.
-//     if((IS_DOT11D_ENABLE(ieee)) && (ieee->state == IEEE80211_NOLINK))
        if (ieee->state == IEEE80211_NOLINK)
                ieee->current_network.channel = 6;
 #endif
 #endif
        ieee->is_set_key = false;
        ieee->link_change(ieee->dev);
-       //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
        if (ieee->state == IEEE80211_LINKED ||
            ieee->state == IEEE80211_ASSOCIATING) {
                ieee->state = IEEE80211_NOLINK;
 
        if (ieee->set_security)
                ieee->set_security(ieee->dev, &sec);
-       //else
-       //      ret = -EOPNOTSUPP;
 
        return ret;
 }
 
        //NM 0.7.0 will not accept channel any more.
        fwrq->m = ieee80211_wlan_frequencies[ieee->current_network.channel-1] * 100000;
        fwrq->e = 1;
-//     fwrq->m = ieee->current_network.channel;
-//     fwrq->e = 0;
 
        return 0;
 }
                             union iwreq_data *wrqu, char *extra)
 {
        u32 tmp_rate;
-#if 0
-       printk("===>mode:%d, halfNmode:%d\n", ieee->mode, ieee->bHalfWirelessN24GMode);
-       if (ieee->mode & (IEEE_A | IEEE_B | IEEE_G))
-               tmp_rate = ieee->rate;
-       else if (ieee->mode & IEEE_N_5G)
-               tmp_rate = 580;
-       else if (ieee->mode & IEEE_N_24G)
-       {
-               if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
-                       tmp_rate = HTHalfMcsToDataRate(ieee, 15);
-               else
-                       tmp_rate = HTMcsToDataRate(ieee, 15);
-       }
-#else
        tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate);
 
-#endif
        wrqu->bitrate.value = tmp_rate * 500000;
 
        return 0;
                                 union iwreq_data *wrqu, char *extra)
 {
        int ret = 0;
-#if 1
+
        if(
                (!ieee->sta_wake_up) ||
-       //      (!ieee->ps_request_tx_ack) ||
                (!ieee->enter_sleep_state) ||
                (!ieee->ps_is_queue_empty)){
 
                return -1;
        }
-#endif
+
        down(&ieee->wx_sem);
 
        if (wrqu->power.disabled){
                goto exit;
        }
        if (wrqu->power.flags & IW_POWER_TIMEOUT) {
-               //ieee->ps_period = wrqu->power.value / 1000;
                ieee->ps_timeout = wrqu->power.value / 1000;
        }
 
        if (wrqu->power.flags & IW_POWER_PERIOD) {
-
-               //ieee->ps_timeout = wrqu->power.value / 1000;
                ieee->ps_period = wrqu->power.value / 1000;
-               //wrq->value / 1024;
-
        }
        switch (wrqu->power.flags & IW_POWER_MODE) {
        case IW_POWER_UNICAST_R:
                break;
 
        case IW_POWER_ON:
-       //      ieee->ps = IEEE80211_PS_DISABLED;
                break;
 
        default:
                wrqu->power.flags = IW_POWER_TIMEOUT;
                wrqu->power.value = ieee->ps_timeout * 1000;
        } else {
-//             ret = -EOPNOTSUPP;
-//             goto exit;
                wrqu->power.flags = IW_POWER_PERIOD;
                wrqu->power.value = ieee->ps_period * 1000;
-//ieee->current_network.dtim_period * ieee->current_network.beacon_interval * 1024;
        }
 
        if ((ieee->ps & (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) == (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST))
 
 ******************************************************************************/
 
 #include <linux/compiler.h>
-//#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
 
 
 void ieee80211_txb_free(struct ieee80211_txb *txb) {
-       //int i;
        if (unlikely(!txb))
                return;
-#if 0
-       for (i = 0; i < txb->nr_frags; i++)
-               if (txb->fragments[i])
-                       dev_kfree_skb_any(txb->fragments[i]);
-#endif
        kfree(txb);
 }
 
                                const struct iphdr *ip = (struct iphdr *)((u8 *)skb->data+14);
                                if (IPPROTO_UDP == ip->protocol) {//FIXME windows is 11 but here UDP in linux kernel is 17.
                                        struct udphdr *udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
-                                       //if(((ntohs(udp->source) == 68) && (ntohs(udp->dest) == 67)) ||
-                                       ///   ((ntohs(udp->source) == 67) && (ntohs(udp->dest) == 68))) {
                                        if(((((u8 *)udp)[1] == 68) && (((u8 *)udp)[3] == 67)) ||
                                                        ((((u8 *)udp)[1] == 67) && (((u8 *)udp)[3] == 68))) {
                                                // 68 : UDP BOOTP client
                                                // 67 : UDP BOOTP server
                                                printk("DHCP pkt src port:%d, dest port:%d!!\n", ((u8 *)udp)[1],((u8 *)udp)[3]);
-                                               // Use low rate to send DHCP packet.
-                                               //if(pMgntInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom)
-                                               //{
-                                               //      tcb_desc->DataRate = MgntQuery_TxRateExcludeCCKRates(ieee);//0xc;//ofdm 6m
-                                               //      tcb_desc->bTxDisableRateFallBack = false;
-                                               //}
-                                               //else
-                                               //pTcb->DataRate = Adapter->MgntInfo.LowestBasicRate;
-                                               //RTPRINT(FDM, WA_IOT, ("DHCP TranslateHeader(), pTcb->DataRate = 0x%x\n", pTcb->DataRate));
 
                                                bdhcp = true;
 #ifdef _RTL8192_EXT_PATCH_
                                        bdhcp = true;
                                        ieee->LPSDelayCnt = ieee->current_network.tim.tim_count;
 
-                                       //if(pMgntInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom)
-                                       //{
-                                       //      tcb_desc->DataRate = MgntQuery_TxRateExcludeCCKRates(Adapter->MgntInfo.mBrates);//0xc;//ofdm 6m
-                                       //      tcb_desc->bTxDisableRateFallBack = FALSE;
-                                       //}
-                                       //else
-                                       //      tcb_desc->DataRate = Adapter->MgntInfo.LowestBasicRate;
-                                       //RTPRINT(FDM, WA_IOT, ("ARP TranslateHeader(), pTcb->DataRate = 0x%x\n", pTcb->DataRate));
-
                                }
                        }
 
 
                         fc = IEEE80211_FTYPE_DATA;
 
-               //if(ieee->current_network.QoS_Enable)
                if(qos_actived)
                        fc |= IEEE80211_STYPE_QOS_DATA;
                else
                        qos_ctl = 0;
                }
 
-               //if (ieee->current_network.QoS_Enable)
                if(qos_actived)
                {
                        hdr_len = IEEE80211_3ADDR_LEN + 2;
                txb->encrypted = encrypt;
                txb->payload_size = bytes;
 
-               //if (ieee->current_network.QoS_Enable)
                if(qos_actived)
                {
                        txb->queue_index = UP2AC(skb->priority);
                                /* The last fragment takes the remaining length */
                                bytes = bytes_last_frag;
                        }
-                       //if(ieee->current_network.QoS_Enable)
+
                        if(qos_actived)
                        {
                                // add 1 only indicate to corresponding seq number control 2006/7/12
 //WB add to fill data tcb_desc here. only first fragment is considered, need to change, and you may remove to other place.
        if (txb)
        {
-#if 1
                cb_desc *tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
                tcb_desc->bTxEnableFwCalcDur = 1;
                if (is_multicast_ether_addr(header.addr1))
                if ( tcb_desc->bMulticast ||  tcb_desc->bBroadcast)
                        tcb_desc->data_rate = ieee->basic_rate;
                else
-                       //tcb_desc->data_rate = CURRENT_RATE(ieee->current_network.mode, ieee->rate, ieee->HTCurrentOperaRate);
                        tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate);
 
                if(bdhcp == true){
-                       // Use low rate to send DHCP packet.
-                       //if(ieee->pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom) {
-                       //      tcb_desc->data_rate = MGN_1M;//MgntQuery_TxRateExcludeCCKRates(ieee);//0xc;//ofdm 6m
-                       //      tcb_desc->bTxDisableRateFallBack = false;
-                       //}
-                       //else
-                       {
                                tcb_desc->data_rate = MGN_1M;
                                tcb_desc->bTxDisableRateFallBack = 1;
-                       }
 
                        tcb_desc->RATRIndex = 7;
                        tcb_desc->bTxUseDriverAssingedRate = 1;
                ieee80211_query_BandwidthMode(ieee, tcb_desc);
                ieee80211_query_protectionmode(ieee, tcb_desc, txb->fragments[0]);
                ieee80211_query_seqnum(ieee, txb->fragments[0], header.addr1);
-//             IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, txb->fragments[0]->data, txb->fragments[0]->len);
-               //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, tcb_desc, sizeof(cb_desc));
-#endif
        }
        spin_unlock_irqrestore(&ieee->lock, flags);
        dev_kfree_skb_any(skb);
 
 }
 
-//EXPORT_SYMBOL(ieee80211_txb_free);
 
 #include <linux/module.h>
 
 #include "ieee80211.h"
-#if 0
-static const char *ieee80211_modes[] = {
-       "?", "a", "b", "ab", "g", "ag", "bg", "abg"
-};
-#endif
+
 struct modes_unit {
        char *mode_string;
        int mode_size;