1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 * This program is distributed in the hope that it will be useful, but WITHOUT
5 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 * You should have received a copy of the GNU General Public License along with
10 * this program; if not, write to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
13 * The full GNU General Public License is included in this distribution in the
14 * file called LICENSE.
16 * Contact Information:
17 * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
19 #include "ieee80211.h"
20 #include "rtl819x_BA.h"
22 /********************************************************************************************************************
23 *function: Activate BA entry. And if Time is nozero, start timer.
24 * input: PBA_RECORD pBA //BA entry to be enabled
25 * u16 Time //indicate time delay.
27 ********************************************************************************************************************/
28 void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time)
32 mod_timer(&pBA->Timer, jiffies + MSECS(Time));
35 /********************************************************************************************************************
36 *function: deactivate BA entry, including its timer.
37 * input: PBA_RECORD pBA //BA entry to be disabled
39 ********************************************************************************************************************/
40 void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA)
43 del_timer_sync(&pBA->Timer);
45 /********************************************************************************************************************
46 *function: deactivete BA entry in Tx Ts, and send DELBA.
48 * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry.
50 * notice: As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME
51 ********************************************************************************************************************/
52 u8 TxTsDeleteBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTxTs)
54 PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure
55 PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord;
56 u8 bSendDELBA = false;
59 if(pPendingBa->bValid)
61 DeActivateBAEntry(ieee, pPendingBa);
66 if(pAdmittedBa->bValid)
68 DeActivateBAEntry(ieee, pAdmittedBa);
75 /********************************************************************************************************************
76 *function: deactivete BA entry in Tx Ts, and send DELBA.
78 * PRX_TS_RECORD pRxTs //Rx Ts which is to deactivate BA entry.
80 * notice: As PRX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME, same with above
81 ********************************************************************************************************************/
82 u8 RxTsDeleteBA( struct ieee80211_device* ieee, PRX_TS_RECORD pRxTs)
84 PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord;
85 u8 bSendDELBA = false;
89 DeActivateBAEntry(ieee, pBa);
96 /********************************************************************************************************************
97 *function: reset BA entry
99 * PBA_RECORD pBA //entry to be reset
101 ********************************************************************************************************************/
102 void ResetBaEntry( PBA_RECORD pBA)
105 pBA->BaParamSet.shortData = 0;
106 pBA->BaTimeoutValue = 0;
107 pBA->DialogToken = 0;
108 pBA->BaStartSeqCtrl.ShortData = 0;
110 //These functions need porting here or not?
111 /*******************************************************************************************************************************
112 *function: construct ADDBAREQ and ADDBARSP frame here together.
113 * input: u8* Dst //ADDBA frame's destination
114 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA.
115 * u16 StatusCode //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?)
116 * u8 type //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
118 * return: sk_buff* skb //return constructed skb to xmit
119 *******************************************************************************************************************************/
120 static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type)
122 struct sk_buff *skb = NULL;
123 struct ieee80211_hdr_3addr* BAReq = NULL;
126 u16 len = ieee->tx_headroom + 9;
127 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __FUNCTION__, type, Dst, ieee->dev);
128 if (pBA == NULL||ieee == NULL)
130 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee);
133 skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
136 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
140 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.
141 skb_reserve(skb, ieee->tx_headroom);
143 BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
145 memcpy(BAReq->addr1, Dst, ETH_ALEN);
146 memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
148 memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
150 BAReq->frame_control = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
152 tag = (u8*)skb_put(skb, 9);
156 *tag ++= pBA->DialogToken;
158 if (ACT_ADDBARSP == type)
161 printk("=====>to send ADDBARSP\n");
162 tmp = cpu_to_le16(StatusCode);
163 memcpy(tag, (u8*)&tmp, 2);
167 tmp = cpu_to_le16(pBA->BaParamSet.shortData);
168 memcpy(tag, (u8*)&tmp, 2);
171 tmp = cpu_to_le16(pBA->BaTimeoutValue);
172 memcpy(tag, (u8*)&tmp, 2);
175 if (ACT_ADDBAREQ == type)
178 memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2);
182 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
186 /********************************************************************************************************************
187 *function: construct DELBA frame
188 * input: u8* dst //DELBA frame's destination
189 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
190 * TR_SELECT TxRxSelect //TX RX direction
191 * u16 ReasonCode //status code.
193 * return: sk_buff* skb //return constructed skb to xmit
194 ********************************************************************************************************************/
195 static struct sk_buff* ieee80211_DELBA(
196 struct ieee80211_device* ieee,
199 TR_SELECT TxRxSelect,
203 DELBA_PARAM_SET DelbaParamSet;
204 struct sk_buff *skb = NULL;
205 struct ieee80211_hdr_3addr* Delba = NULL;
208 u16 len = 6 + ieee->tx_headroom;
211 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:%pM\n", __FUNCTION__, ReasonCode, dst);
213 memset(&DelbaParamSet, 0, 2);
215 DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0;
216 DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
218 skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
221 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
224 skb_reserve(skb, ieee->tx_headroom);
226 Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
228 memcpy(Delba->addr1, dst, ETH_ALEN);
229 memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
230 memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
231 Delba->frame_control = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
233 tag = (u8*)skb_put(skb, 6);
238 // DELBA Parameter Set
239 tmp = cpu_to_le16(DelbaParamSet.shortData);
240 memcpy(tag, (u8*)&tmp, 2);
243 tmp = cpu_to_le16(ReasonCode);
244 memcpy(tag, (u8*)&tmp, 2);
247 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
249 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __FUNCTION__);
253 /********************************************************************************************************************
254 *function: send ADDBAReq frame out
255 * input: u8* dst //ADDBAReq frame's destination
256 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
258 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
259 ********************************************************************************************************************/
260 void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA)
262 struct sk_buff *skb = NULL;
263 skb = ieee80211_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); //construct ACT_ADDBAREQ frames so set statuscode zero.
267 softmac_mgmt_xmit(skb, ieee);
271 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
276 /********************************************************************************************************************
277 *function: send ADDBARSP frame out
278 * input: u8* dst //DELBA frame's destination
279 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
280 * u16 StatusCode //RSP StatusCode
282 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
283 ********************************************************************************************************************/
284 void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode)
286 struct sk_buff *skb = NULL;
287 skb = ieee80211_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); //construct ACT_ADDBARSP frames
290 softmac_mgmt_xmit(skb, ieee);
294 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
300 /********************************************************************************************************************
301 *function: send ADDBARSP frame out
302 * input: u8* dst //DELBA frame's destination
303 * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
304 * TR_SELECT TxRxSelect //TX or RX
305 * u16 ReasonCode //DEL ReasonCode
307 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
308 ********************************************************************************************************************/
310 void ieee80211_send_DELBA(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode)
312 struct sk_buff *skb = NULL;
313 skb = ieee80211_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); //construct ACT_ADDBARSP frames
316 softmac_mgmt_xmit(skb, ieee);
320 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
325 /********************************************************************************************************************
326 *function: RX ADDBAReq
327 * input: struct sk_buff * skb //incoming ADDBAReq skb.
328 * return: 0(pass), other(fail)
329 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
330 ********************************************************************************************************************/
331 int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
333 struct ieee80211_hdr_3addr* req = NULL;
335 u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL;
336 PBA_RECORD pBA = NULL;
337 PBA_PARAM_SET pBaParamSet = NULL;
338 u16* pBaTimeoutVal = NULL;
339 PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL;
340 PRX_TS_RECORD pTS = NULL;
342 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
344 IEEE80211_DEBUG(IEEE80211_DL_ERR,
345 " Invalid skb len in BAREQ(%d / %zd)\n",
347 sizeof(struct ieee80211_hdr_3addr) + 9);
351 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
353 req = ( struct ieee80211_hdr_3addr*) skb->data;
355 dst = (u8*)(&req->addr2[0]);
356 tag += sizeof( struct ieee80211_hdr_3addr);
357 pDialogToken = tag + 2; //category+action
358 pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken
359 pBaTimeoutVal = (u16*)(tag + 5);
360 pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7);
362 printk("====================>rx ADDBAREQ from :%pM\n", dst);
363 //some other capability is not ready now.
364 if( (ieee->current_network.qos_data.active == 0) ||
365 (ieee->pHTInfo->bCurrentHTSupport == false) ||
366 (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ))
368 rc = ADDBA_STATUS_REFUSED;
369 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);
370 goto OnADDBAReq_Fail;
372 // Search for related traffic stream.
373 // If there is no matched TS, reject the ADDBA request.
376 (PTS_COMMON_INFO*)(&pTS),
378 (u8)(pBaParamSet->field.TID),
382 rc = ADDBA_STATUS_REFUSED;
383 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
384 goto OnADDBAReq_Fail;
386 pBA = &pTS->RxAdmittedBARecord;
387 // To Determine the ADDBA Req content
388 // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
389 // I want to check StartSeqCtrl to make sure when we start aggregation!!!
391 if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
393 rc = ADDBA_STATUS_INVALID_PARAM;
394 IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __FUNCTION__);
395 goto OnADDBAReq_Fail;
397 // Admit the ADDBA Request
398 DeActivateBAEntry(ieee, pBA);
399 pBA->DialogToken = *pDialogToken;
400 pBA->BaParamSet = *pBaParamSet;
401 pBA->BaTimeoutValue = *pBaTimeoutVal;
402 pBA->BaStartSeqCtrl = *pBaStartSeqCtrl;
403 //for half N mode we only aggregate 1 frame
404 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)||
405 (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT))
406 pBA->BaParamSet.field.BufferSize = 1;
408 pBA->BaParamSet.field.BufferSize = 32;
409 ActivateBAEntry(ieee, pBA, 0);
410 ieee80211_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
417 BA.BaParamSet = *pBaParamSet;
418 BA.BaTimeoutValue = *pBaTimeoutVal;
419 BA.DialogToken = *pDialogToken;
420 BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE;
421 ieee80211_send_ADDBARsp(ieee, dst, &BA, rc);
422 return 0; //we send RSP out.
427 /********************************************************************************************************************
428 *function: RX ADDBARSP
429 * input: struct sk_buff * skb //incoming ADDBAReq skb.
430 * return: 0(pass), other(fail)
431 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
432 ********************************************************************************************************************/
433 int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
435 struct ieee80211_hdr_3addr* rsp = NULL;
436 PBA_RECORD pPendingBA, pAdmittedBA;
437 PTX_TS_RECORD pTS = NULL;
438 u8* dst = NULL, *pDialogToken = NULL, *tag = NULL;
439 u16* pStatusCode = NULL, *pBaTimeoutVal = NULL;
440 PBA_PARAM_SET pBaParamSet = NULL;
443 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
445 IEEE80211_DEBUG(IEEE80211_DL_ERR,
446 " Invalid skb len in BARSP(%d / %zd)\n",
448 sizeof(struct ieee80211_hdr_3addr) + 9);
451 rsp = ( struct ieee80211_hdr_3addr*)skb->data;
453 dst = (u8*)(&rsp->addr2[0]);
454 tag += sizeof( struct ieee80211_hdr_3addr);
455 pDialogToken = tag + 2;
456 pStatusCode = (u16*)(tag + 3);
457 pBaParamSet = (PBA_PARAM_SET)(tag + 5);
458 pBaTimeoutVal = (u16*)(tag + 7);
460 // Check the capability
461 // Since we can always receive A-MPDU, we just check if it is under HT mode.
462 if( ieee->current_network.qos_data.active == 0 ||
463 ieee->pHTInfo->bCurrentHTSupport == false ||
464 ieee->pHTInfo->bCurrentAMPDUEnable == false )
466 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);
467 ReasonCode = DELBA_REASON_UNKNOWN_BA;
468 goto OnADDBARsp_Reject;
473 // Search for related TS.
474 // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
478 (PTS_COMMON_INFO*)(&pTS),
480 (u8)(pBaParamSet->field.TID),
484 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
485 ReasonCode = DELBA_REASON_UNKNOWN_BA;
486 goto OnADDBARsp_Reject;
489 pTS->bAddBaReqInProgress = false;
490 pPendingBA = &pTS->TxPendingBARecord;
491 pAdmittedBA = &pTS->TxAdmittedBARecord;
495 // Check if related BA is waiting for setup.
496 // If not, reject by sending DELBA frame.
498 if((pAdmittedBA->bValid==true))
500 // Since BA is already setup, we ignore all other ADDBA Response.
501 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n");
504 else if((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken))
506 IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n");
507 ReasonCode = DELBA_REASON_UNKNOWN_BA;
508 goto OnADDBARsp_Reject;
512 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode);
513 DeActivateBAEntry(ieee, pPendingBA);
517 if(*pStatusCode == ADDBA_STATUS_SUCCESS)
520 // Determine ADDBA Rsp content here.
521 // We can compare the value of BA parameter set that Peer returned and Self sent.
522 // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
524 if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
526 // Since this is a kind of ADDBA failed, we delay next ADDBA process.
527 pTS->bAddBaReqDelayed = true;
528 DeActivateBAEntry(ieee, pAdmittedBA);
529 ReasonCode = DELBA_REASON_END_BA;
530 goto OnADDBARsp_Reject;
535 // Admitted condition
537 pAdmittedBA->DialogToken = *pDialogToken;
538 pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal;
539 pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl;
540 pAdmittedBA->BaParamSet = *pBaParamSet;
541 DeActivateBAEntry(ieee, pAdmittedBA);
542 ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal);
544 pTS->bAddBaReqDelayed = true;
545 pTS->bDisable_AddBa = true;
546 ReasonCode = DELBA_REASON_END_BA;
547 goto OnADDBARsp_Reject;
556 BA.BaParamSet = *pBaParamSet;
557 ieee80211_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
563 /********************************************************************************************************************
565 * input: struct sk_buff * skb //incoming ADDBAReq skb.
566 * return: 0(pass), other(fail)
567 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
568 ********************************************************************************************************************/
569 int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
571 struct ieee80211_hdr_3addr* delba = NULL;
572 PDELBA_PARAM_SET pDelBaParamSet = NULL;
573 u16* pReasonCode = NULL;
576 if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
578 IEEE80211_DEBUG(IEEE80211_DL_ERR,
579 " Invalid skb len in DELBA(%d / %zd)\n",
581 sizeof(struct ieee80211_hdr_3addr) + 6);
585 if(ieee->current_network.qos_data.active == 0 ||
586 ieee->pHTInfo->bCurrentHTSupport == false )
588 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);
592 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
593 delba = ( struct ieee80211_hdr_3addr*)skb->data;
594 dst = (u8*)(&delba->addr2[0]);
595 delba += sizeof( struct ieee80211_hdr_3addr);
596 pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2);
597 pReasonCode = (u16*)(delba+4);
599 if(pDelBaParamSet->field.Initiator == 1)
605 (PTS_COMMON_INFO*)&pRxTs,
607 (u8)pDelBaParamSet->field.TID,
611 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __FUNCTION__);
615 RxTsDeleteBA(ieee, pRxTs);
623 (PTS_COMMON_INFO*)&pTxTs,
625 (u8)pDelBaParamSet->field.TID,
629 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __FUNCTION__);
633 pTxTs->bUsingBa = false;
634 pTxTs->bAddBaReqInProgress = false;
635 pTxTs->bAddBaReqDelayed = false;
636 del_timer_sync(&pTxTs->TsAddBaTimer);
637 TxTsDeleteBA(ieee, pTxTs);
643 // ADDBA initiate. This can only be called by TX side.
647 struct ieee80211_device* ieee,
653 PBA_RECORD pBA = &pTS->TxPendingBARecord;
655 if(pBA->bValid==true && bOverwritePending==false)
658 // Set parameters to "Pending" variable set
659 DeActivateBAEntry(ieee, pBA);
661 pBA->DialogToken++; // DialogToken: Only keep the latest dialog token
662 pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!!
663 pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate
664 pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; // TID
665 // BufferSize: This need to be set according to A-MPDU vector
666 pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector
667 pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer
668 pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later.
670 ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
672 ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA);
676 TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect)
679 if(TxRxSelect == TX_DIR)
681 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo;
683 if(TxTsDeleteBA(ieee, pTxTs))
684 ieee80211_send_DELBA(
687 (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord),
689 DELBA_REASON_END_BA);
691 else if(TxRxSelect == RX_DIR)
693 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo;
694 if(RxTsDeleteBA(ieee, pRxTs))
695 ieee80211_send_DELBA(
698 &pRxTs->RxAdmittedBARecord,
700 DELBA_REASON_END_BA );
703 /********************************************************************************************************************
704 *function: BA setup timer
705 * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
708 ********************************************************************************************************************/
709 void BaSetupTimeOut(unsigned long data)
711 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
713 pTxTs->bAddBaReqInProgress = false;
714 pTxTs->bAddBaReqDelayed = true;
715 pTxTs->TxPendingBARecord.bValid = false;
718 void TxBaInactTimeout(unsigned long data)
720 PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
721 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]);
722 TxTsDeleteBA(ieee, pTxTs);
723 ieee80211_send_DELBA(
725 pTxTs->TsCommonInfo.Addr,
726 &pTxTs->TxAdmittedBARecord,
728 DELBA_REASON_TIMEOUT);
731 void RxBaInactTimeout(unsigned long data)
733 PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data;
734 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
736 RxTsDeleteBA(ieee, pRxTs);
737 ieee80211_send_DELBA(
739 pRxTs->TsCommonInfo.Addr,
740 &pRxTs->RxAdmittedBARecord,
742 DELBA_REASON_TIMEOUT);