~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
 */
164
164
        ieee->mgmt_queue_head = nh;
165
165
        ieee->mgmt_queue_ring[nh] = skb;
166
 
 
167
 
        //return 0;
168
166
}
169
167
 
170
168
struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
208
206
                        rate = 0x02;
209
207
        }
210
208
 
211
 
        /*
212
 
        // Data rate of ProbeReq is already decided. Annie, 2005-03-31
213
 
        if( pMgntInfo->bScanInProgress || (pMgntInfo->bDualModeScanStep!=0) )
214
 
        {
215
 
        if(pMgntInfo->dot11CurrentWirelessMode==WIRELESS_MODE_A)
216
 
        rate = 0x0c;
217
 
        else
218
 
        rate = 0x02;
219
 
        }
220
 
         */
221
209
        return rate;
222
210
}
223
211
 
255
243
                                ieee->seq_ctrl[0]++;
256
244
 
257
245
                        /* avoid watchdog triggers */
258
 
        //              ieee->dev->trans_start = jiffies;
259
 
                        ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
260
 
                        //dev_kfree_skb_any(skb);//edit by thomas
 
246
                        ieee->softmac_data_hard_start_xmit(skb, ieee, ieee->basic_rate);
261
247
                }
262
248
 
263
249
                spin_unlock_irqrestore(&ieee->lock, flags);
264
250
        }else{
265
251
                spin_unlock_irqrestore(&ieee->lock, flags);
266
 
                spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
 
252
                spin_lock(&ieee->mgmt_tx_lock);
267
253
 
268
254
                header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
269
255
 
273
259
                        ieee->seq_ctrl[0]++;
274
260
 
275
261
                /* check wether the managed packet queued greater than 5 */
276
 
                if(!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\
277
 
                                (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\
 
262
                if(!ieee->check_nic_enough_desc(ieee, tcb_desc->queue_index)||
 
263
                                (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||
278
264
                                (ieee->queue_stop) ) {
279
265
                        /* insert the skb packet to the management queue */
280
266
                        /* as for the completion function, it does not need
281
267
                         * to check it any more.
282
268
                         * */
283
 
                        //printk("%s():insert to waitqueue!\n",__FUNCTION__);
284
269
                        skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb);
285
270
                } else {
286
 
                        //printk("TX packet!\n");
287
 
                        ieee->softmac_hard_start_xmit(skb,ieee->dev);
288
 
                        //dev_kfree_skb_any(skb);//edit by thomas
 
271
                        ieee->softmac_hard_start_xmit(skb, ieee);
289
272
                }
290
 
                spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
 
273
                spin_unlock(&ieee->mgmt_tx_lock);
291
274
        }
292
275
}
293
276
 
304
287
        tcb_desc->RATRIndex = 7;
305
288
        tcb_desc->bTxDisableRateFallBack = 1;
306
289
        tcb_desc->bTxUseDriverAssingedRate = 1;
307
 
        //printk("=============>%s()\n", __FUNCTION__);
308
290
        if(single){
309
291
 
310
292
                header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
315
297
                        ieee->seq_ctrl[0]++;
316
298
 
317
299
                /* avoid watchdog triggers */
318
 
        //      ieee->dev->trans_start = jiffies;
319
 
                ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
 
300
                ieee->softmac_data_hard_start_xmit(skb, ieee, ieee->basic_rate);
320
301
 
321
302
        }else{
322
303
 
327
308
                else
328
309
                        ieee->seq_ctrl[0]++;
329
310
 
330
 
                ieee->softmac_hard_start_xmit(skb,ieee->dev);
 
311
                ieee->softmac_hard_start_xmit(skb, ieee);
331
312
 
332
313
        }
333
 
        //dev_kfree_skb_any(skb);//edit by thomas
334
314
}
335
315
 
336
316
inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
377
357
        struct sk_buff *skb;
378
358
        if(!ieee->ieee_up)
379
359
                return;
380
 
        //unsigned long flags;
 
360
 
381
361
        skb = ieee80211_get_beacon_(ieee);
382
362
 
383
363
        if (skb){
384
364
                softmac_mgmt_xmit(skb, ieee);
385
365
                ieee->softmac_stats.tx_beacons++;
386
 
                //dev_kfree_skb_any(skb);//edit by thomas
387
366
        }
388
 
//      ieee->beacon_timer.expires = jiffies +
389
 
//              (MSECS( ieee->current_network.beacon_interval -5));
390
367
 
391
 
        //spin_lock_irqsave(&ieee->beacon_lock,flags);
392
368
        if(ieee->beacon_txing && ieee->ieee_up){
393
 
//              if(!timer_pending(&ieee->beacon_timer))
394
 
//                      add_timer(&ieee->beacon_timer);
395
369
                mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5)));
396
370
        }
397
 
        //spin_unlock_irqrestore(&ieee->beacon_lock,flags);
398
371
}
399
372
 
400
373
 
418
391
        if (skb){
419
392
                softmac_mgmt_xmit(skb, ieee);
420
393
                ieee->softmac_stats.tx_probe_rq++;
421
 
                //dev_kfree_skb_any(skb);//edit by thomas
422
394
        }
423
395
}
424
396
 
476
448
 
477
449
                if (ieee->state == IEEE80211_LINKED)
478
450
                        goto out;
479
 
                ieee->set_chan(ieee->dev, ch);
 
451
                ieee->set_chan(ieee, ch);
480
452
#ifdef ENABLE_DOT11D
481
453
                if(channel_map[ch] == 1)
482
454
#endif
545
517
#endif
546
518
        if (ieee->scanning == 0 )
547
519
                goto out;
548
 
        ieee->set_chan(ieee->dev, ieee->current_network.channel);
 
520
        ieee->set_chan(ieee, ieee->current_network.channel);
549
521
#ifdef ENABLE_DOT11D
550
522
        if(channel_map[ieee->current_network.channel] == 1)
551
523
#endif
596
568
void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
597
569
{
598
570
        if(ieee->stop_send_beacons)
599
 
                ieee->stop_send_beacons(ieee->dev);
 
571
                ieee->stop_send_beacons(ieee);
600
572
        if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
601
573
                ieee80211_beacons_stop(ieee);
602
574
}
605
577
void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
606
578
{
607
579
        if(ieee->start_send_beacons)
608
 
                ieee->start_send_beacons(ieee->dev);
 
580
                ieee->start_send_beacons(ieee);
609
581
        if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
610
582
                ieee80211_beacons_start(ieee);
611
583
}
613
585
 
614
586
void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
615
587
{
616
 
//      unsigned long flags;
617
 
 
618
 
        //ieee->sync_scan_hurryup = 1;
619
 
 
620
588
        down(&ieee->scan_sem);
621
 
//      spin_lock_irqsave(&ieee->lock, flags);
622
589
 
623
590
        if (ieee->scanning == 1){
624
591
                ieee->scanning = 0;
626
593
                cancel_delayed_work(&ieee->softmac_scan_wq);
627
594
        }
628
595
 
629
 
//      spin_unlock_irqrestore(&ieee->lock, flags);
630
596
        up(&ieee->scan_sem);
631
597
}
632
598
 
635
601
        if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
636
602
                ieee80211_softmac_stop_scan(ieee);
637
603
        else
638
 
                ieee->stop_scan(ieee->dev);
 
604
                ieee->stop_scan(ieee);
639
605
}
640
606
 
641
607
/* called with ieee->lock held */
643
609
{
644
610
#ifdef ENABLE_IPS
645
611
        if(ieee->ieee80211_ips_leave_wq != NULL)
646
 
                ieee->ieee80211_ips_leave_wq(ieee->dev);
 
612
                ieee->ieee80211_ips_leave_wq(ieee);
647
613
#endif
648
614
 
649
615
#ifdef ENABLE_DOT11D
661
627
                        queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
662
628
                }
663
629
        }else
664
 
                ieee->start_scan(ieee->dev);
 
630
                ieee->start_scan(ieee);
665
631
 
666
632
}
667
633
 
681
647
        if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
682
648
                ieee80211_softmac_scan_syncro(ieee);
683
649
        else
684
 
                ieee->scan_syncro(ieee->dev);
 
650
                ieee->scan_syncro(ieee);
685
651
 
686
652
}
687
653
 
709
675
        memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
710
676
        memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
711
677
 
712
 
        //auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
713
678
        if(ieee->auth_mode == 0)
714
679
                auth->algorithm = WLAN_AUTH_OPEN;
715
680
        else if(ieee->auth_mode == 1)
759
724
        else
760
725
                atim_len = 0;
761
726
 
762
 
#if 1
763
727
        if(ieee80211_is_54g(ieee->current_network))
764
728
                erp_len = 3;
765
729
        else
766
730
                erp_len = 0;
767
 
#else
768
 
      if((ieee->current_network.mode == IEEE_G)
769
 
                ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) {
770
 
                erp_len = 3;
771
 
                erpinfo_content = 0;
772
 
                if(ieee->current_network.buseprotection)
773
 
                        erpinfo_content |= ERP_UseProtection;
774
 
        }
775
 
        else
776
 
                erp_len = 0;
777
 
#endif
778
 
 
779
731
 
780
732
        crypt = ieee->crypt[ieee->tx_keyidx];
781
733
 
783
735
        encrypt = ieee->host_encrypt && crypt && crypt->ops &&
784
736
                ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len));
785
737
        //HT ralated element
786
 
#if 1
 
738
 
787
739
        tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap);
788
740
        tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
789
741
        tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo);
798
750
                tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer);
799
751
                HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len);
800
752
        }
801
 
//      printk("===============>tmp_ht_cap_len is %d,tmp_ht_info_len is %d, tmp_generic_ie_len is %d\n",tmp_ht_cap_len,tmp_ht_info_len,tmp_generic_ie_len);
802
 
#endif
 
753
 
803
754
        beacon_size = sizeof(struct ieee80211_probe_response)+2+
804
755
                ssid_len
805
756
                +3 //channel
808
759
                +atim_len
809
760
                +erp_len
810
761
                +wpa_ie_len
811
 
        //      +tmp_ht_cap_len
812
 
        //      +tmp_ht_info_len
813
 
        //      +tmp_generic_ie_len
814
 
//              +wmm_len+2
815
762
                +ieee->tx_headroom;
816
763
        skb = dev_alloc_skb(beacon_size);
817
764
        if (!skb)
834
781
                cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
835
782
 
836
783
        crypt = ieee->crypt[ieee->tx_keyidx];
837
 
#if 0
838
 
        encrypt = ieee->host_encrypt && crypt && crypt->ops &&
839
 
                (0 == strcmp(crypt->ops->name, "WEP"));
840
 
#endif
841
784
        if (encrypt)
842
785
                beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
843
786
 
865
808
        u16 val16;
866
809
                *(tag++) = MFIE_TYPE_IBSS_SET;
867
810
                *(tag++) = 2;
868
 
                //*((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
869
811
                 val16 = cpu_to_le16(ieee->current_network.atim_window);
870
812
                memcpy((u8 *)tag, (u8 *)&val16, 2);
871
813
                tag+=2;
876
818
                *(tag++) = 1;
877
819
                *(tag++) = erpinfo_content;
878
820
        }
879
 
#if 0
880
 
        //Include High Throuput capability
881
 
 
882
 
        *(tag++) = MFIE_TYPE_HT_CAP;
883
 
        *(tag++) = tmp_ht_cap_len - 2;
884
 
        memcpy(tag, tmp_ht_cap_buf, tmp_ht_cap_len - 2);
885
 
        tag += tmp_ht_cap_len - 2;
886
 
#endif
887
821
        if(rate_ex_len){
888
822
                *(tag++) = MFIE_TYPE_RATES_EX;
889
823
                *(tag++) = rate_ex_len-2;
891
825
                tag+=rate_ex_len-2;
892
826
        }
893
827
 
894
 
#if 0
895
 
        //Include High Throuput info
896
 
 
897
 
        *(tag++) = MFIE_TYPE_HT_INFO;
898
 
        *(tag++) = tmp_ht_info_len - 2;
899
 
        memcpy(tag, tmp_ht_info_buf, tmp_ht_info_len -2);
900
 
        tag += tmp_ht_info_len - 2;
901
 
#endif
902
828
        if (wpa_ie_len)
903
829
        {
904
830
                if (ieee->iw_mode == IW_MODE_ADHOC)
909
835
                tag += wpa_ie_len;
910
836
        }
911
837
 
912
 
#if 0
913
 
        //
914
 
        // Construct Realtek Proprietary Aggregation mode (Set AMPDU Factor to 2, 32k)
915
 
        //
916
 
        if(pHTInfo->bRegRT2RTAggregation)
917
 
        {
918
 
                (*tag++) = 0xdd;
919
 
                (*tag++) = tmp_generic_ie_len - 2;
920
 
                memcpy(tag,tmp_generic_ie_buf,tmp_generic_ie_len -2);
921
 
                tag += tmp_generic_ie_len -2;
922
 
 
923
 
        }
924
 
#endif
925
 
#if 0
926
 
        if(ieee->qos_support)
927
 
        {
928
 
                (*tag++) = 0xdd;
929
 
                (*tag++) = wmm_len;
930
 
                memcpy(tag,QosOui,wmm_len);
931
 
                tag += wmm_len;
932
 
        }
933
 
#endif
934
 
        //skb->dev = ieee->dev;
935
838
        return skb;
936
839
}
937
840
 
1110
1013
inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
1111
1014
{
1112
1015
        struct sk_buff *skb;
1113
 
        //unsigned long flags;
1114
 
 
1115
1016
        struct ieee80211_assoc_request_frame *hdr;
1116
 
        u8 *tag;//,*rsn_ie;
1117
 
        //short info_addr = 0;
1118
 
        //int i;
1119
 
        //u16 suite_count = 0;
1120
 
        //u8 suit_select = 0;
1121
 
        //unsigned int wpa_len = beacon->wpa_ie_len;
1122
 
        //for HT
 
1017
        u8 *tag;
1123
1018
        u8* ht_cap_buf = NULL;
1124
1019
        u8 ht_cap_len=0;
1125
1020
        u8* realtek_ie_buf=NULL;
1344
1239
                        memcpy(tag, realtek_ie_buf,realtek_ie_len -2 );
1345
1240
                }
1346
1241
        }
1347
 
//      printk("<=====%s(), %p, %p\n", __FUNCTION__, ieee->dev, ieee->dev->dev_addr);
1348
 
//      IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
1349
1242
        return skb;
1350
1243
}
1351
1244
 
1399
1292
        else{
1400
1293
                ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
1401
1294
                IEEE80211_DEBUG_MGMT("Sending authentication request\n");
1402
 
                //printk(KERN_WARNING "Sending authentication request\n");
1403
1295
                softmac_mgmt_xmit(skb, ieee);
1404
1296
                //BUGON when you try to add_timer twice, using mod_timer may be better, john0709
1405
1297
                if(!timer_pending(&ieee->associate_timer)){
1406
1298
                        ieee->associate_timer.expires = jiffies + (HZ / 2);
1407
1299
                        add_timer(&ieee->associate_timer);
1408
1300
                }
1409
 
                //dev_kfree_skb_any(skb);//edit by thomas
1410
1301
        }
1411
1302
}
1412
1303
 
1415
1306
        u8 *c;
1416
1307
        struct sk_buff *skb;
1417
1308
        struct ieee80211_network *beacon = &ieee->current_network;
1418
 
//      int hlen = sizeof(struct ieee80211_authentication);
1419
1309
 
1420
1310
        ieee->associate_seq++;
1421
1311
        ieee->softmac_stats.tx_auth_rq++;
1435
1325
 
1436
1326
                softmac_mgmt_xmit(skb, ieee);
1437
1327
                mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
1438
 
#if 0
1439
 
                ieee->associate_timer.expires = jiffies + (HZ / 2);
1440
 
                add_timer(&ieee->associate_timer);
1441
 
#endif
1442
 
                //dev_kfree_skb_any(skb);//edit by thomas
1443
1328
        }
1444
1329
        kfree(challenge);
1445
1330
}
1460
1345
        else{
1461
1346
                softmac_mgmt_xmit(skb, ieee);
1462
1347
                mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
1463
 
#if 0
1464
 
                ieee->associate_timer.expires = jiffies + (HZ / 2);
1465
 
                add_timer(&ieee->associate_timer);
1466
 
#endif
1467
 
                //dev_kfree_skb_any(skb);//edit by thomas
1468
1348
        }
1469
1349
}
1470
1350
void ieee80211_associate_complete_wq(struct work_struct *work)
1490
1370
        {
1491
1371
                printk("Successfully associated, ht not enabled(%d, %d)\n", ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT);
1492
1372
                memset(ieee->dot11HTOperationalRateSet, 0, 16);
1493
 
                //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1494
1373
        }
1495
1374
        ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500);
1496
1375
        // To prevent the immediately calling watch_dog after association.
1499
1378
                ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
1500
1379
                ieee->LinkDetectInfo.NumRecvDataInPeriod= 1;
1501
1380
        }
1502
 
        ieee->link_change(ieee->dev);
 
1381
        ieee->link_change(ieee);
1503
1382
        if(ieee->is_silent_reset == 0){
1504
1383
                printk("============>normal associate\n");
1505
1384
        notify_wx_assoc_event(ieee);
1511
1390
        }
1512
1391
 
1513
1392
        if (ieee->data_hard_resume)
1514
 
                ieee->data_hard_resume(ieee->dev);
 
1393
                ieee->data_hard_resume(ieee);
1515
1394
        netif_carrier_on(ieee->dev);
1516
1395
}
1517
1396
 
1518
1397
void ieee80211_associate_complete(struct ieee80211_device *ieee)
1519
1398
{
1520
 
//      int i;
1521
 
//      struct net_device* dev = ieee->dev;
1522
1399
        del_timer_sync(&ieee->associate_timer);
1523
1400
 
1524
 
#if 0
1525
 
        for(i = 0; i < 6; i++) {
1526
 
          ieee->seq_ctrl[i] = 0;
1527
 
        }
1528
 
#endif
1529
1401
        ieee->state = IEEE80211_LINKED;
1530
 
#if 0
1531
 
        if (ieee->pHTInfo->bCurrentHTSupport)
1532
 
        {
1533
 
                printk("Successfully associated, ht enabled\n");
1534
 
                queue_work(ieee->wq, &ieee->ht_onAssRsp);
1535
 
        }
1536
 
        else
1537
 
        {
1538
 
                printk("Successfully associated, ht not enabled\n");
1539
 
                memset(ieee->dot11HTOperationalRateSet, 0, 16);
1540
 
                HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1541
 
        }
1542
 
#endif
1543
 
        //ieee->UpdateHalRATRTableHandler(dev, ieee->dot11HTOperationalRateSet);
1544
1402
        queue_work(ieee->wq, &ieee->associate_complete_wq);
1545
1403
}
1546
1404
 
1550
1408
        ieee->sync_scan_hurryup = 1;
1551
1409
#ifdef ENABLE_IPS
1552
1410
        if(ieee->ieee80211_ips_leave != NULL)
1553
 
                ieee->ieee80211_ips_leave(ieee->dev);
 
1411
                ieee->ieee80211_ips_leave(ieee);
1554
1412
#endif
1555
1413
 
1556
1414
        down(&ieee->wx_sem);
1557
1415
 
1558
1416
        if (ieee->data_hard_stop)
1559
 
                ieee->data_hard_stop(ieee->dev);
 
1417
                ieee->data_hard_stop(ieee);
1560
1418
 
1561
1419
        ieee80211_stop_scan(ieee);
1562
1420
        printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel);
1563
 
        //ieee->set_chan(ieee->dev, ieee->current_network.channel);
1564
1421
        HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1565
1422
 
1566
 
#ifdef ENABLE_IPS
1567
 
        if(ieee->eRFPowerState == eRfOff)
1568
 
        {
1569
 
                if(ieee->ieee80211_ips_leave_wq != NULL)
1570
 
                        ieee->ieee80211_ips_leave_wq(ieee->dev);
1571
 
 
1572
 
                up(&ieee->wx_sem);
1573
 
                return;
1574
 
        }
1575
 
#endif
1576
 
 
1577
1423
        ieee->associate_seq = 1;
1578
1424
        ieee80211_associate_step1(ieee);
1579
1425
 
1605
1451
                 * This could be obtained by beacons or, if the network does not
1606
1452
                 * broadcast it, it can be put manually.
1607
1453
                 */
1608
 
                apset = ieee->wap_set;//(memcmp(ieee->current_network.bssid, zero,ETH_ALEN)!=0 );
1609
 
                ssidset = ieee->ssid_set;//ieee->current_network.ssid[0] != '\0';
 
1454
                apset = ieee->wap_set;
 
1455
                ssidset = ieee->ssid_set;
1610
1456
                ssidbroad =  !(net->ssid_len == 0 || net->ssid[0]== '\0');
1611
1457
                apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
1612
1458
                ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\
1640
1486
                                }
1641
1487
                                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);
1642
1488
 
1643
 
                                //ieee->pHTInfo->IOTAction = 0;
1644
1489
                                HTResetIOTSetting(ieee->pHTInfo);
1645
1490
                                if (ieee->iw_mode == IW_MODE_INFRA){
1646
1491
                                        /* Join the network for the first time */
1647
1492
                                        ieee->AsocRetryCount = 0;
1648
1493
                                        //for HT by amy 080514
1649
1494
                                        if((ieee->current_network.qos_data.supported == 1) &&
1650
 
                                          // (ieee->pHTInfo->bEnableHT && ieee->current_network.bssht.bdSupportHT))
1651
1495
                                           ieee->current_network.bssht.bdSupportHT)
1652
1496
/*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.*/
1653
1497
                                        {
1654
 
                                        //      ieee->pHTInfo->bCurrentHTSupport = true;
1655
1498
                                                HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network));
1656
1499
                                        }
1657
1500
                                        else
1665
1508
                                        if(ieee80211_is_54g(ieee->current_network) &&
1666
1509
                                                (ieee->modulation & IEEE80211_OFDM_MODULATION)){
1667
1510
                                                ieee->rate = 108;
1668
 
                                                ieee->SetWirelessMode(ieee->dev, IEEE_G);
 
1511
                                                ieee->SetWirelessMode(ieee, IEEE_G);
1669
1512
                                                printk(KERN_INFO"Using G rates\n");
1670
1513
                                        }else{
1671
1514
                                                ieee->rate = 22;
1672
 
                                                ieee->SetWirelessMode(ieee->dev, IEEE_B);
 
1515
                                                ieee->SetWirelessMode(ieee, IEEE_B);
1673
1516
                                                printk(KERN_INFO"Using B rates\n");
1674
1517
                                        }
1675
1518
                                        memset(ieee->dot11HTOperationalRateSet, 0, 16);
1676
 
                                        //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
1677
1519
                                        ieee->state = IEEE80211_LINKED;
1678
1520
                                }
1679
1521
 
1722
1564
 
1723
1565
                if(*(t++) == MFIE_TYPE_CHALLENGE){
1724
1566
                        *chlen = *(t++);
1725
 
                        *challenge = kmalloc(*chlen, GFP_ATOMIC);
1726
 
                        memcpy(*challenge, t, *chlen);
 
1567
                        *challenge = kmemdup(t, *chlen, GFP_ATOMIC);
 
1568
                        if (!*challenge)
 
1569
                                return -ENOMEM;
1727
1570
                }
1728
1571
        }
1729
1572
 
1780
1623
                tag++; /* point to the next tag */
1781
1624
        }
1782
1625
 
1783
 
        //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
1784
1626
        if (ssidlen == 0) return 1;
1785
1627
 
1786
1628
        if (!ssid) return 1; /* ssid not found in tagged param */
1838
1680
{
1839
1681
        u8 dest[ETH_ALEN];
1840
1682
 
1841
 
        //IEEE80211DMESG("Rx probe");
1842
1683
        ieee->softmac_stats.rx_probe_rq++;
1843
 
        //DMESG("Dest is "MACSTR, MAC2STR(dest));
1844
1684
        if (probe_rq_parse(ieee, skb, dest)){
1845
 
                //IEEE80211DMESG("Was for me!");
1846
1685
                ieee->softmac_stats.tx_probe_rs++;
1847
1686
                ieee80211_resp_to_probe(ieee, dest);
1848
1687
        }
1853
1692
{
1854
1693
        u8 dest[ETH_ALEN];
1855
1694
        int status;
1856
 
        //IEEE80211DMESG("Rx probe");
1857
1695
        ieee->softmac_stats.rx_auth_rq++;
1858
1696
 
1859
1697
        status = auth_rq_parse(skb, dest);
1860
1698
        if (status != -1) {
1861
1699
                ieee80211_resp_to_auth(ieee, status, dest);
1862
1700
        }
1863
 
        //DMESG("Dest is "MACSTR, MAC2STR(dest));
1864
 
 
1865
1701
}
1866
1702
 
1867
1703
static inline void
1868
1704
ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
1869
1705
{
1870
 
 
1871
1706
        u8 dest[ETH_ALEN];
1872
 
        //unsigned long flags;
1873
1707
 
1874
1708
        ieee->softmac_stats.rx_ass_rq++;
1875
1709
        if (assoc_rq_parse(skb,dest) != -1){
1877
1711
        }
1878
1712
 
1879
1713
        printk(KERN_INFO"New client associated: %pM\n", dest);
1880
 
        //FIXME
1881
 
        #if 0
1882
 
        spin_lock_irqsave(&ieee->lock,flags);
1883
 
        add_associate(ieee,dest);
1884
 
        spin_unlock_irqrestore(&ieee->lock,flags);
1885
 
        #endif
1886
1714
}
1887
1715
 
1888
1716
 
1911
1739
{
1912
1740
        int timeout = ieee->ps_timeout;
1913
1741
        u8 dtim;
1914
 
        PRT_POWER_SAVE_CONTROL  pPSC = (PRT_POWER_SAVE_CONTROL)(&(ieee->PowerSaveControl));
1915
1742
 
1916
1743
        if(ieee->LPSDelayCnt)
1917
1744
        {
1918
 
                //printk("===============>Delay enter LPS for DHCP and ARP packets...\n");
1919
1745
                ieee->LPSDelayCnt --;
1920
1746
                return 0;
1921
1747
        }
1922
1748
 
1923
1749
        dtim = ieee->current_network.dtim_data;
1924
 
//      printk("%s():DTIM:%d\n",__FUNCTION__,dtim);
1925
1750
        if(!(dtim & IEEE80211_DTIM_VALID))
1926
1751
                return 0;
1927
1752
        timeout = ieee->current_network.beacon_interval; //should we use ps_timeout value or beacon_interval
1928
 
        //printk("VALID\n");
1929
1753
        ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
1930
1754
        /* there's no need to nofity AP that I find you buffered with broadcast packet */
1931
1755
        if(dtim & (IEEE80211_DTIM_UCAST & ieee->ps))
1932
1756
                return 2;
1933
1757
 
1934
1758
        if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))){
1935
 
//              printk("%s():111Oh Oh ,it is not time out return 0\n",__FUNCTION__);
1936
1759
                return 0;
1937
1760
        }
1938
1761
        if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))){
1939
 
//              printk("%s():222Oh Oh ,it is not time out return 0\n",__FUNCTION__);
1940
1762
                return 0;
1941
1763
        }
1942
1764
        if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
1945
1767
 
1946
1768
        if(time_l){
1947
1769
                if(ieee->bAwakePktSent == true) {
1948
 
                        pPSC->LPSAwakeIntvl = 1;//tx wake one beacon
 
1770
                        ieee->LPSAwakeIntvl = 1;//tx wake one beacon
1949
1771
                } else {
1950
1772
                        u8              MaxPeriod = 1;
1951
1773
 
1952
 
                        if(pPSC->LPSAwakeIntvl == 0)
1953
 
                                pPSC->LPSAwakeIntvl = 1;
1954
 
                        //pNdisCommon->RegLPSMaxIntvl /// 0x0 - eFastPs, 0xFF -DTIM, 0xNN - 0xNN * BeaconIntvl
1955
 
                        if(pPSC->RegMaxLPSAwakeIntvl == 0) // Default (0x0 - eFastPs, 0xFF -DTIM, 0xNN - 0xNN * BeaconIntvl)
 
1774
                        if(ieee->LPSAwakeIntvl == 0)
 
1775
                                ieee->LPSAwakeIntvl = 1;
 
1776
                        if(ieee->RegMaxLPSAwakeIntvl == 0) // Default (0x0 - eFastPs, 0xFF -DTIM, 0xNN - 0xNN * BeaconIntvl)
1956
1777
                                MaxPeriod = 1; // 1 Beacon interval
1957
 
                        else if(pPSC->RegMaxLPSAwakeIntvl == 0xFF) // DTIM
 
1778
                        else if(ieee->RegMaxLPSAwakeIntvl == 0xFF) // DTIM
1958
1779
                                MaxPeriod = ieee->current_network.dtim_period;
1959
1780
                        else
1960
 
                                MaxPeriod = pPSC->RegMaxLPSAwakeIntvl;
1961
 
                        pPSC->LPSAwakeIntvl = (pPSC->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (pPSC->LPSAwakeIntvl + 1);
 
1781
                                MaxPeriod = ieee->RegMaxLPSAwakeIntvl;
 
1782
                        ieee->LPSAwakeIntvl = (ieee->LPSAwakeIntvl >= MaxPeriod) ? MaxPeriod : (ieee->LPSAwakeIntvl + 1);
1962
1783
                }
1963
1784
                {
1964
1785
                        u8 LPSAwakeIntvl_tmp = 0;
1965
1786
                        u8 period = ieee->current_network.dtim_period;
1966
1787
                        u8 count = ieee->current_network.tim.tim_count;
1967
1788
                        if(count == 0 ) {
1968
 
                                if(pPSC->LPSAwakeIntvl > period)
1969
 
                                        LPSAwakeIntvl_tmp = period + (pPSC->LPSAwakeIntvl - period) -((pPSC->LPSAwakeIntvl-period)%period);
 
1789
                                if(ieee->LPSAwakeIntvl > period)
 
1790
                                        LPSAwakeIntvl_tmp = period + (ieee->LPSAwakeIntvl - period) -((ieee->LPSAwakeIntvl-period)%period);
1970
1791
                                else
1971
 
                                        LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;
 
1792
                                        LPSAwakeIntvl_tmp = ieee->LPSAwakeIntvl;
1972
1793
 
1973
1794
                        } else {
1974
 
                                if(pPSC->LPSAwakeIntvl > ieee->current_network.tim.tim_count)
1975
 
                                        LPSAwakeIntvl_tmp = count + (pPSC->LPSAwakeIntvl - count) -((pPSC->LPSAwakeIntvl-count)%period);
 
1795
                                if(ieee->LPSAwakeIntvl > ieee->current_network.tim.tim_count)
 
1796
                                        LPSAwakeIntvl_tmp = count + (ieee->LPSAwakeIntvl - count) -((ieee->LPSAwakeIntvl-count)%period);
1976
1797
                                else
1977
 
                                        LPSAwakeIntvl_tmp = pPSC->LPSAwakeIntvl;//ieee->current_network.tim.tim_count;//pPSC->LPSAwakeIntvl;
 
1798
                                        LPSAwakeIntvl_tmp = ieee->LPSAwakeIntvl;
1978
1799
                        }
1979
 
                        //printk("=========>%s()assoc_id:%d(%#x),bAwakePktSent:%d,DTIM:%d, sleep interval:%d, LPSAwakeIntvl_tmp:%d, count:%d\n",__func__,ieee->assoc_id,cpu_to_le16(ieee->assoc_id),ieee->bAwakePktSent,ieee->current_network.dtim_period,pPSC->LPSAwakeIntvl,LPSAwakeIntvl_tmp,count);
1980
1800
 
1981
1801
                *time_l = ieee->current_network.last_dtim_sta_time[0]
1982
1802
                        + MSECS(ieee->current_network.beacon_interval * LPSAwakeIntvl_tmp);
1983
 
                //      * ieee->current_network.dtim_period) * 1000;
1984
1803
        }
1985
1804
        }
1986
1805
 
2000
1819
 
2001
1820
        u32 th,tl;
2002
1821
        short sleep;
2003
 
 
2004
 
        unsigned long flags,flags2;
 
1822
        unsigned long flags;
2005
1823
 
2006
1824
        spin_lock_irqsave(&ieee->lock, flags);
2007
1825
 
2012
1830
        //      #warning CHECK_LOCK_HERE
2013
1831
                printk("=====>%s(): no need to ps,wake up!! ieee->ps is %d,ieee->iw_mode is %d,ieee->state is %d\n",
2014
1832
                        __FUNCTION__,ieee->ps,ieee->iw_mode,ieee->state);
2015
 
                spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
 
1833
                spin_lock(&ieee->mgmt_tx_lock);
2016
1834
 
2017
1835
                ieee80211_sta_wakeup(ieee, 1);
2018
1836
 
2019
 
                spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
 
1837
                spin_unlock(&ieee->mgmt_tx_lock);
2020
1838
        }
2021
1839
 
2022
1840
        sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
2023
1841
        /* 2 wake, 1 sleep, 0 do nothing */
2024
1842
        if(sleep == 0)//it is not time out or dtim is not valid
2025
1843
        {
2026
 
                //printk("===========>sleep is 0,do nothing\n");
2027
1844
                goto out;
2028
1845
        }
2029
1846
        if(sleep == 1){
2030
 
                //printk("===========>sleep is 1,to sleep\n");
2031
1847
                if(ieee->sta_sleep == 1){
2032
 
                        //printk("%s(1): sta_sleep = 1, sleep again ++++++++++ \n", __func__);
2033
 
                        ieee->enter_sleep_state(ieee->dev,th,tl);
 
1848
                        ieee->enter_sleep_state(ieee, th, tl);
2034
1849
                }
2035
1850
 
2036
1851
                else if(ieee->sta_sleep == 0){
2037
 
                //      printk("send null 1\n");
2038
 
                        spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
 
1852
                        spin_lock(&ieee->mgmt_tx_lock);
2039
1853
 
2040
 
                        if(ieee->ps_is_queue_empty(ieee->dev)){
 
1854
                        if (ieee->ps_is_queue_empty(ieee)) {
2041
1855
                                ieee->sta_sleep = 2;
2042
1856
                                ieee->ack_tx_to_ieee = 1;
2043
 
                                //printk("%s(2): sta_sleep = 0, notify AP we will sleeped ++++++++++ SendNullFunctionData\n", __func__);
2044
1857
                                ieee80211_sta_ps_send_null_frame(ieee,1);
2045
1858
                                ieee->ps_th = th;
2046
1859
                                ieee->ps_tl = tl;
2047
1860
                        }
2048
 
                        spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
 
1861
                        spin_unlock(&ieee->mgmt_tx_lock);
2049
1862
 
2050
1863
                }
2051
1864
 
2052
1865
                ieee->bAwakePktSent = false;//after null to power save we set it to false. not listen every beacon.
2053
1866
 
2054
1867
        }else if(sleep == 2){
2055
 
                //printk("==========>sleep is 2,to wakeup\n");
2056
 
                spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
 
1868
                spin_lock(&ieee->mgmt_tx_lock);
2057
1869
 
2058
 
                //printk("%s(3): pkt buffered in ap will awake ++++++++++ ieee80211_sta_wakeup\n", __func__);
2059
1870
                ieee80211_sta_wakeup(ieee,1);
2060
1871
 
2061
 
                spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
 
1872
                spin_unlock(&ieee->mgmt_tx_lock);
2062
1873
        }
2063
1874
 
2064
1875
out:
2072
1883
                if(nl){
2073
1884
                        if(ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING)
2074
1885
                        {
2075
 
                                //printk("%s(1): notify AP we are awaked ++++++++++ SendNullFunctionData\n", __func__);
2076
 
                                //printk("Warning: driver is probably failing to report TX ps error\n");
2077
1886
                                ieee->ack_tx_to_ieee = 1;
2078
1887
                                ieee80211_sta_ps_send_null_frame(ieee, 0);
2079
1888
                        }
2080
1889
                        else
2081
1890
                        {
2082
1891
                                ieee->ack_tx_to_ieee = 1;
2083
 
                                //printk("%s(2): notify AP we are awaked ++++++++++ Send PS-Poll\n", __func__);
2084
1892
                                ieee80211_sta_ps_send_pspoll_frame(ieee);
2085
1893
                        }
2086
1894
                }
2089
1897
        }
2090
1898
 
2091
1899
        if(ieee->sta_sleep == 1)
2092
 
                ieee->sta_wake_up(ieee->dev);
 
1900
                ieee->sta_wake_up(ieee);
2093
1901
        if(nl){
2094
1902
 
2095
1903
                        if(ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING)
2096
1904
                        {
2097
 
                                //printk("%s(3): notify AP we are awaked ++++++++++ SendNullFunctionData\n", __func__);
2098
 
                                //printk("Warning: driver is probably failing to report TX ps error\n");
2099
1905
                                ieee->ack_tx_to_ieee = 1;
2100
1906
                                ieee80211_sta_ps_send_null_frame(ieee, 0);
2101
1907
                        }
2103
1909
                        {
2104
1910
                                ieee->ack_tx_to_ieee = 1;
2105
1911
                        ieee->polling = true;
2106
 
                                //printk("%s(4): notify AP we are awaked ++++++++++ Send PS-Poll\n", __func__);
2107
1912
                                //ieee80211_sta_ps_send_null_frame(ieee, 0);
2108
1913
                                ieee80211_sta_ps_send_pspoll_frame(ieee);
2109
1914
                        }
2116
1921
 
2117
1922
void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
2118
1923
{
2119
 
        unsigned long flags,flags2;
 
1924
        unsigned long flags;
2120
1925
 
2121
1926
        spin_lock_irqsave(&ieee->lock, flags);
2122
1927
 
2124
1929
                /* Null frame with PS bit set */
2125
1930
                if(success){
2126
1931
                        ieee->sta_sleep = 1;
2127
 
                        //printk("notify AP we will sleep and send null ok, so sleep now++++++++++ enter_sleep_state\n");
2128
 
                        ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl);
 
1932
                        ieee->enter_sleep_state(ieee, ieee->ps_th, ieee->ps_tl);
2129
1933
                }
2130
1934
        } else {/* 21112005 - tx again null without PS bit if lost */
2131
1935
 
2132
1936
                if((ieee->sta_sleep == 0) && !success){
2133
 
                        spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
 
1937
                        spin_lock(&ieee->mgmt_tx_lock);
2134
1938
                        //ieee80211_sta_ps_send_null_frame(ieee, 0);
2135
1939
                        if(ieee->pHTInfo->IOTAction & HT_IOT_ACT_NULL_DATA_POWER_SAVING)
2136
1940
                        {
2137
 
                                //printk("notify AP we will sleep but send bull failed, so resend++++++++++ SendNullFunctionData\n");
2138
1941
                                ieee80211_sta_ps_send_null_frame(ieee, 0);
2139
1942
                        }
2140
1943
                        else
2141
1944
                        {
2142
 
                                //printk("notify AP we are awaked but send pspoll failed, so resend++++++++++ Send PS-Poll\n");
2143
1945
                                ieee80211_sta_ps_send_pspoll_frame(ieee);
2144
1946
                        }
2145
 
                        spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
 
1947
                        spin_unlock(&ieee->mgmt_tx_lock);
2146
1948
                }
2147
1949
        }
2148
1950
        spin_unlock_irqrestore(&ieee->lock, flags);
2153
1955
        struct ieee80211_hdr* header = (struct ieee80211_hdr*)skb->data;
2154
1956
        u8* act = ieee80211_get_payload(header);
2155
1957
        u8 tmp = 0;
2156
 
//      IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
 
1958
 
2157
1959
        if (act == NULL)
2158
1960
        {
2159
1961
                IEEE80211_DEBUG(IEEE80211_DL_ERR, "error to get payload of action frame\n");
2172
1974
                        ieee80211_rx_DELBA(ieee, skb);
2173
1975
                        break;
2174
1976
                default:
2175
 
//                      if (net_ratelimit())
2176
 
//                      IEEE80211_DEBUG(IEEE80211_DL_BA, "unknown action frame(%d)\n", tmp);
2177
1977
                        break;
2178
1978
        }
2179
1979
        return;
2190
1990
        int chlen=0;
2191
1991
        int aid;
2192
1992
        struct ieee80211_assoc_response_frame *assoc_resp;
2193
 
//      struct ieee80211_info_element *info_element;
2194
1993
        bool bSupportNmode = true, bHalfSupportNmode = false; //default support N mode, disable halfNmode
2195
1994
 
2196
1995
        if(!ieee->proto_started)
2197
1996
                return 0;
2198
 
#if 0
2199
 
        printk("%d, %d, %d, %d\n", ieee->sta_sleep, ieee->ps, ieee->iw_mode, ieee->state);
2200
 
        if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
2201
 
                ieee->iw_mode == IW_MODE_INFRA &&
2202
 
                ieee->state == IEEE80211_LINKED))
2203
 
 
2204
 
                tasklet_schedule(&ieee->ps_task);
2205
 
 
2206
 
        if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
2207
 
                WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
2208
 
                ieee->last_rx_ps_time = jiffies;
2209
 
#endif
2210
1997
 
2211
1998
        switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
2212
1999
 
2236
2023
                                                        return 1;
2237
2024
                                                }
2238
2025
                                                else
2239
 
                                                {       //filling the PeerHTCap. //maybe not neccesary as we can get its info from current_network.
 
2026
                                                {       //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network.
2240
2027
                                                        memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen);
2241
2028
                                                        memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen);
2242
2029
                                                }
2243
2030
                                                if (ieee->handle_assoc_response != NULL)
2244
 
                                                        ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame*)header, network);
 
2031
                                                        ieee->handle_assoc_response(ieee, (struct ieee80211_assoc_response_frame*)header, network);
2245
2032
                                        }
2246
2033
                                        ieee80211_associate_complete(ieee);
2247
2034
                                } else {
2285
2072
                                                                ieee->softmac_stats.rx_auth_rs_ok++;
2286
2073
                                                                if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE))
2287
2074
                                                                {
2288
 
                                                                        if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
 
2075
                                                                        if (!ieee->GetNmodeSupportBySecCfg(ieee))
2289
2076
                                                                        {
2290
2077
                                                                                // WEP or TKIP encryption
2291
2078
                                                                                if(IsHTHalfNmodeAPs(ieee))
2304
2091
                                                                /* Dummy wirless mode setting to avoid encryption issue */
2305
2092
                                                                if(bSupportNmode) {
2306
2093
                                                                        //N mode setting
2307
 
                                                                        ieee->SetWirelessMode(ieee->dev, \
 
2094
                                                                        ieee->SetWirelessMode(ieee,
2308
2095
                                                                                        ieee->current_network.mode);
2309
2096
                                                                }else{
2310
2097
                                                                        //b/g mode setting
2311
2098
                                                                        /*TODO*/
2312
 
                                                                        ieee->SetWirelessMode(ieee->dev, IEEE_G);
 
2099
                                                                        ieee->SetWirelessMode(ieee, IEEE_G);
2313
2100
                                                                }
2314
2101
 
2315
2102
                                                                if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true)
2361
2148
                                ieee->softmac_stats.reassoc++;
2362
2149
                                ieee->is_roaming = true;
2363
2150
                                ieee80211_disassociate(ieee);
2364
 
                        //      notify_wx_assoc_event(ieee);
2365
 
                                //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
2366
2151
                                RemovePeerTS(ieee, header->addr2);
2367
2152
                                queue_work(ieee->wq, &ieee->associate_procedure_wq);
2368
2153
                        }
2375
2160
                        break;
2376
2161
        }
2377
2162
 
2378
 
        //dev_kfree_skb_any(skb);
2379
2163
        return 0;
2380
2164
}
2381
2165
 
2382
 
/* following are for a simplier TX queue management.
 
2166
/* following are for a simpler TX queue management.
2383
2167
 * Instead of using netif_[stop/wake]_queue the driver
2384
2168
 * will uses these two function (plus a reset one), that
2385
2169
 * will internally uses the kernel netif_* and takes
2411
2195
        ieee80211_sta_wakeup(ieee,0);
2412
2196
 
2413
2197
        /* update the tx status */
2414
 
//      ieee->stats.tx_bytes += txb->payload_size;
2415
 
//      ieee->stats.tx_packets++;
2416
2198
        tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
2417
2199
        if(tcb_desc->bMulticast) {
2418
2200
                ieee->stats.multicast++;
2419
2201
        }
2420
 
#if 1
 
2202
 
2421
2203
        /* if xmit available, just xmit it immediately, else just insert it to the wait queue */
2422
2204
        for(i = 0; i < txb->nr_frags; i++) {
2423
2205
#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
2425
2207
#else
2426
2208
                if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) ||
2427
2209
#endif
2428
 
                (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\
 
2210
                (!ieee->check_nic_enough_desc(ieee, queue_index))||
2429
2211
                     (ieee->queue_stop)) {
2430
2212
                        /* insert the skb packet to the wait queue */
2431
2213
                        /* as for the completion function, it does not need
2432
2214
                         * to check it any more.
2433
2215
                         * */
2434
 
                        //printk("error:no descriptor left@queue_index %d\n", queue_index);
2435
 
                        //ieee80211_rtl_stop_queue(ieee);
2436
2216
#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
2437
2217
                        skb_queue_tail(&ieee->skb_drv_aggQ[queue_index], txb->fragments[i]);
2438
2218
#else
2441
2221
                }else{
2442
2222
                        ieee->softmac_data_hard_start_xmit(
2443
2223
                                        txb->fragments[i],
2444
 
                                        ieee->dev,ieee->rate);
2445
 
                        //ieee->stats.tx_packets++;
2446
 
                        //ieee->stats.tx_bytes += txb->fragments[i]->len;
2447
 
                        //ieee->dev->trans_start = jiffies;
 
2224
                                        ieee, ieee->rate);
2448
2225
                }
2449
2226
        }
2450
 
#endif
 
2227
 
2451
2228
        ieee80211_txb_free(txb);
2452
2229
 
2453
 
//exit:
2454
2230
        spin_unlock_irqrestore(&ieee->lock,flags);
2455
2231
 
2456
2232
}
2468
2244
 
2469
2245
                        ieee->softmac_data_hard_start_xmit(
2470
2246
                                ieee->tx_pending.txb->fragments[i],
2471
 
                                ieee->dev,ieee->rate);
2472
 
                                //(i+1)<ieee->tx_pending.txb->nr_frags);
 
2247
                                ieee, ieee->rate);
2473
2248
                        ieee->stats.tx_packets++;
2474
 
                //      ieee->dev->trans_start = jiffies;
2475
2249
                }
2476
2250
        }
2477
2251
 
2520
2294
                        else
2521
2295
                                ieee->seq_ctrl[0]++;
2522
2296
 
2523
 
                        ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
2524
 
                        //dev_kfree_skb_any(skb);//edit by thomas
 
2297
                        ieee->softmac_data_hard_start_xmit(skb, ieee, ieee->basic_rate);
2525
2298
                }
2526
2299
        }
2527
2300
        if (!ieee->queue_stop && ieee->tx_pending.txb)
2539
2312
 
2540
2313
void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee)
2541
2314
{
2542
 
        //unsigned long flags;
2543
 
        //spin_lock_irqsave(&ieee->lock,flags);
2544
 
 
2545
2315
        if (! netif_queue_stopped(ieee->dev)){
2546
2316
                netif_stop_queue(ieee->dev);
2547
2317
                ieee->softmac_stats.swtxstop++;
2548
2318
        }
2549
2319
        ieee->queue_stop = 1;
2550
 
        //spin_unlock_irqrestore(&ieee->lock,flags);
2551
 
 
2552
2320
}
2553
2321
 
2554
2322
 
2580
2348
 
2581
2349
        memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
2582
2350
 
2583
 
        ieee->set_chan(ieee->dev, ieee->current_network.channel);
 
2351
        ieee->set_chan(ieee, ieee->current_network.channel);
2584
2352
        ieee->state = IEEE80211_LINKED;
2585
 
        ieee->link_change(ieee->dev);
 
2353
        ieee->link_change(ieee);
2586
2354
        notify_wx_assoc_event(ieee);
2587
2355
 
2588
2356
        if (ieee->data_hard_resume)
2589
 
                ieee->data_hard_resume(ieee->dev);
 
2357
                ieee->data_hard_resume(ieee);
2590
2358
 
2591
2359
        netif_carrier_on(ieee->dev);
2592
2360
}
2596
2364
        if(ieee->raw_tx){
2597
2365
 
2598
2366
                if (ieee->data_hard_resume)
2599
 
                        ieee->data_hard_resume(ieee->dev);
 
2367
                        ieee->data_hard_resume(ieee);
2600
2368
 
2601
2369
                netif_carrier_on(ieee->dev);
2602
2370
        }
2631
2399
 
2632
2400
 
2633
2401
#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.
2634
 
//      if((IS_DOT11D_ENABLE(ieee)) && (ieee->state == IEEE80211_NOLINK))
2635
2402
        if (ieee->state == IEEE80211_NOLINK)
2636
2403
                ieee->current_network.channel = 6;
2637
2404
#endif
2690
2457
 
2691
2458
                // By default, WMM function will be disabled in IBSS mode
2692
2459
                ieee->current_network.QoS_Enable = 0;
2693
 
                ieee->SetWirelessMode(ieee->dev, IEEE_G);
 
2460
                ieee->SetWirelessMode(ieee, IEEE_G);
2694
2461
                ieee->current_network.atim_window = 0;
2695
2462
                ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
2696
2463
                if(ieee->short_slot)
2700
2467
 
2701
2468
        ieee->state = IEEE80211_LINKED;
2702
2469
 
2703
 
        ieee->set_chan(ieee->dev, ieee->current_network.channel);
2704
 
        ieee->link_change(ieee->dev);
 
2470
        ieee->set_chan(ieee, ieee->current_network.channel);
 
2471
        ieee->link_change(ieee);
2705
2472
 
2706
2473
        notify_wx_assoc_event(ieee);
2707
2474
 
2708
2475
        ieee80211_start_send_beacons(ieee);
2709
2476
 
2710
2477
        if (ieee->data_hard_resume)
2711
 
                ieee->data_hard_resume(ieee->dev);
 
2478
                ieee->data_hard_resume(ieee);
2712
2479
        netif_carrier_on(ieee->dev);
2713
2480
 
2714
2481
        up(&ieee->wx_sem);
2755
2522
        if (ieee->state == IEEE80211_NOLINK){
2756
2523
#ifdef ENABLE_IPS
2757
2524
                if(ieee->ieee80211_ips_leave_wq != NULL)
2758
 
                        ieee->ieee80211_ips_leave_wq(ieee->dev);
 
2525
                        ieee->ieee80211_ips_leave_wq(ieee);
2759
2526
#endif
2760
2527
                ieee->actscanning = true;
2761
2528
                ieee80211_rtl_start_scan(ieee);
2773
2540
                        ieee80211_reset_queue(ieee);
2774
2541
 
2775
2542
        if (ieee->data_hard_stop)
2776
 
                        ieee->data_hard_stop(ieee->dev);
 
2543
                ieee->data_hard_stop(ieee);
2777
2544
#ifdef ENABLE_DOT11D
2778
2545
        if(IS_DOT11D_ENABLE(ieee))
2779
2546
                Dot11d_Reset(ieee);
2780
2547
#endif
2781
2548
        ieee->is_set_key = false;
2782
 
        ieee->link_change(ieee->dev);
2783
 
        //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
 
2549
        ieee->link_change(ieee);
2784
2550
        if (ieee->state == IEEE80211_LINKED ||
2785
2551
            ieee->state == IEEE80211_ASSOCIATING) {
2786
2552
                ieee->state = IEEE80211_NOLINK;
2937
2703
 
2938
2704
        if (ieee->current_network.beacon_interval == 0)
2939
2705
                ieee->current_network.beacon_interval = 100;
2940
 
//      printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel);
2941
 
//      ieee->set_chan(ieee->dev,ieee->current_network.channel);
2942
2706
 
2943
2707
        for(i = 0; i < 17; i++) {
2944
2708
          ieee->last_rxseq_num[i] = -1;
3027
2791
        ieee->beacon_timer.data = (unsigned long) ieee;
3028
2792
        ieee->beacon_timer.function = ieee80211_send_beacon_cb;
3029
2793
 
3030
 
#ifdef PF_SYNCTHREAD
3031
 
        ieee->wq = create_workqueue(DRV_NAME,0);
3032
 
#else
3033
2794
        ieee->wq = create_workqueue(DRV_NAME);
3034
 
#endif
3035
2795
 
3036
2796
        INIT_DELAYED_WORK(&ieee->start_ibss_wq,ieee80211_start_ibss_wq);
3037
2797
        INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq);
3058
2818
{
3059
2819
        down(&ieee->wx_sem);
3060
2820
#ifdef ENABLE_DOT11D
3061
 
        if(NULL != ieee->pDot11dInfo)
3062
 
        {
3063
 
                kfree(ieee->pDot11dInfo);
3064
 
                ieee->pDot11dInfo = NULL;
3065
 
        }
 
2821
        kfree(ieee->pDot11dInfo);
 
2822
        ieee->pDot11dInfo = NULL;
3066
2823
#endif
3067
2824
        del_timer_sync(&ieee->associate_timer);
3068
2825
 
3176
2933
 
3177
2934
 
3178
2935
        if (ieee->set_security)
3179
 
                ieee->set_security(ieee->dev, &sec);
3180
 
        //else
3181
 
        //      ret = -EOPNOTSUPP;
 
2936
                ieee->set_security(ieee, &sec);
3182
2937
 
3183
2938
        return ret;
3184
2939
}
3226
2981
                        sec.level = SEC_LEVEL_1;
3227
2982
                }
3228
2983
                if (ieee->set_security)
3229
 
                        ieee->set_security(ieee->dev, &sec);
 
2984
                        ieee->set_security(ieee, &sec);
3230
2985
                break;
3231
2986
        }
3232
2987
 
3392
3147
        }
3393
3148
 done:
3394
3149
        if (ieee->set_security)
3395
 
                ieee->set_security(ieee->dev, &sec);
 
3150
                ieee->set_security(ieee, &sec);
3396
3151
 
3397
3152
        /* Do not reset port if card is in Managed mode since resetting will
3398
3153
         * generate new IEEE 802.11 authentication which may end up in looping
3402
3157
        if (ieee->reset_on_keychange &&
3403
3158
            ieee->iw_mode != IW_MODE_INFRA &&
3404
3159
            ieee->reset_port &&
3405
 
            ieee->reset_port(ieee->dev)) {
 
3160
            ieee->reset_port(ieee)) {
3406
3161
                printk("reset_port failed\n");
3407
3162
                param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED;
3408
3163
                return -EINVAL;