staging: rtl8192e: Pass ieee80211_device to callbacks
[pandora-kernel.git] / drivers / staging / rtl8192e / ieee80211 / ieee80211_rx.c
index 9318695..add015e 100644 (file)
@@ -22,7 +22,6 @@
 
 
 #include <linux/compiler.h>
-//#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
@@ -225,7 +224,6 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
 
        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);
@@ -243,9 +241,6 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *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) {
@@ -308,7 +303,6 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
        if (skb->len < 24)
                return 0;
 
-#if 1
         if (ieee->hwsec_active)
         {
                 cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
@@ -317,7 +311,6 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
                 if(ieee->need_sw_enc)
                         tcb_desc->bHwSec = 0;
         }
-#endif
 
        hdr = (struct ieee80211_hdr_4addr *) skb->data;
        fc = le16_to_cpu(hdr->frame_ctl);
@@ -339,7 +332,6 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
                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)
@@ -358,13 +350,13 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
 
        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));
 
@@ -474,14 +466,13 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,
                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) {
@@ -511,19 +502,14 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,
                return 0;
        }
 
-//     if(tid != 0) {
-//             printk(KERN_WARNING ":)))))))))))%x %x %x, fc(%x)\n", tid, *last_seq, seq, header->frame_ctl);
-//     }
        if ((*last_seq == seq) &&
            time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) {
                if (*last_frag == frag){
-                       //printk(KERN_WARNING "[1] go drop!\n");
                        goto drop;
 
                }
                if (*last_frag + 1 != frag)
                        /* out-of-order fragment */
-                       //printk(KERN_WARNING "[2] go drop!\n");
                        goto drop;
        } else
                *last_seq = seq;
@@ -533,9 +519,6 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,
        return 0;
 
 drop:
-//     BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
-//     printk("DUP\n");
-
        return 1;
 }
 bool
@@ -545,7 +528,7 @@ AddReorderEntry(
        )
 {
        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) )
@@ -561,7 +544,7 @@ AddReorderEntry(
                        break;
                }
        }
-#endif
+
        pReorderEntry->List.next = pList->next;
        pReorderEntry->List.next->prev = &pReorderEntry->List;
        pReorderEntry->List.prev = pList;
@@ -574,8 +557,7 @@ void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_
 {
        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
@@ -602,19 +584,14 @@ void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_
                                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) {
-                               //printk("0skb_len(%d)\n", skb->len);
                                sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev);
                                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;
-                               //printk("1skb_len(%d)\n", skb->len);
                                netif_rx(sub_skb);
                        }
                }
@@ -637,10 +614,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
        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;
@@ -693,11 +667,9 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
                IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\
                                pTS->RxIndicateSeq, SeqNum);
                prxbIndicateArray[0] = prxb;
-//             printk("========================>%s(): SeqNum is %d\n",__FUNCTION__,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);
@@ -705,9 +677,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
                        /* 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);
@@ -724,7 +694,6 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
                                IEEE80211_DEBUG(IEEE80211_DL_REORDER,
                                         "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
                        }
-#endif
                }
                else {
                        /*
@@ -766,7 +735,6 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
 
                        IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
                        prxbIndicateArray[index] = pReorderEntry->prxb;
-               //      printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
                        index++;
 
                        list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List);
@@ -793,21 +761,13 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
                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,
@@ -841,7 +801,6 @@ u8 parse_subframe(struct ieee80211_device* ieee,struct sk_buff *skb,
        if(rx_stats->bContainHTC) {
                LLCOffset += sHTCLng;
        }
-       //printk("ChkLength = %d\n", LLCOffset);
        // Null packet, don't indicate it to upper layer
        ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
 
@@ -875,11 +834,6 @@ 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);
@@ -925,9 +879,6 @@ u8 parse_subframe(struct ieee80211_device* ieee,struct sk_buff *skb,
 #ifdef JOHN_NOCPY
                dev_kfree_skb(skb);
 #endif
-               //{just for debug added by david
-               //printk("AMSDU::rxb->nr_subframes = %d\n",rxb->nr_subframes);
-               //}
                return rxb->nr_subframes;
        }
 }
@@ -940,7 +891,6 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 {
        struct net_device *dev = ieee->dev;
        struct ieee80211_hdr_4addr *hdr;
-       //struct ieee80211_hdr_3addrqos *hdr;
 
        size_t hdrlen;
        u16 fc, type, stype, sc;
@@ -953,7 +903,6 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        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;
@@ -963,7 +912,6 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        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];
@@ -998,7 +946,6 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                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
@@ -1077,19 +1024,7 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        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,
@@ -1099,7 +1034,6 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                                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)   )
@@ -1118,24 +1052,9 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                        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
@@ -1208,7 +1127,6 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                }
        }
 #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 &&
@@ -1370,13 +1288,7 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                        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))
        {
@@ -1388,11 +1300,11 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                        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)
        {
@@ -1423,14 +1335,13 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                                        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 ) ||
                                                (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2) )
                                        {
                                                if(ieee->LeisurePSLeave)
-                                                       ieee->LeisurePSLeave(dev);
+                                                       ieee->LeisurePSLeave(ieee);
                                        }
                                }
                        }
@@ -1472,13 +1383,10 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                                }
 
                                /* Indicat the packets to upper layer */
-                               //printk("0skb_len(%d)\n", skb->len);
                                sub_skb->protocol = eth_type_trans(sub_skb, dev);
                                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 */
-                               //printk("1skb_len(%d)\n", skb->len);
                                netif_rx(sub_skb);
                        }
                }
@@ -1503,11 +1411,8 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        return 1;
 
  rx_dropped:
-       if (rxb != NULL)
-       {
-               kfree(rxb);
-               rxb = NULL;
-       }
+       kfree(rxb);
+       rxb = NULL;
        stats->rx_dropped++;
 
        /* Returning 0 indicates to caller that we have not handled the SKB--
@@ -1611,8 +1516,6 @@ static int ieee80211_qos_convert_ac_to_parameters(struct
         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]);
@@ -1763,7 +1666,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
        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;
@@ -1880,12 +1782,8 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                         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;
@@ -1898,8 +1796,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
 
                         offset = (info_element->data[2] >> 1)*2;
 
-                        //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
-
                         if(ieee->assoc_id < 8*offset ||
                                 ieee->assoc_id > 8*(offset + info_element->len -3))
 
@@ -1910,7 +1806,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                         if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
                                 network->dtim_data |= IEEE80211_DTIM_UCAST;
 
-                       //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
                        break;
 
                case MFIE_TYPE_ERP:
@@ -2025,8 +1920,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
 
                        }
 
-                       //if(tmp_htcap_len !=0  ||  tmp_htinfo_len != 0)
-                       {
                                if((info_element->len >= 3 &&
                                         info_element->data[0] == 0x00 &&
                                         info_element->data[1] == 0x05 &&
@@ -2043,17 +1936,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                                                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 &&
@@ -2073,7 +1956,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                                info_element->data[1] == 0x13 &&
                                info_element->data[2] == 0x74))
                        {
-                               //printk("========>%s(): athros AP is exist\n",__FUNCTION__);
                                network->atheros_cap_exist = true;
                        }
                        else
@@ -2085,7 +1967,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                                                info_element->data[2] == 0x43) )
                        {
                                network->marvell_cap_exist = true;
-                               //printk("========>%s(): marvel AP is exist\n",__FUNCTION__);
                        }
 
 
@@ -2231,49 +2112,10 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                case MFIE_TYPE_COUNTRY:
                        IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
                                             info_element->len);
-                       //printk("=====>Receive <%s> Country IE\n",network->ssid);
                        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",
@@ -2348,11 +2190,6 @@ static inline u8 ieee80211_SignalStrengthTranslate(
        {
                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;
 }
@@ -2374,11 +2211,6 @@ static inline int ieee80211_network_init(
        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;
@@ -2415,7 +2247,6 @@ static inline int ieee80211_network_init(
        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) */
@@ -2458,11 +2289,8 @@ static inline int ieee80211_network_init(
        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));
 
@@ -2476,11 +2304,9 @@ static inline int is_same_network(struct ieee80211_network *src,
         * 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)) &&
@@ -2545,15 +2371,10 @@ static inline void update_network(struct ieee80211_network *dst,
 
        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
-       //      printk("====>%s(), aifs:%x, %x\n", __FUNCTION__, dst->qos_data.parameters.aifs[0], src->qos_data.parameters.aifs[0]);
-       //      memcpy(&dst->qos_data, &src->qos_data,
-       //              sizeof(struct ieee80211_qos_data));
        }
        else {
                dst->qos_data.supported = src->qos_data.supported;
@@ -2574,7 +2395,6 @@ static inline void update_network(struct ieee80211_network *dst,
        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|| \
@@ -2582,10 +2402,6 @@ static inline void update_network(struct ieee80211_network *dst,
           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
@@ -2626,7 +2442,6 @@ static inline void ieee80211_process_probe_response(
 #endif
        unsigned long flags;
        short renew;
-       //u8 wmm_info;
 
        memset(&network, 0, sizeof(struct ieee80211_network));
        IEEE80211_DEBUG_SCAN(
@@ -2806,8 +2621,6 @@ static inline void ieee80211_process_probe_response(
                //YJ,add,080819,for hidden ap
                if(is_beacon(beacon->header.frame_ctl) == 0)
                        network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & target->flags);
-               //if(strncmp(network.ssid, "linksys-c",9) == 0)
-               //      printk("====>2 network.ssid=%s FLAG=%d target.ssid=%s FLAG=%d\n", network.ssid, network.flags, target->ssid, target->flags);
                if(((network.flags & NETWORK_EMPTY_ESSID) == NETWORK_EMPTY_ESSID) \
                    && (((network.ssid_len > 0) && (strncmp(target->ssid, network.ssid, network.ssid_len)))\
                    ||((ieee->current_network.ssid_len == network.ssid_len)&&(strncmp(ieee->current_network.ssid, network.ssid, network.ssid_len) == 0)&&(ieee->state == IEEE80211_NOLINK))))
@@ -2821,7 +2634,7 @@ static inline void ieee80211_process_probe_response(
        if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, &network, ieee)&&\
                (ieee->state == IEEE80211_LINKED)) {
                if(ieee->handle_beacon != NULL) {
-                       ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network);
+                       ieee->handle_beacon(ieee, beacon, &ieee->current_network);
                }
        }
 }
@@ -2830,15 +2643,6 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
                      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;
@@ -2852,7 +2656,6 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee,
                ieee80211_process_probe_response(
                        ieee, (struct ieee80211_probe_response *)header, stats);
 
-               //printk("----------->%s()\n", __func__);
                if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
                                        ieee->iw_mode == IW_MODE_INFRA &&
                                        ieee->state == IEEE80211_LINKED))