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 struture 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 * *****************************************************************************************************************************/
8 #include "rtl819x_BA.h"
10 /********************************************************************************************************************
11 *function: Activate BA entry. And if Time is nozero, start timer.
12 * input: PBA_RECORD pBA //BA entry to be enabled
13 * u16 Time //indicate time delay.
15 ********************************************************************************************************************/
16 void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time)
20 mod_timer(&pBA->Timer, jiffies + MSECS(Time));
23 /********************************************************************************************************************
24 *function: deactivate BA entry, including its timer.
25 * input: PBA_RECORD pBA //BA entry to be disabled
27 ********************************************************************************************************************/
28 void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA)
31 del_timer_sync(&pBA->Timer);
33 /********************************************************************************************************************
34 *function: deactivete BA entry in Tx Ts, and send DELBA.
36 * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry.
38 * notice: As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME
39 ********************************************************************************************************************/
40 u8 TxTsDeleteBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTxTs)
42 PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure
43 PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord;
44 u8 bSendDELBA = false;
47 if(pPendingBa->bValid)
49 DeActivateBAEntry(ieee, pPendingBa);
54 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 u8 RxTsDeleteBA( struct ieee80211_device* ieee, PRX_TS_RECORD pRxTs)
72 PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord;
73 u8 bSendDELBA = false;
77 DeActivateBAEntry(ieee, pBa);
84 /********************************************************************************************************************
85 *function: reset BA entry
87 * PBA_RECORD pBA //entry to be reset
89 ********************************************************************************************************************/
90 void ResetBaEntry( PBA_RECORD pBA)
93 pBA->BaParamSet.shortData = 0;
94 pBA->BaTimeoutValue = 0;
96 pBA->BaStartSeqCtrl.ShortData = 0;
98 //These functions need porting here or not?
99 /*******************************************************************************************************************************
100 *function: construct ADDBAREQ and ADDBARSP frame here together.
101 * input: u8* Dst //ADDBA frame's destination
102 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA.
103 * u16 StatusCode //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?)
104 * u8 type //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
106 * return: sk_buff* skb //return constructed skb to xmit
107 *******************************************************************************************************************************/
108 static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type)
110 struct sk_buff *skb = NULL;
111 struct ieee80211_hdr_3addr* BAReq = NULL;
114 u16 len = ieee->tx_headroom + 9;
115 //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2))
116 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:"MAC_FMT", ieee->dev:%p\n", __FUNCTION__, type, MAC_ARG(Dst), ieee->dev);
117 if (pBA == NULL||ieee == NULL)
119 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee);
122 skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
125 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
129 memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
130 skb_reserve(skb, ieee->tx_headroom);
132 BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
134 memcpy(BAReq->addr1, Dst, ETH_ALEN);
135 memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
137 memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
139 BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
141 //tag += sizeof( struct ieee80211_hdr_3addr); //move to action field
142 tag = (u8*)skb_put(skb, 9);
146 *tag ++= pBA->DialogToken;
148 if (ACT_ADDBARSP == type)
151 printk("=====>to send ADDBARSP\n");
152 tmp = cpu_to_le16(StatusCode);
153 memcpy(tag, (u8*)&tmp, 2);
157 tmp = cpu_to_le16(pBA->BaParamSet.shortData);
158 memcpy(tag, (u8*)&tmp, 2);
161 tmp = cpu_to_le16(pBA->BaTimeoutValue);
162 memcpy(tag, (u8*)&tmp, 2);
165 if (ACT_ADDBAREQ == type)
168 memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2);
172 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
177 /********************************************************************************************************************
178 *function: construct DELBA frame
179 * input: u8* dst //DELBA frame's destination
180 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
181 * TR_SELECT TxRxSelect //TX RX direction
182 * u16 ReasonCode //status code.
184 * return: sk_buff* skb //return constructed skb to xmit
185 ********************************************************************************************************************/
186 static struct sk_buff* ieee80211_DELBA(
187 struct ieee80211_device* ieee,
190 TR_SELECT TxRxSelect,
194 DELBA_PARAM_SET DelbaParamSet;
195 struct sk_buff *skb = NULL;
196 struct ieee80211_hdr_3addr* Delba = NULL;
199 //len = head len + DELBA Parameter Set(2) + Reason Code(2)
200 u16 len = 6 + ieee->tx_headroom;
203 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:"MAC_FMT"\n", __FUNCTION__, ReasonCode, MAC_ARG(dst));
205 memset(&DelbaParamSet, 0, 2);
207 DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0;
208 DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
210 skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
213 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
216 // memset(skb->data, 0, len+sizeof( struct ieee80211_hdr_3addr));
217 skb_reserve(skb, ieee->tx_headroom);
219 Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
221 memcpy(Delba->addr1, dst, ETH_ALEN);
222 memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
223 memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
224 Delba->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
226 tag = (u8*)skb_put(skb, 6);
231 // DELBA Parameter Set
232 tmp = cpu_to_le16(DelbaParamSet.shortData);
233 memcpy(tag, (u8*)&tmp, 2);
236 tmp = cpu_to_le16(ReasonCode);
237 memcpy(tag, (u8*)&tmp, 2);
240 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
242 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __FUNCTION__);
246 /********************************************************************************************************************
247 *function: send ADDBAReq frame out
248 * input: u8* dst //ADDBAReq frame's destination
249 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
251 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
252 ********************************************************************************************************************/
253 void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA)
255 struct sk_buff *skb = NULL;
256 skb = ieee80211_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); //construct ACT_ADDBAREQ frames so set statuscode zero.
260 softmac_mgmt_xmit(skb, ieee);
261 //add statistic needed here.
262 //and skb will be freed in softmac_mgmt_xmit(), so omit all dev_kfree_skb_any() outside softmac_mgmt_xmit()
267 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
272 /********************************************************************************************************************
273 *function: send ADDBARSP frame out
274 * input: u8* dst //DELBA frame's destination
275 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
276 * u16 StatusCode //RSP StatusCode
278 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
279 ********************************************************************************************************************/
280 void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode)
282 struct sk_buff *skb = NULL;
283 skb = ieee80211_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); //construct ACT_ADDBARSP frames
286 softmac_mgmt_xmit(skb, ieee);
291 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
297 /********************************************************************************************************************
298 *function: send ADDBARSP frame out
299 * input: u8* dst //DELBA frame's destination
300 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
301 * TR_SELECT TxRxSelect //TX or RX
302 * u16 ReasonCode //DEL ReasonCode
304 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
305 ********************************************************************************************************************/
307 void ieee80211_send_DELBA(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode)
309 struct sk_buff *skb = NULL;
310 skb = ieee80211_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); //construct ACT_ADDBARSP frames
313 softmac_mgmt_xmit(skb, ieee);
318 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
323 /********************************************************************************************************************
324 *function: RX ADDBAReq
325 * input: struct sk_buff * skb //incoming ADDBAReq skb.
326 * return: 0(pass), other(fail)
327 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
328 ********************************************************************************************************************/
329 int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
331 struct ieee80211_hdr_3addr* req = NULL;
333 u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL;
334 PBA_RECORD pBA = NULL;
335 PBA_PARAM_SET pBaParamSet = NULL;
336 u16* pBaTimeoutVal = NULL;
337 PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL;
338 PRX_TS_RECORD pTS = NULL;
340 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
342 IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %ld)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9));
346 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
348 req = ( struct ieee80211_hdr_3addr*) skb->data;
350 dst = (u8*)(&req->addr2[0]);
351 tag += sizeof( struct ieee80211_hdr_3addr);
352 pDialogToken = tag + 2; //category+action
353 pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken
354 pBaTimeoutVal = (u16*)(tag + 5);
355 pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7);
357 printk("====================>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst));
358 //some other capability is not ready now.
359 if( (ieee->current_network.qos_data.active == 0) ||
360 (ieee->pHTInfo->bCurrentHTSupport == false) ||
361 (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) //||
362 // (ieee->pStaQos->bEnableRxImmBA == false) )
364 rc = ADDBA_STATUS_REFUSED;
365 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);
366 goto OnADDBAReq_Fail;
368 // Search for related traffic stream.
369 // If there is no matched TS, reject the ADDBA request.
372 (PTS_COMMON_INFO*)(&pTS),
374 (u8)(pBaParamSet->field.TID),
378 rc = ADDBA_STATUS_REFUSED;
379 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
380 goto OnADDBAReq_Fail;
382 pBA = &pTS->RxAdmittedBARecord;
383 // To Determine the ADDBA Req content
384 // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
385 // I want to check StartSeqCtrl to make sure when we start aggregation!!!
387 if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
389 rc = ADDBA_STATUS_INVALID_PARAM;
390 IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __FUNCTION__);
391 goto OnADDBAReq_Fail;
393 // Admit the ADDBA Request
395 DeActivateBAEntry(ieee, pBA);
396 pBA->DialogToken = *pDialogToken;
397 pBA->BaParamSet = *pBaParamSet;
398 pBA->BaTimeoutValue = *pBaTimeoutVal;
399 pBA->BaStartSeqCtrl = *pBaStartSeqCtrl;
400 //for half N mode we only aggregate 1 frame
401 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)||
402 (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT))
403 pBA->BaParamSet.field.BufferSize = 1;
405 pBA->BaParamSet.field.BufferSize = 32;
406 ActivateBAEntry(ieee, pBA, 0);//pBA->BaTimeoutValue);
407 ieee80211_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
415 BA.BaParamSet = *pBaParamSet;
416 BA.BaTimeoutValue = *pBaTimeoutVal;
417 BA.DialogToken = *pDialogToken;
418 BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE;
419 ieee80211_send_ADDBARsp(ieee, dst, &BA, rc);
420 return 0; //we send RSP out.
425 /********************************************************************************************************************
426 *function: RX ADDBARSP
427 * input: struct sk_buff * skb //incoming ADDBAReq skb.
428 * return: 0(pass), other(fail)
429 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
430 ********************************************************************************************************************/
431 int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
433 struct ieee80211_hdr_3addr* rsp = NULL;
434 PBA_RECORD pPendingBA, pAdmittedBA;
435 PTX_TS_RECORD pTS = NULL;
436 u8* dst = NULL, *pDialogToken = NULL, *tag = NULL;
437 u16* pStatusCode = NULL, *pBaTimeoutVal = NULL;
438 PBA_PARAM_SET pBaParamSet = NULL;
441 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
443 IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %ld)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9));
446 rsp = ( struct ieee80211_hdr_3addr*)skb->data;
448 dst = (u8*)(&rsp->addr2[0]);
449 tag += sizeof( struct ieee80211_hdr_3addr);
450 pDialogToken = tag + 2;
451 pStatusCode = (u16*)(tag + 3);
452 pBaParamSet = (PBA_PARAM_SET)(tag + 5);
453 pBaTimeoutVal = (u16*)(tag + 7);
455 // Check the capability
456 // Since we can always receive A-MPDU, we just check if it is under HT mode.
457 if( ieee->current_network.qos_data.active == 0 ||
458 ieee->pHTInfo->bCurrentHTSupport == false ||
459 ieee->pHTInfo->bCurrentAMPDUEnable == false )
461 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);
462 ReasonCode = DELBA_REASON_UNKNOWN_BA;
463 goto OnADDBARsp_Reject;
468 // Search for related TS.
469 // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
473 (PTS_COMMON_INFO*)(&pTS),
475 (u8)(pBaParamSet->field.TID),
479 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
480 ReasonCode = DELBA_REASON_UNKNOWN_BA;
481 goto OnADDBARsp_Reject;
484 pTS->bAddBaReqInProgress = false;
485 pPendingBA = &pTS->TxPendingBARecord;
486 pAdmittedBA = &pTS->TxAdmittedBARecord;
490 // Check if related BA is waiting for setup.
491 // If not, reject by sending DELBA frame.
493 if((pAdmittedBA->bValid==true))
495 // Since BA is already setup, we ignore all other ADDBA Response.
496 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n");
499 else if((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken))
501 IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n");
502 ReasonCode = DELBA_REASON_UNKNOWN_BA;
503 goto OnADDBARsp_Reject;
507 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode);
508 DeActivateBAEntry(ieee, pPendingBA);
512 if(*pStatusCode == ADDBA_STATUS_SUCCESS)
515 // Determine ADDBA Rsp content here.
516 // We can compare the value of BA parameter set that Peer returned and Self sent.
517 // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
519 if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
521 // Since this is a kind of ADDBA failed, we delay next ADDBA process.
522 pTS->bAddBaReqDelayed = true;
523 DeActivateBAEntry(ieee, pAdmittedBA);
524 ReasonCode = DELBA_REASON_END_BA;
525 goto OnADDBARsp_Reject;
530 // Admitted condition
532 pAdmittedBA->DialogToken = *pDialogToken;
533 pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal;
534 pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl;
535 pAdmittedBA->BaParamSet = *pBaParamSet;
536 DeActivateBAEntry(ieee, pAdmittedBA);
537 ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal);
541 // Delay next ADDBA process.
542 pTS->bAddBaReqDelayed = true;
551 BA.BaParamSet = *pBaParamSet;
552 ieee80211_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
558 /********************************************************************************************************************
560 * input: struct sk_buff * skb //incoming ADDBAReq skb.
561 * return: 0(pass), other(fail)
562 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
563 ********************************************************************************************************************/
564 int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
566 struct ieee80211_hdr_3addr* delba = NULL;
567 PDELBA_PARAM_SET pDelBaParamSet = NULL;
568 u16* pReasonCode = NULL;
571 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
573 IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %ld)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 6));
577 if(ieee->current_network.qos_data.active == 0 ||
578 ieee->pHTInfo->bCurrentHTSupport == false )
580 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);
584 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
585 delba = ( struct ieee80211_hdr_3addr*)skb->data;
586 dst = (u8*)(&delba->addr2[0]);
587 delba += sizeof( struct ieee80211_hdr_3addr);
588 pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2);
589 pReasonCode = (u16*)(delba+4);
591 if(pDelBaParamSet->field.Initiator == 1)
597 (PTS_COMMON_INFO*)&pRxTs,
599 (u8)pDelBaParamSet->field.TID,
603 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __FUNCTION__);
607 RxTsDeleteBA(ieee, pRxTs);
615 (PTS_COMMON_INFO*)&pTxTs,
617 (u8)pDelBaParamSet->field.TID,
621 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __FUNCTION__);
625 pTxTs->bUsingBa = false;
626 pTxTs->bAddBaReqInProgress = false;
627 pTxTs->bAddBaReqDelayed = false;
628 del_timer_sync(&pTxTs->TsAddBaTimer);
629 //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer);
630 TxTsDeleteBA(ieee, pTxTs);
636 // ADDBA initiate. This can only be called by TX side.
640 struct ieee80211_device* ieee,
646 PBA_RECORD pBA = &pTS->TxPendingBARecord;
648 if(pBA->bValid==true && bOverwritePending==false)
651 // Set parameters to "Pending" variable set
652 DeActivateBAEntry(ieee, pBA);
654 pBA->DialogToken++; // DialogToken: Only keep the latest dialog token
655 pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!!
656 pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate
657 pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; // TID
658 // BufferSize: This need to be set according to A-MPDU vector
659 pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector
660 pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer
661 pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later.
663 ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
665 ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA);
669 TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect)
672 if(TxRxSelect == TX_DIR)
674 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo;
676 if(TxTsDeleteBA(ieee, pTxTs))
677 ieee80211_send_DELBA(
680 (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord),
682 DELBA_REASON_END_BA);
684 else if(TxRxSelect == RX_DIR)
686 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo;
687 if(RxTsDeleteBA(ieee, pRxTs))
688 ieee80211_send_DELBA(
691 &pRxTs->RxAdmittedBARecord,
693 DELBA_REASON_END_BA );
696 /********************************************************************************************************************
697 *function: BA setup timer
698 * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
701 ********************************************************************************************************************/
702 void BaSetupTimeOut(unsigned long data)
704 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
706 pTxTs->bAddBaReqInProgress = false;
707 pTxTs->bAddBaReqDelayed = true;
708 pTxTs->TxPendingBARecord.bValid = false;
711 void TxBaInactTimeout(unsigned long data)
713 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
714 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]);
715 TxTsDeleteBA(ieee, pTxTs);
716 ieee80211_send_DELBA(
718 pTxTs->TsCommonInfo.Addr,
719 &pTxTs->TxAdmittedBARecord,
721 DELBA_REASON_TIMEOUT);
724 void RxBaInactTimeout(unsigned long data)
726 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data;
727 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
729 RxTsDeleteBA(ieee, pRxTs);
730 ieee80211_send_DELBA(
732 pRxTs->TsCommonInfo.Addr,
733 &pRxTs->RxAdmittedBARecord,
735 DELBA_REASON_TIMEOUT);