1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4  *
5  * Contact Information: wlanfae <wlanfae@realtek.com>
6  */
7 #include <asm/byteorder.h>
8 #include <asm/unaligned.h>
9 #include <linux/etherdevice.h>
10 #include "rtllib.h"
11 #include "rtl819x_BA.h"
12 
ActivateBAEntry(struct ba_record * pBA,u16 Time)13 static void ActivateBAEntry(struct ba_record *pBA, u16 Time)
14 {
15 	pBA->b_valid = true;
16 	if (Time != 0)
17 		mod_timer(&pBA->timer, jiffies + msecs_to_jiffies(Time));
18 }
19 
DeActivateBAEntry(struct rtllib_device * ieee,struct ba_record * pBA)20 static void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA)
21 {
22 	pBA->b_valid = false;
23 	del_timer_sync(&pBA->timer);
24 }
25 
TxTsDeleteBA(struct rtllib_device * ieee,struct tx_ts_record * pTxTs)26 static u8 TxTsDeleteBA(struct rtllib_device *ieee, struct tx_ts_record *pTxTs)
27 {
28 	struct ba_record *pAdmittedBa = &pTxTs->TxAdmittedBARecord;
29 	struct ba_record *pPendingBa = &pTxTs->TxPendingBARecord;
30 	u8 bSendDELBA = false;
31 
32 	if (pPendingBa->b_valid) {
33 		DeActivateBAEntry(ieee, pPendingBa);
34 		bSendDELBA = true;
35 	}
36 
37 	if (pAdmittedBa->b_valid) {
38 		DeActivateBAEntry(ieee, pAdmittedBa);
39 		bSendDELBA = true;
40 	}
41 	return bSendDELBA;
42 }
43 
RxTsDeleteBA(struct rtllib_device * ieee,struct rx_ts_record * pRxTs)44 static u8 RxTsDeleteBA(struct rtllib_device *ieee, struct rx_ts_record *pRxTs)
45 {
46 	struct ba_record *pBa = &pRxTs->rx_admitted_ba_record;
47 	u8			bSendDELBA = false;
48 
49 	if (pBa->b_valid) {
50 		DeActivateBAEntry(ieee, pBa);
51 		bSendDELBA = true;
52 	}
53 
54 	return bSendDELBA;
55 }
56 
ResetBaEntry(struct ba_record * pBA)57 void ResetBaEntry(struct ba_record *pBA)
58 {
59 	pBA->b_valid			  = false;
60 	pBA->ba_param_set.short_data	  = 0;
61 	pBA->ba_timeout_value		  = 0;
62 	pBA->dialog_token		  = 0;
63 	pBA->ba_start_seq_ctrl.short_data = 0;
64 }
rtllib_ADDBA(struct rtllib_device * ieee,u8 * Dst,struct ba_record * pBA,u16 StatusCode,u8 type)65 static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
66 				    struct ba_record *pBA,
67 				    u16 StatusCode, u8 type)
68 {
69 	struct sk_buff *skb = NULL;
70 	struct rtllib_hdr_3addr *BAReq = NULL;
71 	u8 *tag = NULL;
72 	u16 len = ieee->tx_headroom + 9;
73 
74 	netdev_dbg(ieee->dev, "%s(): frame(%d) sentd to: %pM, ieee->dev:%p\n",
75 		   __func__, type, Dst, ieee->dev);
76 
77 	if (!pBA) {
78 		netdev_warn(ieee->dev, "pBA is NULL\n");
79 		return NULL;
80 	}
81 	skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
82 	if (!skb)
83 		return NULL;
84 
85 	memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr));
86 
87 	skb_reserve(skb, ieee->tx_headroom);
88 
89 	BAReq = skb_put(skb, sizeof(struct rtllib_hdr_3addr));
90 
91 	ether_addr_copy(BAReq->addr1, Dst);
92 	ether_addr_copy(BAReq->addr2, ieee->dev->dev_addr);
93 
94 	ether_addr_copy(BAReq->addr3, ieee->current_network.bssid);
95 	BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
96 
97 	tag = skb_put(skb, 9);
98 	*tag++ = ACT_CAT_BA;
99 	*tag++ = type;
100 	*tag++ = pBA->dialog_token;
101 
102 	if (type == ACT_ADDBARSP) {
103 		RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n");
104 
105 		put_unaligned_le16(StatusCode, tag);
106 		tag += 2;
107 	}
108 
109 	put_unaligned_le16(pBA->ba_param_set.short_data, tag);
110 	tag += 2;
111 
112 	put_unaligned_le16(pBA->ba_timeout_value, tag);
113 	tag += 2;
114 
115 	if (type == ACT_ADDBAREQ) {
116 		memcpy(tag, (u8 *)&(pBA->ba_start_seq_ctrl), 2);
117 		tag += 2;
118 	}
119 
120 #ifdef VERBOSE_DEBUG
121 	print_hex_dump_bytes("%s: ", DUMP_PREFIX_NONE, skb->data,
122 			     __func__, skb->len);
123 #endif
124 	return skb;
125 }
126 
rtllib_DELBA(struct rtllib_device * ieee,u8 * dst,struct ba_record * pBA,enum tr_select TxRxSelect,u16 ReasonCode)127 static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
128 				    struct ba_record *pBA,
129 				    enum tr_select TxRxSelect, u16 ReasonCode)
130 {
131 	union delba_param_set DelbaParamSet;
132 	struct sk_buff *skb = NULL;
133 	struct rtllib_hdr_3addr *Delba = NULL;
134 	u8 *tag = NULL;
135 	u16 len = 6 + ieee->tx_headroom;
136 
137 	if (net_ratelimit())
138 		netdev_dbg(ieee->dev, "%s(): ReasonCode(%d) sentd to: %pM\n",
139 			   __func__, ReasonCode, dst);
140 
141 	memset(&DelbaParamSet, 0, 2);
142 
143 	DelbaParamSet.field.initiator = (TxRxSelect == TX_DIR) ? 1 : 0;
144 	DelbaParamSet.field.tid	= pBA->ba_param_set.field.tid;
145 
146 	skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
147 	if (!skb)
148 		return NULL;
149 
150 	skb_reserve(skb, ieee->tx_headroom);
151 
152 	Delba = skb_put(skb, sizeof(struct rtllib_hdr_3addr));
153 
154 	ether_addr_copy(Delba->addr1, dst);
155 	ether_addr_copy(Delba->addr2, ieee->dev->dev_addr);
156 	ether_addr_copy(Delba->addr3, ieee->current_network.bssid);
157 	Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
158 
159 	tag = skb_put(skb, 6);
160 
161 	*tag++ = ACT_CAT_BA;
162 	*tag++ = ACT_DELBA;
163 
164 
165 	put_unaligned_le16(DelbaParamSet.short_data, tag);
166 	tag += 2;
167 
168 	put_unaligned_le16(ReasonCode, tag);
169 	tag += 2;
170 
171 #ifdef VERBOSE_DEBUG
172 	print_hex_dump_bytes("%s: ", DUMP_PREFIX_NONE, skb->data,
173 			     __func__, skb->len);
174 #endif
175 	return skb;
176 }
177 
rtllib_send_ADDBAReq(struct rtllib_device * ieee,u8 * dst,struct ba_record * pBA)178 static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst,
179 				 struct ba_record *pBA)
180 {
181 	struct sk_buff *skb;
182 
183 	skb = rtllib_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ);
184 
185 	if (skb) {
186 		RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n");
187 		softmac_mgmt_xmit(skb, ieee);
188 	} else {
189 		netdev_dbg(ieee->dev, "Failed to generate ADDBAReq packet.\n");
190 	}
191 }
192 
rtllib_send_ADDBARsp(struct rtllib_device * ieee,u8 * dst,struct ba_record * pBA,u16 StatusCode)193 static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst,
194 				 struct ba_record *pBA, u16 StatusCode)
195 {
196 	struct sk_buff *skb;
197 
198 	skb = rtllib_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP);
199 	if (skb)
200 		softmac_mgmt_xmit(skb, ieee);
201 	else
202 		netdev_dbg(ieee->dev, "Failed to generate ADDBARsp packet.\n");
203 }
204 
rtllib_send_DELBA(struct rtllib_device * ieee,u8 * dst,struct ba_record * pBA,enum tr_select TxRxSelect,u16 ReasonCode)205 static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst,
206 			      struct ba_record *pBA, enum tr_select TxRxSelect,
207 			      u16 ReasonCode)
208 {
209 	struct sk_buff *skb;
210 
211 	skb = rtllib_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode);
212 	if (skb)
213 		softmac_mgmt_xmit(skb, ieee);
214 	else
215 		netdev_dbg(ieee->dev, "Failed to generate DELBA packet.\n");
216 }
217 
rtllib_rx_ADDBAReq(struct rtllib_device * ieee,struct sk_buff * skb)218 int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
219 {
220 	struct rtllib_hdr_3addr *req = NULL;
221 	u16 rc = 0;
222 	u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL;
223 	struct ba_record *pBA = NULL;
224 	union ba_param_set *pBaParamSet = NULL;
225 	u16 *pBaTimeoutVal = NULL;
226 	union sequence_control *pBaStartSeqCtrl = NULL;
227 	struct rx_ts_record *pTS = NULL;
228 
229 	if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
230 		netdev_warn(ieee->dev, "Invalid skb len in BAREQ(%d / %d)\n",
231 			    (int)skb->len,
232 			    (int)(sizeof(struct rtllib_hdr_3addr) + 9));
233 		return -1;
234 	}
235 
236 #ifdef VERBOSE_DEBUG
237 	print_hex_dump_bytes("%s: ", DUMP_PREFIX_NONE, __func__,
238 			     skb->data, skb->len);
239 #endif
240 
241 	req = (struct rtllib_hdr_3addr *)skb->data;
242 	tag = (u8 *)req;
243 	dst = (u8 *)(&req->addr2[0]);
244 	tag += sizeof(struct rtllib_hdr_3addr);
245 	pDialogToken = tag + 2;
246 	pBaParamSet = (union ba_param_set *)(tag + 3);
247 	pBaTimeoutVal = (u16 *)(tag + 5);
248 	pBaStartSeqCtrl = (union sequence_control *)(req + 7);
249 
250 	RT_TRACE(COMP_DBG, "====>rx ADDBAREQ from : %pM\n", dst);
251 	if (!ieee->current_network.qos_data.active ||
252 	    !ieee->pHTInfo->bCurrentHTSupport ||
253 	    (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) {
254 		rc = ADDBA_STATUS_REFUSED;
255 		netdev_warn(ieee->dev,
256 			    "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n",
257 			    ieee->current_network.qos_data.active,
258 			    ieee->pHTInfo->bCurrentHTSupport);
259 		goto OnADDBAReq_Fail;
260 	}
261 	if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
262 	    (u8)(pBaParamSet->field.tid), RX_DIR, true)) {
263 		rc = ADDBA_STATUS_REFUSED;
264 		netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
265 		goto OnADDBAReq_Fail;
266 	}
267 	pBA = &pTS->rx_admitted_ba_record;
268 
269 	if (pBaParamSet->field.ba_policy == BA_POLICY_DELAYED) {
270 		rc = ADDBA_STATUS_INVALID_PARAM;
271 		netdev_warn(ieee->dev, "%s(): BA Policy is not correct\n",
272 			    __func__);
273 		goto OnADDBAReq_Fail;
274 	}
275 
276 	rtllib_FlushRxTsPendingPkts(ieee, pTS);
277 
278 	DeActivateBAEntry(ieee, pBA);
279 	pBA->dialog_token = *pDialogToken;
280 	pBA->ba_param_set = *pBaParamSet;
281 	pBA->ba_timeout_value = *pBaTimeoutVal;
282 	pBA->ba_start_seq_ctrl = *pBaStartSeqCtrl;
283 
284 	if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev) ||
285 	   (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT))
286 		pBA->ba_param_set.field.buffer_size = 1;
287 	else
288 		pBA->ba_param_set.field.buffer_size = 32;
289 
290 	ActivateBAEntry(pBA, 0);
291 	rtllib_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
292 
293 	return 0;
294 
295 OnADDBAReq_Fail:
296 	{
297 		struct ba_record BA;
298 
299 		BA.ba_param_set = *pBaParamSet;
300 		BA.ba_timeout_value = *pBaTimeoutVal;
301 		BA.dialog_token = *pDialogToken;
302 		BA.ba_param_set.field.ba_policy = BA_POLICY_IMMEDIATE;
303 		rtllib_send_ADDBARsp(ieee, dst, &BA, rc);
304 		return 0;
305 	}
306 }
307 
rtllib_rx_ADDBARsp(struct rtllib_device * ieee,struct sk_buff * skb)308 int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
309 {
310 	struct rtllib_hdr_3addr *rsp = NULL;
311 	struct ba_record *pPendingBA, *pAdmittedBA;
312 	struct tx_ts_record *pTS = NULL;
313 	u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL;
314 	u16 *pStatusCode = NULL, *pBaTimeoutVal = NULL;
315 	union ba_param_set *pBaParamSet = NULL;
316 	u16			ReasonCode;
317 
318 	if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
319 		netdev_warn(ieee->dev, "Invalid skb len in BARSP(%d / %d)\n",
320 			    (int)skb->len,
321 			    (int)(sizeof(struct rtllib_hdr_3addr) + 9));
322 		return -1;
323 	}
324 	rsp = (struct rtllib_hdr_3addr *)skb->data;
325 	tag = (u8 *)rsp;
326 	dst = (u8 *)(&rsp->addr2[0]);
327 	tag += sizeof(struct rtllib_hdr_3addr);
328 	pDialogToken = tag + 2;
329 	pStatusCode = (u16 *)(tag + 3);
330 	pBaParamSet = (union ba_param_set *)(tag + 5);
331 	pBaTimeoutVal = (u16 *)(tag + 7);
332 
333 	RT_TRACE(COMP_DBG, "====>rx ADDBARSP from : %pM\n", dst);
334 	if (!ieee->current_network.qos_data.active ||
335 	    !ieee->pHTInfo->bCurrentHTSupport ||
336 	    !ieee->pHTInfo->bCurrentAMPDUEnable) {
337 		netdev_warn(ieee->dev,
338 			    "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",
339 			    ieee->current_network.qos_data.active,
340 			    ieee->pHTInfo->bCurrentHTSupport,
341 			    ieee->pHTInfo->bCurrentAMPDUEnable);
342 		ReasonCode = DELBA_REASON_UNKNOWN_BA;
343 		goto OnADDBARsp_Reject;
344 	}
345 
346 	if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
347 		   (u8)(pBaParamSet->field.tid), TX_DIR, false)) {
348 		netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
349 		ReasonCode = DELBA_REASON_UNKNOWN_BA;
350 		goto OnADDBARsp_Reject;
351 	}
352 
353 	pTS->bAddBaReqInProgress = false;
354 	pPendingBA = &pTS->TxPendingBARecord;
355 	pAdmittedBA = &pTS->TxAdmittedBARecord;
356 
357 	if (pAdmittedBA->b_valid) {
358 		netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n",
359 			   __func__);
360 		return -1;
361 	} else if (!pPendingBA->b_valid ||
362 		   (*pDialogToken != pPendingBA->dialog_token)) {
363 		netdev_warn(ieee->dev,
364 			    "%s(): ADDBA Rsp. BA invalid, DELBA!\n",
365 			    __func__);
366 		ReasonCode = DELBA_REASON_UNKNOWN_BA;
367 		goto OnADDBARsp_Reject;
368 	} else {
369 		netdev_dbg(ieee->dev,
370 			   "%s(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n",
371 			   __func__, *pStatusCode);
372 		DeActivateBAEntry(ieee, pPendingBA);
373 	}
374 
375 	if (*pStatusCode == ADDBA_STATUS_SUCCESS) {
376 		if (pBaParamSet->field.ba_policy == BA_POLICY_DELAYED) {
377 			pTS->bAddBaReqDelayed = true;
378 			DeActivateBAEntry(ieee, pAdmittedBA);
379 			ReasonCode = DELBA_REASON_END_BA;
380 			goto OnADDBARsp_Reject;
381 		}
382 
383 
384 		pAdmittedBA->dialog_token = *pDialogToken;
385 		pAdmittedBA->ba_timeout_value = *pBaTimeoutVal;
386 		pAdmittedBA->ba_start_seq_ctrl = pPendingBA->ba_start_seq_ctrl;
387 		pAdmittedBA->ba_param_set = *pBaParamSet;
388 		DeActivateBAEntry(ieee, pAdmittedBA);
389 		ActivateBAEntry(pAdmittedBA, *pBaTimeoutVal);
390 	} else {
391 		pTS->bAddBaReqDelayed = true;
392 		pTS->bDisable_AddBa = true;
393 		ReasonCode = DELBA_REASON_END_BA;
394 		goto OnADDBARsp_Reject;
395 	}
396 
397 	return 0;
398 
399 OnADDBARsp_Reject:
400 	{
401 		struct ba_record BA;
402 
403 		BA.ba_param_set = *pBaParamSet;
404 		rtllib_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
405 		return 0;
406 	}
407 }
408 
rtllib_rx_DELBA(struct rtllib_device * ieee,struct sk_buff * skb)409 int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
410 {
411 	struct rtllib_hdr_3addr *delba = NULL;
412 	union delba_param_set *pDelBaParamSet = NULL;
413 	u8 *dst = NULL;
414 
415 	if (skb->len < sizeof(struct rtllib_hdr_3addr) + 6) {
416 		netdev_warn(ieee->dev, "Invalid skb len in DELBA(%d / %d)\n",
417 			    (int)skb->len,
418 			    (int)(sizeof(struct rtllib_hdr_3addr) + 6));
419 		return -1;
420 	}
421 
422 	if (!ieee->current_network.qos_data.active ||
423 		!ieee->pHTInfo->bCurrentHTSupport) {
424 		netdev_warn(ieee->dev,
425 			    "received DELBA while QOS or HT is not supported(%d, %d)\n",
426 			    ieee->current_network. qos_data.active,
427 			    ieee->pHTInfo->bCurrentHTSupport);
428 		return -1;
429 	}
430 
431 #ifdef VERBOSE_DEBUG
432 	print_hex_dump_bytes("%s: ", DUMP_PREFIX_NONE, skb->data,
433 			     __func__, skb->len);
434 #endif
435 	delba = (struct rtllib_hdr_3addr *)skb->data;
436 	dst = (u8 *)(&delba->addr2[0]);
437 	pDelBaParamSet = (union delba_param_set *)&delba->payload[2];
438 
439 	if (pDelBaParamSet->field.initiator == 1) {
440 		struct rx_ts_record *pRxTs;
441 
442 		if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst,
443 		    (u8)pDelBaParamSet->field.tid, RX_DIR, false)) {
444 			netdev_warn(ieee->dev,
445 				    "%s(): can't get TS for RXTS. dst:%pM TID:%d\n",
446 				    __func__, dst,
447 				    (u8)pDelBaParamSet->field.tid);
448 			return -1;
449 		}
450 
451 		RxTsDeleteBA(ieee, pRxTs);
452 	} else {
453 		struct tx_ts_record *pTxTs;
454 
455 		if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst,
456 			   (u8)pDelBaParamSet->field.tid, TX_DIR, false)) {
457 			netdev_warn(ieee->dev, "%s(): can't get TS for TXTS\n",
458 				    __func__);
459 			return -1;
460 		}
461 
462 		pTxTs->bUsingBa = false;
463 		pTxTs->bAddBaReqInProgress = false;
464 		pTxTs->bAddBaReqDelayed = false;
465 		del_timer_sync(&pTxTs->TsAddBaTimer);
466 		TxTsDeleteBA(ieee, pTxTs);
467 	}
468 	return 0;
469 }
470 
TsInitAddBA(struct rtllib_device * ieee,struct tx_ts_record * pTS,u8 Policy,u8 bOverwritePending)471 void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
472 		 u8 Policy, u8	bOverwritePending)
473 {
474 	struct ba_record *pBA = &pTS->TxPendingBARecord;
475 
476 	if (pBA->b_valid && !bOverwritePending)
477 		return;
478 
479 	DeActivateBAEntry(ieee, pBA);
480 
481 	pBA->dialog_token++;
482 	pBA->ba_param_set.field.amsdu_support = 0;
483 	pBA->ba_param_set.field.ba_policy = Policy;
484 	pBA->ba_param_set.field.tid = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID;
485 	pBA->ba_param_set.field.buffer_size = 32;
486 	pBA->ba_timeout_value = 0;
487 	pBA->ba_start_seq_ctrl.field.seq_num = (pTS->TxCurSeq + 3) % 4096;
488 
489 	ActivateBAEntry(pBA, BA_SETUP_TIMEOUT);
490 
491 	rtllib_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA);
492 }
493 
TsInitDelBA(struct rtllib_device * ieee,struct ts_common_info * pTsCommonInfo,enum tr_select TxRxSelect)494 void TsInitDelBA(struct rtllib_device *ieee,
495 		 struct ts_common_info *pTsCommonInfo,
496 		 enum tr_select TxRxSelect)
497 {
498 	if (TxRxSelect == TX_DIR) {
499 		struct tx_ts_record *pTxTs =
500 			 (struct tx_ts_record *)pTsCommonInfo;
501 
502 		if (TxTsDeleteBA(ieee, pTxTs))
503 			rtllib_send_DELBA(ieee, pTsCommonInfo->Addr,
504 					  (pTxTs->TxAdmittedBARecord.b_valid) ?
505 					 (&pTxTs->TxAdmittedBARecord) :
506 					(&pTxTs->TxPendingBARecord),
507 					 TxRxSelect, DELBA_REASON_END_BA);
508 	} else if (TxRxSelect == RX_DIR) {
509 		struct rx_ts_record *pRxTs =
510 				 (struct rx_ts_record *)pTsCommonInfo;
511 		if (RxTsDeleteBA(ieee, pRxTs))
512 			rtllib_send_DELBA(ieee, pTsCommonInfo->Addr,
513 					  &pRxTs->rx_admitted_ba_record,
514 					  TxRxSelect, DELBA_REASON_END_BA);
515 	}
516 }
517 
BaSetupTimeOut(struct timer_list * t)518 void BaSetupTimeOut(struct timer_list *t)
519 {
520 	struct tx_ts_record *pTxTs = from_timer(pTxTs, t,
521 					      TxPendingBARecord.timer);
522 
523 	pTxTs->bAddBaReqInProgress = false;
524 	pTxTs->bAddBaReqDelayed = true;
525 	pTxTs->TxPendingBARecord.b_valid = false;
526 }
527 
TxBaInactTimeout(struct timer_list * t)528 void TxBaInactTimeout(struct timer_list *t)
529 {
530 	struct tx_ts_record *pTxTs = from_timer(pTxTs, t,
531 					      TxAdmittedBARecord.timer);
532 	struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device,
533 				     TxTsRecord[pTxTs->num]);
534 	TxTsDeleteBA(ieee, pTxTs);
535 	rtllib_send_DELBA(ieee, pTxTs->TsCommonInfo.Addr,
536 			  &pTxTs->TxAdmittedBARecord, TX_DIR,
537 			  DELBA_REASON_TIMEOUT);
538 }
539 
RxBaInactTimeout(struct timer_list * t)540 void RxBaInactTimeout(struct timer_list *t)
541 {
542 	struct rx_ts_record *pRxTs = from_timer(pRxTs, t,
543 					      rx_admitted_ba_record.timer);
544 	struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device,
545 				     RxTsRecord[pRxTs->num]);
546 
547 	RxTsDeleteBA(ieee, pRxTs);
548 	rtllib_send_DELBA(ieee, pRxTs->ts_common_info.Addr,
549 			  &pRxTs->rx_admitted_ba_record, RX_DIR,
550 			  DELBA_REASON_TIMEOUT);
551 }
552