1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
|
#include "Mp_Precomp.h"
#if WPP_SOFTWARE_TRACE
#include "BAGen.tmh"
#endif
VOID
ActivateBAEntry(
PADAPTER Adapter,
PBA_RECORD pBA,
u2Byte Time
)
{
RT_TRACE(COMP_HT, DBG_LOUD, ("pBA->bValid = TRUE\r\n"));
pBA->bValid = TRUE;
if(Time != 0)
PlatformSetTimer(Adapter, &pBA->Timer, Time);
}
VOID
DeActivateBAEntry(
PADAPTER Adapter,
PBA_RECORD pBA
)
{
RT_TRACE(COMP_HT, DBG_LOUD, ("pBA->bValid = FALSE\r\n"));
pBA->bValid = FALSE;
PlatformCancelTimer(Adapter, &pBA->Timer);
}
VOID
ExtendBAEntry(
PADAPTER Adapter,
PBA_RECORD pBA
)
{
// if(pBA->bValid && pBA->LifeTime!=0)
// {
// PlatformCancelTimer(Adapter, &pBA->Timer);
// PlatformSetTimer(Adapter, &pBA->Timer, pBA->LifeTime);
// }
}
BOOLEAN
TxTsDeleteBA(
PADAPTER Adapter,
PTX_TS_RECORD pTxTs
)
{
PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord;
PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord;
BOOLEAN bSendDELBA = FALSE;
// Delete pending BA
if(pPendingBa->bValid)
{
DeActivateBAEntry(Adapter, pPendingBa);
bSendDELBA = TRUE;
}
// Delete admitted BA
if(pAdmittedBa->bValid)
{
DeActivateBAEntry(Adapter, pAdmittedBa);
bSendDELBA = TRUE;
}
return bSendDELBA;
}
BOOLEAN
RxTsDeleteBA(
PADAPTER Adapter,
PRX_TS_RECORD pRxTs
)
{
PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord;
BOOLEAN bSendDELBA = FALSE;
if(pBa->bValid)
{
DeActivateBAEntry(Adapter, pBa);
bSendDELBA = TRUE;
}
return bSendDELBA;
}
VOID
ResetBaEntry(
PBA_RECORD pBA
)
{
pBA->bValid = FALSE;
pBA->BaParamSet = 0;
pBA->BaTimeoutValue = 0;
pBA->DialogToken = 0;
pBA->BaStartSeqCtrl = 0;
}
VOID
ConstructADDBAReq(
IN PADAPTER Adapter,
IN pu1Byte Addr,
IN PBA_RECORD pBA,
OUT pu1Byte Buffer,
OUT pu4Byte pLength
)
{
OCTET_STRING osADDBAFrame, tmp;
FillOctetString(osADDBAFrame, Buffer, 0);
*pLength = 0;
ConstructMaFrameHdr(
Adapter,
Addr,
ACT_CAT_BA,
ACT_ADDBAREQ,
&osADDBAFrame );
// Dialog Token
FillOctetString(tmp, &pBA->DialogToken, 1);
PacketAppendData(&osADDBAFrame, tmp);
// BA Parameter Set
FillOctetString(tmp, &pBA->BaParamSet, 2);
PacketAppendData(&osADDBAFrame, tmp);
// BA Timeout Value
FillOctetString(tmp, &pBA->BaTimeoutValue, 2);
PacketAppendData(&osADDBAFrame, tmp);
// BA Start SeqCtrl
FillOctetString(tmp, &pBA->BaStartSeqCtrl, 2);
PacketAppendData(&osADDBAFrame, tmp);
*pLength = osADDBAFrame.Length;
}
VOID
ConstructADDBARsp(
IN PADAPTER Adapter,
IN pu1Byte Addr,
IN PBA_RECORD pBA,
IN u2Byte StatusCode,
OUT pu1Byte Buffer,
OUT pu4Byte pLength
)
{
OCTET_STRING osADDBAFrame, tmp;
FillOctetString(osADDBAFrame, Buffer, 0);
*pLength = 0;
ConstructMaFrameHdr(
Adapter,
Addr,
ACT_CAT_BA,
ACT_ADDBARSP,
&osADDBAFrame );
// Dialog Token
FillOctetString(tmp, &pBA->DialogToken, 1);
PacketAppendData(&osADDBAFrame, tmp);
// Status Code
FillOctetString(tmp, &StatusCode, 2);
PacketAppendData(&osADDBAFrame, tmp);
// BA Parameter Set
FillOctetString(tmp, &pBA->BaParamSet, 2);
PacketAppendData(&osADDBAFrame, tmp);
// BA Timeout Value
FillOctetString(tmp, &pBA->BaTimeoutValue, 2);
PacketAppendData(&osADDBAFrame, tmp);
*pLength = osADDBAFrame.Length;
}
VOID
ConstructDELBA(
IN PADAPTER Adapter,
IN pu1Byte Addr,
IN PBA_RECORD pBA,
IN TR_SELECT TxRxSelect,
IN u2Byte ReasonCode,
OUT pu1Byte Buffer,
OUT pu4Byte pLength
)
{
OCTET_STRING osDELBAFrame, tmp;
u2Byte DelbaParamSet=0;
SET_DELBA_PARAM_SET_FIELD_INITIATOR(&DelbaParamSet, (TxRxSelect==TX_DIR)?1:0 );
SET_DELBA_PARAM_SET_FIELD_TID(&DelbaParamSet, GET_BA_PARAM_SET_FIELD_TID(&(pBA->BaParamSet))) ;
FillOctetString(osDELBAFrame, Buffer, 0);
*pLength = 0;
ConstructMaFrameHdr(
Adapter,
Addr,
ACT_CAT_BA,
ACT_DELBA,
&osDELBAFrame );
// DELBA Parameter Set
FillOctetString(tmp, &DelbaParamSet, 2);
PacketAppendData(&osDELBAFrame, tmp);
// Reason Code
FillOctetString(tmp, &ReasonCode, 2);
PacketAppendData(&osDELBAFrame, tmp);
*pLength = osDELBAFrame.Length;
}
VOID
SendADDBAReq(
IN PADAPTER Adapter,
IN pu1Byte Addr,
IN PBA_RECORD pBA
)
{
PRT_TCB pTcb;
PRT_TX_LOCAL_BUFFER pBuf;
u1Byte DataRate = MgntQuery_MgntFrameTxRate(Adapter, Addr);
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>SendADDBAReq()\n"));
PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
if(MgntGetBuffer(Adapter, &pTcb, &pBuf))
{
ConstructADDBAReq(Adapter, Addr, pBA, pBuf->Buffer.VirtualAddress, &pTcb->PacketLength);
if(pTcb->PacketLength != 0)
{
if(ACTING_AS_AP(Adapter))
MgntSendPacket(Adapter, pTcb, pBuf, pTcb->PacketLength, BE_QUEUE, DataRate);
else
MgntSendPacket(Adapter, pTcb, pBuf, pTcb->PacketLength, NORMAL_QUEUE, DataRate);
}
}
PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
}
VOID
SendADDBARsp(
IN PADAPTER Adapter,
IN pu1Byte Addr,
IN PBA_RECORD pBA,
IN u2Byte StatusCode
)
{
PRT_TCB pTcb;
PRT_TX_LOCAL_BUFFER pBuf;
u1Byte DataRate = MgntQuery_MgntFrameTxRate(Adapter, Addr);
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>SendADDBARsp()\n"));
PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
if(MgntGetBuffer(Adapter, &pTcb, &pBuf))
{
ConstructADDBARsp(
Adapter,
Addr,
pBA,
StatusCode,
pBuf->Buffer.VirtualAddress,
&pTcb->PacketLength );
if(pTcb->PacketLength != 0)
MgntSendPacket(Adapter, pTcb, pBuf, pTcb->PacketLength, NORMAL_QUEUE, DataRate);
}
PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
}
VOID
SendDELBA(
IN PADAPTER Adapter,
IN pu1Byte Addr,
IN PBA_RECORD pBA,
IN TR_SELECT TxRxSelect,
IN u2Byte ReasonCode
)
{
PRT_TCB pTcb;
PRT_TX_LOCAL_BUFFER pBuf;
u1Byte DataRate = MgntQuery_MgntFrameTxRate(Adapter, Addr);
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>SendDELBA()\n"));
PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
if(MgntGetBuffer(Adapter, &pTcb, &pBuf))
{
ConstructDELBA(
Adapter,
Addr,
pBA,
TxRxSelect,
ReasonCode,
pBuf->Buffer.VirtualAddress,
&pTcb->PacketLength );
if(pTcb->PacketLength != 0)
MgntSendPacket(Adapter, pTcb, pBuf, pTcb->PacketLength, NORMAL_QUEUE, DataRate);
}
PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
}
RT_STATUS
OnADDBAReq(
IN PADAPTER Adapter,
IN PRT_RFD pRfd,
IN POCTET_STRING mmpdu
)
{
PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
PBA_RECORD pBA;
PRX_TS_RECORD pTS;
pu1Byte Addr = Frame_Addr2(*mmpdu);
u2Byte StatusCode;
RT_TRACE(COMP_QOS, DBG_TRACE, ("=====>OnADDBAReq()\n"));
// CategoryCode(1) + ActionCode(1) + DialogToken(1) + ParameterSet(2) + TimeoutValue(2) + StartSequence(2)
if(mmpdu->Length < sMacHdrLng + 9)
{
RT_TRACE(COMP_QOS, DBG_SERIOUS, ("OnADDBAReq(): Invalid length(%d) of frame\n", mmpdu->Length));
return RT_STATUS_MALFORMED_PKT;
}
//
// Check Block Ack support.
// Reject if there is no support of Block Ack.
//
if( (pMgntInfo->pStaQos->CurrentQosMode == QOS_DISABLE) ||
(pMgntInfo->pHTInfo->bCurrentHTSupport == FALSE) ||
(pMgntInfo->pHTInfo->bAcceptAddbaReq == FALSE) ||
(pMgntInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ) )
{
StatusCode = ADDBA_STATUS_REFUSED;
goto OnADDBAReq_Fail;
}
// Add by hpfan: reject addba when 4-way is not finished
if(pMgntInfo->bWiFiConfg &&
pMgntInfo->SecurityInfo.SecLvl > RT_SEC_LVL_NONE && !SecIsTxKeyInstalled(Adapter, pMgntInfo->Bssid))
{
StatusCode = ADDBA_STATUS_REFUSED;
goto OnADDBAReq_Fail;
}
//
// Search for related traffic stream.
// If there is no matched TS, reject the ADDBA request.
//
if( !GetTs(
Adapter,
(PTS_COMMON_INFO*)(&pTS),
Addr,
GET_BA_FRAME_PARAM_SET_TID(mmpdu->Octet),
RX_DIR,
TRUE) )
{
StatusCode = ADDBA_STATUS_REFUSED;
goto OnADDBAReq_Fail;
}
pBA = &pTS->RxAdmittedBARecord;
//
// To Determine the ADDBA Req content
// We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
// I want to check StartSeqCtrl to make sure when we start aggregation!!!
//
if(GET_BA_FRAME_PARAM_SET_BA_POLICY(mmpdu->Octet) == BA_POLICY_DELAYED)
{
StatusCode = ADDBA_STATUS_INVALID_PARAM;
goto OnADDBAReq_Fail;
}
//
// Clear all packets queued in driver for RxReorder and prepare to receive packet from new
// new sequence start!!
// This fix the protocol IOT issue with Netgear WRT3500.
//
FlushRxTsPendingPkts(Adapter, pTS);
//
// Admit the ADDBA Request
//
DeActivateBAEntry(Adapter, pBA);
PlatformMoveMemory(&(pBA->DialogToken) , GET_BA_FRAME_DIALOG_TOKEN(mmpdu->Octet), 1);
PlatformMoveMemory(&(pBA->BaParamSet) , GET_BA_FRAME_PARAM_SET(mmpdu->Octet), 2);
PlatformMoveMemory(&(pBA->BaTimeoutValue), GET_BA_FRAME_TIMEOUT_VALUE(mmpdu->Octet), 2);
PlatformMoveMemory(&(pBA->BaStartSeqCtrl), GET_BAREQ_FRAME_START_SQECTRL(mmpdu->Octet), 2);
{
SET_BA_PARAM_SET_FIELD_BUF_SIZE( &(pBA->BaParamSet), 64); // At least, forced by SPEC
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnADDBAReq(): SET_FIELD_BUF_SIZE = 64\n"));
}
ActivateBAEntry(Adapter, pBA, 0);
SendADDBARsp(Adapter, Addr, pBA, ADDBA_STATUS_SUCCESS);
// End of procedure.
return RT_STATUS_SUCCESS;
OnADDBAReq_Fail:
{
BA_RECORD BA;
PlatformMoveMemory(&(BA.BaParamSet), GET_BA_FRAME_PARAM_SET(mmpdu->Octet), 2);
PlatformMoveMemory(&(BA.BaTimeoutValue), GET_BA_FRAME_TIMEOUT_VALUE(mmpdu->Octet), 2);
PlatformMoveMemory(&(BA.DialogToken), GET_BA_FRAME_DIALOG_TOKEN(mmpdu->Octet), 1);
SET_BA_PARAM_SET_FIELD_BA_POLICY(&(BA.BaParamSet), BA_POLICY_IMMEDIATE);
SendADDBARsp(Adapter, Addr, &BA, StatusCode);
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnADDBAReq(): OnADDBAReq_Fail\n"));
}
return RT_STATUS_SUCCESS;
}
RT_STATUS
OnADDBARsp(
IN PADAPTER Adapter,
IN PRT_RFD pRfd,
IN POCTET_STRING mmpdu
)
{
PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
PBA_RECORD pPendingBA, pAdmittedBA;
PTX_TS_RECORD pTS;
pu1Byte Addr = Frame_Addr2(*mmpdu);
pu1Byte pDialogToken = GET_BA_FRAME_DIALOG_TOKEN(mmpdu->Octet);
pu1Byte pStatusCode = GET_BA_FRAME_STATUS_CODE(mmpdu->Octet);
u2Byte ReasonCode = ADDBA_STATUS_INVALID_PARAM;
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>OnADDBARsp()\n"));
// CategoryCode(1) + ActionCode(1) + DialogToken(1) + StatusCode(2) + ParameterSet(2) + TimeoutValue(2)
if(mmpdu->Length < sMacHdrLng + 9)
{
RT_TRACE(COMP_QOS, DBG_SERIOUS, ("OnADDBARsp(): Invalid length(%d) of frame\n", mmpdu->Length));
return RT_STATUS_MALFORMED_PKT;
}
//
// Check the capability
// Since we can always receive A-MPDU, we just check if it is under HT mode.
//
if(pMgntInfo->pStaQos->CurrentQosMode == QOS_DISABLE ||
pMgntInfo->pHTInfo->bCurrentHTSupport == FALSE ||
pMgntInfo->pHTInfo->bCurrentAMPDUEnable == FALSE )
{
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
}
//
// Search for related TS.
// If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
//
if (!GetTs(
Adapter,
(PTS_COMMON_INFO*)(&pTS),
Addr,
GET_BA_FRAME_PARAM_SET_TID(mmpdu->Octet),
TX_DIR,
FALSE) )
{
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
}
pTS->bAddBaReqInProgress = FALSE;
pPendingBA = &pTS->TxPendingBARecord;
pAdmittedBA = &pTS->TxAdmittedBARecord;
//
// Check if related BA is waiting for setup.
// If not, reject by sending DELBA frame.
//
if((pAdmittedBA->bValid==TRUE))
{
// Since BA is already setup, we ignore all other ADDBA Response.
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"));
return RT_STATUS_PKT_DROP;
}
else if((pPendingBA->bValid == FALSE) ||(*pDialogToken != pPendingBA->DialogToken))
{
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"));
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
}
else
{
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", (*pStatusCode) ));
DeActivateBAEntry(Adapter, pPendingBA);
}
if((*pStatusCode) == ADDBA_STATUS_SUCCESS)
{
//
// Determine ADDBA Rsp content here.
// We can compare the value of BA parameter set that Peer returned and Self sent.
// If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
//
if(GET_BA_FRAME_PARAM_SET_BA_POLICY(mmpdu->Octet) == BA_POLICY_DELAYED)
{
// Since this is a kind of ADDBA failed, we delay next ADDBA process.
pTS->bAddBaReqDelayed = TRUE;
DeActivateBAEntry(Adapter, pAdmittedBA);
ReasonCode = DELBA_REASON_END_BA;
goto OnADDBARsp_Reject;
}
//
// Admitted condition
//
PlatformMoveMemory(&(pAdmittedBA->DialogToken) , GET_BA_FRAME_DIALOG_TOKEN(mmpdu->Octet), 1);
PlatformMoveMemory(&(pAdmittedBA->BaTimeoutValue), GET_BA_FRAME_TIMEOUT_VALUE(mmpdu->Octet), 2);
PlatformMoveMemory(&(pAdmittedBA->BaStartSeqCtrl), &(pPendingBA->BaStartSeqCtrl), 2);
PlatformMoveMemory(&(pAdmittedBA->BaParamSet) , GET_BA_FRAME_PARAM_SET(mmpdu->Octet), 2);
pAdmittedBA->BufferSize = GET_BA_FRAME_PARAM_SET_BUF_SIZE(mmpdu->Octet);
if(0 == pAdmittedBA->BufferSize)
{
RT_PRINT_ADDR(COMP_HT, DBG_WARNING, "[WARNING]OnADDBARsp(): Incorrect BufferSize (0) in AddBaRsp, skip this BlockAck process for Addr = ", Addr);
ReasonCode = ADDBA_STATUS_INVALID_PARAM;
goto OnADDBARsp_Reject;
}
DeActivateBAEntry(Adapter, pAdmittedBA);
ActivateBAEntry(Adapter, pAdmittedBA, 0 );
}
else
{
// Delay next ADDBA process.
pTS->bAddBaReqDelayed = TRUE;
}
// End of procedure
if(Adapter->TDLSSupport)
{
TDLS_OnAddBaRsp(Adapter, mmpdu);
}
return RT_STATUS_SUCCESS;
OnADDBARsp_Reject:
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnADDBARsp(): Rejected!!!!!!!!ReasonCode=%d\n", ReasonCode));
{
BA_RECORD BA;
PlatformMoveMemory(&(BA.BaParamSet), GET_BA_FRAME_PARAM_SET(mmpdu->Octet), 2);
SendDELBA(Adapter, Addr, &BA, TX_DIR, ReasonCode);
}
return RT_STATUS_SUCCESS;
}
RT_STATUS
OnDELBA(
IN PADAPTER Adapter,
IN PRT_RFD pRfd,
IN POCTET_STRING mmpdu
)
{
PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
pu1Byte Addr = Frame_Addr2(*mmpdu);
BA_RECORD BA;
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>OnDELBA()\n"));
if(pMgntInfo->pStaQos->CurrentQosMode == QOS_DISABLE ||
pMgntInfo->pHTInfo->bCurrentHTSupport == FALSE )
return RT_STATUS_SUCCESS;
// CategoryCode(1) + ActionCode(1) + ParameterSet(2) + ReasonCode(2)
if(mmpdu->Length < sMacHdrLng + 6)
{
RT_TRACE(COMP_QOS, DBG_SERIOUS, ("OnDELBA(): Invalid length(%d) of frame\n", mmpdu->Length));
return RT_STATUS_MALFORMED_PKT;
}
if(GET_DELBA_FRAME_PARAM_SET_INITIATOR(mmpdu->Octet) == 1)
{
PRX_TS_RECORD pRxTs;
if( !GetTs(
Adapter,
(PTS_COMMON_INFO*)&pRxTs,
Addr,
GET_DELBA_FRAME_PARAM_SET_TID(mmpdu->Octet),
RX_DIR,
FALSE) )
{
return RT_STATUS_FAILURE;
}
//BA Process Error when link with Netgear3500 v1
//Fix do S3/S4 long run error
//by sherry 20101124
if(pMgntInfo->IOTPeer == HT_IOT_PEER_MARVELL)
{
PlatformMoveMemory(&(BA.BaParamSet), GET_BA_FRAME_PARAM_SET(mmpdu->Octet), 2);
SendDELBA(Adapter, Addr, &BA, RX_DIR, 1);
}
RxTsDeleteBA(Adapter, pRxTs);
}
else
{
PTX_TS_RECORD pTxTs;
if(!GetTs(
Adapter,
(PTS_COMMON_INFO*)&pTxTs,
Addr,
GET_DELBA_FRAME_PARAM_SET_TID(mmpdu->Octet),
TX_DIR,
FALSE) )
{
return RT_STATUS_FAILURE;
}
pTxTs->bUsingBa = FALSE;
pTxTs->bAddBaReqInProgress = FALSE;
pTxTs->bAddBaReqDelayed = FALSE;
PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer);
TxTsDeleteBA(Adapter, pTxTs);
}
return RT_STATUS_SUCCESS;
}
//
// ADDBA initiate. This can only be called by TX side.
//
VOID
TsInitAddBA(
PADAPTER Adapter,
PTX_TS_RECORD pTS,
u1Byte Policy,
BOOLEAN bOverwritePending
)
{
PBA_RECORD pBA = &pTS->TxPendingBARecord;
PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
PRT_HIGH_THROUGHPUT pHTInfo = GET_HT_INFO(pMgntInfo);
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>TsInitAddBA()\n"));
if(pBA->bValid==TRUE && bOverwritePending==FALSE)
return;
// Set parameters to "Pending" variable set
DeActivateBAEntry(Adapter, pBA);
pBA->DialogToken++; // DialogToken: Only keep the latest dialog token
SET_BA_PARAM_SET_FIELD_AMSDU_SUPPORT(&(pBA->BaParamSet), 0); // Do not support A-MSDU with A-MPDU now!!
SET_BA_PARAM_SET_FIELD_BA_POLICY(&(pBA->BaParamSet), Policy); // Policy: Delayed or Immediate
SET_BA_PARAM_SET_FIELD_TID(&(pBA->BaParamSet), GET_TSPEC_BODY_TSINFO_TSID(pTS->TsCommonInfo.TSpec)); // TID
// BufferSize: This need to be set according to A-MPDU vector
{
SET_BA_PARAM_SET_FIELD_BUF_SIZE(&(pBA->BaParamSet), 64); // BufferSize: This need to be set according to A-MPDU vector
}
// TODO: Enable AMSDU may not be aware of AMPDU
if(HT_AMSDU_WITHIN_AMPDU == pHTInfo->ForcedAMSDUMode)
{
SET_BA_PARAM_SET_FIELD_AMSDU_SUPPORT(&(pBA->BaParamSet), 1);
}
pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer
SET_BA_START_SQECTRL_FIELD_SEQ_NUM(&(pBA->BaStartSeqCtrl), ((pTS->TxCurSeq) % 4096));
ActivateBAEntry(Adapter, pBA, BA_SETUP_TIMEOUT);
SendADDBAReq(Adapter, pTS->TsCommonInfo.Addr, pBA);
if(!ACTING_AS_AP(Adapter))
{
// Negoitate with current SeqNum, but active this BA after 3 packets Txed
SET_BA_START_SQECTRL_FIELD_SEQ_NUM(&(pBA->BaStartSeqCtrl), ((pTS->TxCurSeq + 3) % 4096));
}
}
VOID
TsInitDelBA(
PADAPTER Adapter,
PTS_COMMON_INFO pTsCommonInfo,
TR_SELECT TxRxSelect
)
{
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>TsInitDelBA()\n"));
if(TxRxSelect == TX_DIR)
{
PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo;
if(TxTsDeleteBA(Adapter, pTxTs))
SendDELBA(
Adapter,
pTsCommonInfo->Addr,
(pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord),
TxRxSelect,
DELBA_REASON_END_BA );
}
else if(TxRxSelect == RX_DIR)
{
PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo;
if(RxTsDeleteBA(Adapter, pRxTs))
SendDELBA(
Adapter,
pTsCommonInfo->Addr,
&pRxTs->RxAdmittedBARecord,
TxRxSelect,
DELBA_REASON_END_BA );
}
}
VOID
BaSetupTimeOut(
PRT_TIMER pTimer
)
{
PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTimer->Context;
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>BaSetupTimeOut()\n"));
pTxTs->bAddBaReqInProgress = FALSE;
pTxTs->bAddBaReqDelayed = TRUE;
pTxTs->TxPendingBARecord.bValid = FALSE;
}
VOID
TxBaInactTimeout(
PRT_TIMER pTimer
)
{
PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTimer->Context;
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>TxBaInactTimeout()\n"));
TxTsDeleteBA(Adapter, pTxTs);
SendDELBA(
Adapter,
pTxTs->TsCommonInfo.Addr,
&pTxTs->TxAdmittedBARecord,
TX_DIR,
DELBA_REASON_TIMEOUT );
}
VOID
RxBaInactTimeout(
PRT_TIMER pTimer
)
{
PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTimer->Context;
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====>RxBaInactTimeout()\n"));
if(ACTING_AS_AP(Adapter))
return;
RxTsDeleteBA(Adapter, pRxTs);
SendDELBA(
Adapter,
pRxTs->TsCommonInfo.Addr,
&pRxTs->RxAdmittedBARecord,
RX_DIR,
DELBA_REASON_TIMEOUT );
}
VOID
RxBACheck(
PADAPTER Adapter,
PRT_RFD pRfd,
POCTET_STRING pFrame
)
{
}
//
// Description: Parse BlockAckReq frame
//
// 2015.08.19. Added by tynli.
//
RT_STATUS
OnBAReq(
IN PADAPTER Adapter,
IN PRT_RFD pRfd,
IN OCTET_STRING ospdu
)
{
PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
pu1Byte pBARFrame = ospdu.Octet;
u1Byte BARAckPolicy, MultiTID, CompressedBitmap, GCR, TIDInfo = 0;
u2Byte StartSeqNum, LatestSeqNum;
PRX_TS_RECORD pTS = NULL;
pu1Byte Addr = Frame_Addr2(ospdu);
BAR_TYPE BARType = BAR_TYPE_BASIC_BAR;
RT_TRACE(COMP_QOS, DBG_LOUD, ("=====> OnBAReq()\n"));
// Header (16) + BAR control (2)
if(ospdu.Length < 16 + 2)
{
RT_TRACE(COMP_QOS, DBG_SERIOUS, ("OnBAReq(): Invalid length(%d) of frame\n", ospdu.Length));
return RT_STATUS_MALFORMED_PKT;
}
//
// Check Block Ack Req support.
// Reject if there is no support of Block Ack Req.
//
if((pMgntInfo->pStaQos->CurrentQosMode == QOS_DISABLE) ||
(pMgntInfo->pHTInfo->bCurrentHTSupport == FALSE))
{
//StatusCode = ADDBA_STATUS_REFUSED;
return RT_STATUS_FAILURE;
}
// Get the BAR control field offset
pBARFrame += 16;
BARAckPolicy = GET_BAR_PARAM_CTRL_FIELD_BAR_ACK_POLICY(pBARFrame);
if(BARAckPolicy == BAR_NORMAL_ACK)
{
// Normal Ack
MultiTID = GET_BAR_PARAM_CTRL_FIELD_MULTI_TID(pBARFrame);
CompressedBitmap = GET_BAR_PARAM_CTRL_FIELD_COMPRESSED_BITMAP(pBARFrame);
GCR = GET_BAR_PARAM_CTRL_FIELD_GCR(pBARFrame);
TIDInfo = GET_BAR_PARAM_CTRL_FIELD_TID_INFO(pBARFrame);
if(MultiTID == 0 && CompressedBitmap == 0 && GCR == 0)
{
// Basic BlockAckReq
BARType = BAR_TYPE_BASIC_BAR;
}
else if(MultiTID == 0 && CompressedBitmap == 1 && GCR == 0)
{
// Compressed BlockAckReq
BARType = BAR_TYPE_COMPRESSED_BAR;
}
else if(MultiTID == 1 && CompressedBitmap == 0 && GCR == 0)
{
// Extended Compressed BlockAckReq
BARType = BAR_TYPE_EXT_COMPRESSED_BAR;
}
else if(MultiTID == 1 && CompressedBitmap == 1 && GCR == 0)
{
// Multi-TID BlockAckReq
BARType = BAR_TYPE_MULTI_TID_BAR;
}
else if(MultiTID == 0 && CompressedBitmap == 1 && GCR == 1)
{
// GCR BlockAckReq
BARType = BAR_TYPE_GCR_BAR;
}
else
{
// Reserved
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnBAReq(): BAR type is reserved.\n"));
}
}
else
{
// No Ack
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnBAReq(): BAR ACK policy is No ACK. Not handle now!!\n"));
}
//
// Search for related traffic stream.
//
if(!GetTs(
Adapter,
(PTS_COMMON_INFO*)(&pTS),
Addr,
TIDInfo,
RX_DIR,
TRUE))
{
return RT_STATUS_FAILURE;
}
if(BARType == BAR_TYPE_BASIC_BAR || BARType == BAR_TYPE_COMPRESSED_BAR ||
BARType == BAR_TYPE_EXT_COMPRESSED_BAR || BARType == BAR_TYPE_GCR_BAR)
{
PRT_LIST_ENTRY pList = &pTS->RxPendingPktList;
// Get BAR Info
pBARFrame += 2;
StartSeqNum = GET_BAR_PARAM_INFO_FIELD_STARTING_SEQ_NUM(pBARFrame);
// Check the last received sequence number
if(!RTIsListEmpty(pList))
{
LatestSeqNum = ((PRX_REORDER_ENTRY)pList->Blink)->SeqNum;
}
else
{
// Pending list is empty!
LatestSeqNum = pTS->RxIndicateSeq;
}
// Update Rx indicate seq num for TS.
if(!(SN_LESS(StartSeqNum, LatestSeqNum) || SN_EQUAL(StartSeqNum, LatestSeqNum)))
{
//
// Indicate packets queued in driver for RxReorder and prepare to receive packet from new
// new sequence start!!
//
if(pTS->RxIndicateState==RXTS_INDICATE_BATCH)
IndicateRxReorderList(Adapter, pTS, FALSE);
else if(pTS->RxIndicateState==RXTS_INDICATE_REORDER)
IndicateRxReorderList(Adapter, pTS, TRUE);
if(!(SN_LESS(StartSeqNum, pTS->RxIndicateSeq) || SN_EQUAL(StartSeqNum, pTS->RxIndicateSeq)))
{
pTS->RxIndicateSeq = StartSeqNum;
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnBAReq(): Update Rx indcate starting sequence (%#X)!!\n", StartSeqNum));
}
}
//RT_TRACE(COMP_QOS, DBG_LOUD, ("OnBAReq(): BARAckPolicy=%d, MultiTID=%d, CompressedBitmap=%#X, GCR=%d, TIDInfo=%d, StartSeqNum=%#X\n",
// BARAckPolicy, MultiTID, CompressedBitmap, GCR, TIDInfo, StartSeqNum));
}
else if(BARType == BAR_TYPE_MULTI_TID_BAR)
{
RT_TRACE(COMP_QOS, DBG_LOUD, ("OnBAReq(): Multi-TID BAR is not supported now!!\n"));
}
//RT_PRINT_DATA(COMP_QOS, DBG_LOUD, "OnBAReq() Frame:\n", ospdu.Octet, ospdu.Length);
return RT_STATUS_SUCCESS;
}
|