1 /********************************************************************************************************************************
2 * This file is created to process BA Action Frame. According to 802.11 spec, there are 3 BA action types at all. And as BA is
3 * related to TS, this part need some structure defined in QOS side code. Also TX RX is going to be resturctured, so how to send
4 * ADDBAREQ ADDBARSP and DELBA packet is still on consideration. Temporarily use MANAGE QUEUE instead of Normal Queue.
6 * *****************************************************************************************************************************/
7 #include <asm/byteorder.h>
8 #include <asm/unaligned.h>
10 #include "rtl819x_BA.h"
12 /********************************************************************************************************************
13 *function: Activate BA entry. And if Time is nozero, start timer.
14 * input: PBA_RECORD pBA //BA entry to be enabled
15 * u16 Time //indicate time delay.
17 ********************************************************************************************************************/
18 static void ActivateBAEntry(struct ieee80211_device
*ieee
, PBA_RECORD pBA
, u16 Time
)
22 mod_timer(&pBA
->Timer
, jiffies
+ msecs_to_jiffies(Time
));
25 /********************************************************************************************************************
26 *function: deactivate BA entry, including its timer.
27 * input: PBA_RECORD pBA //BA entry to be disabled
29 ********************************************************************************************************************/
30 static void DeActivateBAEntry(struct ieee80211_device
*ieee
, PBA_RECORD pBA
)
33 del_timer_sync(&pBA
->Timer
);
35 /********************************************************************************************************************
36 *function: deactivete BA entry in Tx Ts, and send DELBA.
38 * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry.
40 * notice: As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME
41 ********************************************************************************************************************/
42 static u8
TxTsDeleteBA(struct ieee80211_device
*ieee
, PTX_TS_RECORD pTxTs
)
44 PBA_RECORD pAdmittedBa
= &pTxTs
->TxAdmittedBARecord
; //These two BA entries must exist in TS structure
45 PBA_RECORD pPendingBa
= &pTxTs
->TxPendingBARecord
;
46 u8 bSendDELBA
= false;
49 if (pPendingBa
->bValid
) {
50 DeActivateBAEntry(ieee
, pPendingBa
);
55 if (pAdmittedBa
->bValid
) {
56 DeActivateBAEntry(ieee
, pAdmittedBa
);
63 /********************************************************************************************************************
64 *function: deactivete BA entry in Tx Ts, and send DELBA.
66 * PRX_TS_RECORD pRxTs //Rx Ts which is to deactivate BA entry.
68 * notice: As PRX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME, same with above
69 ********************************************************************************************************************/
70 static u8
RxTsDeleteBA(struct ieee80211_device
*ieee
, PRX_TS_RECORD pRxTs
)
72 PBA_RECORD pBa
= &pRxTs
->RxAdmittedBARecord
;
73 u8 bSendDELBA
= false;
76 DeActivateBAEntry(ieee
, pBa
);
83 /********************************************************************************************************************
84 *function: reset BA entry
86 * PBA_RECORD pBA //entry to be reset
88 ********************************************************************************************************************/
89 void ResetBaEntry(PBA_RECORD pBA
)
92 pBA
->BaParamSet
.shortData
= 0;
93 pBA
->BaTimeoutValue
= 0;
95 pBA
->BaStartSeqCtrl
.ShortData
= 0;
97 //These functions need porting here or not?
98 /*******************************************************************************************************************************
99 *function: construct ADDBAREQ and ADDBARSP frame here together.
100 * input: u8* Dst //ADDBA frame's destination
101 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA.
102 * u16 StatusCode //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?)
103 * u8 type //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
105 * return: sk_buff* skb //return constructed skb to xmit
106 *******************************************************************************************************************************/
107 static struct sk_buff
*ieee80211_ADDBA(struct ieee80211_device
*ieee
, u8
*Dst
, PBA_RECORD pBA
, u16 StatusCode
, u8 type
)
109 struct sk_buff
*skb
= NULL
;
110 struct rtl_80211_hdr_3addr
*BAReq
= NULL
;
112 u16 len
= ieee
->tx_headroom
+ 9;
113 //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2))
114 IEEE80211_DEBUG(IEEE80211_DL_TRACE
| IEEE80211_DL_BA
, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __func__
, type
, Dst
, ieee
->dev
);
116 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "pBA is NULL\n");
119 skb
= dev_alloc_skb(len
+ sizeof( struct rtl_80211_hdr_3addr
)); //need to add something others? FIXME
121 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "can't alloc skb for ADDBA_REQ\n");
125 memset(skb
->data
, 0, sizeof( struct rtl_80211_hdr_3addr
)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
126 skb_reserve(skb
, ieee
->tx_headroom
);
128 BAReq
= skb_put(skb
, sizeof(struct rtl_80211_hdr_3addr
));
130 memcpy(BAReq
->addr1
, Dst
, ETH_ALEN
);
131 memcpy(BAReq
->addr2
, ieee
->dev
->dev_addr
, ETH_ALEN
);
133 memcpy(BAReq
->addr3
, ieee
->current_network
.bssid
, ETH_ALEN
);
135 BAReq
->frame_ctl
= cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT
); //action frame
137 //tag += sizeof( struct rtl_80211_hdr_3addr); //move to action field
138 tag
= skb_put(skb
, 9);
142 *tag
++= pBA
->DialogToken
;
144 if (ACT_ADDBARSP
== type
) {
146 printk(KERN_INFO
"=====>to send ADDBARSP\n");
148 put_unaligned_le16(StatusCode
, tag
);
153 put_unaligned_le16(pBA
->BaParamSet
.shortData
, tag
);
157 put_unaligned_le16(pBA
->BaTimeoutValue
, tag
);
160 if (ACT_ADDBAREQ
== type
) {
162 memcpy(tag
, (u8
*)&(pBA
->BaStartSeqCtrl
), 2);
166 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA
|IEEE80211_DL_BA
, skb
->data
, skb
->len
);
172 /********************************************************************************************************************
173 *function: construct DELBA frame
174 * input: u8* dst //DELBA frame's destination
175 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
176 * TR_SELECT TxRxSelect //TX RX direction
177 * u16 ReasonCode //status code.
179 * return: sk_buff* skb //return constructed skb to xmit
180 ********************************************************************************************************************/
181 static struct sk_buff
*ieee80211_DELBA(
182 struct ieee80211_device
*ieee
,
185 TR_SELECT TxRxSelect
,
189 DELBA_PARAM_SET DelbaParamSet
;
190 struct sk_buff
*skb
= NULL
;
191 struct rtl_80211_hdr_3addr
*Delba
= NULL
;
193 //len = head len + DELBA Parameter Set(2) + Reason Code(2)
194 u16 len
= 6 + ieee
->tx_headroom
;
197 IEEE80211_DEBUG(IEEE80211_DL_TRACE
| IEEE80211_DL_BA
, "========>%s(), ReasonCode(%d) sentd to:%pM\n", __func__
, ReasonCode
, dst
);
199 memset(&DelbaParamSet
, 0, 2);
201 DelbaParamSet
.field
.Initiator
= (TxRxSelect
==TX_DIR
)?1:0;
202 DelbaParamSet
.field
.TID
= pBA
->BaParamSet
.field
.TID
;
204 skb
= dev_alloc_skb(len
+ sizeof( struct rtl_80211_hdr_3addr
)); //need to add something others? FIXME
206 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "can't alloc skb for ADDBA_REQ\n");
209 // memset(skb->data, 0, len+sizeof( struct rtl_80211_hdr_3addr));
210 skb_reserve(skb
, ieee
->tx_headroom
);
212 Delba
= skb_put(skb
, sizeof(struct rtl_80211_hdr_3addr
));
214 memcpy(Delba
->addr1
, dst
, ETH_ALEN
);
215 memcpy(Delba
->addr2
, ieee
->dev
->dev_addr
, ETH_ALEN
);
216 memcpy(Delba
->addr3
, ieee
->current_network
.bssid
, ETH_ALEN
);
217 Delba
->frame_ctl
= cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT
); //action frame
219 tag
= skb_put(skb
, 6);
224 // DELBA Parameter Set
226 put_unaligned_le16(DelbaParamSet
.shortData
, tag
);
230 put_unaligned_le16(ReasonCode
, tag
);
233 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA
|IEEE80211_DL_BA
, skb
->data
, skb
->len
);
235 IEEE80211_DEBUG(IEEE80211_DL_TRACE
| IEEE80211_DL_BA
, "<=====%s()\n", __func__
);
239 /********************************************************************************************************************
240 *function: send ADDBAReq frame out
241 * input: u8* dst //ADDBAReq frame's destination
242 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
244 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
245 ********************************************************************************************************************/
246 static void ieee80211_send_ADDBAReq(struct ieee80211_device
*ieee
,
247 u8
*dst
, PBA_RECORD pBA
)
250 skb
= ieee80211_ADDBA(ieee
, dst
, pBA
, 0, ACT_ADDBAREQ
); //construct ACT_ADDBAREQ frames so set statuscode zero.
253 softmac_mgmt_xmit(skb
, ieee
);
254 //add statistic needed here.
255 //and skb will be freed in softmac_mgmt_xmit(), so omit all dev_kfree_skb_any() outside softmac_mgmt_xmit()
259 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "alloc skb error in function %s()\n", __func__
);
263 /********************************************************************************************************************
264 *function: send ADDBARSP frame out
265 * input: u8* dst //DELBA frame's destination
266 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
267 * u16 StatusCode //RSP StatusCode
269 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
270 ********************************************************************************************************************/
271 static void ieee80211_send_ADDBARsp(struct ieee80211_device
*ieee
, u8
*dst
,
272 PBA_RECORD pBA
, u16 StatusCode
)
275 skb
= ieee80211_ADDBA(ieee
, dst
, pBA
, StatusCode
, ACT_ADDBARSP
); //construct ACT_ADDBARSP frames
277 softmac_mgmt_xmit(skb
, ieee
);
281 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "alloc skb error in function %s()\n", __func__
);
287 /********************************************************************************************************************
288 *function: send ADDBARSP frame out
289 * input: u8* dst //DELBA frame's destination
290 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
291 * TR_SELECT TxRxSelect //TX or RX
292 * u16 ReasonCode //DEL ReasonCode
294 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
295 ********************************************************************************************************************/
297 static void ieee80211_send_DELBA(struct ieee80211_device
*ieee
, u8
*dst
,
298 PBA_RECORD pBA
, TR_SELECT TxRxSelect
,
302 skb
= ieee80211_DELBA(ieee
, dst
, pBA
, TxRxSelect
, ReasonCode
); //construct ACT_ADDBARSP frames
304 softmac_mgmt_xmit(skb
, ieee
);
308 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "alloc skb error in function %s()\n", __func__
);
312 /********************************************************************************************************************
313 *function: RX ADDBAReq
314 * input: struct sk_buff * skb //incoming ADDBAReq skb.
315 * return: 0(pass), other(fail)
316 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
317 ********************************************************************************************************************/
318 int ieee80211_rx_ADDBAReq(struct ieee80211_device
*ieee
, struct sk_buff
*skb
)
320 struct rtl_80211_hdr_3addr
*req
= NULL
;
322 u8
*dst
= NULL
, *pDialogToken
= NULL
, *tag
= NULL
;
323 PBA_RECORD pBA
= NULL
;
324 PBA_PARAM_SET pBaParamSet
= NULL
;
325 u16
*pBaTimeoutVal
= NULL
;
326 PSEQUENCE_CONTROL pBaStartSeqCtrl
= NULL
;
327 PRX_TS_RECORD pTS
= NULL
;
329 if (skb
->len
< sizeof(struct rtl_80211_hdr_3addr
) + 9) {
330 IEEE80211_DEBUG(IEEE80211_DL_ERR
,
331 " Invalid skb len in BAREQ(%d / %zu)\n",
333 (sizeof(struct rtl_80211_hdr_3addr
) + 9));
337 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA
|IEEE80211_DL_BA
, skb
->data
, skb
->len
);
339 req
= (struct rtl_80211_hdr_3addr
*) skb
->data
;
341 dst
= &req
->addr2
[0];
342 tag
+= sizeof(struct rtl_80211_hdr_3addr
);
343 pDialogToken
= tag
+ 2; //category+action
344 pBaParamSet
= (PBA_PARAM_SET
)(tag
+ 3); //+DialogToken
345 pBaTimeoutVal
= (u16
*)(tag
+ 5);
346 pBaStartSeqCtrl
= (PSEQUENCE_CONTROL
)(req
+ 7);
348 printk(KERN_INFO
"====================>rx ADDBAREQ from :%pM\n", dst
);
349 //some other capability is not ready now.
350 if ((ieee
->current_network
.qos_data
.active
== 0) ||
351 (!ieee
->pHTInfo
->bCurrentHTSupport
)) //||
352 // (!ieee->pStaQos->bEnableRxImmBA) )
354 rc
= ADDBA_STATUS_REFUSED
;
355 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee
->current_network
.qos_data
.active
, ieee
->pHTInfo
->bCurrentHTSupport
);
356 goto OnADDBAReq_Fail
;
358 // Search for related traffic stream.
359 // If there is no matched TS, reject the ADDBA request.
362 (PTS_COMMON_INFO
*)(&pTS
),
364 (u8
)(pBaParamSet
->field
.TID
),
367 rc
= ADDBA_STATUS_REFUSED
;
368 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "can't get TS in %s()\n", __func__
);
369 goto OnADDBAReq_Fail
;
371 pBA
= &pTS
->RxAdmittedBARecord
;
372 // To Determine the ADDBA Req content
373 // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
374 // I want to check StartSeqCtrl to make sure when we start aggregation!!!
376 if (pBaParamSet
->field
.BAPolicy
== BA_POLICY_DELAYED
) {
377 rc
= ADDBA_STATUS_INVALID_PARAM
;
378 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "BA Policy is not correct in %s()\n", __func__
);
379 goto OnADDBAReq_Fail
;
381 // Admit the ADDBA Request
383 DeActivateBAEntry(ieee
, pBA
);
384 pBA
->DialogToken
= *pDialogToken
;
385 pBA
->BaParamSet
= *pBaParamSet
;
386 pBA
->BaTimeoutValue
= *pBaTimeoutVal
;
387 pBA
->BaStartSeqCtrl
= *pBaStartSeqCtrl
;
388 //for half N mode we only aggregate 1 frame
389 if (ieee
->GetHalfNmodeSupportByAPsHandler(ieee
->dev
))
390 pBA
->BaParamSet
.field
.BufferSize
= 1;
392 pBA
->BaParamSet
.field
.BufferSize
= 32;
393 ActivateBAEntry(ieee
, pBA
, pBA
->BaTimeoutValue
);
394 ieee80211_send_ADDBARsp(ieee
, dst
, pBA
, ADDBA_STATUS_SUCCESS
);
402 BA
.BaParamSet
= *pBaParamSet
;
403 BA
.BaTimeoutValue
= *pBaTimeoutVal
;
404 BA
.DialogToken
= *pDialogToken
;
405 BA
.BaParamSet
.field
.BAPolicy
= BA_POLICY_IMMEDIATE
;
406 ieee80211_send_ADDBARsp(ieee
, dst
, &BA
, rc
);
407 return 0; //we send RSP out.
412 /********************************************************************************************************************
413 *function: RX ADDBARSP
414 * input: struct sk_buff * skb //incoming ADDBAReq skb.
415 * return: 0(pass), other(fail)
416 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
417 ********************************************************************************************************************/
418 int ieee80211_rx_ADDBARsp(struct ieee80211_device
*ieee
, struct sk_buff
*skb
)
420 struct rtl_80211_hdr_3addr
*rsp
= NULL
;
421 PBA_RECORD pPendingBA
, pAdmittedBA
;
422 PTX_TS_RECORD pTS
= NULL
;
423 u8
*dst
= NULL
, *pDialogToken
= NULL
, *tag
= NULL
;
424 u16
*pStatusCode
= NULL
, *pBaTimeoutVal
= NULL
;
425 PBA_PARAM_SET pBaParamSet
= NULL
;
428 if (skb
->len
< sizeof(struct rtl_80211_hdr_3addr
) + 9) {
429 IEEE80211_DEBUG(IEEE80211_DL_ERR
,
430 " Invalid skb len in BARSP(%d / %zu)\n",
432 (sizeof(struct rtl_80211_hdr_3addr
) + 9));
435 rsp
= (struct rtl_80211_hdr_3addr
*)skb
->data
;
437 dst
= &rsp
->addr2
[0];
438 tag
+= sizeof(struct rtl_80211_hdr_3addr
);
439 pDialogToken
= tag
+ 2;
440 pStatusCode
= (u16
*)(tag
+ 3);
441 pBaParamSet
= (PBA_PARAM_SET
)(tag
+ 5);
442 pBaTimeoutVal
= (u16
*)(tag
+ 7);
444 // Check the capability
445 // Since we can always receive A-MPDU, we just check if it is under HT mode.
446 if (ieee
->current_network
.qos_data
.active
== 0 ||
447 !ieee
->pHTInfo
->bCurrentHTSupport
||
448 !ieee
->pHTInfo
->bCurrentAMPDUEnable
) {
449 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee
->current_network
.qos_data
.active
, ieee
->pHTInfo
->bCurrentHTSupport
, ieee
->pHTInfo
->bCurrentAMPDUEnable
);
450 ReasonCode
= DELBA_REASON_UNKNOWN_BA
;
451 goto OnADDBARsp_Reject
;
456 // Search for related TS.
457 // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
461 (PTS_COMMON_INFO
*)(&pTS
),
463 (u8
)(pBaParamSet
->field
.TID
),
466 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "can't get TS in %s()\n", __func__
);
467 ReasonCode
= DELBA_REASON_UNKNOWN_BA
;
468 goto OnADDBARsp_Reject
;
471 pTS
->bAddBaReqInProgress
= false;
472 pPendingBA
= &pTS
->TxPendingBARecord
;
473 pAdmittedBA
= &pTS
->TxAdmittedBARecord
;
477 // Check if related BA is waiting for setup.
478 // If not, reject by sending DELBA frame.
480 if (pAdmittedBA
->bValid
) {
481 // Since BA is already setup, we ignore all other ADDBA Response.
482 IEEE80211_DEBUG(IEEE80211_DL_BA
, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n");
485 else if((!pPendingBA
->bValid
) ||(*pDialogToken
!= pPendingBA
->DialogToken
)) {
486 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n");
487 ReasonCode
= DELBA_REASON_UNKNOWN_BA
;
488 goto OnADDBARsp_Reject
;
491 IEEE80211_DEBUG(IEEE80211_DL_BA
, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode
);
492 DeActivateBAEntry(ieee
, pPendingBA
);
496 if(*pStatusCode
== ADDBA_STATUS_SUCCESS
) {
498 // Determine ADDBA Rsp content here.
499 // We can compare the value of BA parameter set that Peer returned and Self sent.
500 // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
502 if (pBaParamSet
->field
.BAPolicy
== BA_POLICY_DELAYED
) {
503 // Since this is a kind of ADDBA failed, we delay next ADDBA process.
504 pTS
->bAddBaReqDelayed
= true;
505 DeActivateBAEntry(ieee
, pAdmittedBA
);
506 ReasonCode
= DELBA_REASON_END_BA
;
507 goto OnADDBARsp_Reject
;
512 // Admitted condition
514 pAdmittedBA
->DialogToken
= *pDialogToken
;
515 pAdmittedBA
->BaTimeoutValue
= *pBaTimeoutVal
;
516 pAdmittedBA
->BaStartSeqCtrl
= pPendingBA
->BaStartSeqCtrl
;
517 pAdmittedBA
->BaParamSet
= *pBaParamSet
;
518 DeActivateBAEntry(ieee
, pAdmittedBA
);
519 ActivateBAEntry(ieee
, pAdmittedBA
, *pBaTimeoutVal
);
522 // Delay next ADDBA process.
523 pTS
->bAddBaReqDelayed
= true;
532 BA
.BaParamSet
= *pBaParamSet
;
533 ieee80211_send_DELBA(ieee
, dst
, &BA
, TX_DIR
, ReasonCode
);
539 /********************************************************************************************************************
541 * input: struct sk_buff * skb //incoming ADDBAReq skb.
542 * return: 0(pass), other(fail)
543 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
544 ********************************************************************************************************************/
545 int ieee80211_rx_DELBA(struct ieee80211_device
*ieee
, struct sk_buff
*skb
)
547 struct rtl_80211_hdr_3addr
*delba
= NULL
;
548 PDELBA_PARAM_SET pDelBaParamSet
= NULL
;
551 if (skb
->len
< sizeof(struct rtl_80211_hdr_3addr
) + 6) {
552 IEEE80211_DEBUG(IEEE80211_DL_ERR
,
553 " Invalid skb len in DELBA(%d / %zu)\n",
555 (sizeof(struct rtl_80211_hdr_3addr
) + 6));
559 if (ieee
->current_network
.qos_data
.active
== 0 ||
560 !ieee
->pHTInfo
->bCurrentHTSupport
) {
561 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee
->current_network
.qos_data
.active
, ieee
->pHTInfo
->bCurrentHTSupport
);
565 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA
|IEEE80211_DL_BA
, skb
->data
, skb
->len
);
566 delba
= (struct rtl_80211_hdr_3addr
*)skb
->data
;
567 dst
= &delba
->addr2
[0];
568 pDelBaParamSet
= (PDELBA_PARAM_SET
)&delba
->payload
[2];
570 if(pDelBaParamSet
->field
.Initiator
== 1) {
575 (PTS_COMMON_INFO
*)&pRxTs
,
577 (u8
)pDelBaParamSet
->field
.TID
,
580 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "can't get TS for RXTS in %s()\n", __func__
);
584 RxTsDeleteBA(ieee
, pRxTs
);
591 (PTS_COMMON_INFO
*)&pTxTs
,
593 (u8
)pDelBaParamSet
->field
.TID
,
596 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "can't get TS for TXTS in %s()\n", __func__
);
600 pTxTs
->bUsingBa
= false;
601 pTxTs
->bAddBaReqInProgress
= false;
602 pTxTs
->bAddBaReqDelayed
= false;
603 del_timer_sync(&pTxTs
->TsAddBaTimer
);
604 //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer);
605 TxTsDeleteBA(ieee
, pTxTs
);
611 // ADDBA initiate. This can only be called by TX side.
615 struct ieee80211_device
*ieee
,
621 PBA_RECORD pBA
= &pTS
->TxPendingBARecord
;
623 if (pBA
->bValid
&& !bOverwritePending
)
626 // Set parameters to "Pending" variable set
627 DeActivateBAEntry(ieee
, pBA
);
629 pBA
->DialogToken
++; // DialogToken: Only keep the latest dialog token
630 pBA
->BaParamSet
.field
.AMSDU_Support
= 0; // Do not support A-MSDU with A-MPDU now!!
631 pBA
->BaParamSet
.field
.BAPolicy
= Policy
; // Policy: Delayed or Immediate
632 pBA
->BaParamSet
.field
.TID
= pTS
->TsCommonInfo
.TSpec
.f
.TSInfo
.field
.ucTSID
; // TID
633 // BufferSize: This need to be set according to A-MPDU vector
634 pBA
->BaParamSet
.field
.BufferSize
= 32; // BufferSize: This need to be set according to A-MPDU vector
635 pBA
->BaTimeoutValue
= 0; // Timeout value: Set 0 to disable Timer
636 pBA
->BaStartSeqCtrl
.field
.SeqNum
= (pTS
->TxCurSeq
+ 3) % 4096; // Block Ack will start after 3 packets later.
638 ActivateBAEntry(ieee
, pBA
, BA_SETUP_TIMEOUT
);
640 ieee80211_send_ADDBAReq(ieee
, pTS
->TsCommonInfo
.Addr
, pBA
);
644 TsInitDelBA( struct ieee80211_device
*ieee
, PTS_COMMON_INFO pTsCommonInfo
, TR_SELECT TxRxSelect
)
647 if(TxRxSelect
== TX_DIR
) {
648 PTX_TS_RECORD pTxTs
= (PTX_TS_RECORD
)pTsCommonInfo
;
650 if(TxTsDeleteBA(ieee
, pTxTs
))
651 ieee80211_send_DELBA(
654 (pTxTs
->TxAdmittedBARecord
.bValid
)?(&pTxTs
->TxAdmittedBARecord
):(&pTxTs
->TxPendingBARecord
),
656 DELBA_REASON_END_BA
);
658 else if(TxRxSelect
== RX_DIR
) {
659 PRX_TS_RECORD pRxTs
= (PRX_TS_RECORD
)pTsCommonInfo
;
660 if(RxTsDeleteBA(ieee
, pRxTs
))
661 ieee80211_send_DELBA(
664 &pRxTs
->RxAdmittedBARecord
,
666 DELBA_REASON_END_BA
);
669 /********************************************************************************************************************
670 *function: BA setup timer
671 * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
674 ********************************************************************************************************************/
675 void BaSetupTimeOut(unsigned long data
)
677 PTX_TS_RECORD pTxTs
= (PTX_TS_RECORD
)data
;
679 pTxTs
->bAddBaReqInProgress
= false;
680 pTxTs
->bAddBaReqDelayed
= true;
681 pTxTs
->TxPendingBARecord
.bValid
= false;
684 void TxBaInactTimeout(unsigned long data
)
686 PTX_TS_RECORD pTxTs
= (PTX_TS_RECORD
)data
;
687 struct ieee80211_device
*ieee
= container_of(pTxTs
, struct ieee80211_device
, TxTsRecord
[pTxTs
->num
]);
688 TxTsDeleteBA(ieee
, pTxTs
);
689 ieee80211_send_DELBA(
691 pTxTs
->TsCommonInfo
.Addr
,
692 &pTxTs
->TxAdmittedBARecord
,
694 DELBA_REASON_TIMEOUT
);
697 void RxBaInactTimeout(unsigned long data
)
699 PRX_TS_RECORD pRxTs
= (PRX_TS_RECORD
)data
;
700 struct ieee80211_device
*ieee
= container_of(pRxTs
, struct ieee80211_device
, RxTsRecord
[pRxTs
->num
]);
702 RxTsDeleteBA(ieee
, pRxTs
);
703 ieee80211_send_DELBA(
705 pRxTs
->TsCommonInfo
.Addr
,
706 &pRxTs
->RxAdmittedBARecord
,
708 DELBA_REASON_TIMEOUT
);