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