1 // SPDX-License-Identifier: GPL-2.0
2 /********************************************************************************************************************************
3 * 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
4 * 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
5 * ADDBAREQ ADDBARSP and DELBA packet is still on consideration. Temporarily use MANAGE QUEUE instead of Normal Queue.
7 * *****************************************************************************************************************************/
8 #include <asm/byteorder.h>
9 #include <asm/unaligned.h>
10 #include "ieee80211.h"
11 #include "rtl819x_BA.h"
13 /********************************************************************************************************************
14 *function: Activate BA entry. And if Time is nozero, start timer.
15 * input: struct ba_record *pBA //BA entry to be enabled
16 * u16 Time //indicate time delay.
18 ********************************************************************************************************************/
19 static void ActivateBAEntry(struct ieee80211_device *ieee, struct ba_record *pBA, u16 Time)
23 mod_timer(&pBA->timer, jiffies + msecs_to_jiffies(Time));
26 /********************************************************************************************************************
27 *function: deactivate BA entry, including its timer.
28 * input: struct ba_record *pBA //BA entry to be disabled
30 ********************************************************************************************************************/
31 static void DeActivateBAEntry(struct ieee80211_device *ieee, struct ba_record *pBA)
34 del_timer_sync(&pBA->timer);
36 /********************************************************************************************************************
37 *function: deactivete BA entry in Tx Ts, and send DELBA.
39 * struct tx_ts_record *pTxTs //Tx Ts which is to deactivate BA entry.
41 * notice: As struct tx_ts_record * structure will be defined in QOS, so wait to be merged. //FIXME
42 ********************************************************************************************************************/
43 static u8 TxTsDeleteBA(struct ieee80211_device *ieee, struct tx_ts_record *pTxTs)
45 struct ba_record *pAdmittedBa = &pTxTs->tx_admitted_ba_record; //These two BA entries must exist in TS structure
46 struct ba_record *pPendingBa = &pTxTs->tx_pending_ba_record;
47 u8 bSendDELBA = false;
50 if (pPendingBa->valid) {
51 DeActivateBAEntry(ieee, pPendingBa);
56 if (pAdmittedBa->valid) {
57 DeActivateBAEntry(ieee, pAdmittedBa);
64 /********************************************************************************************************************
65 *function: deactivete BA entry in Tx Ts, and send DELBA.
67 * struct rx_ts_record *pRxTs //Rx Ts which is to deactivate BA entry.
69 * notice: As struct rx_ts_record * structure will be defined in QOS, so wait to be merged. //FIXME, same with above
70 ********************************************************************************************************************/
71 static u8 RxTsDeleteBA(struct ieee80211_device *ieee, struct rx_ts_record *pRxTs)
73 struct ba_record *pBa = &pRxTs->rx_admitted_ba_record;
74 u8 bSendDELBA = false;
77 DeActivateBAEntry(ieee, pBa);
84 /********************************************************************************************************************
85 *function: reset BA entry
87 * struct ba_record *pBA //entry to be reset
89 ********************************************************************************************************************/
90 void ResetBaEntry(struct ba_record *pBA)
93 pBA->param_set.short_data = 0;
94 pBA->timeout_value = 0;
95 pBA->dialog_token = 0;
96 pBA->start_seq_ctrl.short_data = 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 * struct ba_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, struct ba_record *pBA, u16 StatusCode, u8 type)
110 struct sk_buff *skb = NULL;
111 struct rtl_80211_hdr_3addr *BAReq = NULL;
113 u16 len = ieee->tx_headroom + 9;
114 //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2))
115 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev);
117 IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA is NULL\n");
120 skb = dev_alloc_skb(len + sizeof(struct rtl_80211_hdr_3addr)); //need to add something others? FIXME
124 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.
125 skb_reserve(skb, ieee->tx_headroom);
127 BAReq = skb_put(skb, sizeof(struct rtl_80211_hdr_3addr));
129 memcpy(BAReq->addr1, Dst, ETH_ALEN);
130 memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
132 memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
134 BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
136 //tag += sizeof( struct rtl_80211_hdr_3addr); //move to action field
137 tag = skb_put(skb, 9);
141 *tag++ = pBA->dialog_token;
143 if (ACT_ADDBARSP == type) {
145 netdev_info(ieee->dev, "=====>to send ADDBARSP\n");
147 put_unaligned_le16(StatusCode, tag);
152 put_unaligned_le16(pBA->param_set.short_data, tag);
156 put_unaligned_le16(pBA->timeout_value, tag);
159 if (ACT_ADDBAREQ == type) {
161 memcpy(tag, (u8 *)&(pBA->start_seq_ctrl), 2);
165 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_BA, skb->data, skb->len);
171 /********************************************************************************************************************
172 *function: construct DELBA frame
173 * input: u8* dst //DELBA frame's destination
174 * struct ba_record *pBA //BA_RECORD entry which stores the necessary information for BA
175 * enum tr_select TxRxSelect //TX RX direction
176 * u16 ReasonCode //status code.
178 * return: sk_buff* skb //return constructed skb to xmit
179 ********************************************************************************************************************/
180 static struct sk_buff *ieee80211_DELBA(
181 struct ieee80211_device *ieee,
183 struct ba_record *pBA,
184 enum tr_select TxRxSelect,
188 union delba_param_set DelbaParamSet;
189 struct sk_buff *skb = NULL;
190 struct rtl_80211_hdr_3addr *Delba = NULL;
192 //len = head len + DELBA Parameter Set(2) + Reason Code(2)
193 u16 len = 6 + ieee->tx_headroom;
196 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA,
197 "========>%s(), ReasonCode(%d) sentd to:%pM\n",
198 __func__, ReasonCode, dst);
200 memset(&DelbaParamSet, 0, 2);
202 DelbaParamSet.field.initiator = (TxRxSelect == TX_DIR) ? 1 : 0;
203 DelbaParamSet.field.tid = pBA->param_set.field.tid;
205 skb = dev_alloc_skb(len + sizeof(struct rtl_80211_hdr_3addr)); //need to add something others? FIXME
208 // memset(skb->data, 0, len+sizeof( struct rtl_80211_hdr_3addr));
209 skb_reserve(skb, ieee->tx_headroom);
211 Delba = skb_put(skb, sizeof(struct rtl_80211_hdr_3addr));
213 memcpy(Delba->addr1, dst, ETH_ALEN);
214 memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
215 memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
216 Delba->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
218 tag = skb_put(skb, 6);
223 // DELBA Parameter Set
225 put_unaligned_le16(DelbaParamSet.short_data, tag);
229 put_unaligned_le16(ReasonCode, tag);
232 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_BA, skb->data, skb->len);
234 IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA,
235 "<=====%s()\n", __func__);
239 /********************************************************************************************************************
240 *function: send ADDBAReq frame out
241 * input: u8* dst //ADDBAReq frame's destination
242 * struct ba_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, struct ba_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()
258 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__);
262 /********************************************************************************************************************
263 *function: send ADDBARSP frame out
264 * input: u8* dst //DELBA frame's destination
265 * struct ba_record *pBA //BA_RECORD entry which stores the necessary information for BA
266 * u16 StatusCode //RSP StatusCode
268 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
269 ********************************************************************************************************************/
270 static void ieee80211_send_ADDBARsp(struct ieee80211_device *ieee, u8 *dst,
271 struct ba_record *pBA, u16 StatusCode)
274 skb = ieee80211_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); //construct ACT_ADDBARSP frames
276 softmac_mgmt_xmit(skb, ieee);
279 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__);
285 /********************************************************************************************************************
286 *function: send ADDBARSP frame out
287 * input: u8* dst //DELBA frame's destination
288 * struct ba_record *pBA //BA_RECORD entry which stores the necessary information for BA
289 * enum tr_select TxRxSelect //TX or RX
290 * u16 ReasonCode //DEL ReasonCode
292 * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
293 ********************************************************************************************************************/
295 static void ieee80211_send_DELBA(struct ieee80211_device *ieee, u8 *dst,
296 struct ba_record *pBA, enum tr_select TxRxSelect,
300 skb = ieee80211_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); //construct ACT_ADDBARSP frames
302 softmac_mgmt_xmit(skb, ieee);
305 IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__);
309 /********************************************************************************************************************
310 *function: RX ADDBAReq
311 * input: struct sk_buff * skb //incoming ADDBAReq skb.
312 * return: 0(pass), other(fail)
313 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
314 ********************************************************************************************************************/
315 int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
317 struct rtl_80211_hdr_3addr *req = NULL;
319 u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL;
320 struct ba_record *pBA = NULL;
321 union ba_param_set *pBaParamSet = NULL;
322 u16 *pBaTimeoutVal = NULL;
323 union sequence_control *pBaStartSeqCtrl = NULL;
324 struct rx_ts_record *pTS = NULL;
326 if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) {
327 IEEE80211_DEBUG(IEEE80211_DL_ERR,
328 " Invalid skb len in BAREQ(%d / %zu)\n",
330 (sizeof(struct rtl_80211_hdr_3addr) + 9));
334 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_BA, skb->data, skb->len);
336 req = (struct rtl_80211_hdr_3addr *)skb->data;
338 dst = &req->addr2[0];
339 tag += sizeof(struct rtl_80211_hdr_3addr);
340 pDialogToken = tag + 2; //category+action
341 pBaParamSet = (union ba_param_set *)(tag + 3); //+DialogToken
342 pBaTimeoutVal = (u16 *)(tag + 5);
343 pBaStartSeqCtrl = (union sequence_control *)(req + 7);
345 netdev_info(ieee->dev, "====================>rx ADDBAREQ from :%pM\n", dst);
346 //some other capability is not ready now.
347 if ((ieee->current_network.qos_data.active == 0) ||
348 (!ieee->pHTInfo->bCurrentHTSupport)) //||
349 // (!ieee->pStaQos->bEnableRxImmBA) )
351 rc = ADDBA_STATUS_REFUSED;
352 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);
353 goto OnADDBAReq_Fail;
355 // Search for related traffic stream.
356 // If there is no matched TS, reject the ADDBA request.
359 (struct ts_common_info **)(&pTS),
361 (u8)(pBaParamSet->field.tid),
364 rc = ADDBA_STATUS_REFUSED;
365 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __func__);
366 goto OnADDBAReq_Fail;
368 pBA = &pTS->rx_admitted_ba_record;
369 // To Determine the ADDBA Req content
370 // We can do much more check here, including buffer_size, AMSDU_Support, Policy, StartSeqCtrl...
371 // I want to check StartSeqCtrl to make sure when we start aggregation!!!
373 if (pBaParamSet->field.ba_policy == BA_POLICY_DELAYED) {
374 rc = ADDBA_STATUS_INVALID_PARAM;
375 IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __func__);
376 goto OnADDBAReq_Fail;
378 // Admit the ADDBA Request
380 DeActivateBAEntry(ieee, pBA);
381 pBA->dialog_token = *pDialogToken;
382 pBA->param_set = *pBaParamSet;
383 pBA->timeout_value = *pBaTimeoutVal;
384 pBA->start_seq_ctrl = *pBaStartSeqCtrl;
385 //for half N mode we only aggregate 1 frame
386 if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
387 pBA->param_set.field.buffer_size = 1;
389 pBA->param_set.field.buffer_size = 32;
390 ActivateBAEntry(ieee, pBA, pBA->timeout_value);
391 ieee80211_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
399 BA.param_set = *pBaParamSet;
400 BA.timeout_value = *pBaTimeoutVal;
401 BA.dialog_token = *pDialogToken;
402 BA.param_set.field.ba_policy = BA_POLICY_IMMEDIATE;
403 ieee80211_send_ADDBARsp(ieee, dst, &BA, rc);
404 return 0; //we send RSP out.
409 /********************************************************************************************************************
410 *function: RX ADDBARSP
411 * input: struct sk_buff * skb //incoming ADDBAReq skb.
412 * return: 0(pass), other(fail)
413 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
414 ********************************************************************************************************************/
415 int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb)
417 struct rtl_80211_hdr_3addr *rsp = NULL;
418 struct ba_record *pPendingBA, *pAdmittedBA;
419 struct tx_ts_record *pTS = NULL;
420 u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL;
421 u16 *pStatusCode = NULL, *pBaTimeoutVal = NULL;
422 union ba_param_set *pBaParamSet = NULL;
425 if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) {
426 IEEE80211_DEBUG(IEEE80211_DL_ERR,
427 " Invalid skb len in BARSP(%d / %zu)\n",
429 (sizeof(struct rtl_80211_hdr_3addr) + 9));
432 rsp = (struct rtl_80211_hdr_3addr *)skb->data;
434 dst = &rsp->addr2[0];
435 tag += sizeof(struct rtl_80211_hdr_3addr);
436 pDialogToken = tag + 2;
437 pStatusCode = (u16 *)(tag + 3);
438 pBaParamSet = (union ba_param_set *)(tag + 5);
439 pBaTimeoutVal = (u16 *)(tag + 7);
441 // Check the capability
442 // Since we can always receive A-MPDU, we just check if it is under HT mode.
443 if (ieee->current_network.qos_data.active == 0 ||
444 !ieee->pHTInfo->bCurrentHTSupport ||
445 !ieee->pHTInfo->bCurrentAMPDUEnable) {
446 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);
447 ReasonCode = DELBA_REASON_UNKNOWN_BA;
448 goto OnADDBARsp_Reject;
453 // Search for related TS.
454 // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
458 (struct ts_common_info **)(&pTS),
460 (u8)(pBaParamSet->field.tid),
463 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __func__);
464 ReasonCode = DELBA_REASON_UNKNOWN_BA;
465 goto OnADDBARsp_Reject;
468 pTS->add_ba_req_in_progress = false;
469 pPendingBA = &pTS->tx_pending_ba_record;
470 pAdmittedBA = &pTS->tx_admitted_ba_record;
474 // Check if related BA is waiting for setup.
475 // If not, reject by sending DELBA frame.
477 if (pAdmittedBA->valid) {
478 // Since BA is already setup, we ignore all other ADDBA Response.
479 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n");
481 } else if ((!pPendingBA->valid) || (*pDialogToken != pPendingBA->dialog_token)) {
482 IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n");
483 ReasonCode = DELBA_REASON_UNKNOWN_BA;
484 goto OnADDBARsp_Reject;
486 IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode);
487 DeActivateBAEntry(ieee, pPendingBA);
491 if (*pStatusCode == ADDBA_STATUS_SUCCESS) {
493 // Determine ADDBA Rsp content here.
494 // We can compare the value of BA parameter set that Peer returned and Self sent.
495 // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
497 if (pBaParamSet->field.ba_policy == BA_POLICY_DELAYED) {
498 // Since this is a kind of ADDBA failed, we delay next ADDBA process.
499 pTS->add_ba_req_delayed = true;
500 DeActivateBAEntry(ieee, pAdmittedBA);
501 ReasonCode = DELBA_REASON_END_BA;
502 goto OnADDBARsp_Reject;
507 // Admitted condition
509 pAdmittedBA->dialog_token = *pDialogToken;
510 pAdmittedBA->timeout_value = *pBaTimeoutVal;
511 pAdmittedBA->start_seq_ctrl = pPendingBA->start_seq_ctrl;
512 pAdmittedBA->param_set = *pBaParamSet;
513 DeActivateBAEntry(ieee, pAdmittedBA);
514 ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal);
516 // Delay next ADDBA process.
517 pTS->add_ba_req_delayed = true;
526 BA.param_set = *pBaParamSet;
527 ieee80211_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
533 /********************************************************************************************************************
535 * input: struct sk_buff * skb //incoming ADDBAReq skb.
536 * return: 0(pass), other(fail)
537 * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
538 ********************************************************************************************************************/
539 int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb)
541 struct rtl_80211_hdr_3addr *delba = NULL;
542 union delba_param_set *pDelBaParamSet = NULL;
545 if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 6) {
546 IEEE80211_DEBUG(IEEE80211_DL_ERR,
547 " Invalid skb len in DELBA(%d / %zu)\n",
549 (sizeof(struct rtl_80211_hdr_3addr) + 6));
553 if (ieee->current_network.qos_data.active == 0 ||
554 !ieee->pHTInfo->bCurrentHTSupport) {
555 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);
559 IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA | IEEE80211_DL_BA, skb->data, skb->len);
560 delba = (struct rtl_80211_hdr_3addr *)skb->data;
561 dst = &delba->addr2[0];
562 pDelBaParamSet = (union delba_param_set *)&delba->payload[2];
564 if (pDelBaParamSet->field.initiator == 1) {
565 struct rx_ts_record *pRxTs;
569 (struct ts_common_info **)&pRxTs,
571 (u8)pDelBaParamSet->field.tid,
574 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __func__);
578 RxTsDeleteBA(ieee, pRxTs);
580 struct tx_ts_record *pTxTs;
584 (struct ts_common_info **)&pTxTs,
586 (u8)pDelBaParamSet->field.tid,
589 IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __func__);
593 pTxTs->using_ba = false;
594 pTxTs->add_ba_req_in_progress = false;
595 pTxTs->add_ba_req_delayed = false;
596 del_timer_sync(&pTxTs->ts_add_ba_timer);
597 //PlatformCancelTimer(Adapter, &pTxTs->ts_add_ba_timer);
598 TxTsDeleteBA(ieee, pTxTs);
604 // ADDBA initiate. This can only be called by TX side.
608 struct ieee80211_device *ieee,
609 struct tx_ts_record *pTS,
614 struct ba_record *pBA = &pTS->tx_pending_ba_record;
616 if (pBA->valid && !bOverwritePending)
619 // Set parameters to "Pending" variable set
620 DeActivateBAEntry(ieee, pBA);
622 pBA->dialog_token++; // DialogToken: Only keep the latest dialog token
623 pBA->param_set.field.amsdu_support = 0; // Do not support A-MSDU with A-MPDU now!!
624 pBA->param_set.field.ba_policy = Policy; // Policy: Delayed or Immediate
625 pBA->param_set.field.tid = pTS->ts_common_info.t_spec.ts_info.uc_tsid; // TID
626 // buffer_size: This need to be set according to A-MPDU vector
627 pBA->param_set.field.buffer_size = 32; // buffer_size: This need to be set according to A-MPDU vector
628 pBA->timeout_value = 0; // Timeout value: Set 0 to disable Timer
629 pBA->start_seq_ctrl.field.seq_num = (pTS->tx_cur_seq + 3) % 4096; // Block Ack will start after 3 packets later.
631 ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
633 ieee80211_send_ADDBAReq(ieee, pTS->ts_common_info.addr, pBA);
637 TsInitDelBA(struct ieee80211_device *ieee, struct ts_common_info *pTsCommonInfo, enum tr_select TxRxSelect)
639 if (TxRxSelect == TX_DIR) {
640 struct tx_ts_record *pTxTs = (struct tx_ts_record *)pTsCommonInfo;
642 if (TxTsDeleteBA(ieee, pTxTs))
643 ieee80211_send_DELBA(
646 (pTxTs->tx_admitted_ba_record.valid) ? (&pTxTs->tx_admitted_ba_record) : (&pTxTs->tx_pending_ba_record),
648 DELBA_REASON_END_BA);
649 } else if (TxRxSelect == RX_DIR) {
650 struct rx_ts_record *pRxTs = (struct rx_ts_record *)pTsCommonInfo;
651 if (RxTsDeleteBA(ieee, pRxTs))
652 ieee80211_send_DELBA(
655 &pRxTs->rx_admitted_ba_record,
657 DELBA_REASON_END_BA);
660 /********************************************************************************************************************
661 *function: BA setup timer
662 * input: unsigned long data //acturally we send struct tx_ts_record or struct rx_ts_record to these timer
665 ********************************************************************************************************************/
666 void BaSetupTimeOut(struct timer_list *t)
668 struct tx_ts_record *pTxTs = from_timer(pTxTs, t, tx_pending_ba_record.timer);
670 pTxTs->add_ba_req_in_progress = false;
671 pTxTs->add_ba_req_delayed = true;
672 pTxTs->tx_pending_ba_record.valid = false;
675 void TxBaInactTimeout(struct timer_list *t)
677 struct tx_ts_record *pTxTs = from_timer(pTxTs, t, tx_admitted_ba_record.timer);
678 struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]);
679 TxTsDeleteBA(ieee, pTxTs);
680 ieee80211_send_DELBA(
682 pTxTs->ts_common_info.addr,
683 &pTxTs->tx_admitted_ba_record,
685 DELBA_REASON_TIMEOUT);
688 void RxBaInactTimeout(struct timer_list *t)
690 struct rx_ts_record *pRxTs = from_timer(pRxTs, t, rx_admitted_ba_record.timer);
691 struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
693 RxTsDeleteBA(ieee, pRxTs);
694 ieee80211_send_DELBA(
696 pRxTs->ts_common_info.addr,
697 &pRxTs->rx_admitted_ba_record,
699 DELBA_REASON_TIMEOUT);