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 #if 0 //I try to merge ADDBA_REQ and ADDBA_RSP frames together..
178 /********************************************************************************************************************
179 *function: construct ADDBAREQ frame
180 * input: u8* dst //ADDBARsp frame's destination
181 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA_RSP.
182 * u16 StatusCode //status code.
184 * return: sk_buff* skb //return constructed skb to xmit
185 ********************************************************************************************************************/
186 static struct sk_buff* ieee80211_ADDBA_Rsp( IN struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode)
188 OCTET_STRING osADDBAFrame, tmp;
190 FillOctetString(osADDBAFrame, Buffer, 0);
201 FillOctetString(tmp, &pBA->DialogToken, 1);
202 PacketAppendData(&osADDBAFrame, tmp);
205 FillOctetString(tmp, &StatusCode, 2);
206 PacketAppendData(&osADDBAFrame, tmp);
209 FillOctetString(tmp, &pBA->BaParamSet, 2);
210 PacketAppendData(&osADDBAFrame, tmp);
213 FillOctetString(tmp, &pBA->BaTimeoutValue, 2);
214 PacketAppendData(&osADDBAFrame, tmp);
216 *pLength = osADDBAFrame.Length;
220 /********************************************************************************************************************
221 *function: construct DELBA frame
222 * input: u8* dst //DELBA frame's destination
223 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
224 * TR_SELECT TxRxSelect //TX RX direction
225 * u16 ReasonCode //status code.
227 * return: sk_buff* skb //return constructed skb to xmit
228 ********************************************************************************************************************/
229 static struct sk_buff* ieee80211_DELBA(
230 struct ieee80211_device* ieee,
233 TR_SELECT TxRxSelect,
237 DELBA_PARAM_SET DelbaParamSet;
238 struct sk_buff *skb = NULL;
239 struct ieee80211_hdr_3addr* Delba = NULL;
242 //len = head len + DELBA Parameter Set(2) + Reason Code(2)
243 u16 len = 6 + ieee->tx_headroom;
246 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:"MAC_FMT"\n", __FUNCTION__, ReasonCode, MAC_ARG(dst));
248 memset(&DelbaParamSet, 0, 2);
250 DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0;
251 DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
253 skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
256 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
259 // memset(skb->data, 0, len+sizeof( struct ieee80211_hdr_3addr));
260 skb_reserve(skb, ieee->tx_headroom);
262 Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
264 memcpy(Delba->addr1, dst, ETH_ALEN);
265 memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
266 memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
267 Delba->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
269 tag = (u8*)skb_put(skb, 6);
274 // DELBA Parameter Set
275 tmp = cpu_to_le16(DelbaParamSet.shortData);
276 memcpy(tag, (u8*)&tmp, 2);
279 tmp = cpu_to_le16(ReasonCode);
280 memcpy(tag, (u8*)&tmp, 2);
283 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
285 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __FUNCTION__);
289 /********************************************************************************************************************
290 *function: send ADDBAReq frame out
291 * input: u8* dst //ADDBAReq frame's destination
292 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
294 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
295 ********************************************************************************************************************/
296 void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA)
298 struct sk_buff *skb = NULL;
299 skb = ieee80211_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); //construct ACT_ADDBAREQ frames so set statuscode zero.
303 softmac_mgmt_xmit(skb, ieee);
304 //add statistic needed here.
305 //and skb will be freed in softmac_mgmt_xmit(), so omit all dev_kfree_skb_any() outside softmac_mgmt_xmit()
310 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
315 /********************************************************************************************************************
316 *function: send ADDBARSP frame out
317 * input: u8* dst //DELBA frame's destination
318 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
319 * u16 StatusCode //RSP StatusCode
321 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
322 ********************************************************************************************************************/
323 void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode)
325 struct sk_buff *skb = NULL;
326 skb = ieee80211_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); //construct ACT_ADDBARSP frames
329 softmac_mgmt_xmit(skb, ieee);
334 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
340 /********************************************************************************************************************
341 *function: send ADDBARSP frame out
342 * input: u8* dst //DELBA frame's destination
343 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
344 * TR_SELECT TxRxSelect //TX or RX
345 * u16 ReasonCode //DEL ReasonCode
347 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
348 ********************************************************************************************************************/
350 void ieee80211_send_DELBA(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode)
352 struct sk_buff *skb = NULL;
353 skb = ieee80211_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); //construct ACT_ADDBARSP frames
356 softmac_mgmt_xmit(skb, ieee);
361 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
366 /********************************************************************************************************************
367 *function: RX ADDBAReq
368 * input: struct sk_buff * skb //incoming ADDBAReq skb.
369 * return: 0(pass), other(fail)
370 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
371 ********************************************************************************************************************/
372 int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
374 struct ieee80211_hdr_3addr* req = NULL;
376 u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL;
377 PBA_RECORD pBA = NULL;
378 PBA_PARAM_SET pBaParamSet = NULL;
379 u16* pBaTimeoutVal = NULL;
380 PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL;
381 PRX_TS_RECORD pTS = NULL;
383 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
385 IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9));
389 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
391 req = ( struct ieee80211_hdr_3addr*) skb->data;
393 dst = (u8*)(&req->addr2[0]);
394 tag += sizeof( struct ieee80211_hdr_3addr);
395 pDialogToken = tag + 2; //category+action
396 pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken
397 pBaTimeoutVal = (u16*)(tag + 5);
398 pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7);
400 printk("====================>rx ADDBAREQ from :"MAC_FMT"\n", MAC_ARG(dst));
401 //some other capability is not ready now.
402 if( (ieee->current_network.qos_data.active == 0) ||
403 (ieee->pHTInfo->bCurrentHTSupport == false)) //||
404 // (ieee->pStaQos->bEnableRxImmBA == false) )
406 rc = ADDBA_STATUS_REFUSED;
407 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);
408 goto OnADDBAReq_Fail;
410 // Search for related traffic stream.
411 // If there is no matched TS, reject the ADDBA request.
414 (PTS_COMMON_INFO*)(&pTS),
416 (u8)(pBaParamSet->field.TID),
420 rc = ADDBA_STATUS_REFUSED;
421 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
422 goto OnADDBAReq_Fail;
424 pBA = &pTS->RxAdmittedBARecord;
425 // To Determine the ADDBA Req content
426 // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
427 // I want to check StartSeqCtrl to make sure when we start aggregation!!!
429 if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
431 rc = ADDBA_STATUS_INVALID_PARAM;
432 IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __FUNCTION__);
433 goto OnADDBAReq_Fail;
435 // Admit the ADDBA Request
437 DeActivateBAEntry(ieee, pBA);
438 pBA->DialogToken = *pDialogToken;
439 pBA->BaParamSet = *pBaParamSet;
440 pBA->BaTimeoutValue = *pBaTimeoutVal;
441 pBA->BaStartSeqCtrl = *pBaStartSeqCtrl;
442 //for half N mode we only aggregate 1 frame
443 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
444 pBA->BaParamSet.field.BufferSize = 1;
446 pBA->BaParamSet.field.BufferSize = 32;
447 ActivateBAEntry(ieee, pBA, pBA->BaTimeoutValue);
448 ieee80211_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
456 BA.BaParamSet = *pBaParamSet;
457 BA.BaTimeoutValue = *pBaTimeoutVal;
458 BA.DialogToken = *pDialogToken;
459 BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE;
460 ieee80211_send_ADDBARsp(ieee, dst, &BA, rc);
461 return 0; //we send RSP out.
466 /********************************************************************************************************************
467 *function: RX ADDBARSP
468 * input: struct sk_buff * skb //incoming ADDBAReq skb.
469 * return: 0(pass), other(fail)
470 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
471 ********************************************************************************************************************/
472 int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
474 struct ieee80211_hdr_3addr* rsp = NULL;
475 PBA_RECORD pPendingBA, pAdmittedBA;
476 PTX_TS_RECORD pTS = NULL;
477 u8* dst = NULL, *pDialogToken = NULL, *tag = NULL;
478 u16* pStatusCode = NULL, *pBaTimeoutVal = NULL;
479 PBA_PARAM_SET pBaParamSet = NULL;
482 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
484 IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 9));
487 rsp = ( struct ieee80211_hdr_3addr*)skb->data;
489 dst = (u8*)(&rsp->addr2[0]);
490 tag += sizeof( struct ieee80211_hdr_3addr);
491 pDialogToken = tag + 2;
492 pStatusCode = (u16*)(tag + 3);
493 pBaParamSet = (PBA_PARAM_SET)(tag + 5);
494 pBaTimeoutVal = (u16*)(tag + 7);
496 // Check the capability
497 // Since we can always receive A-MPDU, we just check if it is under HT mode.
498 if( ieee->current_network.qos_data.active == 0 ||
499 ieee->pHTInfo->bCurrentHTSupport == false ||
500 ieee->pHTInfo->bCurrentAMPDUEnable == false )
502 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);
503 ReasonCode = DELBA_REASON_UNKNOWN_BA;
504 goto OnADDBARsp_Reject;
509 // Search for related TS.
510 // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
514 (PTS_COMMON_INFO*)(&pTS),
516 (u8)(pBaParamSet->field.TID),
520 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
521 ReasonCode = DELBA_REASON_UNKNOWN_BA;
522 goto OnADDBARsp_Reject;
525 pTS->bAddBaReqInProgress = false;
526 pPendingBA = &pTS->TxPendingBARecord;
527 pAdmittedBA = &pTS->TxAdmittedBARecord;
531 // Check if related BA is waiting for setup.
532 // If not, reject by sending DELBA frame.
534 if((pAdmittedBA->bValid==true))
536 // Since BA is already setup, we ignore all other ADDBA Response.
537 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n");
540 else if((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken))
542 IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n");
543 ReasonCode = DELBA_REASON_UNKNOWN_BA;
544 goto OnADDBARsp_Reject;
548 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode);
549 DeActivateBAEntry(ieee, pPendingBA);
553 if(*pStatusCode == ADDBA_STATUS_SUCCESS)
556 // Determine ADDBA Rsp content here.
557 // We can compare the value of BA parameter set that Peer returned and Self sent.
558 // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
560 if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
562 // Since this is a kind of ADDBA failed, we delay next ADDBA process.
563 pTS->bAddBaReqDelayed = true;
564 DeActivateBAEntry(ieee, pAdmittedBA);
565 ReasonCode = DELBA_REASON_END_BA;
566 goto OnADDBARsp_Reject;
571 // Admitted condition
573 pAdmittedBA->DialogToken = *pDialogToken;
574 pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal;
575 pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl;
576 pAdmittedBA->BaParamSet = *pBaParamSet;
577 DeActivateBAEntry(ieee, pAdmittedBA);
578 ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal);
582 // Delay next ADDBA process.
583 pTS->bAddBaReqDelayed = true;
592 BA.BaParamSet = *pBaParamSet;
593 ieee80211_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
599 /********************************************************************************************************************
601 * input: struct sk_buff * skb //incoming ADDBAReq skb.
602 * return: 0(pass), other(fail)
603 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
604 ********************************************************************************************************************/
605 int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
607 struct ieee80211_hdr_3addr* delba = NULL;
608 PDELBA_PARAM_SET pDelBaParamSet = NULL;
609 u16* pReasonCode = NULL;
612 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
614 IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", skb->len, (sizeof( struct ieee80211_hdr_3addr) + 6));
618 if(ieee->current_network.qos_data.active == 0 ||
619 ieee->pHTInfo->bCurrentHTSupport == false )
621 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);
625 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
626 delba = ( struct ieee80211_hdr_3addr*)skb->data;
627 dst = (u8*)(&delba->addr2[0]);
628 delba += sizeof( struct ieee80211_hdr_3addr);
629 pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2);
630 pReasonCode = (u16*)(delba+4);
632 if(pDelBaParamSet->field.Initiator == 1)
638 (PTS_COMMON_INFO*)&pRxTs,
640 (u8)pDelBaParamSet->field.TID,
644 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __FUNCTION__);
648 RxTsDeleteBA(ieee, pRxTs);
656 (PTS_COMMON_INFO*)&pTxTs,
658 (u8)pDelBaParamSet->field.TID,
662 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __FUNCTION__);
666 pTxTs->bUsingBa = false;
667 pTxTs->bAddBaReqInProgress = false;
668 pTxTs->bAddBaReqDelayed = false;
669 del_timer_sync(&pTxTs->TsAddBaTimer);
670 //PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer);
671 TxTsDeleteBA(ieee, pTxTs);
677 // ADDBA initiate. This can only be called by TX side.
681 struct ieee80211_device* ieee,
687 PBA_RECORD pBA = &pTS->TxPendingBARecord;
689 if(pBA->bValid==true && bOverwritePending==false)
692 // Set parameters to "Pending" variable set
693 DeActivateBAEntry(ieee, pBA);
695 pBA->DialogToken++; // DialogToken: Only keep the latest dialog token
696 pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!!
697 pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate
698 pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; // TID
699 // BufferSize: This need to be set according to A-MPDU vector
700 pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector
701 pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer
702 pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later.
704 ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
706 ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA);
710 TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect)
713 if(TxRxSelect == TX_DIR)
715 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo;
717 if(TxTsDeleteBA(ieee, pTxTs))
718 ieee80211_send_DELBA(
721 (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord),
723 DELBA_REASON_END_BA);
725 else if(TxRxSelect == RX_DIR)
727 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo;
728 if(RxTsDeleteBA(ieee, pRxTs))
729 ieee80211_send_DELBA(
732 &pRxTs->RxAdmittedBARecord,
734 DELBA_REASON_END_BA );
737 /********************************************************************************************************************
738 *function: BA setup timer
739 * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
742 ********************************************************************************************************************/
743 void BaSetupTimeOut(unsigned long data)
745 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
747 pTxTs->bAddBaReqInProgress = false;
748 pTxTs->bAddBaReqDelayed = true;
749 pTxTs->TxPendingBARecord.bValid = false;
752 void TxBaInactTimeout(unsigned long data)
754 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
755 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]);
756 TxTsDeleteBA(ieee, pTxTs);
757 ieee80211_send_DELBA(
759 pTxTs->TsCommonInfo.Addr,
760 &pTxTs->TxAdmittedBARecord,
762 DELBA_REASON_TIMEOUT);
765 void RxBaInactTimeout(unsigned long data)
767 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data;
768 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
770 RxTsDeleteBA(ieee, pRxTs);
771 ieee80211_send_DELBA(
773 pRxTs->TsCommonInfo.Addr,
774 &pRxTs->RxAdmittedBARecord,
776 DELBA_REASON_TIMEOUT);