rtl8192e: Remove occurences of #if 1
[pandora-kernel.git] / drivers / staging / rtl8192e / rtl819x_TSProc.c
1 /******************************************************************************
2  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3  *
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
7  * more details.
8  *
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
12  *
13  * The full GNU General Public License is included in this distribution in the
14  * file called LICENSE.
15  *
16  * Contact Information:
17  * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
19 #include "rtllib.h"
20 #include <linux/etherdevice.h>
21 #include "rtl819x_TS.h"
22 extern void _setup_timer( struct timer_list*, void*, unsigned long);
23
24 void TsSetupTimeOut(unsigned long data)
25 {
26 }
27
28 void TsInactTimeout(unsigned long data)
29 {
30 }
31
32 void RxPktPendingTimeout(unsigned long data)
33 {
34         PRX_TS_RECORD   pRxTs = (PRX_TS_RECORD)data;
35         struct rtllib_device *ieee = container_of(pRxTs, struct rtllib_device, RxTsRecord[pRxTs->num]);
36
37         PRX_REORDER_ENTRY       pReorderEntry = NULL;
38
39         unsigned long flags = 0;
40         struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
41         u8 index = 0;
42         bool bPktInBuf = false;
43
44         spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
45         if (pRxTs->RxTimeoutIndicateSeq != 0xffff)
46         {
47                 while(!list_empty(&pRxTs->RxPendingPktList))
48                 {
49                         pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
50                         if (index == 0)
51                                 pRxTs->RxIndicateSeq = pReorderEntry->SeqNum;
52
53                         if ( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ||
54                                 SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)   )
55                         {
56                                 list_del_init(&pReorderEntry->List);
57
58                                 if (SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq))
59                                         pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096;
60
61                                 RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Indicate SeqNum: %d\n",__func__, pReorderEntry->SeqNum);
62                                 stats_IndicateArray[index] = pReorderEntry->prxb;
63                                 index++;
64
65                                 list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List);
66                         }
67                         else
68                         {
69                                 bPktInBuf = true;
70                                 break;
71                         }
72                 }
73         }
74
75         if (index>0){
76                 pRxTs->RxTimeoutIndicateSeq = 0xffff;
77
78                 if (index > REORDER_WIN_SIZE){
79                         RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
80                         spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
81                         return;
82                 }
83                 rtllib_indicate_packets(ieee, stats_IndicateArray, index);
84                 bPktInBuf = false;
85         }
86
87         if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff)){
88                 pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq;
89                 mod_timer(&pRxTs->RxPktPendingTimer,  jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime));
90         }
91         spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
92 }
93
94 void TsAddBaProcess(unsigned long data)
95 {
96         PTX_TS_RECORD   pTxTs = (PTX_TS_RECORD)data;
97         u8 num = pTxTs->num;
98         struct rtllib_device *ieee = container_of(pTxTs, struct rtllib_device, TxTsRecord[num]);
99
100         TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false);
101         RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n");
102 }
103
104
105 void ResetTsCommonInfo(PTS_COMMON_INFO  pTsCommonInfo)
106 {
107         memset(pTsCommonInfo->Addr, 0, 6);
108         memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY));
109         memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM);
110         pTsCommonInfo->TClasProc = 0;
111         pTsCommonInfo->TClasNum = 0;
112 }
113
114 void ResetTxTsEntry(PTX_TS_RECORD pTS)
115 {
116         ResetTsCommonInfo(&pTS->TsCommonInfo);
117         pTS->TxCurSeq = 0;
118         pTS->bAddBaReqInProgress = false;
119         pTS->bAddBaReqDelayed = false;
120         pTS->bUsingBa = false;
121         pTS->bDisable_AddBa = false;
122         ResetBaEntry(&pTS->TxAdmittedBARecord);
123         ResetBaEntry(&pTS->TxPendingBARecord);
124 }
125
126 void ResetRxTsEntry(PRX_TS_RECORD pTS)
127 {
128         ResetTsCommonInfo(&pTS->TsCommonInfo);
129         pTS->RxIndicateSeq = 0xffff;
130         pTS->RxTimeoutIndicateSeq = 0xffff;
131         ResetBaEntry(&pTS->RxAdmittedBARecord);
132 }
133 #ifdef _RTL8192_EXT_PATCH_
134 void ResetAdmitTRStream(struct rtllib_device *ieee, u8 *Addr)
135 {
136         u8      dir;
137         bool                            search_dir[4] = {0, 0, 0, 0};
138         struct list_head*               psearch_list;
139         PTS_COMMON_INFO pRet = NULL;
140         PRX_TS_RECORD pRxTS = NULL;
141         PTX_TS_RECORD pTxTS = NULL;
142
143         if (ieee->iw_mode != IW_MODE_MESH)
144                 return;
145
146         search_dir[DIR_DOWN]    = true;
147         psearch_list = &ieee->Rx_TS_Admit_List;
148         for (dir = 0; dir <= DIR_BI_DIR; dir++)
149         {
150                 if (search_dir[dir] ==false )
151                         continue;
152                 list_for_each_entry(pRet, psearch_list, List){
153                         if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir))
154                         {
155                                 pRxTS = (PRX_TS_RECORD)pRet;
156                                 pRxTS->RxIndicateSeq = 0xffff;
157                                 pRxTS->RxTimeoutIndicateSeq = 0xffff;
158                         }
159
160                 }
161         }
162         search_dir[DIR_UP]      = true;
163         psearch_list = &ieee->Tx_TS_Admit_List;
164         for (dir = 0; dir <= DIR_BI_DIR; dir++)
165         {
166                 if (search_dir[dir] ==false )
167                         continue;
168                 list_for_each_entry(pRet, psearch_list, List){
169                         if ((memcmp(pRet->Addr, Addr, 6) == 0) && (pRet->TSpec.f.TSInfo.field.ucDirection == dir))
170                         {
171                                 pTxTS = (PTX_TS_RECORD)pRet;
172                                 pTxTS->TxCurSeq = 0xffff;
173                         }
174
175                 }
176         }
177
178         return;
179 }
180 #endif
181
182 void TSInitialize(struct rtllib_device *ieee)
183 {
184         PTX_TS_RECORD           pTxTS  = ieee->TxTsRecord;
185         PRX_TS_RECORD           pRxTS  = ieee->RxTsRecord;
186         PRX_REORDER_ENTRY       pRxReorderEntry = ieee->RxReorderEntry;
187         u8                              count = 0;
188         RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __func__);
189         INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
190         INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
191         INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List);
192
193         for (count = 0; count < TOTAL_TS_NUM; count++)
194         {
195                 pTxTS->num = count;
196                 _setup_timer(&pTxTS->TsCommonInfo.SetupTimer,
197                             TsSetupTimeOut,
198                             (unsigned long) pTxTS);
199
200                 _setup_timer(&pTxTS->TsCommonInfo.InactTimer,
201                             TsInactTimeout,
202                             (unsigned long) pTxTS);
203
204                 _setup_timer(&pTxTS->TsAddBaTimer,
205                             TsAddBaProcess,
206                             (unsigned long) pTxTS);
207
208                 _setup_timer(&pTxTS->TxPendingBARecord.Timer,
209                             BaSetupTimeOut,
210                             (unsigned long) pTxTS);
211                 _setup_timer(&pTxTS->TxAdmittedBARecord.Timer,
212                             TxBaInactTimeout,
213                             (unsigned long) pTxTS);
214
215                 ResetTxTsEntry(pTxTS);
216                 list_add_tail(&pTxTS->TsCommonInfo.List,
217                                 &ieee->Tx_TS_Unused_List);
218                 pTxTS++;
219         }
220
221         INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List);
222         INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List);
223         INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List);
224         for (count = 0; count < TOTAL_TS_NUM; count++)
225         {
226                 pRxTS->num = count;
227                 INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
228
229                 _setup_timer(&pRxTS->TsCommonInfo.SetupTimer,
230                             TsSetupTimeOut,
231                             (unsigned long) pRxTS);
232
233                 _setup_timer(&pRxTS->TsCommonInfo.InactTimer,
234                             TsInactTimeout,
235                             (unsigned long) pRxTS);
236
237                 _setup_timer(&pRxTS->RxAdmittedBARecord.Timer,
238                             RxBaInactTimeout,
239                             (unsigned long) pRxTS);
240
241                 _setup_timer(&pRxTS->RxPktPendingTimer,
242                             RxPktPendingTimeout,
243                             (unsigned long) pRxTS);
244
245                 ResetRxTsEntry(pRxTS);
246                 list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List);
247                 pRxTS++;
248         }
249         INIT_LIST_HEAD(&ieee->RxReorder_Unused_List);
250         for (count = 0; count < REORDER_ENTRY_NUM; count++)
251         {
252                 list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
253                 if (count == (REORDER_ENTRY_NUM-1))
254                         break;
255                 pRxReorderEntry = &ieee->RxReorderEntry[count+1];
256         }
257
258 }
259
260 void AdmitTS(struct rtllib_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime)
261 {
262         del_timer_sync(&pTsCommonInfo->SetupTimer);
263         del_timer_sync(&pTsCommonInfo->InactTimer);
264
265         if (InactTime!=0)
266                 mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime));
267 }
268
269
270 PTS_COMMON_INFO SearchAdmitTRStream(struct rtllib_device *ieee, u8*     Addr, u8 TID, TR_SELECT TxRxSelect)
271 {
272         u8      dir;
273         bool                            search_dir[4] = {0, 0, 0, 0};
274         struct list_head*               psearch_list;
275         PTS_COMMON_INFO pRet = NULL;
276         if (ieee->iw_mode == IW_MODE_MASTER)
277         {
278                 if (TxRxSelect == TX_DIR)
279                 {
280                         search_dir[DIR_DOWN] = true;
281                         search_dir[DIR_BI_DIR]= true;
282                 }
283                 else
284                 {
285                         search_dir[DIR_UP]      = true;
286                         search_dir[DIR_BI_DIR]= true;
287                 }
288         }
289         else if (ieee->iw_mode == IW_MODE_ADHOC)
290         {
291                 if (TxRxSelect == TX_DIR)
292                         search_dir[DIR_UP]      = true;
293                 else
294                         search_dir[DIR_DOWN] = true;
295         }
296         else
297         {
298                 if (TxRxSelect == TX_DIR)
299                 {
300                         search_dir[DIR_UP]      = true;
301                         search_dir[DIR_BI_DIR]= true;
302                         search_dir[DIR_DIRECT]= true;
303                 }
304                 else
305                 {
306                         search_dir[DIR_DOWN] = true;
307                         search_dir[DIR_BI_DIR]= true;
308                         search_dir[DIR_DIRECT]= true;
309                 }
310         }
311
312         if (TxRxSelect == TX_DIR)
313                 psearch_list = &ieee->Tx_TS_Admit_List;
314         else
315                 psearch_list = &ieee->Rx_TS_Admit_List;
316
317         for (dir = 0; dir <= DIR_BI_DIR; dir++)
318         {
319                 if (search_dir[dir] ==false )
320                         continue;
321                 list_for_each_entry(pRet, psearch_list, List){
322                         if (memcmp(pRet->Addr, Addr, 6) == 0)
323                                 if (pRet->TSpec.f.TSInfo.field.ucTSID == TID)
324                                         if (pRet->TSpec.f.TSInfo.field.ucDirection == dir)
325                                         {
326                                                 break;
327                                         }
328
329                 }
330                 if (&pRet->List  != psearch_list)
331                         break;
332         }
333
334         if (&pRet->List  != psearch_list){
335                 return pRet ;
336         }
337         else
338                 return NULL;
339 }
340
341 void MakeTSEntry(
342                 PTS_COMMON_INFO pTsCommonInfo,
343                 u8*             Addr,
344                 PTSPEC_BODY     pTSPEC,
345                 PQOS_TCLAS      pTCLAS,
346                 u8              TCLAS_Num,
347                 u8              TCLAS_Proc
348         )
349 {
350         u8      count;
351
352         if (pTsCommonInfo == NULL)
353                 return;
354
355         memcpy(pTsCommonInfo->Addr, Addr, 6);
356
357         if (pTSPEC != NULL)
358                 memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY));
359
360         for (count = 0; count < TCLAS_Num; count++)
361                 memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS));
362
363         pTsCommonInfo->TClasProc = TCLAS_Proc;
364         pTsCommonInfo->TClasNum = TCLAS_Num;
365 }
366
367 #ifdef _RTL8192_EXT_PATCH_
368 void dump_ts_list(struct list_head * ts_list)
369 {
370         PTS_COMMON_INFO pRet = NULL;
371         u8 i=0;
372         list_for_each_entry(pRet, ts_list, List){
373                 printk("i=%d ADD:"MAC_FMT", TID:%d, dir:%d\n",i,MAC_ARG(pRet->Addr), pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection);
374                 i++;
375         }
376
377 }
378 #endif
379
380 bool GetTs(
381         struct rtllib_device*   ieee,
382         PTS_COMMON_INFO                 *ppTS,
383         u8*                             Addr,
384         u8                              TID,
385         TR_SELECT                       TxRxSelect,
386         bool                            bAddNewTs)
387 {
388         u8      UP = 0;
389         if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr))
390         {
391                 RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or Multicast\n");
392                 return false;
393         }
394         if (ieee->current_network.qos_data.supported == 0) {
395                 UP = 0;
396         } else {
397                 if (!IsACValid(TID)) {
398                         RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is not valid\n", __func__, TID);
399                         return false;
400                 }
401
402                 switch (TID) {
403                 case 0:
404                 case 3:
405                         UP = 0;
406                         break;
407                 case 1:
408                 case 2:
409                         UP = 2;
410                         break;
411                 case 4:
412                 case 5:
413                         UP = 5;
414                         break;
415                 case 6:
416                 case 7:
417                         UP = 7;
418                         break;
419                 }
420         }
421
422         *ppTS = SearchAdmitTRStream(
423                         ieee,
424                         Addr,
425                         UP,
426                         TxRxSelect);
427         if (*ppTS != NULL)
428         {
429                 return true;
430         }
431         else
432         {
433                 if (bAddNewTs == false)
434                 {
435                         RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed(tid:%d)\n", UP);
436                         return false;
437                 }
438                 else
439                 {
440                         TSPEC_BODY      TSpec;
441                         PQOS_TSINFO             pTSInfo = &TSpec.f.TSInfo;
442                         struct list_head*       pUnusedList =
443                                                                 (TxRxSelect == TX_DIR)?
444                                                                 (&ieee->Tx_TS_Unused_List):
445                                                                 (&ieee->Rx_TS_Unused_List);
446
447                         struct list_head*       pAddmitList =
448                                                                 (TxRxSelect == TX_DIR)?
449                                                                 (&ieee->Tx_TS_Admit_List):
450                                                                 (&ieee->Rx_TS_Admit_List);
451
452                         DIRECTION_VALUE         Dir =           (ieee->iw_mode == IW_MODE_MASTER)?
453                                                                 ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP):
454                                                                 ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN);
455                         RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n");
456                         if (!list_empty(pUnusedList))
457                         {
458                                 (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List);
459                                 list_del_init(&(*ppTS)->List);
460                                 if (TxRxSelect==TX_DIR)
461                                 {
462                                         PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo);
463                                         ResetTxTsEntry(tmp);
464                                 }
465                                 else{
466                                         PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo);
467                                         ResetRxTsEntry(tmp);
468                                 }
469
470                                 RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:"MAC_FMT" ppTs=%p\n", UP, Dir, MAC_ARG(Addr), *ppTS);
471                                 pTSInfo->field.ucTrafficType = 0;
472                                 pTSInfo->field.ucTSID = UP;
473                                 pTSInfo->field.ucDirection = Dir;
474                                 pTSInfo->field.ucAccessPolicy = 1;
475                                 pTSInfo->field.ucAggregation = 0;
476                                 pTSInfo->field.ucPSB = 0;
477                                 pTSInfo->field.ucUP = UP;
478                                 pTSInfo->field.ucTSInfoAckPolicy = 0;
479                                 pTSInfo->field.ucSchedule = 0;
480
481                                 MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0);
482                                 AdmitTS(ieee, *ppTS, 0);
483                                 list_add_tail(&((*ppTS)->List), pAddmitList);
484
485                                 return true;
486                         }
487                         else
488                         {
489                                 RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!", __func__,Dir);
490                                 return false;
491                         }
492                 }
493         }
494 }
495
496 void RemoveTsEntry(
497         struct rtllib_device*   ieee,
498         PTS_COMMON_INFO                 pTs,
499         TR_SELECT                       TxRxSelect
500         )
501 {
502         del_timer_sync(&pTs->SetupTimer);
503         del_timer_sync(&pTs->InactTimer);
504         TsInitDelBA(ieee, pTs, TxRxSelect);
505
506         if (TxRxSelect == RX_DIR)
507         {
508                 PRX_REORDER_ENTRY       pRxReorderEntry;
509                 PRX_TS_RECORD           pRxTS = (PRX_TS_RECORD)pTs;
510
511                 if (timer_pending(&pRxTS->RxPktPendingTimer))
512                         del_timer_sync(&pRxTS->RxPktPendingTimer);
513
514                 while(!list_empty(&pRxTS->RxPendingPktList)){
515                         pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
516                         RTLLIB_DEBUG(RTLLIB_DL_REORDER,"%s(): Delete SeqNum %d!\n",__func__, pRxReorderEntry->SeqNum);
517                         list_del_init(&pRxReorderEntry->List);
518                         {
519                                 int i = 0;
520                                 struct rtllib_rxb * prxb = pRxReorderEntry->prxb;
521                                 if (unlikely(!prxb)){
522                                         return;
523                                 }
524                                 for (i =0; i < prxb->nr_subframes; i++) {
525                                         dev_kfree_skb(prxb->subframes[i]);
526                                 }
527                                 kfree(prxb);
528                                 prxb = NULL;
529                         }
530                         list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
531                 }
532         }
533         else{
534                 PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs;
535                 del_timer_sync(&pTxTS->TsAddBaTimer);
536         }
537 }
538
539 void RemovePeerTS(struct rtllib_device* ieee, u8* Addr)
540 {
541         PTS_COMMON_INFO pTS, pTmpTS;
542         printk("===========>RemovePeerTS,"MAC_FMT"\n", MAC_ARG(Addr));
543
544         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
545         {
546                 if (memcmp(pTS->Addr, Addr, 6) == 0)
547                 {
548                         RemoveTsEntry(ieee, pTS, TX_DIR);
549                         list_del_init(&pTS->List);
550                         list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
551                 }
552         }
553
554         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
555         {
556                 if (memcmp(pTS->Addr, Addr, 6) == 0)
557                 {
558                         printk("====>remove Tx_TS_admin_list\n");
559                         RemoveTsEntry(ieee, pTS, TX_DIR);
560                         list_del_init(&pTS->List);
561                         list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
562                 }
563         }
564
565         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
566         {
567                 if (memcmp(pTS->Addr, Addr, 6) == 0)
568                 {
569                         RemoveTsEntry(ieee, pTS, RX_DIR);
570                         list_del_init(&pTS->List);
571                         list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
572                 }
573         }
574
575         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
576         {
577                 if (memcmp(pTS->Addr, Addr, 6) == 0)
578                 {
579                         RemoveTsEntry(ieee, pTS, RX_DIR);
580                         list_del_init(&pTS->List);
581                         list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
582                 }
583         }
584 }
585
586 void RemoveAllTS(struct rtllib_device* ieee)
587 {
588         PTS_COMMON_INFO pTS, pTmpTS;
589
590         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
591         {
592                 RemoveTsEntry(ieee, pTS, TX_DIR);
593                 list_del_init(&pTS->List);
594                 list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
595         }
596
597         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
598         {
599                 RemoveTsEntry(ieee, pTS, TX_DIR);
600                 list_del_init(&pTS->List);
601                 list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
602         }
603
604         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
605         {
606                 RemoveTsEntry(ieee, pTS, RX_DIR);
607                 list_del_init(&pTS->List);
608                 list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
609         }
610
611         list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
612         {
613                 RemoveTsEntry(ieee, pTS, RX_DIR);
614                 list_del_init(&pTS->List);
615                 list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
616         }
617 }
618
619 void TsStartAddBaProcess(struct rtllib_device* ieee, PTX_TS_RECORD      pTxTS)
620 {
621         if (pTxTS->bAddBaReqInProgress == false)
622         {
623                 pTxTS->bAddBaReqInProgress = true;
624
625                 if (pTxTS->bAddBaReqDelayed)
626                 {
627                         RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n");
628                         mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY));
629                 }
630                 else
631                 {
632                         RTLLIB_DEBUG(RTLLIB_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n");
633                         mod_timer(&pTxTS->TsAddBaTimer, jiffies+10);
634                 }
635         }
636         else
637                 RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n", __func__);
638 }